Update reading time HTML element after fetching the original web page
This commit is contained in:
parent
ce35b46fee
commit
c0ee3ed375
3 changed files with 7 additions and 3 deletions
|
@ -130,7 +130,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if and .user.ShowReadingTime (gt .entry.ReadingTime 0) }}
|
{{ if and .user.ShowReadingTime (gt .entry.ReadingTime 0) }}
|
||||||
·
|
·
|
||||||
<span>
|
<span class="entry-reading-time">
|
||||||
{{ plural "entry.estimated_reading_time" .entry.ReadingTime .entry.ReadingTime }}
|
{{ plural "entry.estimated_reading_time" .entry.ReadingTime .entry.ReadingTime }}
|
||||||
</span>
|
</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"miniflux.app/http/request"
|
"miniflux.app/http/request"
|
||||||
"miniflux.app/http/response/json"
|
"miniflux.app/http/response/json"
|
||||||
|
"miniflux.app/locale"
|
||||||
"miniflux.app/model"
|
"miniflux.app/model"
|
||||||
"miniflux.app/proxy"
|
"miniflux.app/proxy"
|
||||||
"miniflux.app/reader/processor"
|
"miniflux.app/reader/processor"
|
||||||
|
@ -64,5 +65,7 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
|
||||||
json.ServerError(w, r, err)
|
json.ServerError(w, r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
json.OK(w, r, map[string]string{"content": proxy.ImageProxyRewriter(h.router, entry.Content)})
|
readingTime := locale.NewPrinter(user.Language).Plural("entry.estimated_reading_time", entry.ReadingTime, entry.ReadingTime)
|
||||||
|
|
||||||
|
json.OK(w, r, map[string]string{"content": proxy.ImageProxyRewriter(h.router, entry.Content), "reading_time": readingTime})
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,8 +334,9 @@ function handleFetchOriginalContent() {
|
||||||
element.innerHTML = previousInnerHTML;
|
element.innerHTML = previousInnerHTML;
|
||||||
|
|
||||||
response.json().then((data) => {
|
response.json().then((data) => {
|
||||||
if (data.hasOwnProperty("content")) {
|
if (data.hasOwnProperty("content") && data.hasOwnProperty("reading_time")) {
|
||||||
document.querySelector(".entry-content").innerHTML = data.content;
|
document.querySelector(".entry-content").innerHTML = data.content;
|
||||||
|
document.querySelector(".entry-reading-time").innerHTML = data.reading_time;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue