Config page boilerplate

FossilOrigin-Name: bc30f815e30d2776fd26c2147963e4358c73f9efc09b64ff527459fc5e5f9319
This commit is contained in:
nekobit 2022-08-18 22:31:34 +00:00
parent ad8819f482
commit dfd49db8d3
8 changed files with 189 additions and 45 deletions

2
dist/treebird.css vendored
View file

@ -106,7 +106,7 @@ table.ui-table td
#navbar
{
border-top: 2px solid #fff;
background: linear-gradient(#fbfbfb 37%, #efefef 50%, #e4e4e9);
background: linear-gradient(#fbfbfb 40%, #efefef 50%, #e4e4e9);
width: 1000px;
border-bottom: 2px solid #bfbfc4;
z-index: 999;

20
perl/config.pm Normal file
View file

@ -0,0 +1,20 @@
package config;
use strict;
use warnings;
our @EXPORT = qw( general appearance );
use Exporter 'import';
use template_helpers 'to_template';
sub general
{
}
sub appearance
{
}
1;

View file

@ -12,6 +12,7 @@ use account;
use lists;
use search;
use chat;
use config;
# my $template = Template->new(
# {

View file

@ -42,6 +42,8 @@
#include "../templates/search_tags.ctt"
#include "../templates/content_chats.ctt"
#include "../templates/chat.ctt"
#include "../templates/config_general.ctt"
#include "../templates/config_appearance.ctt"
PerlInterpreter* my_perl;
HV* template_files;
@ -74,6 +76,8 @@ void init_template_files(pTHX)
hv_stores(template_files, "search_tags.tt", newSVpv(data_search_tags_tt, data_search_tags_tt_size));
hv_stores(template_files, "content_chats.tt", newSVpv(data_content_chats_tt, data_content_chats_tt_size));
hv_stores(template_files, "chat.tt", newSVpv(data_chat_tt, data_chat_tt_size));
hv_stores(template_files, "config_general.tt", newSVpv(data_config_general_tt, data_config_general_tt_size));
hv_stores(template_files, "config_appearance.tt", newSVpv(data_config_appearance_tt, data_config_appearance_tt_size));
}
void cleanup_template_files()

View file

@ -17,6 +17,7 @@
*/
#include "page_config.h"
#include "global_perl.h"
#include <stdlib.h>
#include <string.h>
#include "http.h"
@ -44,69 +45,51 @@ enum config_category
CONFIG_CAT_ACCOUNT
};
static char* construct_config_sidebar(enum config_category cat, size_t* size)
{
struct config_sidebar_template tdata = {
.prefix = config_url_prefix,
.general_active = CAT_TEXT(cat, CONFIG_CAT_GENERAL),
.general = L10N[L10N_EN_US][L10N_GENERAL],
.appearance_active = CAT_TEXT(cat, CONFIG_CAT_APPEARANCE),
.appearance = L10N[L10N_EN_US][L10N_APPEARANCE],
.account_active = CAT_TEXT(cat, CONFIG_CAT_ACCOUNT),
.account = L10N[L10N_EN_US][L10N_ACCOUNT],
};
return tmpl_gen_config_sidebar(&tdata, size);
}
void content_config_general(PATH_ARGS)
{
char* sidebar_html = construct_config_sidebar(CONFIG_CAT_GENERAL, NULL);
struct config_general_template tdata = {
.js_on = bool_checked(js),
.jsactions_on = bool_checked(jsactions),
.jsreply_on = bool_checked(jsreply),
.jslive_on = bool_checked(jslive),
.status_attachments_on = bool_checked(stat_attachments),
.status_greentexts_on = bool_checked(stat_greentexts),
.status_dopameme_on = bool_checked(stat_dope),
.status_oneclicksoftware_on = bool_checked(stat_oneclicksoftware),
.status_emojo_likes_on = bool_checked(stat_emojo_likes),
.status_hide_muted_on = bool_checked(stat_hide_muted),
.instance_show_shoutbox_on = bool_checked(instance_show_shoutbox),
.instance_panel_on = bool_checked(instance_panel),
.notifications_embed_on = bool_checked(notif_embed)
};
char* general_page = tmpl_gen_config_general(&tdata, NULL);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
PERL_STACK_SCALAR_CALL("config::general");
char* dup = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_CONFIG,
.content = general_page,
.sidebar_left = sidebar_html
.content = dup,
.session = session_hv,
.sidebar_left = NULL
};
render_base_page(&b, req, ssn, api);
// Cleanup
free(sidebar_html);
free(general_page);
Safefree(dup);
}
void content_config_appearance(PATH_ARGS)
{
char* sidebar_html = construct_config_sidebar(CONFIG_CAT_APPEARANCE, NULL);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
PERL_STACK_SCALAR_CALL("config::appearance");
char* dup = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_CONFIG,
.content = data_config_appearance,
.sidebar_left = sidebar_html
.content = dup,
.session = session_hv,
.sidebar_left = NULL
};
render_base_page(&b, req, ssn, api);
// Cleanup
free(sidebar_html);
Safefree(dup);
}
void content_config(PATH_ARGS)

View file

@ -27,7 +27,7 @@
void content_config_appearance(PATH_ARGS);
void content_config_general(PATH_ARGS);
void content_config_account(PATH_ARGS);
//void content_config_account(PATH_ARGS);
void content_config(PATH_ARGS);
#endif // PAGE_CONFIG_H

View file

