Skip to content

Commit

Permalink
Remove useless links on top of page, but instead add link to "Add"
Browse files Browse the repository at this point in the history
which leads to /page
  • Loading branch information
xdevelnet committed Aug 1, 2023
1 parent 4a57eaf commit 269c3c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const char default_header_nocache_3[] = "Expires: 0";

#define LI_AND_A_TAGS_PREF "<li><a href=/tags?tag="
#define LI_A_SUFF "</a></li>"
#define LI_AND_A_PAGE_FULL_STR "<li><a href=/page>Add" LI_A_SUFF
#define LI_AND_A_USER "<li><a href=/user>"
#define LI_FULL_LOGIN_STR LI_AND_A_USER "Login" LI_A_SUFF
#define LI_AND_A_LOGOUT_FULL_STR "<li><a href=/logout>Logout" LI_A_SUFF
Expand Down Expand Up @@ -256,7 +257,7 @@ bool is_user_legit(struct layer_context *l, struct usr *u) {
return true;
}

#define BUF_USERDISPLAY_CALC (sizeof(u->display_name)+strizeof(LI_AND_A_LOGOUT_FULL_STR)+strizeof(LI_AND_A_USER)+strizeof(LI_A_SUFF)+sizeof(char))
#define BUF_USERDISPLAY_CALC (strizeof(LI_AND_A_PAGE_FULL_STR)+sizeof(u->display_name)+strizeof(LI_AND_A_LOGOUT_FULL_STR)+strizeof(LI_AND_A_USER)+strizeof(LI_A_SUFF)+sizeof(char))

