aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md69
1 files changed, 69 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0a1d95b..397639e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,71 @@
# blogc
+
A blog compiler.
+
+
+## Design Notes
+
+The main idea is simple: a source file is read by the compiler, and a result file is written by the compiler.
+
+The source file must provide (almost) all the data needed to build the result file, including any variables. The result file is built using a template, that defines how the information provided by the source file should be used to generate a reasonable result file.
+
+The compiler will always generate a single file, no matter how many source files are provided to it. If more than one source file is provided, the template must know how to convert them to a single result file.
+
+The templates can define blocks. If something is defined outside of blocks, it should be used for any source. If it is inside a block, it should only be used if the block matches the compiler arguments, e.g: ``single_source`` is used if just one source file is provided, ``multiple_sources`` is used if more than one source file is provided, being used once for each source file, and ``multiple_sources_once`` is used if more than one source file is provide, but only once.
+
+The variables defined in the source file are only available inside blocks. If something does not depends the source files, and is global, it must be hardcoded in templates, for the sake of simplicity.
+
+As the compiler is output-agnostic, Atom feeds and sitemaps should be generated using templates as well.
+
+The content defined in source files must be written using Markdown syntax. Javascript and CSS are allowed, then be careful!
+
+The compiler is designed to be used with any POSIX-compatible implementation of ``make``.
+
+
+### Source file syntax
+
+```
+TITLE: My nice post
+DATE: 2007-04-05T12:30-02:00
+----
+# I'm a title
+
+test content
+```
+
+``DATE`` is the only variable required by the compiler, because it will be used to sort the source files, if you provide multiple source files. It is an ISO-8601 date-time, with seconds, and always in UTC. If you want to show the date of your posts in your blog, you can use the ``DATE`` variable, but it won't be nicely formated, it will always be an ISO-8601 date-time.
+
+All the variables used in templates are mandatory. The compiler will raise errors if template requires a variable and it is not found in the source file.
+
+Variables are single line, and all the whitespace characters, including tabs, before and after the leading and trailing letters will be removed.
+
+Markdown-parsed content is available in template blocks as the ``CONTENT`` variable.
+
+
+### Template file syntax
+
+```html
+<html>
+ <head>
+ {% block single_source %}
+ <title>My cool blog >> {{ TITLE }}</title>
+ {% endblock %}
+ {% block multiple_sources %}
+ <title>My cool blog - Main page</title>
+ {% endblock %}
+ </head>
+ <body>
+ <h1>My cool blog</h1>
+ {% block single_source %}
+ <h2>{{ TITLE }}</h2>
+ <h4>Published in: {{ DATE }}</h4>
+ {{ CONTENT }}
+ {% endblock %}
+ {% block multiple_sources_once %}<ul>{% endblock %}
+ {% block multiple_sources %}<p><a href="{{ HREF }}">{{ TITLE }}</a> - {{ DATE }}</p>{% endblock %}
+ {% block multiple_sources_once %}</ul>{% endblock %}
+ </body>
+</html>
+```
+
+This template would generate a list of posts, if multiple source files were provided, and single pages for each post, if only one source file was provided. The ``HREF`` variable is generated by the compiler, and is a relative url, suitable to create link. (TODO: decide on how to generate the ``HREF`` variable).