1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Subscribe to feeds with the Android Share menu

This commit is contained in:
Ilya Mateyko 2021-01-01 13:15:33 +00:00 committed by fguillot
parent 94eaf0e254
commit ab82c4b300
4 changed files with 45 additions and 8 deletions

View file

@ -13,6 +13,8 @@ import (
"miniflux.app/ui/form"
"miniflux.app/ui/session"
"miniflux.app/ui/view"
"mvdan.cc/xurls/v2"
)
func (h *handler) bookmarklet(w http.ResponseWriter, r *http.Request) {
@ -33,6 +35,17 @@ func (h *handler) bookmarklet(w http.ResponseWriter, r *http.Request) {
bookmarkletURL := request.QueryStringParam(r, "uri", "")
// Extract URL from text supplied by Web Share Target API.
//
// This is because Android intents have no concept of URL, so apps
// just shove a URL directly into the EXTRA_TEXT intent field.
//
// See https://bugs.chromium.org/p/chromium/issues/detail?id=789379.
text := request.QueryStringParam(r, "text", "")
if text != "" && bookmarkletURL == "" {
bookmarkletURL = xurls.Relaxed().FindString(text)
}
view.Set("form", form.SubscriptionForm{URL: bookmarkletURL})
view.Set("categories", categories)
view.Set("menu", "feeds")