[wiki] [sites] build-page: permit user-defined directories names || Josuah Demangeon

From: <git_AT_suckless.org>
Date: Sat, 05 Jan 2019 17:19:20 +0100

commit 65ac19b172851290b0cd6f4bd6ab36db57208d22
Author: Josuah Demangeon <mail_AT_josuah.net>
Date: Sat Jan 5 17:17:03 2019 +0100

    build-page: permit user-defined directories names
    
    Use an array of { label-directory } instead of deducing the label
    from the directory name. This is needed to have suckless.org
    under the name of suckless.org.

diff --git a/build-page.c b/build-page.c
index f62a820a..2c9c3089 100644
--- a/build-page.c
+++ b/build-page.c
_AT_@ -39,7 +39,8 @@ char *html_nav_bar =
         " <a href=\"//git.suckless.org\">source</a>
"
         " </span>
";
 
-char *html_footer = "<div id=\"footer\">
"
+char *html_footer =
+ "<div id=\"footer\">
"
         "<span class=\"right\">
"
         "&copy; 2006-2019 suckless.org community
"
         "| <a href=\"//ev.suckless.org/impressum\">Impressum</a>
"
_AT_@ -47,15 +48,18 @@ char *html_footer = "<div id=\"footer\">
"
         "</span>
"
         "</div>
";
 
-char *domain_list[] = {
- "home.suckless.org",
- "dwm.suckless.org",
- "st.suckless.org",
- "core.suckless.org",
- "surf.suckless.org",
- "tools.suckless.org",
- "libs.suckless.org",
- NULL
+struct domain {
+ char *label;
+ char *dir;
+} domain_list[] = {
+ { "home", "suckless.org" },
+ { "dwm", "dwm.suckless.org", },
+ { "st", "st.suckless.org", },
+ { "core", "core.suckless.org", },
+ { "surf", "surf.suckless.org", },
+ { "tools", "tools.suckless.org", },
+ { "libs", "libs.suckless.org", },
+ { NULL, NULL }
 };
 
 void
_AT_@ -187,24 +191,15 @@ print_header(char *domain, char *page)
 void
 print_nav_bar(char *domain, char *page)
 {
- char name[1024];
- char *s;
- char **d;
+ struct domain *d;
         (void)page;
 
         puts("<div id=\"menu\">");
- for (d = domain_list; *d; ++d) {
+ for (d = domain_list; d->dir; ++d) {
                 fputs(" <a ", stdout);
- if (strcmp(domain, *d) == 0)
+ if (strcmp(domain, d->dir) == 0)
                         fputs("class=\"thisSite\" ", stdout);
-
- printf("href=\"//%s\">", *d);
- strncpy(name, *d, sizeof name - 1); name[sizeof name - 1] = '- if ((s = strchr(name, '.'))) {
- *s = '- fputs(name, stdout);
- }
- fputs("</a>
", stdout);
+ printf("href=\"//%s/\">%s</a>
", d->dir, d->label);
         }
         fputs(html_nav_bar, stdout);
         puts("</div>");
Received on Sat Jan 05 2019 - 17:19:20 CET

This archive was generated by hypermail 2.3.0 : Sat Jan 05 2019 - 17:24:26 CET