about summary refs log tree commit diff
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* fix(main): set PATH_INFO=/ for index HEAD mastersternenseemann2020-12-281-1/+1
| | | | | We assume that SCRIPT_NAME does not end in a slash or is empty and thus PATH_INFO _must_ start with a slash.
* fix(main): correct routing sanity checksternenseemann2020-09-191-2/+6
|
* refactor(treewide): prefix public/internal API with sternenblog/sternenseemann2020-08-261-8/+9
|
* feat(template): pass context to template, simplify apisternenseemann2020-08-251-10/+31
| | | | | | | | | | | | | | | | | New struct template_data is passed to all template functions, allowing to e. g. reflect the current entry in template_header and to unify template_single_entry, template_index_entry, template_error into template_main which switches behavior depending on data.page_type. BREAKING CHANGES: * remove template_single_entry, template_index_entry, template_error; replaced by template_main * template_header, template_footer: type change refactor(templates/simple): use xml_escape where applicable feat(templates/simple): navigate using header / entry titles feat(templates/simple): change <title> depending on subpage
* feat(main): add asserts to catch bugs in routingsternenseemann2020-08-251-0/+9
| | | | These assert runtime assumptions
* fix(main): call correct entry templatesternenseemann2020-08-251-1/+5
|
* feat(rss,atom): gen abs paths from webroot if no external_urlsternenseemann2020-08-251-22/+23
|
* refactor(main): rework routing to minimize code duplicationsternenseemann2020-08-251-109/+89
|
* feat(rss,atom): use SERVER_{NAME,PORT} for external URLsternenseemann2020-08-251-28/+41
|
* fix(send_standard_headers): don't read from uninitialized memorysternenseemann2020-08-251-1/+6
|
* feat(rss,atom): mmap on demand like in blog_indexsternenseemann2020-08-241-70/+67
| | | | | | | | | | | | * entry * add entry_unget_text: implements unmmaping * free_entry: now expects pointer * index: adjust for entry changes * main * adjust for entry changes * use on demand mmaping in blog_atom and blog_rss * shell.nix * add strace for mmap debugging
* feat(main): add simple caching support via max-agesternenseemann2020-08-241-36/+26
| | | | | | * remove support for RSS <ttl> element, remove BLOG_RSS_TTL * add BLOG_CACHE_MAX_AGE, send Cache-Control headers * TODO: more sophisticated caching support? ETag support?
* feat(main): add atom feedsternenseemann2020-08-241-2/+132
| | | | | feat(templates/simple.c): link to atom feed as well refactor(templates/simple.c): replace make_link with catn_alloc
* refactor(stringutil): add function catn_alloc to ease url building in main.csternenseemann2020-08-211-2/+4
| | | | | | | | | * bitutil.{c,h} → stringutil.{c,h} (more appropriate) * new function catn_alloc(size_t n, ...) which concats `n` given strings into an dynamically allocated buffer, mostly useful for building URLs which is done in blog_rss. may be a possibility to use in entry.c, but code there might be too specific.
* feat(rss): minor improvements and refactor time formattingsternenseemann2020-08-201-26/+24
| | | | | | | * add timeutil.{c,h}: utility for formatting timestamps * wrap feed description in CDATA * use xml_escaped where applicable * use time of latest entry for lastBuildDate
* fix(treewide): use same type when comparingsternenseemann2020-08-111-2/+2
|
* feat(xml): add support for CDATA sectionssternenseemann2020-08-111-2/+2
| | | | | | | | | | * xml_open_cdata and xml_close_cdata add convenient support for this * tracked on stack using the newly introduced field type which is of enum xml_tag_type which may either be XML_NORMAL_TAG or XML_CDATA. * xml_close_all and xml_close_including also support closing CDATA sections now * xml_close_including now behaves like xml_close_all if NULL is given as tag, xml_close_all newly aliased to xml_close_including(..., NULL)
* feat(main): mmap only on demand and unmap asapsternenseemann2020-08-081-2/+11
| | | | | | | This should limit peak memory consumption to sizeof(struct entry) * amount_of_entries + sizeof largest_file. Previously it was size of the index plus size of all entries' files as they were all read into memory first thing and only freed afterwards.
* feat(treewide): major reworksternenseemann2020-08-081-278/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, I got a bit carried away after realizing that the initial change would be a breaking change anyways, so I am now left with a huge diff which can't be really split up. Please excuse this. The changes are as follows: * Rename blogpost → entry (breaking): make_blogpost → make_entry, blog_post → blog_entry etc. * Rename blogdefs.h → core.h (breaking) * Split functions from main.c into cgiutil and entry * entry / make_entry: * Use modification time instead of time in filename (breaking) * Rename timestamp → time (breaking) * Add field title (currently basename, breaking) * Add field text and text_size which can be use to store the contents of the associated file using mmap (fields default to NULL and -1 respectively, breaking) * Do PATH_INFO resolving and on disk path building in make_entry instead of in blog_index / blog_rss / blog_entry * entry_get_text: add function to mmap an entry's file into the structure * free_entry: also unmap file if present * make_index: Add function to build an array of entries reverse sorted by time * blog_index / blog_rss: * use make_index instead of scandir and make_blogpost_from_dirent * (blog_rss) use entry_get_text to pass the template the text of the entry. * template: * template_post_index_entry → template_index_entry (breaking) * template_post_single_entry → template_single_entry (breaking) * replace template_error_404() with generic template_error(status) * templates/simple.c: * Use xml library instead of printf * Use entry.text instead of opening the file in the template * include CSS if BLOG_CSS is set in config.h * document internal and public interfaces using doxygen * build process: * build object files individually * build process configuration in config.mk (breaking) * support templates in arbitrary locations * build default config.h if it's missing * add install phase * Rename target to sternenblog.cgi (breaking)
* style(treewide): tabs → spacessternenseemann2020-07-271-240/+240
|
* Fix misdetection of lfi attackslukasepple2016-01-031-2/+2
|
* fixed LFI vulnerabilitylukasepple2014-08-151-0/+8
|
* fixed the RSS feedsternenseemann2014-08-081-5/+6
|
* fixed missing closing CDATA tagsternenseemann2014-08-081-1/+1
|
* it's called sternenblog!Lukas Epple2014-08-081-1/+1
|
* error checkinglukasepple2014-08-081-1/+6
|
* moved the templating stuff to struct blogpostlukasepple2014-08-081-40/+17
|
* made date parsing working!lukasepple2014-08-081-1/+10
|
* (re)added feature macroslukasepple2014-08-081-0/+2
|
* something was wrong with my timeinfo freeslukasepple2014-08-081-2/+0
|
* fixed some memory leakslukasepple2014-08-081-2/+8
|
* added RSS Feed and new struct blogpost, time parsing isn't working yetlukasepple2014-08-071-7/+179
|
* out of the nowhere a cgi blog software appearslukasepple2014-08-021-0/+176