diff --git a/dist/treebird20.css b/dist/treebird20.css index d1ea772..fc0fad1 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -185,6 +185,23 @@ input[type=button]:active, input[type=submit]:active, .sidebarbtn:active, .btn:a cursor: pointer; } +.btn-disabled +{ + color: #cacaca !important; + background: #f3f3f3 !important; +} + +.btn-disabled:hover +{ + background: #f3f3f3; +} + +.btn-disabled:active +{ + background: #f3f3f3; +} + + input[type=button], input[type=submit] { border: 1px solid #cacaca; diff --git a/src/navigation.c b/src/navigation.c index c1bb9a3..dd107e7 100644 --- a/src/navigation.c +++ b/src/navigation.c @@ -16,19 +16,31 @@ * along with this program. If not, see . */ +#include #include "navigation.h" - #include "easprintf.h" // Pages #include "../static/navigation.chtml" -char* construct_navigation_box(char* prev_id, char* next_id, size_t* size) +#define SUBMIT_HTML "" + +char* construct_navigation_box(char* start_id, + char* prev_id, + char* next_id, + size_t* size) { char* nav_html; + int is_start = strcmp(start_id, prev_id) == 0; size_t s = easprintf(&nav_html, data_navigation_html, + start_id, prev_id, + // Disable button if at start + is_start ? "btn-disabled" : "", + is_start ? "" : SUBMIT_HTML, + // If user pressed next, reserve start state + start_id, next_id); if (size) *size = s; return nav_html; diff --git a/src/navigation.h b/src/navigation.h index 124ccf8..e15901b 100644 --- a/src/navigation.h +++ b/src/navigation.h @@ -21,6 +21,9 @@ #include #include -char* construct_navigation_box(char* prev_id, char* next_id, size_t* size); +char* construct_navigation_box(char* start_id, + char* prev_id, + char* next_id, + size_t* size); #endif // NAVIGATION_H diff --git a/src/query.c b/src/query.c index 3558c08..9762b59 100644 --- a/src/query.c +++ b/src/query.c @@ -35,7 +35,6 @@ char* read_query_data() // BEGIN Query references struct key_value_refs refs[] = { { "offset", &(query.offset) }, - { "id", &(query.id) }, }; // END Query references @@ -81,6 +80,10 @@ char* read_post_data() { "username", &(post.username) }, { "password", &(post.password) }, { "replyid", &(post.replyid) }, + { "min_id", &(post.min_id) }, + { "max_id", &(post.max_id) }, + { "start_id", &(post.start_id) }, + }; // END Query references diff --git a/src/query.h b/src/query.h index c7fa89e..fc8d60e 100644 --- a/src/query.h +++ b/src/query.h @@ -36,12 +36,14 @@ struct query_values char* username; char* password; char* replyid; + char* min_id; + char* max_id; + char* start_id; }; struct get_values { char* offset; - char* id; }; extern struct query_values post; diff --git a/src/timeline.c b/src/timeline.c index a004bcf..31cb7da 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -25,6 +25,7 @@ #include "easprintf.h" #include "reply.h" #include "navigation.h" +#include "query.h" #include "../static/navigation.chtml" @@ -36,14 +37,15 @@ void tl_public(mastodont_t* api, int local) struct mstdnt_storage storage = { 0 }; char* status_format, *post_box, *navigation_box; char* output = NULL; + char* start_id; struct mstdnt_args args = { .local = local, .remote = 0, .only_media = 0, - .max_id = NULL, + .max_id = post.max_id, .since_id = NULL, - .min_id = NULL, + .min_id = post.min_id, .limit = 20 }; @@ -61,10 +63,15 @@ void tl_public(mastodont_t* api, int local) cleanup = 1; } + // If not set, set it + start_id = post.start_id ? post.start_id : statuses[0].id; + // Create post box post_box = construct_post_box(NULL, "", NULL); - navigation_box = construct_navigation_box( - statuses[0].id, statuses[status_count].id, NULL); + navigation_box = construct_navigation_box(start_id, + statuses[0].id, + statuses[status_count-1].id, + NULL); easprintf(&output, "%s%s%s", post_box, status_format, navigation_box); struct base_page b = { diff --git a/static/navigation.html b/static/navigation.html index 608b14f..655a2be 100644 --- a/static/navigation.html +++ b/static/navigation.html @@ -1,7 +1,7 @@ - + Up @@ -9,18 +9,20 @@ - + - - Previous - + + + Previous + %s - + - + + Next