cld-ssg

The static site generator (to be) used for hellocld.com
git clone git://git.hellocld.com/cld-ssg
Log | Files | Refs

commit 772d4a72d7a951e87b9eddc4056793ed0df6772c
parent cf1fbb492c43f97a9e1439ef4b7bd815513c8830
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Mon, 30 Sep 2019 22:15:20 -0400

Lots of additions, project's nearly done

- Added stylesheet
- Added favicon
- Updated header/footer to be more functional
- Added image posting test
- Added logo
- Updates to main (whitespace?)

Diffstat:
Massets/footer.html | 3+++
Massets/header.html | 17++++++++++++++++-
Afiles/favicon.png | 0
Afiles/images/cld-logo.png | 0
Afiles/images/style.css | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afiles/style.css | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mmain.c | 13+++++++++----
Apostdir/2019-09-30-21-38-img-test.md | 7+++++++
8 files changed, 145 insertions(+), 5 deletions(-)

diff --git a/assets/footer.html b/assets/footer.html @@ -1,2 +1,5 @@ +<footer> +<p>&copy;2019 Chris Langford Design</p> +</footer> </body> </html> diff --git a/assets/header.html b/assets/header.html @@ -1,5 +1,20 @@ <!DOCTYPE html> -<html> +<html lang="en-US"> <head> +<title>cld</title> +<meta charset="UTF-8"> +<link rel="stylesheet" type="text/css" href="/style.css"> +<link rel="icon" type="image/png" href="/favicon.png"> </head> <body> +<header> +<a href="/index.html"><img src="/images/cld-logo.png"/></a> +<nav> +<ul> +<li><a href="/archive.html">Archive</a></li> +<li><a href="https://git.hellocld.com">Repos</a></li> +<li><a href="mailto:chris@hellocld.com">Contact</a></li> +<li><a href="#">RSS</a></li> +</ul> +</nav> +</header> diff --git a/files/favicon.png b/files/favicon.png Binary files differ. diff --git a/files/images/cld-logo.png b/files/images/cld-logo.png Binary files differ. diff --git a/files/images/style.css b/files/images/style.css @@ -0,0 +1,55 @@ +body { + background: #ddd; + font-family: sans-serif; + max-width: 600px; + margin-left: auto; + margin-right: auto; + padding-left:16px; + padding-right: 16px; +} + +header img { + max-width: 96px; + padding: 16px 8px; +} + +footer { + background-color: black; + color: #ddd; + margin: 0; + padding: 1px 8px; +} + +nav ul { + list-style-type: none; + margin: 0; + padding: 0; + background-color: black; + overflow: hidden; +} + +nav li { + float: left; +} + +nav li a { + display: block; + width: 60px; + padding: 8px; + text-decoration: none; + background-color: black; + text-align: center; + color: #ddd; +} + +nav li a:hover { + color: black; + background-color: #ddd; +} +article { + padding: 8px; +} + +article img { + max-width: 100%; +} diff --git a/files/style.css b/files/style.css @@ -0,0 +1,54 @@ +body { + background: #d0c3b4; + font-family: sans-serif; + color: #373530; + max-width: 600px; + margin-left: auto; + margin-right: auto; + padding-left:16px; + padding-right: 16px; +} + +header img { + max-width: 96px; + padding: 16px 8px; +} + +nav ul { + list-style-type: none; + margin: 0; + padding: 0; + background-color: #373530; + overflow: hidden; +} + +nav li { + float: left; +} + +nav li a { + display: block; + width: 60px; + padding: 8px; + text-decoration: none; + background-color: #373530; + text-align: center; + color: #d0c3b4; +} + +nav li a:hover { + color: #373530; + background-color: #d0c3b4; +} +article { + padding: 8px; +} + +article img { + max-width: 100%; +} + +footer { + padding: 0 8px; + color: #a09e99; +}+ \ No newline at end of file diff --git a/main.c b/main.c @@ -196,12 +196,13 @@ int write_post(struct post *post) /* Generate the directory structure */ sprintf(buf, "%s%s", HTMLDIR, post->dir); printf("DEBUG: %s\n", buf); + if(create_directory(buf) < 0) return -1; sprintf(buf, "%s%s%s", HTMLDIR, post->dir, post->fhtml); FILE *f = fopen(buf, "w"); - sprintf(buf, "%s%s%s", header, post->content, footer); + sprintf(buf, "%s<article>%s</article>%s", header, post->content, footer); fprintf(f, buf); fclose(f); return 0; @@ -220,12 +221,16 @@ int write_index(struct post *posts[], int totalPosts) return -1; } int c = 0; - while(totalPosts-- > 0 && c++ < INDEX_POSTS) + while(totalPosts-- > 0 && c++ < INDEX_POSTS) { + fprintf(f, "<article>\n"); if(fprintf(f, posts[totalPosts]->content) < 0) { errprintf("write_index", errno); fclose(f); return -1; } + fprintf(f, "</article>\n"); + fprintf(f, "<hr>\n"); + } if(fprintf(f, footer) < 0) { errprintf("write_index", errno); fclose(f); @@ -240,7 +245,7 @@ int write_archive(struct post *posts[], int totalPosts) sprintf(buf, "%s%s", HTMLDIR, "archive.html"); FILE *f = fopen(buf, "w"); fprintf(f, header); - fprintf(f, "<ul>\n"); + fprintf(f, "<article>\n<ul>\n"); while(totalPosts-- > 0) { strftime(buf, MAX_URL_CHARS, "%Y-%m-%d", posts[totalPosts]->time); fprintf(f, "<li><a href=\"%s%s\">%s - %s</a></li>\n", @@ -249,7 +254,7 @@ int write_archive(struct post *posts[], int totalPosts) buf, posts[totalPosts]->title); } - fprintf(f, "</ul>\n"); + fprintf(f, "</ul>\n</article>\n"); fprintf(f, footer); fclose(f); return 0; diff --git a/postdir/2019-09-30-21-38-img-test.md b/postdir/2019-09-30-21-38-img-test.md @@ -0,0 +1,7 @@ +# Image testin + +Testing a post with an *image* this time! + +![](/images/doge.png) + +Nifty!