WebFactory Default Index Page

Introduction

WebFactory CMS 0.5 is a simple (still very capable) CMS for mostly static web pages.

One main difference towards common static site generators is that most functionality including site generation is available directly from the web interface.

The low level features of WebFactory described below is what WebFactory is without any kind of customisation. This means that most functions are accessed directly by editing URLs. In a production site simple helpers (like buttons) may be included as a convenience.

Restricted access

By default the customisation 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

Customisation

The current page is called index

Change this page by opening the following url. This link is also available as a Edit link in top left corner.

/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.

{{ template:default }}

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

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.

Example page

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

Link: apage

If you want to link to this page above named apage from markdown use the following link format

[link title to apage](/apage)

Other administrative functions

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

/all

Render all pages by opening the following url

/render/all

Search all (rendered) pages

/search

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 a constant.

{{ const:message }}

Multiple parameters are supplied separated by comma.

Custom parameters also override constant definitions. For instance the constant version (=0.5) 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 be overridden 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 "2024-04-14", is the result if you include a reference in a page. The dynamic data is generated when page is rendered.

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>{{ const:domain }}/index</loc>
      <lastmod>2024-04-14</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
   <url>
      <loc>{{ const:domain }}/apage</loc>
      <lastmod>{{ dynamic:date }}</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
</urlset> 

Note the reference to one constant domain and one dynamic date which are replaced when rendered.

These files are currently not editable via web ui.

File upload

Basic file upload is also supported by default.

/upload

Files are stored to /public/files folder by default so they are accessible via links or HTML tags from pages.