changeset 285:6e9b5530306e

docs: Still more documentation.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 02 Mar 2015 22:42:16 -0800
parents a8cf2ed9d3af
children a2d283d1033d
files docs/docs/02_general.md docs/docs/03_content.md docs/docs/03_content/01_creating-pages.md docs/docs/03_content/03_formatters.md docs/docs/03_content/04_templating-assets/debug_info_closed.png docs/docs/03_content/04_templating-assets/debug_info_open.png docs/docs/03_content/04_templating.md docs/docs/03_content/05_content-segments.md
diffstat 8 files changed, 187 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/docs/docs/02_general.md	Sun Mar 01 22:06:01 2015 -0800
+++ b/docs/docs/02_general.md	Mon Mar 02 22:42:16 2015 -0800
@@ -4,7 +4,7 @@
 
 This section gives a general overview of PieCrust:
 
-{% for part in family.children %}
+{% for part in family.children -%}
 * [{{part.title}}]({{part.url}})
 {% endfor %}
 
--- a/docs/docs/03_content.md	Sun Mar 01 22:06:01 2015 -0800
+++ b/docs/docs/03_content.md	Mon Mar 02 22:42:16 2015 -0800
@@ -10,7 +10,7 @@
 [cm]: {{docurl('content-model')}}
 
 
-{% for part in family.children %}
+{% for part in family.children -%}
 * [{{part.title}}]({{part.url}})
 {% endfor %}
 
--- a/docs/docs/03_content/01_creating-pages.md	Sun Mar 01 22:06:01 2015 -0800
+++ b/docs/docs/03_content/01_creating-pages.md	Mon Mar 02 22:42:16 2015 -0800
@@ -11,14 +11,10 @@
 process of creating pages.
 
 
-[src]: {{docurl('content-model/sources')}}
-[dcm]: {{docurl('content-model/default-model')}}
-
-
 ## Overview
 
 All pages sources have a _file-system endpoint_, which is usually a
-sub-directory of you website's root directory. They will look for pages inside
+sub-directory of your website's root directory. They will look for pages inside
 that endpoint, and load any file that matches that source's naming convention.
 
 Generally speaking, page sources will load any files that:
@@ -28,8 +24,14 @@
   default, those are `.md` and `.textile`, for Markdown and Textile formatted
   pages respectively).
 
+Different sources have different conventions -- mostly naming of the page files.
+We'll look at how it works for the sources in the [default content model][dcm].
+To learn about other sources, see the [page sources reference][srcref].
 
-## Simple pages
+
+## Default content model pages
+
+### Simple pages
 
 When using the default content model, PieCrust will load simple pages out of the
 `pages/` endpoint. The relative path of a page from the `pages/` directory will
@@ -45,7 +47,7 @@
 > whatnot.
 
 
-## Blog posts
+### Blog posts
 
 When using the default content model, PieCrust will load blog posts out of the
 `posts/` endpoint. There are different naming conventions available depending on
@@ -65,3 +67,12 @@
   auto-formats (usually `md` for Markdown texts and `textile` for Textile
   texts).
 
