Changeset 39 in code


Ignore:
Timestamp:
Sep 2, 2015, 9:21:50 PM (10 years ago)
Author:
zaitsev.serge
Message:

updated README

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/README.md

    r13 r39  
    1515* Cross-platform
    1616* Highly extensible
     17* Works well for blogs and generic static websites (landing pages etc)
    1718* Easy to learn
    1819* Fast
     
    2627## Ideology
    2728
    28 Keep your texts in markdown format in the root directory of your blog/site.
     29Keep your texts in markdown, [amber] or HTML format right in the main directory
     30of your blog/site.
    2931
    3032Keep all service files (extensions, layout pages, deployment scripts etc)
    3133in the `.zs` subdirectory.
    3234
    33 Define variables in the header of the markdown files:
     35Define variables in the header of the content files using [YAML]:
    3436
    3537        title: My web site
    3638        keywords: best website, hello, world
     39        ---
    3740
    38         Markdown text goes after a *newline*
     41        Markdown text goes after a header *separator*
    3942
    4043Use placeholders for variables and plugins in your markdown or html
    41 files, e.g. `{{ title }}`.
     44files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
    4245
    4346Write extensions in any language you like and put them into the `.zs`
     
    4750placeholder.
    4851
    49 Extensions can use special environment variables, like:
     52Every variable from the content header will be passed via environment variables like `title` becomes `$ZS_TITLE` and so on. There are some special variables:
    5053
    5154* `$ZS` - a path to the `zs` executable
     
    5457* `$ZS_URL` - a URL for the currently generated page
    5558
    56 You can also pass command line arguments, e.g: `{{ my-plugin arg1 arg2 }}`
     59## Example of RSS generation
    5760
    58 ## Example of RSS generation
     61Extensions can be written in any language you know (Bash, Python, Lua, JavaScript, Go, even Assembler). Here's an example of how to scan all markdown blog posts and create RSS items:
     62
     63``` bash
     64for f in ./blog/*.md ; do
     65        d=$($ZS var $f date)
     66        if [ ! -z $d ] ; then
     67                timestamp=`date --date "$d" +%s`
     68                url=`$ZS var $f url`
     69                title=`$ZS var $f title | tr A-Z a-z`
     70                descr=`$ZS var $f description`
     71                echo $timestamp \
     72                        "<item>" \
     73                        "<title>$title</title>" \
     74                        "<link>http://zserge.com/$url</link>" \
     75                        "<description>$descr</description>" \
     76                        "<pubDate>$(date --date @$timestamp -R)</pubDate>" \
     77                        "<guid>http://zserge.com/$url</guid>" \
     78                "</item>"
     79        fi
     80done | sort -r -n | cut -d' ' -f2-
     81```
    5982
    6083## Hooks
    6184
    6285There are two special plugin names that are executed every time the build
    63 happens - `pre` and `post`. You can define some global action here like compile
    64 your LESS to CSS etc:
     86happens - `prehook` and `posthook`. You can define some global actions here like
     87content generation, or additional commands, like LESS to CSS conversion:
    6588
    6689        # .zs/post
     
    7093        rm -f $ZS_OUTDIR/styles.css
    7194
     95## Syntax sugar
     96
     97By default, `zs` converts each `.amber` file into `.html`, so you can use lightweight Jade-like syntax instead of bloated HTML.
     98
     99Also, `zs` converts `.gcss` into `.css`, so you don't really need LESS or SASS. More about GCSS can be found [here][gcss].
     100
    72101## Command line usage
    73102
    74103`zs build` re-builds your site.
     104
     105`zs build <file>` re-builds one file and prints resulting content to stdout.
    75106
    76107`zs watch` rebuilds your site every time you modify any file.
     
    83114
    84115The software is distributed under the MIT license.
     116
     117[amber]: https://github.com/eknkc/amber/
     118[YAML]: https://github.com/go-yaml/yaml
     119[gcss]: https://github.com/yosssi/gcss
Note: See TracChangeset for help on using the changeset viewer.