diff --git a/src/cookie.c b/src/cookie.c
index a1ef6b3..a135a70 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -61,6 +61,14 @@ char* read_cookies_env(struct cookie_values* cookies)
{ "jsactions", &(cookies->jsactions), key_int },
{ "jsreply", &(cookies->jsreply), key_int },
{ "jslive", &(cookies->jslive), key_int },
+ { "js", &(cookies->js), key_int },
+ { "statattachments", &(cookies->stat_attachments), key_int },
+ { "statgreentexts", &(cookies->stat_greentexts), key_int },
+ { "statdope", &(cookies->stat_dope), key_int },
+ { "statoneclicksoftware", &(cookies->stat_oneclicksoftware), key_int },
+ { "statemojilikes", &(cookies->stat_emoji_likes), key_int },
+ { "instanceshowshoutbox", &(cookies->instance_show_shoutbox), key_int },
+ { "instancepanel", &(cookies->instance_panel), key_int },
};
do
diff --git a/src/cookie.h b/src/cookie.h
index 9dae2d4..0398e1a 100644
--- a/src/cookie.h
+++ b/src/cookie.h
@@ -33,6 +33,14 @@ struct cookie_values
int jsactions;
int jsreply;
int jslive;
+ int js;
+ int stat_attachments;
+ int stat_greentexts;
+ int stat_dope;
+ int stat_oneclicksoftware;
+ int stat_emoji_likes;
+ int instance_show_shoutbox;
+ int instance_panel;
};
struct http_cookie_info
diff --git a/src/local_config.h b/src/local_config.h
index bd82e26..bd36a96 100644
--- a/src/local_config.h
+++ b/src/local_config.h
@@ -30,6 +30,15 @@ struct local_config
int jsactions;
int jsreply;
int jslive;
+ int js;
+ int stat_attachments;
+ int stat_greentexts;
+ int stat_dope;
+ int stat_oneclicksoftware;
+ int stat_emoji_likes;
+ int stat_hide_muted;
+ int instance_show_shoutbox;
+ int instance_panel;
};
#endif // LOCAL_CONFIG_H
diff --git a/src/local_config_set.c b/src/local_config_set.c
index 093b450..6cdf867 100644
--- a/src/local_config_set.c
+++ b/src/local_config_set.c
@@ -38,21 +38,13 @@ int set_config_str(char** ssn,
int set_config_int(int* ssn,
char* cookie_name,
- char* value)
+ int value)
{
- if (!value) return 0;
- char* err = NULL;
- long str_l = strtol(value, &err, 0);
-
- // Not a number
- if (err == value)
- return 0;
-
if (ssn)
{
- *ssn = str_l;
+ *ssn = value;
printf("Set-Cookie: %s=%ld; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
- cookie_name, str_l);
+ cookie_name, value);
}
return 1;
@@ -72,40 +64,18 @@ void load_config(struct session* ssn, mastodont_t* api)
if (storage)
cleanup_media_storages(ssn, storage);
}
- set_config_str(&(ssn->config.theme), "theme", ssn->post.theme);
- set_config_int(&(ssn->config.themeclr), "themeclr", ssn->post.themeclr);
+ set_config_str(&(ssn->config.theme), "theme", ssn->post.theme, ssn->cookie.theme);
+ set_config_int(&(ssn->config.themeclr), "themeclr", ssn->post.themeclr, ssn->cookie.themeclr);
- set_config_int(&(ssn->config.jsactions), "jsactions", ssn->post.jsactions);
- set_config_int(&(ssn->config.jsreply), "jsreply", ssn->post.jsreply);
- set_config_int(&(ssn->config.jslive), "jslive", ssn->post.jslive);
-}
-
-#define SET_COOKIE_CONFIG(post, cookie, config) do{ \
- if (cookie && !post) \
- config = cookie; \
- } while(0);
-
-void read_config(struct session* ssn)
-{
- SET_COOKIE_CONFIG(ssn->post.theme,
- ssn->cookies.theme,
- ssn->config.theme);
- SET_COOKIE_CONFIG(ssn->post.themeclr,
- ssn->cookies.themeclr,
- ssn->config.themeclr);
- SET_COOKIE_CONFIG(ssn->post.jsactions,
- ssn->cookies.jsactions,
- ssn->config.jsactions);
- SET_COOKIE_CONFIG(ssn->post.jsreply,
- ssn->cookies.jsreply,
- ssn->config.jsreply);
- SET_COOKIE_CONFIG(ssn->post.jslive,
- ssn->cookies.jslive,
- ssn->config.jslive);
- SET_COOKIE_CONFIG(0,
- ssn->cookies.logged_in,
- ssn->config.logged_in);
- SET_COOKIE_CONFIG((ssn->post.files.content && ssn->post.files.content[0].content),
- ssn->cookies.background_url,
- ssn->config.background_url);
+ set_config_int(&(ssn->config.jsactions), "jsactions", ssn->cookie.theme, ssn->post.jsactions);
+ set_config_int(&(ssn->config.jsreply), "jsreply", ssn->cookie.theme, ssn->post.jsreply);
+ set_config_int(&(ssn->config.jslive), "jslive", ssn->cookie.theme, ssn->post.jslive);
+ set_config_int(&(ssn->config.js), "js", ssn->cookie.theme, ssn->post.js);
+ set_config_int(&(ssn->config.stat_attachments), "statattachments", ssn->cookie.theme, ssn->post.stat_attachments);
+ set_config_int(&(ssn->config.stat_greentexts), "statgreentexts", ssn->cookie.theme, ssn->post.stat_greentexts);
+ set_config_int(&(ssn->config.stat_dope), "statdope", ssn->cookie.theme, ssn->post.stat_dope);
+ set_config_int(&(ssn->config.stat_oneclicksoftware), "statoneclicksoftware", ssn->cookie.theme, ssn->post.stat_oneclicksoftware);
+ set_config_int(&(ssn->config.stat_emoji_likes), "statemojilikes", ssn->cookie.theme, ssn->post.stat_emoji_likes);
+ set_config_int(&(ssn->config.instance_show_shoutbox), "instanceshowshoutbox", ssn->cookie.theme, ssn->post.instance_show_shoutbox);
+ set_config_int(&(ssn->config.instance_panel), "instancepanel", ssn->cookie.theme, ssn->post.instance_panel);
}
diff --git a/src/local_config_set.h b/src/local_config_set.h
index 6c7082b..ee02389 100644
--- a/src/local_config_set.h
+++ b/src/local_config_set.h
@@ -29,7 +29,7 @@ int set_config_str(char** ssn,
int set_config_int(int* ssn,
char* cookie_name,
- char* value);
+ int value);
void load_config(struct session* ssn, mastodont_t* api);
void read_config(struct session* ssn);
diff --git a/src/main.c b/src/main.c
index a23d291..9a91e34 100644
--- a/src/main.c
+++ b/src/main.c
@@ -47,14 +47,24 @@ int main(void)
// API
while (FCGI_Accept() >= 0)
{
+ // Default config
struct session ssn = {
.config = {
.changed = 0,
.theme = "treebird20",
.themeclr = 0,
- .jsactions = 0,
- .jsreply = 0,
- .jslive = 0
+ .jsactions = 1,
+ .jsreply = 1,
+ .jslive = 0,
+ .js = 1,
+ .stat_attachments = 1,
+ .stat_greentexts = 1,
+ .stat_dope = 1,
+ .stat_oneclicksoftware = 1,
+ .stat_emoji_likes = 0,
+ .stat_hide_muted = 0,
+ .instance_show_shoutbox = 1,
+ .instance_panel = 1,
},
.cookies = { 0 },
.post = { 0 },
diff --git a/src/notifications.c b/src/notifications.c
index 6d349f2..a9b15cd 100644
--- a/src/notifications.c
+++ b/src/notifications.c
@@ -102,7 +102,8 @@ char* construct_notification_compact(struct session* ssn,
notif->status->replies_count,
notif->status->reblogs_count,
notif->status->favourites_count);
- status_format = reformat_status(notif->status->content,
+ status_format = reformat_status(ssn,
+ notif->status->content,
notif->status->emojis,
notif->status->emojis_len);
}
diff --git a/src/query.c b/src/query.c
index 6642322..335443b 100644
--- a/src/query.c
+++ b/src/query.c
@@ -104,10 +104,10 @@ char* read_post_data(struct query_values* post)
{ "itype", &(post->itype), key_string },
{ "id", &(post->id), key_string },
{ "theme", &(post->theme), key_string },
- { "themeclr", &(post->themeclr), key_string },
- { "jsactions", &(post->jsactions), key_string },
- { "jsreply", &(post->jsreply), key_string },
- { "jslive", &(post->jslive), key_string },
+ { "themeclr", &(post->themeclr), key_int },
+ { "jsactions", &(post->jsactions), key_int },
+ { "jsreply", &(post->jsreply), key_int },
+ { "jslive", &(post->jslive), key_int },
{ "username", &(post->username), key_string },
{ "password", &(post->password), key_string },
{ "replyid", &(post->replyid), key_string },
@@ -117,6 +117,15 @@ char* read_post_data(struct query_values* post)
{ "instance", &(post->instance), key_string },
{ "visibility", &(post->visibility), key_string },
{ "emojoindex", &(post->emojoindex), key_int },
+ { "js", &(post->js), key_int },
+ { "statattachments", &(post->stat_attachments), key_int },
+ { "statgreentexts", &(post->stat_greentexts), key_int },
+ { "statdope", &(post->stat_dope), key_int },
+ { "statoneclicksoftware", &(post->stat_oneclicksoftware), key_int },
+ { "statemojolikes", &(post->stat_emoji_likes), key_int },
+ { "stathidemuted", &(post->stat_hide_muted), key_int },
+ { "instanceshowshoutbox", &(post->instance_show_shoutbox), key_int },
+ { "instancepanel", &(post->instance_panel), key_int },
{ "file", &(post->files), key_files }
};
// END Query references
diff --git a/src/query.h b/src/query.h
index f408a94..a422d5e 100644
--- a/src/query.h
+++ b/src/query.h
@@ -46,10 +46,19 @@ struct query_values
{
// Config
char* theme;
- char* themeclr;
- char* jsactions;
- char* jsreply;
- char* jslive;
+ int themeclr;
+ int jsactions;
+ int jsreply;
+ int jslive;
+ int js;
+ int stat_attachments;
+ int stat_greentexts;
+ int stat_dope;
+ int stat_oneclicksoftware;
+ int stat_emoji_likes;
+ int stat_hide_muted;
+ int instance_show_shoutbox;
+ int instance_panel;
char* content;
char* itype;
diff --git a/src/status.c b/src/status.c
index 121b94a..9f0213b 100644
--- a/src/status.c
+++ b/src/status.c
@@ -301,11 +301,18 @@ char* construct_in_reply_to(struct mstdnt_status* status,
#define REGEX_GREENTEXT "((?:^|
|\\s)>.*?)(?:
|$)"
#define REGEX_GREENTEXT_LEN 6
-char* reformat_status(char* content, struct mstdnt_emoji* emos, size_t emos_len)
+char* reformat_status(struct session* ssn,
+ char* content,
+ struct mstdnt_emoji* emos,
+ size_t emos_len)
{
- char* gt_res;
+ char* gt_res = NULL;
char* emo_res;
- gt_res = greentextify(content);
+ if (ssn->config.stat_greentexts)
+ gt_res = greentextify(content);
+ else
+ gt_res = content;
+
if (emos)
{
emo_res = emojify(gt_res, emos, emos_len);
@@ -449,7 +456,8 @@ char* construct_status(struct session* ssn,
status->account.emojis_len);
// Format status
- char* parse_content = reformat_status(status->content, status->emojis, status->emojis_len);
+ char* parse_content = reformat_status(ssn, status->content, status->emojis, status->emojis_len);
+
// Find and replace
if (args && args->highlight_word)
{
diff --git a/src/status.h b/src/status.h
index bd281c2..7dbc657 100644
--- a/src/status.h
+++ b/src/status.h
@@ -85,7 +85,10 @@ char* construct_status_interaction_profiles(struct mstdnt_account* reblogs,
size_t* ret_size);
char* construct_status_interaction_profile(struct interact_profile_args* args, size_t index, int* size);
char* construct_status_interactions_label(char* header, int val, size_t* size);
-char* reformat_status(char* content, struct mstdnt_emoji* emos, size_t emos_len);
+char* reformat_status(struct session* ssn,
+ char* content,
+ struct mstdnt_emoji* emos,
+ size_t emos_len);
char* greentextify(char* content);
// Status frontends
diff --git a/static/config_general.html b/static/config_general.html
index 8b98c43..c975b13 100644
--- a/static/config_general.html
+++ b/static/config_general.html
@@ -37,7 +37,7 @@