diff --git a/dist/treebird20.css b/dist/treebird20.css
index f7959e1..f854e6f 100644
--- a/dist/treebird20.css
+++ b/dist/treebird20.css
@@ -98,7 +98,7 @@ table.ui-table td
#navbar-right-container
{
- width: 800px;
+ width: 782px;
display: inline-block;
position: relative;
top: 9px;
diff --git a/dist/treebird40.css b/dist/treebird40.css
index 0f99876..30444b8 100644
--- a/dist/treebird40.css
+++ b/dist/treebird40.css
@@ -23,7 +23,7 @@ body
margin-right: auto;
box-shadow: 0px 2px 15px rgba(0, 0, 0, 0.3);
border-width: 0;
- border-radius: 5px;
+ border-radius: 8px;
}
.hidden
@@ -63,14 +63,14 @@ table.ui-table td
#content
{
overflow: hidden;
- border-bottom-left-radius: 5px;
- border-bottom-right-radius: 5px;
+ border-bottom-left-radius: 8px;
+ border-bottom-right-radius: 8px;
}
#navbar
{
- border-top-left-radius: 5px;
- border-top-right-radius: 5px;
+ border-top-left-radius: 8px;
+ border-top-right-radius: 8px;
background: rgba(245, 245, 245, 0.8);
backdrop-filter: blur(12px);
width: 1000px;
@@ -98,7 +98,7 @@ table.ui-table td
#navbar-right-container
{
- width: 800px;
+ width: 782px;
display: inline-block;
position: relative;
top: 11px;
diff --git a/src/attachments.c b/src/attachments.c
index 9f325cb..2b6e9aa 100644
--- a/src/attachments.c
+++ b/src/attachments.c
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include "easprintf.h"
#include "attachments.h"
@@ -31,6 +32,57 @@ struct attachments_args
mstdnt_bool sensitive;
};
+int try_upload_media(struct mstdnt_storage* storage,
+ struct session* ssn,
+ mastodont_t* api,
+ struct mstdnt_attachment** attachments,
+ char*** media_ids)
+{
+ if (!ssn->post.files.array_size)
+ return 1;
+
+ if (media_ids)
+ *media_ids = malloc(sizeof(char*) * ssn->post.files.array_size);
+
+ *attachments = malloc(sizeof(struct mstdnt_attachment) * ssn->post.files.array_size);
+
+ for (int i = 0; i < ssn->post.files.array_size; ++i)
+ {
+ struct file_content* content = ssn->post.files.content + i;
+ struct mstdnt_upload_media_args args = {
+ .file = {
+ .file = content->content,
+ .filename = content->filename,
+ .filesize = content->content_size,
+ .filetype = content->filetype,
+ },
+ .thumbnail = NULL,
+ .description = "Treebird image"
+ };
+
+ mastodont_upload_media(api,
+ &args,
+ storage,
+ *attachments + i);
+
+ if (media_ids)
+ {
+ (*media_ids)[i] = malloc(strlen((*attachments)[i].id)+1);
+ strcpy((*media_ids)[i], (*attachments)[i].id);
+ }
+ }
+
+ return 0;
+}
+
+void cleanup_media_ids(struct session* ssn, char** media_ids)
+{
+ if (!media_ids) return;
+ for (size_t i = 0; i < ssn->post.files.array_size; ++i)
+ free(media_ids[i]);
+ free(media_ids);
+}
+
char* construct_attachment(mstdnt_bool sensitive, struct mstdnt_attachment* att, int* str_size)
{
char* att_html;
diff --git a/src/attachments.h b/src/attachments.h
index ca53e49..171a66e 100644
--- a/src/attachments.h
+++ b/src/attachments.h
@@ -19,7 +19,14 @@
#ifndef ATTACHMENTS_H
#define ATTACHMENTS_H
#include
+#include "session.h"
+int try_upload_media(struct mstdnt_storage* storage,
+ struct session* ssn,
+ mastodont_t* api,
+ struct mstdnt_attachment** attachments,
+ char*** media_ids);
+void cleanup_media_ids(struct session* ssn, char** media_ids);
char* construct_attachment(mstdnt_bool sensitive, struct mstdnt_attachment* att, int* str_size);
char* construct_attachments(mstdnt_bool sensitive, struct mstdnt_attachment* atts, size_t atts_len, size_t* str_size);
diff --git a/src/status.c b/src/status.c
index 0b55182..de698d1 100644
--- a/src/status.c
+++ b/src/status.c
@@ -46,64 +46,19 @@ struct status_args
struct mstdnt_status* status;
};
-// TODO move to attachments.c
-int try_upload_media(struct session* ssn,
- mastodont_t* api,
- char*** media_ids)
-{
- struct mstdnt_attachment attachment;
- struct mstdnt_storage storage;
-
- if (!ssn->post.files.array_size)
- return 1;
- *media_ids = malloc(sizeof(char*) * ssn->post.files.array_size);
-
- for (int i = 0; i < ssn->post.files.array_size; ++i)
- {
- struct file_content* content = ssn->post.files.content + i;
- struct mstdnt_upload_media_args args = {
- .file = {
- .file = content->content,
- .filename = content->filename,
- .filesize = content->content_size,
- .filetype = content->filetype,
- },
- .thumbnail = NULL,
- .description = "Treebird image"
- };
-
- mastodont_upload_media(api,
- &args,
- &storage,
- &attachment);
-
- (*media_ids)[i] = malloc(strlen(attachment.id)+1);
- strcpy((*media_ids)[i], attachment.id);
- }
-
- return 0;
-}
-
-void cleanup_media_ids(struct session* ssn, char** media_ids)
-{
- if (!media_ids) return;
- for (size_t i = 0; i < ssn->post.files.array_size; ++i)
- free(media_ids[i]);
- free(media_ids);
-}
-
int try_post_status(struct session* ssn, mastodont_t* api)
{
if (!(ssn->post.content)) return 1;
- struct mstdnt_storage storage;
+ struct mstdnt_storage storage, att_storage = { 0 };
char** files;
size_t files_len;
+ struct mstdnt_attachment* attachments = NULL;
char** media_ids = NULL;
// Upload images
- try_upload_media(ssn, api, &media_ids);
+ try_upload_media(&att_storage, ssn, api, &attachments, &media_ids);
// Cookie copy and read
struct mstdnt_args args = {
@@ -127,7 +82,9 @@ int try_post_status(struct session* ssn, mastodont_t* api)
// TODO cleanup when errors are properly implemented
mastodont_storage_cleanup(&storage);
+ mastodont_storage_cleanup(&att_storage);
cleanup_media_ids(ssn, media_ids);
+ if (attachments) free(attachments);
return 0;
}
@@ -139,7 +96,6 @@ void content_status_create(struct session* ssn, mastodont_t* api, char** data)
try_post_status(ssn, api);
redirect(REDIRECT_303, referer);
-
}
int try_interact_status(struct session* ssn, mastodont_t* api, char* id)
diff --git a/src/status.h b/src/status.h
index 0a10f2a..d0a5692 100644
--- a/src/status.h
+++ b/src/status.h
@@ -28,9 +28,6 @@
#define STATUS_EMOJI_PICKER (1<<1)
char* construct_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size_t* size);
-int try_upload_media(struct session* ssn,
- mastodont_t* api,
- char*** media_ids);
int try_post_status(struct session* ssn, mastodont_t* api);
int try_interact_status(struct session* ssn, mastodont_t* api, char* id);
void content_status_create(struct session* ssn, mastodont_t* api, char** data);
diff --git a/static/config_appearance.html b/static/config_appearance.html
index dd39bef..f90eaec 100644
--- a/static/config_appearance.html
+++ b/static/config_appearance.html
@@ -23,6 +23,12 @@
+ Background
+