diff --git a/.gitignore b/.gitignore index 07c8463..a5b6029 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ filec **/*.cgi **/*.o **/*.chtml -mastodont-c/ \ No newline at end of file +mastodont-c diff --git a/Makefile b/Makefile index 5e113b6..1d45ada 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/src/index.c b/src/index.c index b854336..b819414 100644 --- a/src/index.c +++ b/src/index.c @@ -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); } diff --git a/src/index.h b/src/index.h index 7659408..16aef0d 100644 --- a/src/index.h +++ b/src/index.h @@ -18,7 +18,8 @@ #ifndef INDEX_H #define INDEX_H +#include -void content_index(); +void content_index(mastodont_t* api); #endif // INDEX_H diff --git a/src/main.c b/src/main.c index 3cbf4cf..e12fce8 100644 --- a/src/main.c +++ b/src/main.c @@ -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(); }