diff --git a/Makefile b/Makefile index e6f4f18..28d3a25 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,8 @@ $(PAGES_DIR)/account_info.chtml: $(PAGES_DIR)/account_info.html ./filec $< data_account_info_html > $@ $(PAGES_DIR)/search.chtml: $(PAGES_DIR)/search.html ./filec $< data_search_html > $@ +$(PAGES_DIR)/scrobble.chtml: $(PAGES_DIR)/scrobble.html + ./filec $< data_scrobble_html > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/src/account.c b/src/account.c index 45011db..f1fa394 100644 --- a/src/account.c +++ b/src/account.c @@ -25,9 +25,9 @@ #include "easprintf.h" #include "status.h" #include "http.h" +#include "scrobble.h" // Files -#include "../static/index.chtml" #include "../static/account.chtml" #include "../static/account_info.chtml" @@ -82,7 +82,7 @@ static char* account_scrobbles_cb(struct session* ssn, mastodont_t* api, struct .min_id = NULL, .since_id = NULL, .offset = 0, - .limit = 0 + .limit = 20 }; if (mastodont_get_scrobbles(api, acct->id, &args, &storage, &scrobbles, &scrobbles_len)) @@ -90,7 +90,7 @@ static char* account_scrobbles_cb(struct session* ssn, mastodont_t* api, struct scrobbles_html = construct_error(storage.error, E_ERROR, 1, NULL); } else { - /* scrobble_html = construct_statuses(api, statuses, statuses_len, NULL); */ + scrobbles_html = construct_scrobbles(scrobbles, scrobbles_len, NULL); if (!scrobbles_html) scrobbles_html = construct_error("No scrobbles", E_NOTICE, 1, NULL); } @@ -240,6 +240,8 @@ char* construct_account_page(mastodont_t* api, return result; } + + void content_account_statuses(struct session* ssn, mastodont_t* api, char** data) { fetch_account_page(ssn, api, data[0], ACCT_TAB_STATUSES, account_statuses_cb); diff --git a/src/scrobble.c b/src/scrobble.c new file mode 100644 index 0000000..58ddad7 --- /dev/null +++ b/src/scrobble.c @@ -0,0 +1,48 @@ +/* + * Treebird - 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 "scrobble.h" +#include "easprintf.h" +#include "string_helpers.h" + +#include "../static/scrobble.chtml" + +char* construct_scrobble(struct mstdnt_scrobble* scrobble, int* size) +{ + char* scrobble_html; + size_t s; + + s = easprintf(&scrobble_html, data_scrobble_html, + scrobble->title, + scrobble->artist, + scrobble->length, + scrobble->album); + + if (size) *size = s; + return scrobble_html; +} + +static char* construct_scrobble_voidwrap(void* passed, size_t index, int* res) +{ + return construct_scrobble((struct mstdnt_scrobble*)passed + index, res); +} + +char* construct_scrobbles(struct mstdnt_scrobble* scrobbles, size_t scrobbles_len, size_t* ret_size) +{ + return construct_func_strings(construct_scrobble_voidwrap, scrobbles, scrobbles_len, ret_size); +} diff --git a/src/scrobble.h b/src/scrobble.h new file mode 100644 index 0000000..c03e8ce --- /dev/null +++ b/src/scrobble.h @@ -0,0 +1,26 @@ +/* + * Treebird - 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 SCROBBLE_H +#define SCROBBLE_H +#include + +char* construct_scrobble(struct mstdnt_scrobble* scrobble, int* size); +char* construct_scrobbles(struct mstdnt_scrobble* scrobbles, size_t scrobbles_len, size_t* ret_size); + +#endif /* SCROBBLE_H */ diff --git a/static/scrobble.html b/static/scrobble.html new file mode 100644 index 0000000..23d43e8 --- /dev/null +++ b/static/scrobble.html @@ -0,0 +1,2 @@ +%s - %s - %d - %s - Public? +