Skip to content

Commit

Permalink
deploy via script
Browse files Browse the repository at this point in the history
  • Loading branch information
kaangiray26 committed Jun 28, 2023
1 parent 8787911 commit 8042629
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 37 deletions.
9 changes: 0 additions & 9 deletions minify_extractors.sh

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "vite build && npx cap sync",
"preview": "vite preview",
"deploy": "sh deploy.sh",
"production": "vite build && ./node_modules/.bin/terser src/js/extractors.js --compress --output=src/js/extractors.min.js && npx cap copy"
"deploy": "sh deploy.sh"
},
"dependencies": {
"@capacitor/android": "^5.0.5",
Expand All @@ -29,4 +28,4 @@
"terser": "^5.18.2",
"vite": "^4.3.9"
}
}
}
27 changes: 13 additions & 14 deletions src/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,6 @@ textarea {
background-color: firebrick;
}

@keyframes loading {
0% {
width: 25%;
margin-left: -25%;
}

100% {
width: 25%;
margin-left: 100%;
}
}

.btn-touch {
border: 0 !important;
}
Expand All @@ -122,8 +110,7 @@ textarea {
}

.btn-touch-border {
border: 1px solid #dee2e6;
border-radius: 0.375rem
border: 1px solid #dee2e6 !important;
}

.img-saved {
Expand All @@ -138,4 +125,16 @@ textarea {
padding-bottom: 6px;
padding-right: 12px;
padding-left: 12px;
}

@keyframes loading {
0% {
width: 25%;
margin-left: -25%;
}

100% {
width: 25%;
margin-left: 100%;
}
}
93 changes: 90 additions & 3 deletions src/components/Home.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="row row-cols-1 g-0 m-3 mb-0">
<div class="col-12 mb-3">
<div class="row row-cols-1 g-0 m-3 mt-0">
<div class="col-12 mt-3">
<div class="card border-0 theme-shadow rounded">
<div class="card-body p-0">
<div class="border-bottom px-2 py-1">
Expand All @@ -15,5 +15,92 @@
</div>
</div>
</div>
<div v-if="last_upvote" class="col-12 mt-3">
<div class="card border-0 theme-shadow rounded">
<div class="card-body p-0">
<div class="d-flex align-items-center px-2 py-1">
<span class="fw-bold me-2">Last upvote</span>
<small class="text-muted">{{ format_date(last_upvote.created_at) }}</small>
</div>
<div class="px-2">
<span class="bi bi-card-text me-1"></span>
<span>{{ last_upvote.post }}</span>
</div>
<div class="d-flex justify-content-end bg-light rounded">
<button type="button" class="btn btn-touch click-effect bi bi-chat"
@click="open_post(last_upvote)"></button>
</div>
</div>
</div>
</div>
<div v-if="last_comment" class="col-12 mt-3">
<div class="card border-0 theme-shadow rounded">
<div class="card-body p-0">
<div class="d-flex align-items-center px-2 py-1">
<span class="fw-bold me-2">Last comment</span>
<small class="text-muted">{{ format_date(last_comment.created_at) }}</small>
</div>
<div class="px-2">
<span class="bi bi-card-text me-1"></span>
<span>{{ last_comment.post }}</span>
</div>
<div class="d-flex p-theme border-top">
<span v-html="last_comment.comment" class="text-break"></span>
</div>
<div class="d-flex justify-content-end bg-light rounded">
<button type="button" class="btn btn-touch click-effect bi bi-chat"
@click="open_post(last_comment)"></button>
</div>
</div>
</div>
</div>
</div>
</template>
</template>

<script setup>
import { ref, onBeforeMount } from 'vue';
import { useRouter } from 'vue-router';
import { get_latest } from "/js/utils.js";
const router = useRouter();
const last_upvote = ref(null);
const last_comment = ref(null);
async function setup() {
let response = await get_latest();
if (!response) {
return
}
last_upvote.value = response.last_added_upvote;
last_comment.value = response.last_added_comment;
}
async function open_post(item) {
router.push(item.post)
}
function format_date(dt) {
let date = new Date(dt);
let date_string = date.toLocaleString("en-GB", {
year: "numeric",
month: "short",
day: "numeric",
});
let time_string = date.toLocaleString("en-GB", {
hour: "numeric",
minute: "numeric",
hour12: false,
})
return `${date_string} ${time_string}`
}
onBeforeMount(() => {
setup();
})
</script>
7 changes: 4 additions & 3 deletions src/components/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div class="input-group mt-2">
<span class="input-group-text" :class="{ 'bi bi-circle': !reloaded, 'bi bi-circle-fill': reloaded }"
id="basic-addon2"></span>
<button type="button" class="btn btn-touch-border click-effect" :disabled="reloading"
@click="reload_extractors">Reload extractors</button>
<button type="button" class="btn btn-touch-border click-effect" @click="reload_extractors">Reload
extractors</button>
</div>
<div class="d-flex justify-content-between align-items-center mt-3">
<router-link to="/profile/saved" class="btn btn-touch click-effect"
Expand All @@ -39,8 +39,9 @@ const path = computed(() => router.currentRoute.value.path);
const reloading = ref(false);
const reloaded = ref(false);
async function reload_extractors() {
async function reload_extractors(obj) {
if (reloading.value) return;
reloading.value = true;
reloaded.value = false;
Expand Down
15 changes: 11 additions & 4 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,23 @@ async function remove_comments(id, identifier) {
async function reload_extractors() {
let list = JSON.parse(localStorage.getItem("list"));

if (!list || !list.length) {
console.log("List not found, fetching from server...");
let response = fetch("https://kaangiray26.github.io/endless/list.json")
if (!list || !Object.keys(list).length) {
let response = await fetch("https://kaangiray26.github.io/endless/list.json")
.then(res => res.json())
.catch(err => null);
if (!response) {
localStorage.setItem("list", JSON.stringify([]));
return
}
localStorage.setItem("list", JSON.stringify(response));
}
}

export { get_server, get_upvotes, post_upvotes, remove_upvotes, get_comments, post_comments, remove_comments, reload_extractors }
async function get_latest() {
let server = get_server();
return await fetch(server)
.then(res => res.json())
.catch(err => null);
}

export { get_server, get_upvotes, post_upvotes, remove_upvotes, get_comments, post_comments, remove_comments, reload_extractors, get_latest }

0 comments on commit 8042629

Please sign in to comment.