diff --git a/include/utils_op/utils.h b/include/utils_op/utils.h index 08fca2e..b74f8c5 100644 --- a/include/utils_op/utils.h +++ b/include/utils_op/utils.h @@ -11,5 +11,6 @@ char *concat_to_front(char **str1, char *str2); char *get_status_message(int status_code); char *to_lower(char *str); char *trim(char *str); +char *repair_spaces(char *str); #endif \ No newline at end of file diff --git a/src/articles_op/article.c b/src/articles_op/article.c index 39dda7a..dcf701c 100644 --- a/src/articles_op/article.c +++ b/src/articles_op/article.c @@ -2,7 +2,7 @@ int list_articles(article_info **articles) { - FILE *file = fopen("./static/articles_list.db", "r"); + FILE *file = fopen("./static/articles/list.db", "r"); if (file == NULL) { perror("Couldn't open db file"); diff --git a/src/articles_op/html.c b/src/articles_op/html.c index bb12226..77e7494 100644 --- a/src/articles_op/html.c +++ b/src/articles_op/html.c @@ -1,5 +1,6 @@ #include "../../include/articles_op/html.h" #include "../../include/articles_op/article.h" +#include "../../include/utils_op/utils.h" int gen_html_article(article_info article, char **out) { @@ -25,6 +26,8 @@ int gen_html_article(article_info article, char **out) process_md(article, &content); + article.title = repair_spaces(article.title); + int line_length = snprintf(NULL, 0, template_str, article.title, article.title, content) + 1; *out = malloc(line_length); if (*out == NULL) @@ -53,6 +56,8 @@ int gen_html_article_list(article_info *articles, int n, char **out) for (int i = 0; i < n; i++) { + articles[i].title = repair_spaces(articles[i].title); + int line_length = snprintf(NULL, 0, "
  • %s
  • \n", i, articles[i].title) + 1; insert = malloc(line_length); diff --git a/src/utils_op/utils.c b/src/utils_op/utils.c index 426e11b..819ef2f 100644 --- a/src/utils_op/utils.c +++ b/src/utils_op/utils.c @@ -85,4 +85,17 @@ char *trim(char *str) } return str; -} \ No newline at end of file +} + +char *repair_spaces(char *str) +{ + for (int i = 0; i < strlen(str); i++) + { + if (str[i] == '_') + { + str[i] = ' '; + } + } + + return str; +} diff --git a/static/articles/First article/chart1.png b/static/articles/First article/chart1.png deleted file mode 100644 index 4aa221b..0000000 Binary files a/static/articles/First article/chart1.png and /dev/null differ diff --git a/static/articles/First article/First article.md b/static/articles/My_first_article_on_this_site/My_first_article_on_this_site.md similarity index 95% rename from static/articles/First article/First article.md rename to static/articles/My_first_article_on_this_site/My_first_article_on_this_site.md index 5fb39f9..15a6800 100644 --- a/static/articles/First article/First article.md +++ b/static/articles/My_first_article_on_this_site/My_first_article_on_this_site.md @@ -1,7 +1,7 @@ # My first article on this site This is my own site written in pure C with templates in html and some css styles. All articles are stored in markdown format and are processed by server to convert them to html and send to client. Links list on the homepage is also generated dynamically to show all the articles, currntly avaliable on disk. -![Data flow](https://c.imge.to/2020/07/03/P5RIaj.png) +![Data flow](/articles/My_first_article_on_this_site/P5RIaj.png) *Data flow* As for all the pages of this site are pure html, it can be read from really old computers or text-based browsers. Server Side Rendered (SSR) webpages are also good for search engines. diff --git a/static/articles/My_first_article_on_this_site/P5RIaj.png b/static/articles/My_first_article_on_this_site/P5RIaj.png new file mode 100644 index 0000000..2427d27 Binary files /dev/null and b/static/articles/My_first_article_on_this_site/P5RIaj.png differ diff --git a/static/articles/list.db b/static/articles/list.db new file mode 100644 index 0000000..a0e477a --- /dev/null +++ b/static/articles/list.db @@ -0,0 +1 @@ +1593768639 My_first_article_on_this_site \ No newline at end of file diff --git a/static/articles_list.db b/static/articles_list.db deleted file mode 100644 index c9eba98..0000000 --- a/static/articles_list.db +++ /dev/null @@ -1 +0,0 @@ -1593768639 First article \ No newline at end of file