From 206be5ba1579fbd658093143088fce62a27df7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 25 Oct 2022 20:00:56 -0700 Subject: [PATCH] Rename column to CategoriesSortingOrder --- client/model.go | 84 ++++++++++++------------ database/migrations.go | 2 +- locale/translations/de_DE.json | 2 +- locale/translations/el_EL.json | 2 +- locale/translations/en_US.json | 2 +- locale/translations/es_ES.json | 2 +- locale/translations/fi_FI.json | 2 +- locale/translations/fr_FR.json | 2 +- locale/translations/hi_IN.json | 2 +- locale/translations/it_IT.json | 2 +- locale/translations/ja_JP.json | 2 +- locale/translations/nl_NL.json | 2 +- locale/translations/pl_PL.json | 2 +- locale/translations/pt_BR.json | 2 +- locale/translations/ru_RU.json | 2 +- locale/translations/tr_TR.json | 2 +- locale/translations/uk_UA.json | 2 +- locale/translations/zh_CN.json | 2 +- locale/translations/zh_TW.json | 2 +- model/categories_sort_options.go | 5 +- model/user.go | 88 +++++++++++++------------- storage/category.go | 2 +- storage/user.go | 26 ++++---- template/templates/views/settings.html | 8 +-- ui/form/settings.go | 74 +++++++++++----------- ui/settings_show.go | 34 +++++----- 26 files changed, 178 insertions(+), 179 deletions(-) diff --git a/client/model.go b/client/model.go index 34f09224..4335120c 100644 --- a/client/model.go +++ b/client/model.go @@ -18,28 +18,28 @@ const ( // User represents a user in the system. type User struct { - ID int64 `json:"id"` - Username string `json:"username"` - Password string `json:"password,omitempty"` - IsAdmin bool `json:"is_admin"` - Theme string `json:"theme"` - Language string `json:"language"` - Timezone string `json:"timezone"` - EntryDirection string `json:"entry_sorting_direction"` - EntryOrder string `json:"entry_sorting_order"` - Stylesheet string `json:"stylesheet"` - GoogleID string `json:"google_id"` - OpenIDConnectID string `json:"openid_connect_id"` - EntriesPerPage int `json:"entries_per_page"` - KeyboardShortcuts bool `json:"keyboard_shortcuts"` - ShowReadingTime bool `json:"show_reading_time"` - EntrySwipe bool `json:"entry_swipe"` - LastLoginAt *time.Time `json:"last_login_at"` - DisplayMode string `json:"display_mode"` - DefaultReadingSpeed int `json:"default_reading_speed"` - CJKReadingSpeed int `json:"cjk_reading_speed"` - DefaultHomePage string `json:"default_home_page"` - CategoriesSortOrder string `json:"categories_sort_order"` + ID int64 `json:"id"` + Username string `json:"username"` + Password string `json:"password,omitempty"` + IsAdmin bool `json:"is_admin"` + Theme string `json:"theme"` + Language string `json:"language"` + Timezone string `json:"timezone"` + EntryDirection string `json:"entry_sorting_direction"` + EntryOrder string `json:"entry_sorting_order"` + Stylesheet string `json:"stylesheet"` + GoogleID string `json:"google_id"` + OpenIDConnectID string `json:"openid_connect_id"` + EntriesPerPage int `json:"entries_per_page"` + KeyboardShortcuts bool `json:"keyboard_shortcuts"` + ShowReadingTime bool `json:"show_reading_time"` + EntrySwipe bool `json:"entry_swipe"` + LastLoginAt *time.Time `json:"last_login_at"` + DisplayMode string `json:"display_mode"` + DefaultReadingSpeed int `json:"default_reading_speed"` + CJKReadingSpeed int `json:"cjk_reading_speed"` + DefaultHomePage string `json:"default_home_page"` + CategoriesSortingOrder string `json:"categories_sorting_order"` } func (u User) String() string { @@ -57,26 +57,26 @@ type UserCreationRequest struct { // UserModificationRequest represents the request to update a user. type UserModificationRequest struct { - Username *string `json:"username"` - Password *string `json:"password"` - IsAdmin *bool `json:"is_admin"` - Theme *string `json:"theme"` - Language *string `json:"language"` - Timezone *string `json:"timezone"` - EntryDirection *string `json:"entry_sorting_direction"` - EntryOrder *string `json:"entry_sorting_order"` - Stylesheet *string `json:"stylesheet"` - GoogleID *string `json:"google_id"` - OpenIDConnectID *string `json:"openid_connect_id"` - EntriesPerPage *int `json:"entries_per_page"` - KeyboardShortcuts *bool `json:"keyboard_shortcuts"` - ShowReadingTime *bool `json:"show_reading_time"` - EntrySwipe *bool `json:"entry_swipe"` - DisplayMode *string `json:"display_mode"` - DefaultReadingSpeed *int `json:"default_reading_speed"` - CJKReadingSpeed *int `json:"cjk_reading_speed"` - DefaultHomePage *string `json:"default_home_page"` - CategoriesSortOrder *string `json:"categories_sort_order"` + Username *string `json:"username"` + Password *string `json:"password"` + IsAdmin *bool `json:"is_admin"` + Theme *string `json:"theme"` + Language *string `json:"language"` + Timezone *string `json:"timezone"` + EntryDirection *string `json:"entry_sorting_direction"` + EntryOrder *string `json:"entry_sorting_order"` + Stylesheet *string `json:"stylesheet"` + GoogleID *string `json:"google_id"` + OpenIDConnectID *string `json:"openid_connect_id"` + EntriesPerPage *int `json:"entries_per_page"` + KeyboardShortcuts *bool `json:"keyboard_shortcuts"` + ShowReadingTime *bool `json:"show_reading_time"` + EntrySwipe *bool `json:"entry_swipe"` + DisplayMode *string `json:"display_mode"` + DefaultReadingSpeed *int `json:"default_reading_speed"` + CJKReadingSpeed *int `json:"cjk_reading_speed"` + DefaultHomePage *string `json:"default_home_page"` + CategoriesSortingOrder *string `json:"categories_sorting_order"` } // Users represents a list of users. diff --git a/database/migrations.go b/database/migrations.go index 6a568031..af83888c 100644 --- a/database/migrations.go +++ b/database/migrations.go @@ -618,7 +618,7 @@ var migrations = []func(tx *sql.Tx) error{ }, func(tx *sql.Tx) (err error) { _, err = tx.Exec(` - ALTER TABLE users ADD COLUMN categories_sort_order text not null default 'unread_count'; + ALTER TABLE users ADD COLUMN categories_sorting_order text not null default 'unread_count'; `) return }, diff --git a/locale/translations/de_DE.json b/locale/translations/de_DE.json index 73de3f7e..3ef47a17 100644 --- a/locale/translations/de_DE.json +++ b/locale/translations/de_DE.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Benutzerdefiniertes CSS", "form.prefs.label.entry_order": "Eintrag Sortierspalte", "form.prefs.label.default_home_page": "Standard Startseite", - "form.prefs.label.categories_sort_order": "Kategorien sortieren", + "form.prefs.label.categories_sorting_order": "Kategorien sortieren", "form.import.label.file": "OPML Datei", "form.import.label.url": "URL", "form.integration.fever_activate": "Fever API aktivieren", diff --git a/locale/translations/el_EL.json b/locale/translations/el_EL.json index bd3f550a..bc9e77a2 100644 --- a/locale/translations/el_EL.json +++ b/locale/translations/el_EL.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Προσαρμοσμένο CSS", "form.prefs.label.entry_order": "Στήλη ταξινόμησης εισόδου", "form.prefs.label.default_home_page": "Προεπιλεγμένη αρχική σελίδα", - "form.prefs.label.categories_sort_order": "Ταξινόμηση κατηγοριών", + "form.prefs.label.categories_sorting_order": "Ταξινόμηση κατηγοριών", "form.import.label.file": "Αρχείο OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Ενεργοποιήστε το Fever API", diff --git a/locale/translations/en_US.json b/locale/translations/en_US.json index f8a5e574..b993744b 100644 --- a/locale/translations/en_US.json +++ b/locale/translations/en_US.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Custom CSS", "form.prefs.label.entry_order": "Entry Sorting Column", "form.prefs.label.default_home_page": "Default home page", - "form.prefs.label.categories_sort_order": "Categories Sorting", + "form.prefs.label.categories_sorting_order": "Categories Sorting", "form.import.label.file": "OPML file", "form.import.label.url": "URL", "form.integration.fever_activate": "Activate Fever API", diff --git a/locale/translations/es_ES.json b/locale/translations/es_ES.json index f2b51d51..6b14c96d 100644 --- a/locale/translations/es_ES.json +++ b/locale/translations/es_ES.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "CSS personalizado", "form.prefs.label.entry_order": "Columna de clasificación de entradas", "form.prefs.label.default_home_page": "Página de inicio por defecto", - "form.prefs.label.categories_sort_order": "Clasificación por categorías", + "form.prefs.label.categories_sorting_order": "Clasificación por categorías", "form.import.label.file": "Archivo OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Activar API de Fever", diff --git a/locale/translations/fi_FI.json b/locale/translations/fi_FI.json index e6b0c8ef..cea9970f 100644 --- a/locale/translations/fi_FI.json +++ b/locale/translations/fi_FI.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Mukautettu CSS", "form.prefs.label.entry_order": "Lajittele sarakkeen mukaan", "form.prefs.label.default_home_page": "Oletusarvoinen etusivu", - "form.prefs.label.categories_sort_order": "Kategorioiden lajittelu", + "form.prefs.label.categories_sorting_order": "Kategorioiden lajittelu", "form.import.label.file": "OPML-tiedosto", "form.import.label.url": "URL", "form.integration.fever_activate": "Ota Fever API käyttöön", diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index 961b1a12..4ad16d59 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "CSS personnalisé", "form.prefs.label.entry_order": "Colonne de tri des entrées", "form.prefs.label.default_home_page": "Page d'accueil par défaut", - "form.prefs.label.categories_sort_order": "Colonne de tri des catégories", + "form.prefs.label.categories_sorting_order": "Colonne de tri des catégories", "form.import.label.file": "Fichier OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Activer l'API de Fever", diff --git a/locale/translations/hi_IN.json b/locale/translations/hi_IN.json index 646f5898..d44bc99e 100644 --- a/locale/translations/hi_IN.json +++ b/locale/translations/hi_IN.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "कस्टम सीएसएस", "form.prefs.label.entry_order": "प्रवेश छँटाई कॉलम", "form.prefs.label.default_home_page": "डिफ़ॉल्ट होमपेज़", - "form.prefs.label.categories_sort_order": "श्रेणियाँ छँटाई", + "form.prefs.label.categories_sorting_order": "श्रेणियाँ छँटाई", "form.import.label.file": "ओपीएमएल फ़ाइल", "form.import.label.url": "यूआरएल", "form.integration.fever_activate": "फीवर एपीआई सक्रिय करें", diff --git a/locale/translations/it_IT.json b/locale/translations/it_IT.json index aa0c9d39..c22ade55 100644 --- a/locale/translations/it_IT.json +++ b/locale/translations/it_IT.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "CSS personalizzati", "form.prefs.label.entry_order": "Colonna di ordinamento delle voci", "form.prefs.label.default_home_page": "Pagina iniziale predefinita", - "form.prefs.label.categories_sort_order": "Ordinamento delle categorie", + "form.prefs.label.categories_sorting_order": "Ordinamento delle categorie", "form.import.label.file": "File OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Abilita l'API di Fever", diff --git a/locale/translations/ja_JP.json b/locale/translations/ja_JP.json index 75d8cf00..08a95266 100644 --- a/locale/translations/ja_JP.json +++ b/locale/translations/ja_JP.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "カスタムCSS", "form.prefs.label.entry_order": "エントリーソートカラム", "form.prefs.label.default_home_page": "デフォルトのトップページ", - "form.prefs.label.categories_sort_order": "カテゴリの並べ替え", + "form.prefs.label.categories_sorting_order": "カテゴリの並べ替え", "form.import.label.file": "OPML ファイル", "form.import.label.url": "URL", "form.integration.fever_activate": "Fever API を有効にする", diff --git a/locale/translations/nl_NL.json b/locale/translations/nl_NL.json index bf80d9b0..4ca58f4d 100644 --- a/locale/translations/nl_NL.json +++ b/locale/translations/nl_NL.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Aangepaste CSS", "form.prefs.label.entry_order": "Ingang Sorteerkolom", "form.prefs.label.default_home_page": "Standaard startpagina", - "form.prefs.label.categories_sort_order": "Categorieën sorteren", + "form.prefs.label.categories_sorting_order": "Categorieën sorteren", "form.import.label.file": "OPML-bestand", "form.import.label.url": "URL", "form.integration.fever_activate": "Activeer Fever API", diff --git a/locale/translations/pl_PL.json b/locale/translations/pl_PL.json index 217d0131..da9d949e 100644 --- a/locale/translations/pl_PL.json +++ b/locale/translations/pl_PL.json @@ -315,7 +315,7 @@ "form.prefs.label.custom_css": "Niestandardowy CSS", "form.prefs.label.entry_order": "Kolumna sortowania wpisów", "form.prefs.label.default_home_page": "Domyślna strona główna", - "form.prefs.label.categories_sort_order": "Sortowanie kategorii", + "form.prefs.label.categories_sorting_order": "Sortowanie kategorii", "form.import.label.file": "Plik OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Aktywuj Fever API", diff --git a/locale/translations/pt_BR.json b/locale/translations/pt_BR.json index 39f7edac..91f9c743 100644 --- a/locale/translations/pt_BR.json +++ b/locale/translations/pt_BR.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "CSS customizado", "form.prefs.label.entry_order": "Coluna de Ordenação de Entrada", "form.prefs.label.default_home_page": "Página inicial predefinida", - "form.prefs.label.categories_sort_order": "Classificação das categorias", + "form.prefs.label.categories_sorting_order": "Classificação das categorias", "form.import.label.file": "Arquivo OPML", "form.import.label.url": "URL", "form.integration.fever_activate": "Ativar API do Fever", diff --git a/locale/translations/ru_RU.json b/locale/translations/ru_RU.json index 8f55e78a..f9f8234d 100644 --- a/locale/translations/ru_RU.json +++ b/locale/translations/ru_RU.json @@ -315,7 +315,7 @@ "form.prefs.label.custom_css": "Пользовательские CSS", "form.prefs.label.entry_order": "Колонка сортировки ввода", "form.prefs.label.default_home_page": "Домашняя страница по умолчанию", - "form.prefs.label.categories_sort_order": "Сортировка категорий", + "form.prefs.label.categories_sorting_order": "Сортировка категорий", "form.import.label.file": "OPML файл", "form.import.label.url": "URL", "form.integration.fever_activate": "Активировать Fever API", diff --git a/locale/translations/tr_TR.json b/locale/translations/tr_TR.json index f93d305f..5d7f07ae 100644 --- a/locale/translations/tr_TR.json +++ b/locale/translations/tr_TR.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "Özel CSS", "form.prefs.label.entry_order": "Giriş Sıralama Sütunu", "form.prefs.label.default_home_page": "Varsayılan ana sayfa", - "form.prefs.label.categories_sort_order": "Kategoriler sıralama", + "form.prefs.label.categories_sorting_order": "Kategoriler sıralama", "form.import.label.file": "OPML dosyası", "form.import.label.url": "URL", "form.integration.fever_activate": "Fever API'yi Etkinleştir", diff --git a/locale/translations/uk_UA.json b/locale/translations/uk_UA.json index d397e546..52e1c054 100644 --- a/locale/translations/uk_UA.json +++ b/locale/translations/uk_UA.json @@ -312,7 +312,7 @@ "form.prefs.label.custom_css": "Спеціальний CSS", "form.prefs.label.entry_order": "Стовпець сортування записів", "form.prefs.label.default_home_page": "Домашня сторінка за умовчанням", - "form.prefs.label.categories_sort_order": "Сортування за категоріями", + "form.prefs.label.categories_sorting_order": "Сортування за категоріями", "form.import.label.file": "Файл OPML", "form.import.label.url": "URL-адреса", "form.integration.fever_activate": "Увімкнути API Fever", diff --git a/locale/translations/zh_CN.json b/locale/translations/zh_CN.json index 94630575..3ccdea7d 100644 --- a/locale/translations/zh_CN.json +++ b/locale/translations/zh_CN.json @@ -311,7 +311,7 @@ "form.prefs.label.custom_css": "自定义 CSS", "form.prefs.label.entry_order": "文章排序依据", "form.prefs.label.default_home_page": "默认主页", - "form.prefs.label.categories_sort_order": "分类排序", + "form.prefs.label.categories_sorting_order": "分类排序", "form.import.label.file": "OPML 文件", "form.import.label.url": "URL", "form.integration.fever_activate": "启用 Fever API", diff --git a/locale/translations/zh_TW.json b/locale/translations/zh_TW.json index f76ef458..e046e7f1 100644 --- a/locale/translations/zh_TW.json +++ b/locale/translations/zh_TW.json @@ -313,7 +313,7 @@ "form.prefs.label.custom_css": "自定義 CSS", "form.prefs.label.entry_order": "文章排序依據", "form.prefs.label.default_home_page": "默認主頁", - "form.prefs.label.categories_sort_order": "分類排序", + "form.prefs.label.categories_sorting_order": "分類排序", "form.import.label.file": "OPML 檔案", "form.import.label.url": "URL", "form.integration.fever_activate": "啟用 Fever API", diff --git a/model/categories_sort_options.go b/model/categories_sort_options.go index c7feb2c6..fa77f1cc 100644 --- a/model/categories_sort_options.go +++ b/model/categories_sort_options.go @@ -1,11 +1,10 @@ -// Copyright 2017 Frédéric Guillot. All rights reserved. +// Copyright 2022 Frédéric Guillot. All rights reserved. // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. package model // import "miniflux.app/model" -// HomePages returns the list of available home pages. -func CategoriesSortOptions() map[string]string { +func CategoriesSortingOptions() map[string]string { return map[string]string{ "unread_count": "form.prefs.select.unread_count", "alphabetical": "form.prefs.select.alphabetical", diff --git a/model/user.go b/model/user.go index a642c26c..341d28dc 100644 --- a/model/user.go +++ b/model/user.go @@ -12,28 +12,28 @@ import ( // User represents a user in the system. type User struct { - ID int64 `json:"id"` - Username string `json:"username"` - Password string `json:"-"` - IsAdmin bool `json:"is_admin"` - Theme string `json:"theme"` - Language string `json:"language"` - Timezone string `json:"timezone"` - EntryDirection string `json:"entry_sorting_direction"` - EntryOrder string `json:"entry_sorting_order"` - Stylesheet string `json:"stylesheet"` - GoogleID string `json:"google_id"` - OpenIDConnectID string `json:"openid_connect_id"` - EntriesPerPage int `json:"entries_per_page"` - KeyboardShortcuts bool `json:"keyboard_shortcuts"` - ShowReadingTime bool `json:"show_reading_time"` - EntrySwipe bool `json:"entry_swipe"` - LastLoginAt *time.Time `json:"last_login_at"` - DisplayMode string `json:"display_mode"` - DefaultReadingSpeed int `json:"default_reading_speed"` - CJKReadingSpeed int `json:"cjk_reading_speed"` - DefaultHomePage string `json:"default_home_page"` - CategoriesSortOrder string `json:"categories_sort_order"` + ID int64 `json:"id"` + Username string `json:"username"` + Password string `json:"-"` + IsAdmin bool `json:"is_admin"` + Theme string `json:"theme"` + Language string `json:"language"` + Timezone string `json:"timezone"` + EntryDirection string `json:"entry_sorting_direction"` + EntryOrder string `json:"entry_sorting_order"` + Stylesheet string `json:"stylesheet"` + GoogleID string `json:"google_id"` + OpenIDConnectID string `json:"openid_connect_id"` + EntriesPerPage int `json:"entries_per_page"` + KeyboardShortcuts bool `json:"keyboard_shortcuts"` + ShowReadingTime bool `json:"show_reading_time"` + EntrySwipe bool `json:"entry_swipe"` + LastLoginAt *time.Time `json:"last_login_at"` + DisplayMode string `json:"display_mode"` + DefaultReadingSpeed int `json:"default_reading_speed"` + CJKReadingSpeed int `json:"cjk_reading_speed"` + DefaultHomePage string `json:"default_home_page"` + CategoriesSortingOrder string `json:"categories_sorting_order"` } // UserCreationRequest represents the request to create a user. @@ -47,26 +47,26 @@ type UserCreationRequest struct { // UserModificationRequest represents the request to update a user. type UserModificationRequest struct { - Username *string `json:"username"` - Password *string `json:"password"` - Theme *string `json:"theme"` - Language *string `json:"language"` - Timezone *string `json:"timezone"` - EntryDirection *string `json:"entry_sorting_direction"` - EntryOrder *string `json:"entry_sorting_order"` - Stylesheet *string `json:"stylesheet"` - GoogleID *string `json:"google_id"` - OpenIDConnectID *string `json:"openid_connect_id"` - EntriesPerPage *int `json:"entries_per_page"` - IsAdmin *bool `json:"is_admin"` - KeyboardShortcuts *bool `json:"keyboard_shortcuts"` - ShowReadingTime *bool `json:"show_reading_time"` - EntrySwipe *bool `json:"entry_swipe"` - DisplayMode *string `json:"display_mode"` - DefaultReadingSpeed *int `json:"default_reading_speed"` - CJKReadingSpeed *int `json:"cjk_reading_speed"` - DefaultHomePage *string `json:"default_home_page"` - CategoriesSortOrder *string `json:"categories_sort_order"` + Username *string `json:"username"` + Password *string `json:"password"` + Theme *string `json:"theme"` + Language *string `json:"language"` + Timezone *string `json:"timezone"` + EntryDirection *string `json:"entry_sorting_direction"` + EntryOrder *string `json:"entry_sorting_order"` + Stylesheet *string `json:"stylesheet"` + GoogleID *string `json:"google_id"` + OpenIDConnectID *string `json:"openid_connect_id"` + EntriesPerPage *int `json:"entries_per_page"` + IsAdmin *bool `json:"is_admin"` + KeyboardShortcuts *bool `json:"keyboard_shortcuts"` + ShowReadingTime *bool `json:"show_reading_time"` + EntrySwipe *bool `json:"entry_swipe"` + DisplayMode *string `json:"display_mode"` + DefaultReadingSpeed *int `json:"default_reading_speed"` + CJKReadingSpeed *int `json:"cjk_reading_speed"` + DefaultHomePage *string `json:"default_home_page"` + CategoriesSortingOrder *string `json:"categories_sorting_order"` } // Patch updates the User object with the modification request. @@ -147,8 +147,8 @@ func (u *UserModificationRequest) Patch(user *User) { user.DefaultHomePage = *u.DefaultHomePage } - if u.CategoriesSortOrder != nil { - user.CategoriesSortOrder = *u.CategoriesSortOrder + if u.CategoriesSortingOrder != nil { + user.CategoriesSortingOrder = *u.CategoriesSortingOrder } } diff --git a/storage/category.go b/storage/category.go index 52e7dcc0..14e19a53 100644 --- a/storage/category.go +++ b/storage/category.go @@ -133,7 +133,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error user_id=$1 ` - if user.CategoriesSortOrder == "alphabetical" { + if user.CategoriesSortingOrder == "alphabetical" { query = query + ` ORDER BY c.title ASC diff --git a/storage/user.go b/storage/user.go index e06cd5eb..15b706ff 100644 --- a/storage/user.go +++ b/storage/user.go @@ -89,7 +89,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m default_reading_speed, cjk_reading_speed, default_home_page, - categories_sort_order + categories_sorting_order ` tx, err := s.db.Begin() @@ -125,7 +125,7 @@ func (s *Storage) CreateUser(userCreationRequest *model.UserCreationRequest) (*m &user.DefaultReadingSpeed, &user.CJKReadingSpeed, &user.DefaultHomePage, - &user.CategoriesSortOrder, + &user.CategoriesSortingOrder, ) if err != nil { tx.Rollback() @@ -180,7 +180,7 @@ func (s *Storage) UpdateUser(user *model.User) error { default_reading_speed=$17, cjk_reading_speed=$18, default_home_page=$19, - categories_sort_order=$20 + categories_sorting_order=$20 WHERE id=$21 ` @@ -206,7 +206,7 @@ func (s *Storage) UpdateUser(user *model.User) error { user.DefaultReadingSpeed, user.CJKReadingSpeed, user.DefaultHomePage, - user.CategoriesSortOrder, + user.CategoriesSortingOrder, user.ID, ) if err != nil { @@ -233,7 +233,7 @@ func (s *Storage) UpdateUser(user *model.User) error { default_reading_speed=$16, cjk_reading_speed=$17, default_home_page=$18, - categories_sort_order=$19 + categories_sorting_order=$19 WHERE id=$20 ` @@ -258,7 +258,7 @@ func (s *Storage) UpdateUser(user *model.User) error { user.DefaultReadingSpeed, user.CJKReadingSpeed, user.DefaultHomePage, - user.CategoriesSortOrder, + user.CategoriesSortingOrder, user.ID, ) @@ -304,7 +304,7 @@ func (s *Storage) UserByID(userID int64) (*model.User, error) { default_reading_speed, cjk_reading_speed, default_home_page, - categories_sort_order + categories_sorting_order FROM users WHERE @@ -337,7 +337,7 @@ func (s *Storage) UserByUsername(username string) (*model.User, error) { default_reading_speed, cjk_reading_speed, default_home_page, - categories_sort_order + categories_sorting_order FROM users WHERE @@ -370,7 +370,7 @@ func (s *Storage) UserByField(field, value string) (*model.User, error) { default_reading_speed, cjk_reading_speed, default_home_page, - categories_sort_order + categories_sorting_order FROM users WHERE @@ -410,7 +410,7 @@ func (s *Storage) UserByAPIKey(token string) (*model.User, error) { u.default_reading_speed, u.cjk_reading_speed, u.default_home_page, - u.categories_sort_order + u.categories_sorting_order FROM users u LEFT JOIN @@ -444,7 +444,7 @@ func (s *Storage) fetchUser(query string, args ...interface{}) (*model.User, err &user.DefaultReadingSpeed, &user.CJKReadingSpeed, &user.DefaultHomePage, - &user.CategoriesSortOrder, + &user.CategoriesSortingOrder, ) if err == sql.ErrNoRows { @@ -540,7 +540,7 @@ func (s *Storage) Users() (model.Users, error) { default_reading_speed, cjk_reading_speed, default_home_page, - categories_sort_order + categories_sorting_order FROM users ORDER BY username ASC @@ -575,7 +575,7 @@ func (s *Storage) Users() (model.Users, error) { &user.DefaultReadingSpeed, &user.CJKReadingSpeed, &user.DefaultHomePage, - &user.CategoriesSortOrder, + &user.CategoriesSortingOrder, ) if err != nil { diff --git a/template/templates/views/settings.html b/template/templates/views/settings.html index 5904e89c..549ab275 100644 --- a/template/templates/views/settings.html +++ b/template/templates/views/settings.html @@ -70,10 +70,10 @@ {{ end }} - - + {{ range $key, $value := .categories_sorting_options }} + {{ end }} diff --git a/ui/form/settings.go b/ui/form/settings.go index b86d199a..20382d28 100644 --- a/ui/form/settings.go +++ b/ui/form/settings.go @@ -14,24 +14,24 @@ import ( // SettingsForm represents the settings form. type SettingsForm struct { - Username string - Password string - Confirmation string - Theme string - Language string - Timezone string - EntryDirection string - EntryOrder string - EntriesPerPage int - KeyboardShortcuts bool - ShowReadingTime bool - CustomCSS string - EntrySwipe bool - DisplayMode string - DefaultReadingSpeed int - CJKReadingSpeed int - DefaultHomePage string - CategoriesSortOrder string + Username string + Password string + Confirmation string + Theme string + Language string + Timezone string + EntryDirection string + EntryOrder string + EntriesPerPage int + KeyboardShortcuts bool + ShowReadingTime bool + CustomCSS string + EntrySwipe bool + DisplayMode string + DefaultReadingSpeed int + CJKReadingSpeed int + DefaultHomePage string + CategoriesSortingOrder string } // Merge updates the fields of the given user. @@ -51,7 +51,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User { user.CJKReadingSpeed = s.CJKReadingSpeed user.DefaultReadingSpeed = s.DefaultReadingSpeed user.DefaultHomePage = s.DefaultHomePage - user.CategoriesSortOrder = s.CategoriesSortOrder + user.CategoriesSortingOrder = s.CategoriesSortingOrder if s.Password != "" { user.Password = s.Password @@ -99,23 +99,23 @@ func NewSettingsForm(r *http.Request) *SettingsForm { cjkReadingSpeed = 0 } return &SettingsForm{ - Username: r.FormValue("username"), - Password: r.FormValue("password"), - Confirmation: r.FormValue("confirmation"), - Theme: r.FormValue("theme"), - Language: r.FormValue("language"), - Timezone: r.FormValue("timezone"), - EntryDirection: r.FormValue("entry_direction"), - EntryOrder: r.FormValue("entry_order"), - EntriesPerPage: int(entriesPerPage), - KeyboardShortcuts: r.FormValue("keyboard_shortcuts") == "1", - ShowReadingTime: r.FormValue("show_reading_time") == "1", - CustomCSS: r.FormValue("custom_css"), - EntrySwipe: r.FormValue("entry_swipe") == "1", - DisplayMode: r.FormValue("display_mode"), - DefaultReadingSpeed: int(defaultReadingSpeed), - CJKReadingSpeed: int(cjkReadingSpeed), - DefaultHomePage: r.FormValue("default_home_page"), - CategoriesSortOrder: r.FormValue("categories_sort_order"), + Username: r.FormValue("username"), + Password: r.FormValue("password"), + Confirmation: r.FormValue("confirmation"), + Theme: r.FormValue("theme"), + Language: r.FormValue("language"), + Timezone: r.FormValue("timezone"), + EntryDirection: r.FormValue("entry_direction"), + EntryOrder: r.FormValue("entry_order"), + EntriesPerPage: int(entriesPerPage), + KeyboardShortcuts: r.FormValue("keyboard_shortcuts") == "1", + ShowReadingTime: r.FormValue("show_reading_time") == "1", + CustomCSS: r.FormValue("custom_css"), + EntrySwipe: r.FormValue("entry_swipe") == "1", + DisplayMode: r.FormValue("display_mode"), + DefaultReadingSpeed: int(defaultReadingSpeed), + CJKReadingSpeed: int(cjkReadingSpeed), + DefaultHomePage: r.FormValue("default_home_page"), + CategoriesSortingOrder: r.FormValue("categories_sorting_order"), } } diff --git a/ui/settings_show.go b/ui/settings_show.go index 3f92c722..bfab21b5 100644 --- a/ui/settings_show.go +++ b/ui/settings_show.go @@ -27,22 +27,22 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) { } settingsForm := form.SettingsForm{ - Username: user.Username, - Theme: user.Theme, - Language: user.Language, - Timezone: user.Timezone, - EntryDirection: user.EntryDirection, - EntryOrder: user.EntryOrder, - EntriesPerPage: user.EntriesPerPage, - KeyboardShortcuts: user.KeyboardShortcuts, - ShowReadingTime: user.ShowReadingTime, - CustomCSS: user.Stylesheet, - EntrySwipe: user.EntrySwipe, - DisplayMode: user.DisplayMode, - DefaultReadingSpeed: user.DefaultReadingSpeed, - CJKReadingSpeed: user.CJKReadingSpeed, - DefaultHomePage: user.DefaultHomePage, - CategoriesSortOrder: user.CategoriesSortOrder, + Username: user.Username, + Theme: user.Theme, + Language: user.Language, + Timezone: user.Timezone, + EntryDirection: user.EntryDirection, + EntryOrder: user.EntryOrder, + EntriesPerPage: user.EntriesPerPage, + KeyboardShortcuts: user.KeyboardShortcuts, + ShowReadingTime: user.ShowReadingTime, + CustomCSS: user.Stylesheet, + EntrySwipe: user.EntrySwipe, + DisplayMode: user.DisplayMode, + DefaultReadingSpeed: user.DefaultReadingSpeed, + CJKReadingSpeed: user.CJKReadingSpeed, + DefaultHomePage: user.DefaultHomePage, + CategoriesSortingOrder: user.CategoriesSortingOrder, } timezones, err := h.store.Timezones() @@ -60,7 +60,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) { view.Set("countUnread", h.store.CountUnreadEntries(user.ID)) view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID)) view.Set("default_home_pages", model.HomePages()) - view.Set("categories_sort_options", model.CategoriesSortOptions()) + view.Set("categories_sorting_options", model.CategoriesSortingOptions()) html.OK(w, r, view.Render("settings")) }