Mastodont load

FossilOrigin-Name: 834b0fd5e06c00d0cc94eb520d9efdda483eae6df8da5b7bf253205f95f56035
This commit is contained in:
me@ow.nekobit.net 2022-01-20 04:45:33 +00:00
parent ebaac88d36
commit 6f4b964212
5 changed files with 17 additions and 8 deletions

2
.gitignore vendored
View file

@ -2,4 +2,4 @@ filec
**/*.cgi
**/*.o
**/*.chtml
mastodont-c/
mastodont-c

View file

@ -14,7 +14,7 @@ TARGET = ratfe.cgi
MASTODONT_URL = https://git.nekobit.net/repos/mastodont-c.git
all: $(MASTODONT_DIR) $(TARGET)
all: $(MASTODONT_DIR) dep_build $(TARGET)
$(TARGET): filec $(PAGES_CMP) $(OBJ)
$(CC) -o $(DIST)$(TARGET) $(OBJ) $(LDFLAGS)
@ -28,9 +28,11 @@ filec: src/file-to-c/main.o
$(PAGES_DIR)/index.chtml: $(PAGES_DIR)/index.html
./filec $< data_index_html > $@
$(MASTODONT_DIR):
git clone $(MASTODONT_URL)
$(MASTODONT_DIR):
git clone $(MASTODONT_URL) || true
@echo -e "\033[38;5;13mRun 'make update' to update mastodont-c\033[0m"
dep_build:
make -C $(MASTODONT_DIR)
update:

View file

@ -23,7 +23,9 @@
// Files
#include "../static/index.chtml"
void content_index()
void content_index(mastodont_t* api)
{
struct mstdnt_response response;
mastodont_timeline_public(api, NULL, &response);
printf(data_index_html, config_canonical_name);
}

View file

@ -18,7 +18,8 @@
#ifndef INDEX_H
#define INDEX_H
#include <mastodont.h>
void content_index();
void content_index(mastodont_t* api);
#endif // INDEX_H

View file

@ -29,16 +29,20 @@ int main()
// Content type is always HTML
fputs("Content-type: text/html\r\n\r\n", stdout);
// Global init
mastodont_global_curl_init();
mastodont_t api;
api.url = config_instance_url;
mastodont_init(&api);
// Default index
if (path == NULL || (path && strcmp(path, "/")))
{
content_index();
content_index(&api);
}
// Cleanup
mastodont_free(&api);
mastodont_global_curl_cleanup();
}