WebFactory Default Index Page

Introduction

static-site-generator

WebFactory CMS 0.2 system is a super simple CMS system for static web pages.

Restricted access

By default the customization is behind a login.

Default login admin / webfactory is defined in settings.rb. Be sure to replace that with your own login before going to production.

To force logout go to.

/logout

Customization

The current page is called index

Change this page by opening the following url

/edit/index

View pre-generated version of this page on following url

/index

Render new version of this page on following url

/render/index

Create a new page mypage by (1) opening the following url

/edit/mypage

And (2) include a template reference in the top of the new page.

But exclude any spaces within brackets. Spaces are added here just to avoid that the reference interpreted as a valid one.

{{ template:default }}

Reference other sections of a page (existing or non-existing) by inserting following markup within a page, but with spaces removed.

{{ section:route/section }}

Reference constant definitions (defined in config/constants.json) by inserting following markup within a page, but with spaces removed.

{{ const:name }}

Change template by changing header parameter "default" to your custom template file located in templates/.

{{ template:custom }}

Pages and sections

A page is a markup file (markdown or html) with a template configuration in the top of the page. Note no speces are allowed within brackets.

{{ template:default }}

A page may include all the contents it needs directly in the page, but may also reference other markup parts called, sections.

A page and a section look the same and are edited and created the same way. The only difference is that a page must include a template reference (in the top) to make it complete as a page. A section must not include a template reference because it is already part of a page. A page cannot have multiple document roots.

Example page

Below a pre-defined page has been created as an example.

Link: apage

Other admistrative

Show a list of all pages and sections by opening the following url

/all

Render all pages by opening the following url

/render/all

Advanced

Custom parameters in sections

Often a section can be used for many pages with just minor modification.

To allow better reuse between sections and avoid duplication it is possible to add custom parameters in the section reference. For instance if you want a custom message in a subsection for difference pages you can supply the custom parameter as follows.

{{ section:route/asection, message="Kilroy was here!" }}

The dynamic parameters is accessed from the section the same way as constant.

{{ const:message }}

Multiple parameters are supplied separated by comma.

Custom parameters also override constant definitions. For instance the constant version (=0.2) can be overridden in a subsection as follows.

{{ section:route/asection, message="Kilroy was here!", version="9.9" }}

Parameters are even allowed in templates. If you e.g. use a constant title in the template it can overridded by supplying the custom title in the template reference.

{{ template:default, title="My custom title for a page" }}

Dynamic generators

If you need even more flexibility it is possible to use custom ruby code to generate content to be used on a page.

These generators works in a similar way as constants, except that custom ruby code generate the results.

The following function is supplied as default.

def date
  Time.now.strftime("%F")
end

It is defined in dynamic.rb in class Dynamic. If you need other dynamic functions you can simply add them to the Dynamic class.

The dynamic is accessed in the same way as a constant except it is called a dynamic.

{{ dynamic:date }}

This "2019-11-03", is the result if you include a reference in a page.

Support other files

To handle common additional files like robots.txt and sitemap.xml general support for .xml and .txt files is included.

If you place one of these files in /pages folder they will be copied to /public folder when all pages are rendered (/render/all). The files may include const and dynamic references just as regular pages.

For instance this pages site map is defined as follows.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://webfactory.lounge.se/index</loc>
      <lastmod>2019-11-03</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
   <url>
      <loc>http://webfactory.lounge.se/apage</loc>
      <lastmod>2019-11-03</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
</urlset> 

Note the reference to one constant domain and one dynamic date.

These files are currently not editable via web ui.