diff --git a/dist/skel.css b/dist/skel.css
index ef7ab11..4482d60 100644
--- a/dist/skel.css
+++ b/dist/skel.css
@@ -454,3 +454,33 @@ ul li:not(:last-child) .split,
list-style-type: none;
padding-left: 15px;
}
+
+/* Attachments */
+.attachments img
+{
+ min-width: 100px;
+ max-width: 300px;
+ min-height: 100px;
+ max-height: 300px;
+}
+
+.attachments
+{
+ margin: 10px 0 3px 0;
+}
+
+.zoom
+{
+ transition: transform .1s;
+ transition-timing-function: cubic-bezier(0, 1, 1, 1);
+}
+
+.zoom:hover
+{
+ transform: scaleX(1.8) scaleY(1.8);
+}
+
+.statusbox textarea
+{
+ border: 1px solid #cacaca;
+}
diff --git a/src/attachments.c b/src/attachments.c
new file mode 100644
index 0000000..420d649
--- /dev/null
+++ b/src/attachments.c
@@ -0,0 +1,54 @@
+/*
+ * RatFE - Lightweight frontend for Pleroma
+ * Copyright (C) 2022 Nekobit
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include "easprintf.h"
+#include "attachments.h"
+#include "string_helpers.h"
+
+// Pages
+#include "../static/attachments.chtml"
+#include "../static/attachment_image.chtml"
+
+char* construct_attachment(struct mstdnt_attachment* att, int* str_size)
+{
+ char* att_html;
+
+ size_t s = easprintf(&att_html, data_attachment_image_html,
+ att->url);
+ if (str_size) *str_size = s;
+ return att_html;
+}
+
+static char* construct_attachments_voidwrap(void* passed, size_t index, int* res)
+{
+ return construct_attachment((struct mstdnt_attachment*)passed + index, res);
+}
+
+char* construct_attachments(struct mstdnt_attachment* atts, size_t atts_len, size_t* str_size)
+{
+ size_t elements_size;
+ char* elements = construct_func_strings(construct_attachments_voidwrap, atts, atts_len, &elements_size);
+ char* att_view;
+
+ size_t s = easprintf(&att_view, data_attachments_html, elements);
+ if (str_size) *str_size = s;
+ // Cleanup
+ free(elements);
+ return att_view;
+}
diff --git a/src/attachments.h b/src/attachments.h
new file mode 100644
index 0000000..ad4f24e
--- /dev/null
+++ b/src/attachments.h
@@ -0,0 +1,26 @@
+/*
+ * RatFE - Lightweight frontend for Pleroma
+ * Copyright (C) 2022 Nekobit
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef ATTACHMENTS_H
+#define ATTACHMENTS_H
+#include
+
+char* construct_attachment(struct mstdnt_attachment* att, int* str_size);
+char* construct_attachments(struct mstdnt_attachment* atts, size_t atts_len, size_t* str_size);
+
+#endif // ATTACHMENTS_H
diff --git a/src/index.c b/src/index.c
index e24035f..c466aab 100644
--- a/src/index.c
+++ b/src/index.c
@@ -17,57 +17,10 @@
*/
#include
-#include
-#include "base_page.h"
-#include "../config.h"
-#include "index.h"
-#include "status.h"
-#include "easprintf.h"
-#include "reply.h"
-
-// Files
-#include "../static/index.chtml"
-#include "../static/post.chtml"
+#include "timeline.h"
void content_index(mastodont_t* api)
{
- int cleanup = 0;
- size_t status_count, statuses_html_count;
- struct mstdnt_status* statuses;
- struct mstdnt_storage storage = { 0 };
- char* status_format, *post_box;
- char* output = NULL;
-
- try_post_status(api);
-
- if (mastodont_timeline_public(api, NULL, &storage, &statuses, &status_count))
- {
- status_format = "An error occured loading the timeline";
- }
- else {
- // Construct statuses into HTML
- status_format = construct_statuses(statuses, status_count, &statuses_html_count);
- if (!status_format)
- status_format = "Error in malloc!";
- cleanup = 1;
- }
-
- // Create post box
- post_box = construct_post_box(NULL, "", NULL);
- easprintf(&output, "%s %s", post_box, status_format);
-
- struct base_page b = {
- .locale = L10N_EN_US,
- .content = output,
- .sidebar_right = NULL
- };
-
- // Output
- render_base_page(&b);
-
- // Cleanup
- mastodont_storage_cleanup(&storage);
- if (cleanup) free(status_format);
- if (post_box) free(post_box);
- if (output) free(output);
+ // Check logins
+ tl_public(api, 0);
}
diff --git a/src/main.c b/src/main.c
index 62dd029..05d297e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,7 @@
#include "query.h"
#include "status.h"
#include "lists.h"
+#include "timeline.h"
int main(void)
{
@@ -63,7 +64,10 @@ int main(void)
{ "/status/:/interact", status_interact },
{ "/status/:/reply", status_reply },
{ "/status/:", status_view },
- { "/lists", content_lists }
+ { "/lists/for/:", content_tl_list },
+ { "/lists", content_lists },
+ { "/federated", content_tl_federated },
+ { "/local", content_tl_local },
};
handle_paths(&api, paths, sizeof(paths)/sizeof(paths[0]));
diff --git a/src/status.c b/src/status.c
index 2a4e395..34e8076 100644
--- a/src/status.c
+++ b/src/status.c
@@ -25,6 +25,7 @@
#include "cookie.h"
#include "string_helpers.h"
#include "reply.h"
+#include "attachments.h"
#include "../config.h"
// Pages
@@ -89,13 +90,16 @@ char* construct_status(struct mstdnt_status* status, int* size)
char* reply_count = NULL;
char* repeat_count = NULL;
char* favourites_count = NULL;
+ char* attachments = NULL;
if (status->replies_count)
easprintf(&reply_count, NUM_STR, status->replies_count);
if (status->reblogs_count)
easprintf(&repeat_count, NUM_STR, status->reblogs_count);
if (status->favourites_count)
easprintf(&favourites_count, NUM_STR, status->favourites_count);
-
+ if (status->media_attachments_len)
+ attachments = construct_attachments(status->media_attachments, status->media_attachments_len, NULL);
+
size_t s = easprintf(&stat_html, data_status_html,
status->account.avatar,
status->account.display_name, /* Username */
@@ -104,6 +108,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
status->account.acct, /* Account */
"Public", /* visibility */
status->content,
+ attachments ? attachments : "",
config_url_prefix,
status->id,
reply_count ? reply_count : "",
@@ -124,6 +129,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
if (reply_count) free(reply_count);
if (repeat_count) free(repeat_count);
if (favourites_count) free(favourites_count);
+ if (attachments) free(attachments);
return stat_html;
}
@@ -164,7 +170,7 @@ void content_status(mastodont_t* api, char** data, size_t data_size, int is_repl
struct mstdnt_storage storage, status_storage;
struct mstdnt_status* statuses_before, *statuses_after, status;
size_t stat_before_len, stat_after_len;
- char* before_html = NULL, *stat_html = NULL, *after_html = NULL, *stat_reply;
+ char* before_html = NULL, *stat_html = NULL, *after_html = NULL, *stat_reply = NULL;
try_post_status(api);
diff --git a/src/timeline.c b/src/timeline.c
new file mode 100644
index 0000000..dddafc0
--- /dev/null
+++ b/src/timeline.c
@@ -0,0 +1,151 @@
+/*
+ * RatFE - Lightweight frontend for Pleroma
+ * Copyright (C) 2022 Nekobit
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "timeline.h"
+#include
+#include
+#include "base_page.h"
+#include "../config.h"
+#include "index.h"
+#include "status.h"
+#include "easprintf.h"
+#include "reply.h"
+
+void tl_public(mastodont_t* api, int local)
+{
+ int cleanup = 0;
+ size_t status_count, statuses_html_count;
+ struct mstdnt_status* statuses;
+ struct mstdnt_storage storage = { 0 };
+ char* status_format, *post_box;
+ char* output = NULL;
+
+ struct mstdnt_timeline_public_args args = {
+ .local = local,
+ .remote = 0,
+ .only_media = 0,
+ .max_id = NULL,
+ .since_id = NULL,
+ .min_id = NULL,
+ .limit = 20,
+ };
+
+ try_post_status(api);
+
+ if (mastodont_timeline_public(api, &args, &storage, &statuses, &status_count))
+ {
+ status_format = "An error occured loading the timeline";
+ }
+ else {
+ // Construct statuses into HTML
+ status_format = construct_statuses(statuses, status_count, &statuses_html_count);
+ if (!status_format)
+ status_format = "Error in malloc!";
+ cleanup = 1;
+ }
+
+ // Create post box
+ post_box = construct_post_box(NULL, "", NULL);
+ easprintf(&output, "%s %s", post_box, status_format);
+
+ struct base_page b = {
+ .locale = L10N_EN_US,
+ .content = output,
+ .sidebar_right = NULL
+ };
+
+ // Output
+ render_base_page(&b);
+
+ // Cleanup
+ mastodont_storage_cleanup(&storage);
+ if (cleanup) free(status_format);
+ if (post_box) free(post_box);
+ if (output) free(output);
+}
+
+void tl_list(mastodont_t* api, char* list_id)
+{
+ int cleanup = 0;
+ size_t status_count, statuses_html_count;
+ struct mstdnt_status* statuses;
+ struct mstdnt_storage storage = { 0 };
+ char* status_format, *post_box;
+ char* output = NULL;
+
+ struct mstdnt_timeline_list_args args = {
+ .max_id = NULL,
+ .since_id = NULL,
+ .min_id = NULL,
+ .limit = 20,
+ };
+
+ try_post_status(api);
+
+ if (mastodont_timeline_list(api, list_id, &args, &storage, &statuses, &status_count))
+ {
+ status_format = "An error occured loading the timeline";
+ }
+ else {
+ // Construct statuses into HTML
+ status_format = construct_statuses(statuses, status_count, &statuses_html_count);
+ if (!status_format)
+ status_format = "Error in malloc!";
+ cleanup = 1;
+ }
+
+ // Create post box
+ post_box = construct_post_box(NULL, "", NULL);
+ easprintf(&output, "%s %s", post_box, status_format);
+
+ struct base_page b = {
+ .locale = L10N_EN_US,
+ .content = output,
+ .sidebar_right = NULL
+ };
+
+ // Output
+ render_base_page(&b);
+
+ // Cleanup
+ mastodont_storage_cleanup(&storage);
+ if (cleanup) free(status_format);
+ if (post_box) free(post_box);
+}
+
+
+void content_tl_federated(mastodont_t* api, char** data, size_t data_size)
+{
+ (void)data;
+ (void)data_size;
+ tl_public(api, 0);
+}
+
+void content_tl_local(mastodont_t* api, char** data, size_t data_size)
+{
+ (void)data;
+ (void)data_size;
+ tl_public(api, 1);
+}
+
+void content_tl_list(mastodont_t* api, char** data, size_t data_size)
+{
+ (void)data;
+ (void)data_size;
+ tl_list(api, data[0]);
+}
diff --git a/src/timeline.h b/src/timeline.h
new file mode 100644
index 0000000..6e4e9e7
--- /dev/null
+++ b/src/timeline.h
@@ -0,0 +1,32 @@
+/*
+ * RatFE - Lightweight frontend for Pleroma
+ * Copyright (C) 2022 Nekobit
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef TIMELINE_H
+#define TIMELINE_H
+#include
+#include
+
+// Federated and local are here
+void tl_public(mastodont_t* api, int local);
+void tl_list(mastodont_t* api, char* list_id);
+
+void content_tl_federated(mastodont_t* api, char** data, size_t data_size);
+void content_tl_local(mastodont_t* api, char** data, size_t data_size);
+void content_tl_list(mastodont_t* api, char** data, size_t data_size);
+
+#endif // TIMELINE_H
diff --git a/static/attachment_image.html b/static/attachment_image.html
index 5aa8f1c..a664a8c 100644
--- a/static/attachment_image.html
+++ b/static/attachment_image.html
@@ -1 +1 @@
-
+