@ -0,0 +1,42 @@
<div class="simple-page">
<form action="appearance" method="post" enctype="multipart/form-data">
<!-- Lets server know we sent it -->
<input type="hidden" name="set" value="1">
<h1>Appearance</h1>
<input class="btn btn-single" type="submit" value="Save">
<h3>Theme variant</h3>
<ul>
<li>
<label for="cfgthemevar">Theme variant</label>
<select name="theme" id="cfgthemevar">
<option value="treebird" title="Created by nekobit (@neko@rdrama.cc) | Former dark variant created by Grumbulon (@grumbulon@freecumextremist.com)">Treebird - Default, simple theme</option>
<option value="solarized" title="Created by coyote (@coyote@pl.lain.sh)">Solarized - Solarized colors for pleasant viewing</option>
</select>
</li>
</ul>
<h3>Color Scheme</h3>
<ul>
<li>
<input type="radio" id="cfglight" name="themeclr" value="0" checked>
<label for="cfglight">Light</label>
</li>
<li>
<input type="radio" id="cfgdark" name="themeclr" value="1">
<label for="cfgdark">Dark</label>
</li>
</ul>
<h3>Background</h3>
<ul>
<li>
<input type="file" name="file">
</li>
</ul>
<ul>
<li>
Sidebar opacity: <input type="range" name="sidebaropacity" min="0" max="255" value="255">
</li>
</ul>
<input class="btn btn-single" type="submit" value="Save">
</form>
</div>

View file

@ -0,0 +1,94 @@
<div class="simple-page">
<form action="general" method="post">
<!-- Lets server know we sent it -->
<input type="hidden" name="set" value="1">
<h1>General</h1>
<input class="btn btn-single" type="submit" value="Save">
<h3>Locales</h3>
<ul>
<li>
<label for="cfglang">Language:</label>
<select name="lang" id="cfglang">
<option value="0">English</option>
<option value="1">Spanish</option>
<option value="2">Chinese (Traditional)</option>
</select>
</li>
</ul>
<h3>JavaScript</h3>
<ul>
<li>
<input type="checkbox" id="cfgjs" name="js" value="1" {{%s:js_on}}>
<label for="cfgjs">Enable JavaScript - If disabled, overrides options below</label>
</li>
<!-- <li> -->
<!-- <input type="checkbox" id="cfgjsactions" name="jsactions" value="1" {{%s:jsactions_on}}> -->
<!-- <label for="cfgjsactions">Quick actions - Likes, Boosts, etc done in background</label> -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="checkbox" id="cfgjsreply" name="jsreply" value="1" {{%s:jsreply_on}}> -->
<!-- <label for="cfgjsreply">Quick reply - Replies don't require redirects</label> -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="checkbox" id="cfgjslive" name="jslive" value="1" {{%s:jslive_on}}> -->
<!-- <label for="cfgjslive">Live update - Statuses, chats, and reactions fetch on the fly</label> -->
<!-- </li> -->
</ul>
<h3>Statuses</h3>
<ul>
<li>
<input type="checkbox" id="cfgstatattachments" name="statattachments" value="1" {{%s:status_attachments_on}}>
<label for="cfgstatattachments">Show attachments - If disabled, attachments are links instead</label>
</li>
<li>
<input type="checkbox" id="cfgstatgreentexts" name="statgreentexts" value="1" {{%s:status_greentexts_on}}>
<label for="cfgstatgreentexts">Show greentexts</label>
</li>
<li>
<input type="checkbox" id="cfgstatdope" name="statdope" value="1" {{%s:status_dopameme_on}}>
<label for="cfgstatdope">Show dopameme numbers - Likes, comments, and boost counts</label>
</li>
<li>
<input type="checkbox" id="cfgstatoneclicksoftware" name="statoneclicksoftware" value="1" {{%s:status_oneclicksoftware_on}}>
<label for="cfgstatoneclicksoftware">Show Like-Boost button - Show a button in the status which likes and boosts a post</label>
</li>
<li>
<input type="checkbox" id="interactimg" name="interact_img" value="1" {{%s:status_interact_img_on}}>
<label for="interactimg">Use IMG for interaction buttons - Compatibility</label>
</li>
<!-- <li> -->
<!-- <input type="checkbox" id="cfgstatemojolikes" name="statemojolikes" value="1" {{%s:status_emojo_likes_on}}> -->
<!-- <label for="cfgstatemojolikes">Convert Emoji reacts to likes - Also disables the emoji reaction button</label> -->
<!-- </li> -->
<!-- <li> -->
<!-- <input type="checkbox" id="cfgstathidemuted" name="stathidemuted" value="1" {{%s:status_hide_muted_on}}> -->
<!-- <label for="cfgstathidemuted">Hide statuses from muted users and threads - If disabled, statuses will appear collapsed</label> -->
<!-- </li> -->
</ul>
<h3>Instance</h3>
<ul>
<!-- <li> -->
<!-- <input type="checkbox" id="cfginstanceshowshoutbox" name="instanceshowshoutbox" value="1" {{%s:instance_show_shoutbox_on}}> -->
<!-- <label for="cfginstanceshowshoutbox">Show instance shoutbox (JS required)</label> -->
<!-- </li> -->
<li>
<input type="checkbox" id="cfginstancepanel" name="instancepanel" value="1" {{%s:instance_panel_on}}>
<label for="cfginstancepanel">Show instance panel - <em>Admins should <strong>not</strong> use the instance panel for major announcements</em></label>
</li>
</ul>
<h3>Notifications</h3>
<ul>
<li>
<input type="checkbox" id="cfgnotifembed" name="notifembed" value="1" {{%s:notifications_embed_on}}>
<label for="cfgnotifembed">Display notifications in iFrame - iFrames separate loading from the main page</label>
</li>
</ul>
<input class="btn btn-single" type="submit" value="Save">
</form>
</div>