From 31da4db14fdda364b1c72460a81e3ccce67ff7e8 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 29 Apr 2018 17:43:40 -0700 Subject: Do not show save link if no integration is configured --- storage/integration.go | 15 +++++ template/common.go | 34 ++++++------ template/html/bookmark_entries.html | 30 ++++++++++ template/html/category_entries.html | 2 +- template/html/common/item_meta.html | 30 +++++----- template/html/entry.html | 20 ++++--- template/html/feed_entries.html | 2 +- template/html/history.html | 37 ------------ template/html/history_entries.html | 37 ++++++++++++ template/html/starred.html | 30 ---------- template/html/unread.html | 40 ------------- template/html/unread_entries.html | 40 +++++++++++++ template/views.go | 108 ++++++++++++++++++------------------ ui/bookmark_entries.go | 3 +- ui/category_entries.go | 1 + ui/entry_bookmark.go | 92 ++++++++++++++++++++++++++++++ ui/entry_category.go | 1 + ui/entry_feed.go | 1 + ui/entry_read.go | 1 + ui/entry_starred.go | 91 ------------------------------ ui/entry_unread.go | 1 + ui/feed_entries.go | 1 + ui/history_entries.go | 3 +- ui/unread_entries.go | 3 +- 24 files changed, 328 insertions(+), 295 deletions(-) create mode 100644 template/html/bookmark_entries.html delete mode 100644 template/html/history.html create mode 100644 template/html/history_entries.html delete mode 100644 template/html/starred.html delete mode 100644 template/html/unread.html create mode 100644 template/html/unread_entries.html create mode 100644 ui/entry_bookmark.go delete mode 100644 ui/entry_starred.go diff --git a/storage/integration.go b/storage/integration.go index 5a60d85..6a389de 100644 --- a/storage/integration.go +++ b/storage/integration.go @@ -176,3 +176,18 @@ func (s *Storage) CreateIntegration(userID int64) error { return nil } + +// HasSaveEntry returns true if the given user can save articles to third-parties. +func (s *Storage) HasSaveEntry(userID int64) (result bool) { + query := ` + SELECT true FROM integrations + WHERE user_id=$1 AND + (pinboard_enabled='t' OR instapaper_enabled='t' OR wallabag_enabled='t' OR nunux_keeper_enabled='t') + ` + + if err := s.db.QueryRow(query, userID).Scan(&result); err != nil { + result = false + } + + return result +} diff --git a/template/common.go b/template/common.go index 62645ef..f573ba1 100644 --- a/template/common.go +++ b/template/common.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-04-29 16:22:00.539326448 -0700 PDT m=+0.023616542 +// 2018-04-29 17:36:50.459886967 -0700 PDT m=+0.024552529 package template @@ -32,18 +32,25 @@ var templateCommonMap = map[string]string{
  • -
  • - {{ t "Save" }} -
  • + {{ if .hasSaveEntry }} +
  • + {{ t "Save" }} +
  • + {{ end }}
  • {{ t "Original" }}
  • + {{ if .entry.CommentsURL }} +
  • + {{ t "Comments" }} +
  • + {{ end }}
  • {{ if eq .entry.Status "read" }}✘ {{ t "Unread" }}{{ else }}✔ {{ t "Read" }}{{ end }}
  • - {{ if .entry.CommentsURL }} -
  • - {{ t "Comments" }} -
  • - {{ end }} {{ end }}`, @@ -220,7 +222,7 @@ var templateCommonMap = map[string]string{ var templateCommonMapChecksums = map[string]string{ "entry_pagination": "f1465fa70f585ae8043b200ec9de5bf437ffbb0c19fb7aefc015c3555614ee27", - "item_meta": "c14b5b36076e087346def2ebcef4876ed5e8165218f40dc017db44e754c22d03", + "item_meta": "6cff8ae243f19dac936e523867d2975f70aa749b2a461ae63f6ebbca94cf7419", "layout": "c7565e2cf904612e236bc1d7167c6c124ffe5d27348608eb5c2336606f266896", "pagination": "6ff462c2b2a53bc5448b651da017f40a39f1d4f16cef4b2f09784f0797286924", } diff --git a/template/html/bookmark_entries.html b/template/html/bookmark_entries.html new file mode 100644 index 0000000..afd8192 --- /dev/null +++ b/template/html/bookmark_entries.html @@ -0,0 +1,30 @@ +{{ define "title"}}{{ t "Favorites" }} ({{ .total }}){{ end }} + +{{ define "content"}} + + +{{ if not .entries }} +

    {{ t "There is no bookmark at the moment." }}

    +{{ else }} +
    + {{ range .entries }} +
    +
    + + {{ if ne .Feed.Icon.IconID 0 }} + + {{ end }} + {{ .Title }} + + {{ .Feed.Category.Title }} +
    + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} +
    + {{ end }} +
    + {{ template "pagination" .pagination }} +{{ end }} + +{{ end }} diff --git a/template/html/category_entries.html b/template/html/category_entries.html index 8910f22..41d3c40 100644 --- a/template/html/category_entries.html +++ b/template/html/category_entries.html @@ -27,7 +27,7 @@ {{ .Feed.Category.Title }} - {{ template "item_meta" dict "user" $.user "entry" . }} + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} {{ end }} diff --git a/template/html/common/item_meta.html b/template/html/common/item_meta.html index 7d83c15..7c43ef5 100644 --- a/template/html/common/item_meta.html +++ b/template/html/common/item_meta.html @@ -7,18 +7,25 @@
  • -
  • - {{ t "Save" }} -
  • + {{ if .hasSaveEntry }} +
  • + {{ t "Save" }} +
  • + {{ end }}
  • {{ t "Original" }}
  • + {{ if .entry.CommentsURL }} +
  • + {{ t "Comments" }} +
  • + {{ end }}
  • {{ if eq .entry.Status "read" }}✘ {{ t "Unread" }}{{ else }}✔ {{ t "Read" }}{{ end }}
  • - {{ if .entry.CommentsURL }} -
  • - {{ t "Comments" }} -
  • - {{ end }} {{ end }} \ No newline at end of file diff --git a/template/html/entry.html b/template/html/entry.html index 55d0390..cc061aa 100644 --- a/template/html/entry.html +++ b/template/html/entry.html @@ -18,15 +18,17 @@ data-value="{{ if .Starred }}star{{ else }}unstar{{ end }}" >{{ if .entry.Starred }}★ {{ t "Unstar" }}{{ else }}☆ {{ t "Star" }}{{ end }} -
  • - {{ t "Save" }} -
  • + {{ if .hasSaveEntry }} +
  • + {{ t "Save" }} +
  • + {{ end }}
  • {{ .Feed.Category.Title }} - {{ template "item_meta" dict "user" $.user "entry" . }} + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} {{ end }} diff --git a/template/html/history.html b/template/html/history.html deleted file mode 100644 index 3b806da..0000000 --- a/template/html/history.html +++ /dev/null @@ -1,37 +0,0 @@ -{{ define "title"}}{{ t "History" }} ({{ .total }}){{ end }} - -{{ define "content"}} - - -{{ if not .entries }} -

    {{ t "There is no history at the moment." }}

    -{{ else }} -
    - {{ range .entries }} - - {{ end }} -
    - {{ template "pagination" .pagination }} -{{ end }} - -{{ end }} diff --git a/template/html/history_entries.html b/template/html/history_entries.html new file mode 100644 index 0000000..ed82dae --- /dev/null +++ b/template/html/history_entries.html @@ -0,0 +1,37 @@ +{{ define "title"}}{{ t "History" }} ({{ .total }}){{ end }} + +{{ define "content"}} + + +{{ if not .entries }} +

    {{ t "There is no history at the moment." }}

    +{{ else }} +
    + {{ range .entries }} +
    +
    + + {{ if ne .Feed.Icon.IconID 0 }} + + {{ end }} + {{ .Title }} + + {{ .Feed.Category.Title }} +
    + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} +
    + {{ end }} +
    + {{ template "pagination" .pagination }} +{{ end }} + +{{ end }} diff --git a/template/html/starred.html b/template/html/starred.html deleted file mode 100644 index e2a2407..0000000 --- a/template/html/starred.html +++ /dev/null @@ -1,30 +0,0 @@ -{{ define "title"}}{{ t "Favorites" }} ({{ .total }}){{ end }} - -{{ define "content"}} - - -{{ if not .entries }} -

    {{ t "There is no bookmark at the moment." }}

    -{{ else }} -
    - {{ range .entries }} - - {{ end }} -
    - {{ template "pagination" .pagination }} -{{ end }} - -{{ end }} diff --git a/template/html/unread.html b/template/html/unread.html deleted file mode 100644 index c8e0a8e..0000000 --- a/template/html/unread.html +++ /dev/null @@ -1,40 +0,0 @@ -{{ define "title"}}{{ t "Unread Items" }} {{ if gt .countUnread 0 }}({{ .countUnread }}){{ end }} {{ end }} - -{{ define "content"}} - - -{{ if not .entries }} -

    {{ t "There is no unread article." }}

    -{{ else }} -
    - {{ range .entries }} - - {{ end }} -
    - {{ template "pagination" .pagination }} -{{ end }} - -{{ end }} \ No newline at end of file diff --git a/template/html/unread_entries.html b/template/html/unread_entries.html new file mode 100644 index 0000000..b23049e --- /dev/null +++ b/template/html/unread_entries.html @@ -0,0 +1,40 @@ +{{ define "title"}}{{ t "Unread Items" }} {{ if gt .countUnread 0 }}({{ .countUnread }}){{ end }} {{ end }} + +{{ define "content"}} + + +{{ if not .entries }} +

    {{ t "There is no unread article." }}

    +{{ else }} +
    + {{ range .entries }} +
    +
    + + {{ if ne .Feed.Icon.IconID 0 }} + + {{ end }} + {{ .Title }} + + {{ .Feed.Category.Title }} +
    + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} +
    + {{ end }} +
    + {{ template "pagination" .pagination }} +{{ end }} + +{{ end }} \ No newline at end of file diff --git a/template/views.go b/template/views.go index 712dc60..3c2167a 100644 --- a/template/views.go +++ b/template/views.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-04-29 16:22:00.531039167 -0700 PDT m=+0.015329261 +// 2018-04-29 17:36:50.450844913 -0700 PDT m=+0.015510475 package template @@ -91,6 +91,37 @@ var templateViewsMap = map[string]string{ {{ end }} +{{ end }} +`, + "bookmark_entries": `{{ define "title"}}{{ t "Favorites" }} ({{ .total }}){{ end }} + +{{ define "content"}} + + +{{ if not .entries }} +

    {{ t "There is no bookmark at the moment." }}

    +{{ else }} +
    + {{ range .entries }} +
    +
    + + {{ if ne .Feed.Icon.IconID 0 }} + + {{ end }} + {{ .Title }} + + {{ .Feed.Category.Title }} +
    + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} +
    + {{ end }} +
    + {{ template "pagination" .pagination }} +{{ end }} + {{ end }} `, "categories": `{{ define "title"}}{{ t "Categories" }} ({{ .total }}){{ end }} @@ -179,7 +210,7 @@ var templateViewsMap = map[string]string{ {{ .Feed.Category.Title }} - {{ template "item_meta" dict "user" $.user "entry" . }} + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} {{ end }} @@ -483,15 +514,17 @@ var templateViewsMap = map[string]string{ data-value="{{ if .Starred }}star{{ else }}unstar{{ end }}" >{{ if .entry.Starred }}★ {{ t "Unstar" }}{{ else }}☆ {{ t "Star" }}{{ end }}
  • -
  • - {{ t "Save" }} -
  • + {{ if .hasSaveEntry }} +
  • + {{ t "Save" }} +
  • + {{ end }}
  • {{ .Feed.Category.Title }} - {{ template "item_meta" dict "user" $.user "entry" . }} + {{ template "item_meta" dict "user" $.user "entry" . "hasSaveEntry" $.hasSaveEntry }} {{ end }} @@ -705,7 +738,7 @@ var templateViewsMap = map[string]string{ {{ end }} `, - "history": `{{ define "title"}}{{ t "History" }} ({{ .total }}){{ end }} + "history_entries": `{{ define "title"}}{{ t "History" }} ({{ .total }}){{ end }} {{ define "content"}}