forked from mirrors/treebird
Config sidebar, focused sidebar items
FossilOrigin-Name: 0020cf420a262b023b7b11eef46efc28b2ad42a439d9dfd35057aad823f4894e
This commit is contained in:
parent
282b914e6c
commit
c19ad92804
15 changed files with 108 additions and 17 deletions
2
Makefile
2
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
|
||||
|
|
37
dist/treebird20.css
vendored
37
dist/treebird20.css
vendored
|
@ -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 *
|
||||
**********************/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ?
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -21,17 +21,42 @@
|
|||
#include <string.h>
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<li>
|
||||
<a class="sidebarbtn-sub" href="%s/config/general">%s</a>
|
||||
<a class="sidebarbtn-sub" href="%s/config/appearance">%s</a>
|
||||
</li>
|
||||
<ul class="sidebar-config">
|
||||
<li><a class="sidebarbtn-sub %s" href="%s/config/general">%s</a></li>
|
||||
<li><a class="sidebarbtn-sub %s" href="%s/config/appearance">%s</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
<tr>
|
||||
<td id="leftbar" class="sidebar">
|
||||
<ul>
|
||||
<li><a class="sidebarbtn" href="%s/">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/local/">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/federated/">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/notifications">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/lists">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/direct">%s</a></li>
|
||||
<li><a class="sidebarbtn" href="%s/config">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/local/">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/federated/">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/notifications">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/lists">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/direct">%s</a></li>
|
||||
<li><a class="sidebarbtn %s" href="%s/config">%s</a></li>
|
||||
</ul>
|
||||
%s
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue