forked from mirrors/treebird
Lists base
FossilOrigin-Name: c2d8bf314f68cf17f732d9adc9e562ab1ae3c4895e8aae0463fc21ab9fa80ee0
This commit is contained in:
parent
d2861ddb1c
commit
041868d214
8 changed files with 117 additions and 2 deletions
4
Makefile
4
Makefile
|
@ -38,6 +38,10 @@ $(PAGES_DIR)/login.chtml: $(PAGES_DIR)/login.html
|
|||
./filec $< data_login_html > $@
|
||||
$(PAGES_DIR)/post.chtml: $(PAGES_DIR)/post.html
|
||||
./filec $< data_post_html > $@
|
||||
$(PAGES_DIR)/list.chtml: $(PAGES_DIR)/list.html
|
||||
./filec $< data_list_html > $@
|
||||
$(PAGES_DIR)/lists.chtml: $(PAGES_DIR)/lists.html
|
||||
./filec $< data_lists_html > $@
|
||||
|
||||
$(MASTODONT_DIR):
|
||||
git clone $(MASTODONT_URL) || true
|
||||
|
|
55
src/lists.c
Normal file
55
src/lists.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "base_page.h"
|
||||
#include "../config.h"
|
||||
#include "account.h"
|
||||
#include "easprintf.h"
|
||||
#include "status.h"
|
||||
#include "lists.h"
|
||||
|
||||
// Files
|
||||
#include "../static/index.chtml"
|
||||
#include "../static/account.chtml"
|
||||
#include "../static/list.chtml"
|
||||
#include "../static/lists.chtml"
|
||||
|
||||
void construct_list(struct mstdnt_list* list, int* size)
|
||||
{
|
||||
char* list_html;
|
||||
size_t s = easprintf(&list_html, data_list_html,
|
||||
"");
|
||||
if (size) *size = s;
|
||||
return list_html;
|
||||
}
|
||||
|
||||
void content_lists(mastodont_t* api, char** data, size_t size)
|
||||
{
|
||||
struct base_page b = {
|
||||
.locale = L10N_EN_US,
|
||||
.content = data_lists_html,
|
||||
.sidebar_right = NULL
|
||||
};
|
||||
|
||||
// Output
|
||||
render_base_page(&b);
|
||||
|
||||
// Cleanup
|
||||
}
|
26
src/lists.h
Normal file
26
src/lists.h
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LISTS_H
|
||||
#define LISTS_H
|
||||
#include <stddef.h>
|
||||
#include <mastodont.h>
|
||||
|
||||
void content_lists(mastodont_t* api, char** data, size_t size);
|
||||
|
||||
#endif // LISTS_H
|
|
@ -30,6 +30,7 @@
|
|||
#include "cookie.h"
|
||||
#include "query.h"
|
||||
#include "status.h"
|
||||
#include "lists.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
@ -59,7 +60,8 @@ int main(void)
|
|||
{ "/config", content_config },
|
||||
{ "/login", content_login },
|
||||
{ "/@:", content_account },
|
||||
{ "/status/:", content_status }
|
||||
{ "/status/:", content_status },
|
||||
{ "/lists", content_lists }
|
||||
};
|
||||
|
||||
handle_paths(&api, paths, sizeof(paths)/sizeof(paths[0]));
|
||||
|
|
|
@ -97,6 +97,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
|
|||
status->favourited ? "nobutton-active" : "",
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
config_url_prefix,
|
||||
status->id);
|
||||
if (size) *size = s;
|
||||
return stat_html;
|
||||
|
@ -150,13 +151,17 @@ void content_status(mastodont_t* api, char** data, size_t data_size)
|
|||
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;
|
||||
|
||||
|
||||
#ifdef _TEST_
|
||||
#include "test/status_test.h"
|
||||
#else
|
||||
mastodont_status_context(api, data[0], &storage, &statuses_before, &statuses_after,
|
||||
&stat_before_len, &stat_after_len);
|
||||
mastodont_view_status(api, data[0], &status_storage, &status);
|
||||
before_html = construct_statuses(statuses_before, stat_before_len, NULL);
|
||||
stat_html = construct_status(&status, NULL);
|
||||
after_html = construct_statuses(statuses_after, stat_after_len, NULL);
|
||||
#endif
|
||||
|
||||
easprintf(&output, "%s%s%s",
|
||||
before_html != NULL ? before_html : "",
|
||||
|
|
16
src/test/status_test.h
Normal file
16
src/test/status_test.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* BEGIN Status_test */
|
||||
|
||||
struct mstdnt_status status_test = {
|
||||
.account = {
|
||||
.avatar = "/ratfe_logo.png",
|
||||
.display_name = "Test user",
|
||||
.acct = "user@test.com",
|
||||
},
|
||||
.content = "Hello world<br><br>Hi",
|
||||
|
||||
};
|
||||
before_html = construct_status(&status_test, NULL);
|
||||
stat_html = construct_status(&status_test, NULL);
|
||||
after_html = construct_status(&status_test, NULL);
|
||||
|
||||
/* END Status_test */
|
1
static/list.html
Normal file
1
static/list.html
Normal file
|
@ -0,0 +1 @@
|
|||
<li><a href="%s/lists/for/%s" class="btn split">%s</a></li>
|
6
static/lists.html
Normal file
6
static/lists.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<h1 class="center">Lists</h1>
|
||||
|
||||
<ul class="large-list center">
|
||||
%s
|
||||
<li><a href="%s/lists/create" class="btn split">Create new list</a></li>
|
||||
</ul>
|
Loading…
Reference in a new issue