correct docs, make saving async
Jes Olson j3s@c3f.net
Mon, 24 Feb 2025 23:18:58 -0500
5 files changed,
47 insertions(+),
10 deletions(-)
M
files/index.tmpl.html
→
files/index.tmpl.html
@@ -18,6 +18,11 @@
===CHANGELOG=== +2025-02 + +- archive.is -> archive.org +- make save async + 2024-04-29 i have save support & reworked the UI a little
M
files/saves.tmpl.html
→
files/saves.tmpl.html
@@ -11,12 +11,11 @@ use the "save" button to save posts that you like!
vore's save system is unique: when you click the "save" button, vore will: - - store the article title & domain - - submit an https://archive.is request on your behalf - - store the archive.is link + - submit an https://archive.org request on your behalf for the linked page + - store the article + archive link together this ensures that all saved articles will remain -accessible indefinitely. +accessible forever! it also means that you may save the same article more than once, if you'd like!
M
files/user.tmpl.html
→
files/user.tmpl.html
@@ -22,11 +22,45 @@ <span class=puny title="{{ .Date }}">
published {{ .Date | timeSince }} via <a href="//{{ .Link | printDomain }}"> {{ .Link | printDomain }}</a> - | <a href="/save/{{ .Link | escapeURL }}">save</a> + | <a href="#" + data-save-url="/save/{{ .Link | escapeURL }}" + onclick="saveItem(this); return false;"> + save + </a> </span> </li> {{ end }} </ul> + +<script> +function saveItem(element) { + const url = element.dataset.saveUrl; + const states = [".", "..", "..."]; + let index = 0; + + const intervalId = setInterval(() => { + element.textContent = "saving" + states[index]; + index = (index + 1) % states.length; + }, 300); + + fetch(url) + .then(response => { + if (!response.ok) { + throw new Error(`Request failed with status ${response.status}`); + } + return response.text(); + }) + .then(data => { + clearInterval(intervalId); + element.textContent = "saved!"; + }) + .catch(error => { + console.error(error); + clearInterval(intervalId); + element.textContent = "error!"; + }); +} +</script> {{ template "tail" . }} {{ end }}
M
readme
→
readme
@@ -29,13 +29,13 @@
- do not natively display posts posts always look like shit away from their home websites. instead of doing any of that nonsense, vore just takes website snapshots - via archive.is and presents them to the user. + via archive.org and presents them to the user. - saved entries will NEVER change/expire if a user uses the "save" feature, the data they were looking at must never be lost. therefore, we just copy whatever the active post state was from - memory & also snapshot the website via archive.is & link to the + memory & also snapshot the website via archive.org & link to the snapshot. this way, there's always a cached version available to use.
M
site.go
→
site.go
@@ -117,8 +117,8 @@ }
http.Redirect(w, r, "/", http.StatusSeeOther) } -// saveHandler is an HTMX endpoint that returns the text "saved!" when -// a post has been saved to a user's account +// saveHandler is an endpoint that takes a url, archives it +// via archive.org, and then saves it to the user's account. func (s *Site) saveHandler(w http.ResponseWriter, r *http.Request) { if !s.loggedIn(r) { s.renderErr(w, "", http.StatusUnauthorized)@@ -159,7 +159,6 @@ log.Println(err)
fmt.Fprintf(w, "error!!!") return } - fmt.Fprintf(w, "saved! you can go back now. this will eventually be async. lol.") } func (s *Site) userHandler(w http.ResponseWriter, r *http.Request) {