diff --git a/Makefile b/Makefile index 3a6a797..2175b68 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,8 @@ $(PAGES_DIR)/error_404.chtml: $(PAGES_DIR)/error_404.html ./filec $< data_error_404_html > $@ $(PAGES_DIR)/navigation.chtml: $(PAGES_DIR)/navigation.html ./filec $< data_navigation_html > $@ +$(PAGES_DIR)/config_sidebar.chtml: $(PAGES_DIR)/config_sidebar.html + ./filec $< data_config_sidebar_html > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/dist/treebird20.css b/dist/treebird20.css index 9da9912..5cdf2a0 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -122,7 +122,7 @@ table.ui-table td #leftbar ul { - margin: 0px 0px 10px 0px; + margin: 0; padding: 0; } @@ -228,17 +228,47 @@ input[type=button], input[type=submit] .sidebarbtn { - border-bottom: 1px solid #dadada; display: block; + border-bottom: 1px solid #dadada; padding: 8px 8px 8px 16px; } +.sidebarbtn.focused +{ + border-right: 3px solid #aa0000; +} + +.sidebarbtn-sub +{ + display: block; + color: #000; + padding: 8px; + padding-left: 32px; + text-decoration: none; +} + +.sidebar-config +{ + background-color: #efefef; + border-left: 3px solid #aa0000; + box-shadow: inset 0px 2px 3px rgba(0, 0, 0, 0.1); +} + +.sidebarbtn-sub.focused +{ + font-weight: bold; +} + +.sidebarbtn-sub:active, .sidebarbtn-sub:hover +{ + background-color: #dadada; +} + ul li:first-child a.sidebarbtn { border-top: 1px solid #dadada; } - /**************************** * Notifications * ***************************/ @@ -494,7 +524,6 @@ ul li:first-child a.sidebarbtn padding-left: 15px; } - /********************** * Profiles * **********************/ diff --git a/src/account.c b/src/account.c index 896df44..ee56050 100644 --- a/src/account.c +++ b/src/account.c @@ -92,7 +92,8 @@ void content_account(mastodont_t* api, char** data, size_t size) account_page = "Malloc error"; } - struct base_page b = { + struct base_page b = { + .category = BASE_CAT_NONE, .locale = L10N_EN_US, .content = account_page, .sidebar_left = NULL diff --git a/src/base_page.c b/src/base_page.c index 1dfa009..c7f6c37 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -23,6 +23,7 @@ #include "easprintf.h" #include "cookie.h" #include "notifications.h" +#include "string_helpers.h" #include "../config.h" // Files @@ -79,18 +80,25 @@ void render_base_page(struct base_page* page, mastodont_t* api) config_url_prefix, L10N[locale][L10N_SEARCH_PLACEHOLDER], L10N[locale][L10N_SEARCH_BUTTON], + CAT_TEXT(page->category, BASE_CAT_HOME), config_url_prefix, L10N[locale][L10N_HOME], + CAT_TEXT(page->category, BASE_CAT_LOCAL), config_url_prefix, L10N[locale][L10N_LOCAL], + CAT_TEXT(page->category, BASE_CAT_FEDERATED), config_url_prefix, L10N[locale][L10N_FEDERATED], + CAT_TEXT(page->category, BASE_CAT_NOTIFICATIONS), config_url_prefix, L10N[locale][L10N_NOTIFICATIONS], + CAT_TEXT(page->category, BASE_CAT_LISTS), config_url_prefix, L10N[locale][L10N_LISTS], + CAT_TEXT(page->category, BASE_CAT_DIRECT), config_url_prefix, L10N[locale][L10N_DIRECT], + CAT_TEXT(page->category, BASE_CAT_CONFIG), config_url_prefix, L10N[locale][L10N_CONFIG], page->sidebar_left ? diff --git a/src/base_page.h b/src/base_page.h index 351e19b..b954a1a 100644 --- a/src/base_page.h +++ b/src/base_page.h @@ -22,8 +22,21 @@ #include "l10n.h" #include "local_config.h" +enum base_category +{ + BASE_CAT_NONE, + BASE_CAT_HOME, + BASE_CAT_LOCAL, + BASE_CAT_FEDERATED, + BASE_CAT_NOTIFICATIONS, + BASE_CAT_LISTS, + BASE_CAT_DIRECT, + BASE_CAT_CONFIG, +}; + struct base_page { + enum base_category category; enum l10n_locale locale; char* content; char* sidebar_left; diff --git a/src/lists.c b/src/lists.c index 970dcab..11eafed 100644 --- a/src/lists.c +++ b/src/lists.c @@ -83,6 +83,7 @@ void content_lists(mastodont_t* api, char** data, size_t size) } struct base_page b = { + .category = BASE_CAT_LISTS, .locale = L10N_EN_US, .content = lists_page, .sidebar_left = NULL diff --git a/src/login.c b/src/login.c index 2b3b81a..2169d48 100644 --- a/src/login.c +++ b/src/login.c @@ -89,6 +89,7 @@ void content_login(mastodont_t* api, char** data, size_t data_size) L10N[L10N_EN_US][L10N_LOGIN_BTN]); struct base_page b = { + .category = BASE_CAT_NONE, .locale = L10N_EN_US, .content = page, .sidebar_left = NULL diff --git a/src/notifications.c b/src/notifications.c index 4abbedd..9076383 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -139,6 +139,7 @@ void content_notifications(mastodont_t* api, char** data, size_t data_size) notif_html ? notif_html : "Not logged in"); struct base_page b = { + .category = BASE_CAT_NOTIFICATIONS, .locale = L10N_EN_US, .content = page, .sidebar_left = NULL diff --git a/src/page_config.c b/src/page_config.c index add29a6..0a78796 100644 --- a/src/page_config.c +++ b/src/page_config.c @@ -21,17 +21,42 @@ #include #include "base_page.h" #include "../config.h" +#include "easprintf.h" #include "page_config.h" #include "query.h" #include "cookie.h" #include "local_config.h" +#include "string_helpers.h" +#include "l10n.h" // Pages #include "../static/index.chtml" #include "../static/config.chtml" +#include "../static/config_sidebar.chtml" + +enum config_category +{ + CONFIG_CAT_GENERAL, + CONFIG_CAT_APPEARANCE +}; + +static char* construct_config_sidebar(enum config_category cat, size_t* size) +{ + char* sidebar_html; + size_t s = easprintf(&sidebar_html, data_config_sidebar_html, + CAT_TEXT(cat, CONFIG_CAT_GENERAL), + config_url_prefix, + L10N[L10N_EN_US][L10N_GENERAL], + CAT_TEXT(cat, CONFIG_CAT_APPEARANCE), + config_url_prefix, + L10N[L10N_EN_US][L10N_APPEARANCE]); + if (size) *size = s; + return sidebar_html; +} void content_config(mastodont_t* api, char** data, size_t size) { + char* sidebar_html = construct_config_sidebar(CONFIG_CAT_GENERAL, NULL); if (post.theme) { g_config.theme = post.theme; @@ -41,10 +66,13 @@ void content_config(mastodont_t* api, char** data, size_t size) } struct base_page b = { + .category = BASE_CAT_CONFIG, .locale = L10N_EN_US, .content = data_config_html, - .sidebar_left = data_config_sidebar_html + .sidebar_left = sidebar_html }; render_base_page(&b, api); + // Cleanup + free(sidebar_html); } diff --git a/src/status.c b/src/status.c index 13aecee..734f0cd 100644 --- a/src/status.c +++ b/src/status.c @@ -243,6 +243,7 @@ void content_status(mastodont_t* api, char** data, size_t data_size, int is_repl after_html ? after_html : ""); struct base_page b = { + .category = BASE_CAT_NONE, .locale = L10N_EN_US, .content = output, .sidebar_left = NULL diff --git a/src/string_helpers.h b/src/string_helpers.h index 0305ba0..8afd817 100644 --- a/src/string_helpers.h +++ b/src/string_helpers.h @@ -23,6 +23,9 @@ /** Returns str. If NULL, returns empty string */ #define STR_NULL_EMPTY(str) ((str) ? (str) : "") +#define CAT_TEXT(cat, cfg_cat) ((cat) == (cfg_cat)) ? "focused" : "" + + /** * Constructs a string based on a function * diff --git a/src/test.c b/src/test.c index 1388541..a374662 100644 --- a/src/test.c +++ b/src/test.c @@ -68,6 +68,7 @@ void content_test(mastodont_t* api, char** data, size_t data_size) ENV_TBL_GET(ENV_CONTENT_LENGTH)); struct base_page b = { + .category = BASE_CAT_NONE, .locale = L10N_EN_US, .content = page, .sidebar_left = NULL diff --git a/src/timeline.c b/src/timeline.c index 483207d..d30a66d 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -83,6 +83,7 @@ void tl_public(mastodont_t* api, int local) STR_NULL_EMPTY(navigation_box)); struct base_page b = { + .category = BASE_CAT_HOME, .locale = L10N_EN_US, .content = output, .sidebar_left = NULL @@ -137,6 +138,7 @@ void tl_list(mastodont_t* api, char* list_id) data_navigation_html); struct base_page b = { + .category = BASE_CAT_LISTS, .locale = L10N_EN_US, .content = output, .sidebar_left = NULL diff --git a/static/config_sidebar.html b/static/config_sidebar.html index a298a8f..2193ea4 100644 --- a/static/config_sidebar.html +++ b/static/config_sidebar.html @@ -1,4 +1,4 @@ -
  • - %s - %s -
  • + diff --git a/static/index.html b/static/index.html index c404aff..3884798 100644 --- a/static/index.html +++ b/static/index.html @@ -26,13 +26,13 @@ %s