Skip to content

Commit

Permalink
feat: public interests
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Jun 30, 2024
1 parent 9ffa673 commit a0db132
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion helm/webapp/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metadata:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "etag: f1c2188";
more_set_headers "etag: 9ffa673";
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
Expand Down
11 changes: 0 additions & 11 deletions web/sub-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,6 @@ function loadSubDetailsById(id) {
document.getElementById("sub-discovered-sources").style.display = "block";
document.getElementById("button-follow").style.display = "block";
const headers = getAuthHeaders();
const authProvider = localStorage.getItem(keyAuthProvider);
const subFeedLinkElement = document.getElementById("sub-feed-link");
switch (authProvider) {
case "Telegram": {
subFeedLinkElement.href = "https://t.me/AwakariBot";
break;
}
default:
subFeedLinkElement.href = `https://reader.awakari.com/v1/sub/rss/${id}`;
break;
}
Subscriptions
.fetch(id, headers)
.then(resp => resp ? resp.json() : null)
Expand Down
2 changes: 1 addition & 1 deletion web/sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<script src="api/subscriptions.js"></script>
<script src="api/usage.js"></script>
<script src="api/limits.js"></script>
<script src="sub.js?v=bd49abb-1"></script>
<script src="sub.js?v=9ffa673"></script>
<script>
navigator.serviceWorker.register("sw.js");
</script>
Expand Down
25 changes: 21 additions & 4 deletions web/sub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const templateSub = (sub) => `
<div class="hover:text-blue-500 hover:bg-gray-100 dark:hover:bg-gray-800 flex w-[320px] sm:w-[400px] space-x-1"
onclick="window.location.assign('sub-details.html?id=${sub.id}')">
<span class="pr-1 py-2 text-slate-500">
${sub.public ? '🔉': ''}
<sup>${sub.hasOwnProperty("followers")? sub.followers : '' }</sup>
</span>
<span class="truncate py-2 grow">
${sub.description}
</span>
Expand Down Expand Up @@ -49,7 +53,7 @@ function load() {
});

const urlParams = new URLSearchParams(window.location.search);
loadSubscriptions(urlParams.get("filter"), false);
loadSubscriptions(urlParams.get("filter"), urlParams.get("own"));
}

function loadSubscriptions(filter, ownOnly) {
Expand Down Expand Up @@ -89,6 +93,17 @@ function loadSubscriptions(filter, ownOnly) {
} else {
document.getElementById("filter").value = filter;
}

if (ownOnly == null) {
ownOnly = document.getElementById("own").checked;
} else if (ownOnly === true || ownOnly === "true") {
ownOnly = true;
document.getElementById("own").checked = true;
} else {
ownOnly = false;
document.getElementById("own").checked = false;
}

document.getElementById("wait").style.display = "block";

const headers = getAuthHeaders();
Expand Down Expand Up @@ -117,7 +132,8 @@ function loadSubscriptions(filter, ownOnly) {
btnPrev.removeAttribute("disabled");
if (subs.length > 0) {
btnPrev.onclick = () => {
window.location.assign(`sub.html?cursor=${subs[0].id}&order=ASC&filter=${encodeURIComponent(filter)}`)
const sub = subs[0];
window.location.assign(`sub.html?cursor=${sub.id}&followers=${sub.hasOwnProperty('followers')? sub.followers : '0'}&order=ASC&filter=${encodeURIComponent(filter)}&own=${ownOnly}`)
}
} else {
btnPrev.onclick = () => {
Expand All @@ -131,7 +147,8 @@ function loadSubscriptions(filter, ownOnly) {
if (subs.length === pageLimit) {
btnNext.removeAttribute("disabled");
btnNext.onclick = () => {
window.location.assign(`sub.html?cursor=${subs[pageLimit - 1].id}&order=DESC&filter=${encodeURIComponent(filter)}`)
const sub = subs[pageLimit - 1];
window.location.assign(`sub.html?cursor=${sub.id}&followers=${sub.hasOwnProperty('followers')? sub.followers : '0'}&order=DESC&filter=${encodeURIComponent(filter)}&own=${ownOnly}`)
}
} else {
btnNext.disabled = "disabled";
Expand All @@ -155,7 +172,7 @@ function loadSubscriptions(filter, ownOnly) {
}
} else if (order === "ASC") {
// back to the beginning
window.location.assign(`sub.html?filter=${encodeURIComponent(filter)}`);
window.location.assign(`sub.html?filter=${encodeURIComponent(filter)}&own=${ownOnly}`);
}
}
}
Expand Down

0 comments on commit a0db132

Please sign in to comment.