static void internal_server_error(reqargs a, const char *error) {
struct appcontext *con = CONTEXT;
Expand All @@ -281,7 +282,7 @@ static void internal_server_error(reqargs a, const char *error) {
char buffer[CBL_MAX(KEY_VAL_MAXKEYLEN, BUF_USERDISPLAY_CALC)];
ssize_t size = - ((ssize_t) sizeof(struct usr));
if (find_cookie_existence(a, "id", buffer) != 0 and key_val(buffer, u, &size, l, NULL) == true and is_user_valid(u) == true) {
size_t strsize = (size_t) sprintf(buffer, LI_AND_A_USER "%s" LI_A_SUFF LI_AND_A_LOGOUT_FULL_STR, u->display_name);
size_t strsize = (size_t) sprintf(buffer, LI_AND_A_PAGE_FULL_STR LI_AND_A_USER "%s" LI_A_SUFF LI_AND_A_LOGOUT_FULL_STR, u->display_name);
out[USER_PAGE_PART] = buffer;
outsizes[USER_PAGE_PART] = strsize;
}
Expand Down Expand Up @@ -315,7 +316,7 @@ static void notfound(reqargs a) {
char buffer[CBL_MAX(KEY_VAL_MAXKEYLEN, BUF_USERDISPLAY_CALC)];
ssize_t size = - ((ssize_t) sizeof(struct usr));
if (find_cookie_existence(a, "id", buffer) != 0 and key_val(buffer, u, &size, l, NULL) == true and is_user_valid(u) == true) {
size_t strsize = (size_t) sprintf(buffer, LI_AND_A_USER "%s" LI_A_SUFF LI_AND_A_LOGOUT_FULL_STR, u->display_name);
size_t strsize = (size_t) sprintf(buffer, LI_AND_A_PAGE_FULL_STR LI_AND_A_USER "%s" LI_A_SUFF LI_AND_A_LOGOUT_FULL_STR, u->display_name);
out[USER_PAGE_PART] = buffer;
outsizes[USER_PAGE_PART] = strsize;
}
Expand Down Expand Up @@ -373,6 +374,7 @@ static inline void selector_show_tag_processing(reqargs a, struct blog_record *b
APP_WRITE(LI_FULL_LOGIN_STR, strizeof(LI_FULL_LOGIN_STR));
break;
}
APP_WRITECS(LI_AND_A_PAGE_FULL_STR);
APP_WRITE(LI_AND_A_USER, strizeof(LI_AND_A_USER));
APP_WRITE(u->display_name, strlen(u->display_name));
APP_WRITE(LI_A_SUFF, strizeof(LI_A_SUFF));
Expand Down Expand Up @@ -532,6 +534,7 @@ static inline void record_show_tag_processing(reqargs a, int32_t tag, struct blo
APP_WRITE(LI_FULL_LOGIN_STR, strizeof(LI_FULL_LOGIN_STR));
break;
}
APP_WRITECS(LI_AND_A_PAGE_FULL_STR);
APP_WRITE(LI_AND_A_USER, strizeof(LI_AND_A_USER));
APP_WRITE(u->display_name, strlen(u->display_name));
APP_WRITE(LI_A_SUFF, strizeof(LI_A_SUFF));
Expand Down Expand Up @@ -639,6 +642,7 @@ static inline void user_panel_processing(reqargs a, int32_t tag, struct usr *u)
APP_WRITE(u->display_name, strlen(u->display_name));
break;
case USER_PAGE_PART:
APP_WRITECS(LI_AND_A_PAGE_FULL_STR);
APP_WRITE(LI_AND_A_USER, strizeof(LI_AND_A_USER));
APP_WRITE(u->display_name, strlen(u->display_name));
APP_WRITE(LI_A_SUFF, strizeof(LI_A_SUFF));
Expand Down Expand Up @@ -846,6 +850,7 @@ static inline void editor_processing(reqargs a, int32_t tag, struct usr *u, char
APP_WRITE(default_add_edit_form_html, strizeof(default_add_edit_form_html));
break;
case USER_PAGE_PART:
APP_WRITECS(LI_AND_A_PAGE_FULL_STR);
APP_WRITE(LI_AND_A_USER, strizeof(LI_AND_A_USER));
APP_WRITE(u->display_name, strlen(u->display_name));
APP_WRITE(LI_A_SUFF, strizeof(LI_A_SUFF));
Expand Down
2 changes: 1 addition & 1 deletion static/minimalist/index (copy).html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><meta charset=utf-8><title>{{title}} - {{sitename}}</title><meta name=viewport content="width=device-width,initial-scale=1"><style>@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Regular.woff2) format("woff2"),url(static/minimalist/Lora-Regular.woff) format("woff");font-style:normal;font-weight:400}@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Medium.woff2) format("woff2"),url(static/minimalist/Lora-Medium.woff) format("woff");font-style:normal;font-weight:500}@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Bold.woff2) format("woff2"),url(static/minimalist/Lora-Bold.woff) format("woff");font-style:normal;font-weight:700}</style><link rel=stylesheet href="static/minimalist/main.css?v=4"><link rel="stylesheet" href="static/minimalist/simplemde-theme-base.min.css"><script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script><div class=page><header><div class=container><div class=header-content><a href=/ class=header-logo>{{sitename}}</a><ul class=header-menu><li><a href="/">Home</a></li><li><a href="/about-1">About</a></li><li><a href="/contact-2">Contact us</a></li>{{user}}</ul></div></div></header><div class=jumbotron-block><img src=static/minimalist/jumbotron-pic.jpg alt></div><div class=main-content>{{repeat_1}}<article class=simple-article><div class=container><ul class="tags-list">{{tags}}</ul><h1>{{title}}</h1><div class=simple-text>{{content}}</div></div></article>{{repeat_2}}</div><footer>{{footer}}</footer></div>
<!doctype html><meta charset=utf-8><title>{{title}} - {{sitename}}</title><meta name=viewport content="width=device-width,initial-scale=1"><style>@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Regular.woff2) format("woff2"),url(static/minimalist/Lora-Regular.woff) format("woff");font-style:normal;font-weight:400}@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Medium.woff2) format("woff2"),url(static/minimalist/Lora-Medium.woff) format("woff");font-style:normal;font-weight:500}@font-face{font-display:swap;font-family:lora;src:url(static/minimalist/Lora-Bold.woff2) format("woff2"),url(static/minimalist/Lora-Bold.woff) format("woff");font-style:normal;font-weight:700}</style><link rel=stylesheet href="static/minimalist/main.css?v=4"><link rel="stylesheet" href="static/minimalist/simplemde-theme-base.min.css"><script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script><div class=page><header><div class=container><div class=header-content><a href=/ class=header-logo>{{sitename}}</a><ul class=header-menu><li><a href="/">Home</a></li>{{user}}</ul></div></div></header><div class=jumbotron-block><img src=static/minimalist/jumbotron-pic.jpg alt></div><div class=main-content>{{repeat_1}}<article class=simple-article><div class=container><ul class="tags-list">{{tags}}</ul><h1>{{title}}</h1><div class=simple-text>{{content}}</div></div></article>{{repeat_2}}</div><footer>{{footer}}</footer></div>
Binary file modified static/minimalist/index (copy).ssb
Binary file not shown.
4 changes: 1 addition & 3 deletions static/minimalist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
<header>
<div class="container">
<div class="header-content">
<a href="/" class="header-logo">Minimalist blog </a>
<a href="/" class="header-logo">Minimalist blog</a>
<ul class="header-menu">
<li><a href="/">Home</a></li>
<li><a href="/about-1">About</a></li>
<li><a href="/contact-2">Contact us</a></li>
{{user}}
</ul>
</div>
Expand Down
Binary file modified static/minimalist/index.ssb
Binary file not shown.

0 comments on commit 269c3c4

Please sign in to comment.