diff --git a/dist/treebird20.css b/dist/treebird20.css
index f854e6f..8778590 100644
--- a/dist/treebird20.css
+++ b/dist/treebird20.css
@@ -5,6 +5,12 @@
Other themes do not need to be compatible with Netsurf and older browsers or use tables,
I just wanted this to be as compatible as possible, go wild with your own themes */
+*
+{
+ margin: 0;
+ padding: 0;
+}
+
html
{
background-color: #f6f6f6;
@@ -12,12 +18,15 @@ html
body
{
+ background-attachment: fixed !important;
+ background-size: cover !important;
background-color: unset;
font-family: Arial, Helvetica, sans-serif;
}
#main-page
{
+ margin: 8px;
width: 1000px;
border-top: 0 !important;
margin-left: auto;
diff --git a/dist/treebird40.css b/dist/treebird40.css
index 30444b8..7d1735c 100644
--- a/dist/treebird40.css
+++ b/dist/treebird40.css
@@ -5,6 +5,12 @@
Other themes do not need to be compatible with Netsurf and older browsers or use tables,
I just wanted this to be as compatible as possible, go wild with your own themes */
+*
+{
+ margin: 0;
+ padding: 0;
+}
+
html
{
background-color: #f6f6f6;
@@ -12,6 +18,8 @@ html
body
{
+ background-attachment: fixed !important;
+ background-size: cover !important;
background-color: unset;
font-family: Arial, Helvetica, sans-serif;
}
diff --git a/src/base_page.c b/src/base_page.c
index 5f750b6..8b94a87 100644
--- a/src/base_page.c
+++ b/src/base_page.c
@@ -29,11 +29,14 @@
// Files
#include "../static/index.chtml"
+#define BODY_STYLE "style=\"background:url('%s');\""
+
void render_base_page(struct base_page* page, struct session* ssn, mastodont_t* api)
{
char* cookie = getenv("HTTP_COOKIE");
enum l10n_locale locale = page->locale;
char* login_string = "";
+ char* background_url_css = NULL;
char* sidebar_str = NULL;
// Mastodont, used for notifications sidebar
struct mstdnt_storage storage = { 0 };
@@ -46,8 +49,15 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
ssn->config.theme = ssn->cookies.theme;
if (ssn->cookies.logged_in)
login_string = "";
+ if (ssn->cookies.background_url)
+ ssn->config.background_url = ssn->cookies.background_url;
}
+ if (ssn->config.background_url)
+ {
+ easprintf(&background_url_css, BODY_STYLE, ssn->config.background_url);
+ }
+
// Get / Show notifications on sidebar
if (ssn->cookies.logged_in && ssn->cookies.access_token)
{
@@ -75,6 +85,7 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
L10N[locale][L10N_APP_NAME],
ssn->config.theme,
ssn->config.themeclr ? "-dark" : "",
+ background_url_css ? background_url_css : "",
config_url_prefix,
L10N[locale][L10N_APP_NAME],
login_string,
@@ -122,4 +133,5 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
free(data);
cleanup:
if (sidebar_str) free(sidebar_str);
+ if (background_url_css) free(background_url_css);
}
diff --git a/src/cookie.c b/src/cookie.c
index 538e6b5..42311e3 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -53,7 +53,8 @@ char* read_cookies_env(struct cookie_values* cookies)
{ "access_token", &(cookies->access_token), key_string },
{ "logged_in", &(cookies->logged_in), key_string },
{ "theme", &(cookies->theme), key_string },
- { "instance_url", &(cookies->instance_url), key_string }
+ { "instance_url", &(cookies->instance_url), key_string },
+ { "background_url", &(cookies->background_url), key_string },
};
do
diff --git a/src/cookie.h b/src/cookie.h
index cb24184..3c1db61 100644
--- a/src/cookie.h
+++ b/src/cookie.h
@@ -26,6 +26,7 @@ struct cookie_values
char* logged_in;
char* theme;
char* instance_url;
+ char* background_url;
};
struct http_cookie_info
diff --git a/src/local_config.h b/src/local_config.h
index 2af328d..36950af 100644
--- a/src/local_config.h
+++ b/src/local_config.h
@@ -24,6 +24,7 @@ struct local_config
{
int changed;
char* theme;
+ char* background_url;
int themeclr;
int jsactions;
int jsreply;
diff --git a/src/local_config_set.c b/src/local_config_set.c
index 254645a..7e0cf8b 100644
--- a/src/local_config_set.c
+++ b/src/local_config_set.c
@@ -58,8 +58,17 @@ int set_config_int(int* ssn,
return 1;
}
-void load_config(struct session* ssn)
+void load_config(struct session* ssn, mastodont_t* api)
{
+ if (ssn->post.theme && ssn->post.files.array_size && ssn->post.files.content[0].content_size)
+ {
+ struct mstdnt_attachment* attachments = NULL;
+ struct mstdnt_storage storage = { 0 };
+ if (try_upload_media(&storage, ssn, api, &attachments, NULL) == 0)
+ {
+ set_config_str(&(ssn->config.background_url), "background_url", attachments[0].url);
+ }
+ }
set_config_str(&(ssn->config.theme), "theme", ssn->post.theme);
set_config_int(&(ssn->config.themeclr), "themeclr", ssn->post.themeclr);
diff --git a/src/local_config_set.h b/src/local_config_set.h
index 554446a..9c26064 100644
--- a/src/local_config_set.h
+++ b/src/local_config_set.h
@@ -18,8 +18,10 @@
#ifndef LOCAL_CONFIG_SET_H
#define LOCAL_CONFIG_SET_H
+#include
#include "local_config.h"
#include "session.h"
+#include "attachments.h"
int set_config_str(char** ssn,
char* cookie_name,
@@ -29,6 +31,6 @@ int set_config_int(int* ssn,
char* cookie_name,
char* value);
-void load_config(struct session* ssn);
+void load_config(struct session* ssn, mastodont_t* api);
#endif // LOCAL_CONFIG_SET_H
diff --git a/src/page_config.c b/src/page_config.c
index aa3aff2..77f8a22 100644
--- a/src/page_config.c
+++ b/src/page_config.c
@@ -65,7 +65,7 @@ void content_config_general(struct session* ssn, mastodont_t* api, char** data)
{
char* sidebar_html = construct_config_sidebar(CONFIG_CAT_GENERAL, NULL);
- load_config(ssn);
+ load_config(ssn, api);
struct base_page b = {
.category = BASE_CAT_CONFIG,
@@ -84,7 +84,7 @@ void content_config_appearance(struct session* ssn, mastodont_t* api, char** dat
{
char* sidebar_html = construct_config_sidebar(CONFIG_CAT_APPEARANCE, NULL);
- load_config(ssn);
+ load_config(ssn, api);
struct base_page b = {
.category = BASE_CAT_CONFIG,
diff --git a/static/config_appearance.html b/static/config_appearance.html
index f90eaec..ef09a44 100644
--- a/static/config_appearance.html
+++ b/static/config_appearance.html
@@ -1,5 +1,5 @@