1
0
Fork 0

Import OPML from URL

This commit is contained in:
Peter De Wachter 2019-08-15 09:48:07 +02:00 committed by Frédéric Guillot
parent ac45307da6
commit d882bbca85
14 changed files with 95 additions and 10 deletions

View file

@ -223,6 +223,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Neueste Artikel zuerst",
"form.prefs.label.keyboard_shortcuts": "Tastaturkürzel aktivieren",
"form.import.label.file": "OPML Datei",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Fever API aktivieren",
"form.integration.fever_username": "Fever Benutzername",
"form.integration.fever_password": "Fever Passwort",
@ -518,6 +519,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Recent entries first",
"form.prefs.label.keyboard_shortcuts": "Enable keyboard shortcuts",
"form.import.label.file": "OPML file",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activate Fever API",
"form.integration.fever_username": "Fever Username",
"form.integration.fever_password": "Fever Password",
@ -793,6 +795,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Entradas recientes primero",
"form.prefs.label.keyboard_shortcuts": "Habilitar atajos de teclado",
"form.import.label.file": "Archivo OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activar API de Fever",
"form.integration.fever_username": "Nombre de usuario de Fever",
"form.integration.fever_password": "Contraseña de Fever",
@ -1068,6 +1071,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Éléments récents en premier",
"form.prefs.label.keyboard_shortcuts": "Activer les raccourcis clavier",
"form.import.label.file": "Fichier OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activer l'API de Fever",
"form.integration.fever_username": "Nom d'utilisateur pour l'API de Fever",
"form.integration.fever_password": "Mot de passe pour l'API de Fever",
@ -1363,6 +1367,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Prima i più vecchi",
"form.prefs.label.keyboard_shortcuts": "Abilita le scorciatoie da tastiera",
"form.import.label.file": "File OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Abilita l'API di Fever",
"form.integration.fever_username": "Nome utente dell'account Fever",
"form.integration.fever_password": "Password dell'account Fever",
@ -1638,6 +1643,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Recente items eerst",
"form.prefs.label.keyboard_shortcuts": "Schakel sneltoetsen in",
"form.import.label.file": "OPML-bestand",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activeer Fever API",
"form.integration.fever_username": "Fever gebruikersnaam",
"form.integration.fever_password": "Fever wachtwoord",
@ -1933,6 +1939,7 @@ var translations = map[string]string{
"form.prefs.label.keyboard_shortcuts": "Włącz skróty klawiaturowe",
"form.prefs.select.recent_first": "Najnowsze wpisy jako pierwsze",
"form.import.label.file": "Plik OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Aktywuj Fever API",
"form.integration.fever_username": "Login do Fever",
"form.integration.fever_password": "Hasło do Fever",
@ -2234,6 +2241,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "Сначала последние записи",
"form.prefs.label.keyboard_shortcuts": "Включить сочетания клавиш",
"form.import.label.file": "OPML файл",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Активировать Fever API",
"form.integration.fever_username": "Имя пользователя Fever",
"form.integration.fever_password": "Пароль Fever",
@ -2513,6 +2521,7 @@ var translations = map[string]string{
"form.prefs.select.recent_first": "新->旧",
"form.prefs.label.keyboard_shortcuts": "启用键盘快捷键",
"form.import.label.file": "OPML 文件",
"form.import.label.url": "URL",
"form.integration.fever_activate": "启用 Fever API",
"form.integration.fever_username": "Fever 用户名",
"form.integration.fever_password": "Fever 密码",
@ -2583,13 +2592,13 @@ var translations = map[string]string{
}
var translationsChecksums = map[string]string{
"de_DE": "d8679b1026dffcdefe9afe519562ec52078f072cedd64f589bddb2b083fe5887",
"en_US": "7333eb884f4b98b238e07730187342dbc17149c68fabcc73c60478d75b7aa3c8",
"es_ES": "32d094110fd92971fe20a0ac2c3cb15db6a6fb06dba94815d75cab00cf4b73e3",
"fr_FR": "dda1c84e1b970efa8c564d459365ee17ad256ce684d7a036b31da70b50266ab2",
"it_IT": "b9e7ec9ad3ddd3a439ce238b5dd189000501bf26905d24fbb84ee77703999543",
"nl_NL": "04fa292f0ee9d4e98c39ecb1df11965881034f26685afb0081026850347a3b1c",
"pl_PL": "734173b0ceadcb1386dfc98e730fef40282f45dd45c02ac918ae1bb4b7ec0c39",
"ru_RU": "d50e95a88aec5ff8d43d197eeaa294e3ed2009181901e9deaffe48f7aa560a26",
"zh_CN": "b27685df8ed3accb573ca1401f25077e5c26f1e3e98d96e07353876821d53835",
"de_DE": "2ca6c01934316256bf3f06bd1d40fb7700834b285ac87a24692389e4f39de7c2",
"en_US": "547bca5fe9062da289f6d8ab0d3c3f6156d6ae5c3718fa6c0fdbb3853e4c7a8a",
"es_ES": "eb01f7a1fd73cdc54468435887f1c1201489aeceda25f852a63ce6aa80e54e52",
"fr_FR": "76f0555737a9b5c7ec5e40e6242e24b74ebb9457290a3924a9fc2058b5b6da1c",
"it_IT": "335d2a9b3eda6313a9521abf4b7fd8597575a5aa0a664cebe54a467ac5db944d",
"nl_NL": "f30abf2bf7eddd499a012beee07f47da8633788ebf6db5ff685922a6ec66f5fd",
"pl_PL": "a664bd0d472818557d98de50ed8f04f96c2b9307a66c24c04e589dc07c465a8b",
"ru_RU": "7d4c82d2c3710bbf3b9ea07ed2cfcc32e7c7b45836539b5ce0ab10ec1290e615",
"zh_CN": "dc68f7d06b360ada0fed620522cec80baf7ed417fb54a3c3271849ccdaa69086",
}

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Neueste Artikel zuerst",
"form.prefs.label.keyboard_shortcuts": "Tastaturkürzel aktivieren",
"form.import.label.file": "OPML Datei",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Fever API aktivieren",
"form.integration.fever_username": "Fever Benutzername",
"form.integration.fever_password": "Fever Passwort",

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Recent entries first",
"form.prefs.label.keyboard_shortcuts": "Enable keyboard shortcuts",
"form.import.label.file": "OPML file",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activate Fever API",
"form.integration.fever_username": "Fever Username",
"form.integration.fever_password": "Fever Password",

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Entradas recientes primero",
"form.prefs.label.keyboard_shortcuts": "Habilitar atajos de teclado",
"form.import.label.file": "Archivo OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activar API de Fever",
"form.integration.fever_username": "Nombre de usuario de Fever",
"form.integration.fever_password": "Contraseña de Fever",

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Éléments récents en premier",
"form.prefs.label.keyboard_shortcuts": "Activer les raccourcis clavier",
"form.import.label.file": "Fichier OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activer l'API de Fever",
"form.integration.fever_username": "Nom d'utilisateur pour l'API de Fever",
"form.integration.fever_password": "Mot de passe pour l'API de Fever",

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Prima i più vecchi",
"form.prefs.label.keyboard_shortcuts": "Abilita le scorciatoie da tastiera",
"form.import.label.file": "File OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Abilita l'API di Fever",
"form.integration.fever_username": "Nome utente dell'account Fever",
"form.integration.fever_password": "Password dell'account Fever",

View file

@ -218,6 +218,7 @@
"form.prefs.select.recent_first": "Recente items eerst",
"form.prefs.label.keyboard_shortcuts": "Schakel sneltoetsen in",
"form.import.label.file": "OPML-bestand",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Activeer Fever API",
"form.integration.fever_username": "Fever gebruikersnaam",
"form.integration.fever_password": "Fever wachtwoord",

View file

@ -220,6 +220,7 @@
"form.prefs.label.keyboard_shortcuts": "Włącz skróty klawiaturowe",
"form.prefs.select.recent_first": "Najnowsze wpisy jako pierwsze",
"form.import.label.file": "Plik OPML",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Aktywuj Fever API",
"form.integration.fever_username": "Login do Fever",
"form.integration.fever_password": "Hasło do Fever",

View file

@ -220,6 +220,7 @@
"form.prefs.select.recent_first": "Сначала последние записи",
"form.prefs.label.keyboard_shortcuts": "Включить сочетания клавиш",
"form.import.label.file": "OPML файл",
"form.import.label.url": "URL",
"form.integration.fever_activate": "Активировать Fever API",
"form.integration.fever_username": "Имя пользователя Fever",
"form.integration.fever_password": "Пароль Fever",

View file

@ -216,6 +216,7 @@
"form.prefs.select.recent_first": "新->旧",
"form.prefs.label.keyboard_shortcuts": "启用键盘快捷键",
"form.import.label.file": "OPML 文件",
"form.import.label.url": "URL",
"form.integration.fever_activate": "启用 Fever API",
"form.integration.fever_username": "Fever 用户名",
"form.integration.fever_password": "Fever 密码",

View file

@ -31,4 +31,15 @@
</div>
</form>
<form action="{{ route "fetchOPML" }}" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf" value="{{ .csrf }}">
<label for="form-url">{{ t "form.import.label.url" }}</label>
<input type="url" name="url" id="form-url">
<div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.import" }}</button>
</div>
</form>
{{ end }}

View file

@ -955,6 +955,17 @@ var templateViewsMap = map[string]string{
</div>
</form>
<form action="{{ route "fetchOPML" }}" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf" value="{{ .csrf }}">
<label for="form-url">{{ t "form.import.label.url" }}</label>
<input type="url" name="url" id="form-url">
<div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.import" }}</button>
</div>
</form>
{{ end }}
`,
"integrations": `{{ define "title"}}{{ t "page.integrations.title" }}{{ end }}
@ -1469,7 +1480,7 @@ var templateViewsMapChecksums = map[string]string{
"feed_entries": "4bb6b96ba4d13dbaf22dcf6dd95ae36b6e5a0c99175d502865a164dc68fd4bae",
"feeds": "d11fb629921e22bbf6d9ecb1adcc38922fafcee84f81c437abf47209544bd1c5",
"history_entries": "9763d2120cfaeb78d406fdc029197fed2f7cfa7682970eeedae82ae79be65519",
"import": "8349e47a783bb40d8e9248b4771656e5f006185e11079e1c4680dd52633420ed",
"import": "d7abfdc2cd4db38ed695d5fecd140e2e736d3633127589e1292736224dc23798",
"integrations": "f85b4a48ab1fc13b8ca94bfbbc44bd5e8784f35b26a63ec32cbe82b96b45e008",
"login": "2e72d2d4b9786641b696bedbed5e10b04bdfd68254ddbbdb0a53cca621d200c7",
"search_entries": "d71849a4f2b0573c7c76ad0ea941812009e9f022de60895987a781d3e6f08a01",

View file

@ -7,6 +7,7 @@ package ui // import "miniflux.app/ui"
import (
"net/http"
"miniflux.app/http/client"
"miniflux.app/http/request"
"miniflux.app/http/response/html"
"miniflux.app/http/route"
@ -59,3 +60,46 @@ func (h *handler) uploadOPML(w http.ResponseWriter, r *http.Request) {
html.Redirect(w, r, route.Path(h.router, "feeds"))
}
func (h *handler) fetchOPML(w http.ResponseWriter, r *http.Request) {
user, err := h.store.UserByID(request.UserID(r))
if err != nil {
html.ServerError(w, r, err)
return
}
url := r.FormValue("url")
if url == "" {
html.Redirect(w, r, route.Path(h.router, "import"))
return
}
logger.Debug(
"[UI:FetchOPML] User #%d fetching this URL: %s",
user.ID,
url,
)
sess := session.New(h.store, request.SessionID(r))
view := view.New(h.tpl, r, sess)
view.Set("menu", "feeds")
view.Set("user", user)
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
clt := client.New(url)
resp, err := clt.Get()
if err != nil {
view.Set("errorMessage", err)
html.OK(w, r, view.Render("import"))
return
}
if impErr := opml.NewHandler(h.store).Import(user.ID, resp.Body); impErr != nil {
view.Set("errorMessage", impErr)
html.OK(w, r, view.Render("import"))
return
}
html.Redirect(w, r, route.Path(h.router, "feeds"))
}

View file

@ -112,6 +112,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool, feedHa
uiRouter.HandleFunc("/export", handler.exportFeeds).Name("export").Methods("GET")
uiRouter.HandleFunc("/import", handler.showImportPage).Name("import").Methods("GET")
uiRouter.HandleFunc("/upload", handler.uploadOPML).Name("uploadOPML").Methods("POST")
uiRouter.HandleFunc("/fetch", handler.fetchOPML).Name("fetchOPML").Methods("POST")
// OAuth2 flow.
uiRouter.HandleFunc("/oauth2/{provider}/unlink", handler.oauth2Unlink).Name("oauth2Unlink").Methods("GET")