+> Running `chef prepare post my-new-blog-post` will create a new blog post with
+> a slug of `my-new-blog-post`, dated today. This makes it quick to write a new
+> blog post!
+
+
+[src]: {{docurl('content-model/sources')}}
+[dcm]: {{docurl('content-model/default-model')}}
+[srcref]: {{docurl('reference/sources')}}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/docs/03_content/03_formatters.md	Mon Mar 02 22:42:16 2015 -0800
@@ -0,0 +1,31 @@
+---
+title: Formatters
+---
+
+As explained in the documentation about [how PieCrust works][how], the page
+contents that you write go through a _formatter_ before the page is rendered or
+baked. PieCrust ships with 2 standard formatters: [Markdown][] and [Textile][].
+
+The formatter used on a page is determined by the `format` setting in the page's
+[configuration header][pageconf]:
+
+    * `markdown` for Markdown
+    * `textile` for Textile
+
+If unspecified, the extension of the page file is matched against the
+`site/auto_formats` setting in the [site configuration][siteconf]:
+
+    * `.md` for Markdown
+    * `.textile` for Textile
+
+Otherwise, the `site/default_format` setting in the site configuration will be
+used, and that's Markdown by default.
+
+
+
+[how]: {{docurl('general/how-it-works')}}
+[pageconf]: {{docurl('content/page-configuration')}}
+[siteconf]: {{docurl('general/site-configuration')}}
+[markdown]: https://en.wikipedia.org/wiki/Markdown
+[textile]: https://en.wikipedia.org/wiki/Textile_(markup_language)
+
Binary file docs/docs/03_content/04_templating-assets/debug_info_closed.png has changed
Binary file docs/docs/03_content/04_templating-assets/debug_info_open.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/docs/03_content/04_templating.md	Mon Mar 02 22:42:16 2015 -0800
@@ -0,0 +1,62 @@
+---
+title: Templating
+---
+
+As explained in the documentation about [how PieCrust works][how], the page
+contents that you write go through a _templating_ phase, which is when a page
+can execute some logic, insert reusable bits of markup, or reference other
+pieces of content or metadata from elsewhere in you website.
+
+PieCrust uses [Jinja][] for templating. There's too much data exposed to it to
+go over on this page, but check out the [templating data reference][dataref] for
+an exhaustive list. The main pieces of data are:
+
+* `page`: the page's configuration header. So if the page has a `title`,
+  `page.title` would be its value.
+
+* `pagination`: a pagination object that lets you iterate over other pages
+  (typically blog posts). `pagination.items` returns the pages, which come with
+  their own metadata (_i.e._ their configuration header) and contents. There are
+  also various properties to access counts, next/previous pages, etc.
+
+* `assets`: the current page's [assets][].
+
+* `family`: access to other pages in the same source -- children pages (_i.e._
+  pages in a directory of the same name as the current page), sibling pages,
+  parent pages, etc.
+
+You can use those pieces of data, and many more, along with Jinja's powerful
+template syntax, to make pretty much anything you can think of.
+
+
+### Debug info window
+
+A very powerful thing to use when using templating data is the PieCrust debug
+info window. You can enable it by adding the following to your layouts, just
+before the `</body>` tag:
+
+    {%raw%}
+    {{ piecrust.debug_info|safe }}
+    {%endraw%}
+
+Most of the time, this won't render anything. If, however, you add `?!debug` at
+the end of the URL while previewing your website with `chef serve`, then it will
+render as small overlay at the bottom right of your browser's window:
+
+![debug info closed]({{assets.debug_info_closed}})
+
+You can then expand the bottom part and reveal all the available templating data
+for the current page:
+
+![debug info open]({{assets.debug_info_open}})
+
+
+
+
+[how]: {{docurl('general/how-it-works')}}
+[pageconf]: {{docurl('content/page-configuration')}}
+[siteconf]: {{docurl('general/site-configuration')}}
+[dataref]: {{docurl('reference/templating-data')}}
+[assets]: {{docurl('content/assets')}}
+[jinja]: http://jinja.pocoo.org/docs/dev/templates/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/docs/03_content/05_content-segments.md	Mon Mar 02 22:42:16 2015 -0800
@@ -0,0 +1,74 @@
+---
+title: Content Segments
+---
+
+A page file is usually split in two sections: the [configuration
+header][pageconf], and the content itself:
+
+    ---
+    foo: bar
+    something: else
+    ---
+    Content goes here.
+
+When making a layout for a page, or inserting a page into another (like listing
+blog posts), you would use `content` to get that second section.
+
+But the contents of a page can also be split into _segments_.
+
+
+## Segments
+
+A page segment starts with the following marker:
+
+    ---name---
+
+You can replace `name` with something else, which will be the name of the
+segment.
+
+By default, the first segment (from the top of the file, or from just after the
+configuration header if there's one) will be named `content`.
+
+This mean you can create a page like so:
+
+    ---
+    title: Page with multiple segments
+    ---
+    The contents go here.
+
+    ---sidebar---
+    Sidebar goes here
+
+You can them use, the page's layout, both the `content` and `sidebar` segments
+to put each piece of text in its appropriate place.
+
+You can also specify a [formatter][] for a given segment, by adding `:formatter`
+after the segment's name. For instance, to disable formatting for the `sidebar`
+segment (because you want to write pure HTML and there's no need to have
+Markdown in the way):
+
+    ---
+    title: Page with multiple segments
+    ---
+    The contents go here.
+
+    ---sidebar:none---
+    <aside>
+        Sidebar goes here
+    </aside>
+
+
+## Parts
+
+You can switch formatters from one segment to the next, but you can also switch
+formatters _inside_ a given segment! You can use the following marker for this:
+
+    <--name-->
+
+The text will be formatted with formatter `name` until the end of the current
+segment, or until the end of the file.
+
+
+[pageconf]: {{docurl('content/page-configuration')}}
+[formatter]: {{docurl('content/formatters')}}
+