add README and docs
This commit is contained in:
		
							
								
								
									
										39
									
								
								docs/content/cli.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								docs/content/cli.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
:title: Command Line Interface
 | 
			
		||||
:date: 2022-09-30
 | 
			
		||||
 | 
			
		||||
======================
 | 
			
		||||
Command Line Interface
 | 
			
		||||
======================
 | 
			
		||||
 | 
			
		||||
::
 | 
			
		||||
 | 
			
		||||
    Usage: rsw init [--no-makefile] [<name>]
 | 
			
		||||
       rsw build [-c <file>]
 | 
			
		||||
       rsw print [-c <file>] [--default] [--json]
 | 
			
		||||
       rsw (-h | --help | -v | --version)
 | 
			
		||||
 | 
			
		||||
    Commands:
 | 
			
		||||
      init          initialise new site.
 | 
			
		||||
      build         build site.
 | 
			
		||||
      print         print configuration.
 | 
			
		||||
 | 
			
		||||
    Options:
 | 
			
		||||
      -c <file>, --config <file>    configuaration file.
 | 
			
		||||
      -j, --json                    JSON output.
 | 
			
		||||
      -d, --default                 print default config.
 | 
			
		||||
      -M, --no-makefile             do not create Makefile.
 | 
			
		||||
      -h, --help                    print this help message and exit.
 | 
			
		||||
      -v, --version                 print version and exit.
 | 
			
		||||
 | 
			
		||||
Makefile usage
 | 
			
		||||
==============
 | 
			
		||||
 | 
			
		||||
::
 | 
			
		||||
 | 
			
		||||
    Available targets:
 | 
			
		||||
 | 
			
		||||
      build          build HTML
 | 
			
		||||
      serve          run local HTTP server
 | 
			
		||||
      css <theme>    generate Pygments stylesheet
 | 
			
		||||
 | 
			
		||||
    Run make without target to build html
 | 
			
		||||
							
								
								
									
										71
									
								
								docs/content/configuration.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								docs/content/configuration.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
			
		||||
:title: Configuration
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
=============
 | 
			
		||||
Configuration
 | 
			
		||||
=============
 | 
			
		||||
 | 
			
		||||
Dirs (``dirs``)
 | 
			
		||||
===============
 | 
			
		||||
 | 
			
		||||
build_dir
 | 
			
		||||
    Default: build
 | 
			
		||||
 | 
			
		||||
content_dir
 | 
			
		||||
    Default: content
 | 
			
		||||
 | 
			
		||||
templates_dir
 | 
			
		||||
    Default: layouts
 | 
			
		||||
 | 
			
		||||
static_dir
 | 
			
		||||
    Default: static
 | 
			
		||||
 | 
			
		||||
    .. note::
 | 
			
		||||
 | 
			
		||||
        Content of this diretory will be placed into site root. Use
 | 
			
		||||
        subdirectories for files here, e.g. css/, img/, etc.
 | 
			
		||||
 | 
			
		||||
Default settings for pages (``defaults``)
 | 
			
		||||
=========================================
 | 
			
		||||
 | 
			
		||||
template
 | 
			
		||||
    Default: template.jinja2
 | 
			
		||||
 | 
			
		||||
    Default page template.
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
    Default: page
 | 
			
		||||
 | 
			
		||||
    Default article type.
 | 
			
		||||
 | 
			
		||||
Custom site data (``site``)
 | 
			
		||||
===========================
 | 
			
		||||
 | 
			
		||||
datetime_format
 | 
			
		||||
    Default: %Y-%m-%d
 | 
			
		||||
 | 
			
		||||
    See `Format Codes`_.
 | 
			
		||||
 | 
			
		||||
Pygments (``pygments``)
 | 
			
		||||
=======================
 | 
			
		||||
 | 
			
		||||
theme
 | 
			
		||||
    Default: default
 | 
			
		||||
 | 
			
		||||
    Generate CSS style with following command::
 | 
			
		||||
 | 
			
		||||
        make css style_name
 | 
			
		||||
 | 
			
		||||
    See `Pygments Styles`_ and `pygmentize`_.
 | 
			
		||||
 | 
			
		||||
Docutils (``docutils``)
 | 
			
		||||
=======================
 | 
			
		||||
 | 
			
		||||
See `Docutils Configuration`_.
 | 
			
		||||
 | 
			
		||||
.. Links
 | 
			
		||||
 | 
			
		||||
.. _Format Codes: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
 | 
			
		||||
.. _Pygments Styles: https://pygments.org/styles/
 | 
			
		||||
.. _pygmentize: https://pygments.org/docs/cmdline/
 | 
			
		||||
.. _Docutils Configuration: https://docutils.sourceforge.io/docs/user/config.html
 | 
			
		||||
							
								
								
									
										114
									
								
								docs/content/data_sources.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								docs/content/data_sources.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
:title: Data Sources
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
============
 | 
			
		||||
Data Sources
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
The diagram below shows the data sources and variables that can be used in
 | 
			
		||||
templates.
 | 
			
		||||
 | 
			
		||||
::
 | 
			
		||||
 | 
			
		||||
    ┌─────────────────┐
 | 
			
		||||
    │  settings.toml  ├───► site, pygments_theme ──┐
 | 
			
		||||
    └─────────────────┘                            │
 | 
			
		||||
                                                   │
 | 
			
		||||
    ┌─────────────────┐                   ┌────────▼────────┐
 | 
			
		||||
    │      *.rst      ├───► page, html ───► template.jinja2 │
 | 
			
		||||
    └────────┬────────┘                   └────────▲────────┘
 | 
			
		||||
             │                                     │
 | 
			
		||||
    ┌────────▼────────┐                            │
 | 
			
		||||
    │ Aggregated data ├───► aggr ──────────────────┘
 | 
			
		||||
    └─────────────────┘
 | 
			
		||||
 | 
			
		||||
\*.rst Files
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
The \*.rst files contain a part with document attributes called Docinfo (see
 | 
			
		||||
`field lists`_ and `bibliographic elements`_) and a part with the content of
 | 
			
		||||
the article.
 | 
			
		||||
 | 
			
		||||
You can come up with your own attributes. Attributes can contain only strings.
 | 
			
		||||
 | 
			
		||||
There some special attributes used by rSW:
 | 
			
		||||
 | 
			
		||||
============ =============== =========================
 | 
			
		||||
Attribute    Required        Deafult
 | 
			
		||||
============ =============== =========================
 | 
			
		||||
``type``     No              page
 | 
			
		||||
``template`` No              template.jinja2
 | 
			
		||||
``date``     Yes             None
 | 
			
		||||
``title``    No              None
 | 
			
		||||
============ =============== =========================
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
    Article type. Can be post for blog posts or ``page`` for standalone
 | 
			
		||||
    pages.
 | 
			
		||||
 | 
			
		||||
template
 | 
			
		||||
    The template to be used when rendering the HTML page.
 | 
			
		||||
 | 
			
		||||
    The attribute value must be the path to the template file relative to the
 | 
			
		||||
    template directory. For example, the templates/index.jinja2 file would be:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: rst
 | 
			
		||||
 | 
			
		||||
        :template: index.jinja2
 | 
			
		||||
 | 
			
		||||
    The path to the templates directory and default template can be overridden
 | 
			
		||||
    in **settings.toml**.
 | 
			
		||||
 | 
			
		||||
date
 | 
			
		||||
    Date in ISO format YYYY-MM-DD. This attribute is used to sort the list of
 | 
			
		||||
    posts. The date format can be overridden in **settings.toml**.
 | 
			
		||||
 | 
			
		||||
title
 | 
			
		||||
    Title of the article. It is not required and is not processed by rSW in
 | 
			
		||||
    any way, but it is desirable to fill it for use in templates.
 | 
			
		||||
 | 
			
		||||
.. note::
 | 
			
		||||
 | 
			
		||||
    The ``authors`` attribute is `special`_ and is not yet supported by rSW.
 | 
			
		||||
    Using ``authors`` will result in an error when building the site.
 | 
			
		||||
 | 
			
		||||
settings.toml
 | 
			
		||||
=============
 | 
			
		||||
 | 
			
		||||
The configuration file has a special ``site`` section, all data from which is
 | 
			
		||||
passed to the template unchanged. 
 | 
			
		||||
 | 
			
		||||
The structure and data types can be arbitrary. The file uses the
 | 
			
		||||
`TOML <https://toml.io/>`_ format.
 | 
			
		||||
 | 
			
		||||
For example, in this way you can pass basic information about the site:
 | 
			
		||||
 | 
			
		||||
.. code-block:: toml
 | 
			
		||||
 | 
			
		||||
    [site]
 | 
			
		||||
    title = 'My site'
 | 
			
		||||
    name = 'My awesome site'
 | 
			
		||||
    description = 'Awesome site about awesome things'
 | 
			
		||||
    datetime_format = '%d %b %Y'
 | 
			
		||||
 | 
			
		||||
A special variable ``pygments_theme`` is also passed to the template from the
 | 
			
		||||
configuration file. It contains the value of ``pygments.theme``.
 | 
			
		||||
 | 
			
		||||
Aggregated data
 | 
			
		||||
===============
 | 
			
		||||
 | 
			
		||||
A dictionary with aggregated data. This data is collected during site
 | 
			
		||||
generation before HTML-pages are rendered.
 | 
			
		||||
 | 
			
		||||
Aggregated data contains lists of blog posts and standalone pages.
 | 
			
		||||
 | 
			
		||||
The list of posts is sorted in descending order by date from the ``date``
 | 
			
		||||
attribute.
 | 
			
		||||
 | 
			
		||||
The next article will describe the use of this data in templates.
 | 
			
		||||
 | 
			
		||||
.. Links
 | 
			
		||||
 | 
			
		||||
.. _field lists: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html\#field-lists
 | 
			
		||||
.. _bibliographic elements: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements
 | 
			
		||||
.. _special: https://docutils.sourceforge.io/docs/ref/doctree.html#authors
 | 
			
		||||
							
								
								
									
										199
									
								
								docs/content/examples.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								docs/content/examples.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,199 @@
 | 
			
		||||
:title: Examples
 | 
			
		||||
:date: 2022-09-30
 | 
			
		||||
 | 
			
		||||
========
 | 
			
		||||
Examples
 | 
			
		||||
========
 | 
			
		||||
 | 
			
		||||
Blog site example
 | 
			
		||||
=================
 | 
			
		||||
 | 
			
		||||
For the blog, we will need to create three template files and at least two
 | 
			
		||||
.rst files.
 | 
			
		||||
 | 
			
		||||
Edit your **settings.toml**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: toml
 | 
			
		||||
 | 
			
		||||
    [defaults]
 | 
			
		||||
    template = 'post.jinja2'
 | 
			
		||||
    type = 'post'
 | 
			
		||||
 | 
			
		||||
    [site]
 | 
			
		||||
    title = 'My Blog'
 | 
			
		||||
 | 
			
		||||
Generate Pygments theme:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
   make css default
 | 
			
		||||
 | 
			
		||||
Create basic template **layouts/base.jinja2**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
    <!DOCTYPE html>
 | 
			
		||||
    <html lang="en">
 | 
			
		||||
      <head>
 | 
			
		||||
        <meta charset="utf-8">
 | 
			
		||||
        <link rel="stylesheet" href="/css/pygments/{{ pygments_theme }}.css">
 | 
			
		||||
        <link rel="stylesheet" href="/css/style.css">
 | 
			
		||||
        <title>{{ page.title }} | {{ site.title }}</title>
 | 
			
		||||
      </head>
 | 
			
		||||
    <body>
 | 
			
		||||
      {% block content %}{% endblock %}
 | 
			
		||||
    </body>
 | 
			
		||||
    </html>
 | 
			
		||||
 | 
			
		||||
Home page template **layouts/index.jinja2**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
    {% extends "base.jinja2" %}
 | 
			
		||||
    {% block content %}
 | 
			
		||||
      <h1>{{ site.title }}</h1>
 | 
			
		||||
      <ul id="posts">
 | 
			
		||||
        {% for post in aggr.posts %}
 | 
			
		||||
          <li>
 | 
			
		||||
            <a href="{{ post.path }}">{{ post.title }}</a>
 | 
			
		||||
            <span class="meta"> — {{ post.date }}</span>
 | 
			
		||||
          </li>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
      </ul>
 | 
			
		||||
      {{ html | safe }}
 | 
			
		||||
    {% endblock %}
 | 
			
		||||
 | 
			
		||||
Posts tempalte **layouts/post.jinja2**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
    {% extends "base.jinja2" %}
 | 
			
		||||
    {% block content %}
 | 
			
		||||
      <a href="/">Back to the home page</a>
 | 
			
		||||
      <article>
 | 
			
		||||
        {{ html | safe }}
 | 
			
		||||
      </article>
 | 
			
		||||
    {% endblock %}
 | 
			
		||||
 | 
			
		||||
Create dummy home page **content/index.rst** with fields:
 | 
			
		||||
 | 
			
		||||
.. code-block:: rst
 | 
			
		||||
 | 
			
		||||
    :title: Homepage
 | 
			
		||||
    :date: 1970-01-01
 | 
			
		||||
    :type: page
 | 
			
		||||
    :template: index.jinja2
 | 
			
		||||
 | 
			
		||||
Create first blog post **content/hello_world.rst**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: rst
 | 
			
		||||
 | 
			
		||||
    :title: Hello, World!
 | 
			
		||||
    :date: 1970-01-01
 | 
			
		||||
 | 
			
		||||
    =============
 | 
			
		||||
    Hello, World!
 | 
			
		||||
    =============
 | 
			
		||||
 | 
			
		||||
    Hello, there! This is my first site built with *re*\ **Structured**\ *Web*!
 | 
			
		||||
 | 
			
		||||
Now build site:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
   make
 | 
			
		||||
   make serve
 | 
			
		||||
 | 
			
		||||
Page navigation
 | 
			
		||||
===============
 | 
			
		||||
 | 
			
		||||
This code is used on this site to organize pagination.
 | 
			
		||||
 | 
			
		||||
**settings.toml**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: toml
 | 
			
		||||
 | 
			
		||||
    [site]
 | 
			
		||||
    [[site.sidebar]]
 | 
			
		||||
    title = 'First'
 | 
			
		||||
    url = '/first.html'
 | 
			
		||||
 | 
			
		||||
    [[site.sidebar]]
 | 
			
		||||
    title = 'Second'
 | 
			
		||||
    url = '/second.html'
 | 
			
		||||
 | 
			
		||||
    [[site.sidebar]]
 | 
			
		||||
    title = 'Third'
 | 
			
		||||
    url = '/third.html'
 | 
			
		||||
 | 
			
		||||
**layouts/template.jinja2**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
    {# Display Sidebar #}
 | 
			
		||||
    <strong>Contents</strong>
 | 
			
		||||
    <ul id="contents">
 | 
			
		||||
      {% for item in site.sidebar %}
 | 
			
		||||
        <li>
 | 
			
		||||
          <a href="{{ item.url }}">{{ item.title }}</a>
 | 
			
		||||
        </li>
 | 
			
		||||
      {% endfor %}
 | 
			
		||||
    </ul>
 | 
			
		||||
 | 
			
		||||
    {# Page content #}
 | 
			
		||||
    <article>
 | 
			
		||||
      {{ html | safe }}
 | 
			
		||||
    </article>
 | 
			
		||||
 | 
			
		||||
    {# Pagination #}
 | 
			
		||||
    {% for item in site.sidebar %}
 | 
			
		||||
      {% if item.title == page.title %}
 | 
			
		||||
        {% set current = site.sidebar.index(item) %}
 | 
			
		||||
        {% set last = site.sidebar.index(site.sidebar[-1]) %}
 | 
			
		||||
        {% if current == 0 %}
 | 
			
		||||
          {# If curret page is a first page #}
 | 
			
		||||
            <a href="{{ site.sidebar[current+1].url }}">
 | 
			
		||||
              {{ site.sidebar[current+1].title }} --></a>
 | 
			
		||||
        {% elif current == last %}
 | 
			
		||||
          {# If curret page is a last page #}
 | 
			
		||||
            <a href="{{ site.sidebar[current-1].url }}">
 | 
			
		||||
              <-- {{ site.sidebar[current-1].title }}</a></div>
 | 
			
		||||
        {% else %}
 | 
			
		||||
            <a href="{{ site.sidebar[current-1].url }}">
 | 
			
		||||
              <-- {{ site.sidebar[current-1].title }}</a>
 | 
			
		||||
            <a href="{{ site.sidebar[current+1].url }}">
 | 
			
		||||
              {{ site.sidebar[current+1].title }} --></a>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
      {% endif %}
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
 | 
			
		||||
**content/index.rst**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: rst
 | 
			
		||||
 | 
			
		||||
    :title: Homepage
 | 
			
		||||
    :date: 1907-01-01
 | 
			
		||||
 | 
			
		||||
    =======
 | 
			
		||||
    Welcome
 | 
			
		||||
    =======
 | 
			
		||||
 | 
			
		||||
    Hello, there!
 | 
			
		||||
 | 
			
		||||
Page example e.g. **content/first.rst**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: rst
 | 
			
		||||
 | 
			
		||||
    :title: First
 | 
			
		||||
    :date: 1907-01-01
 | 
			
		||||
 | 
			
		||||
    =====
 | 
			
		||||
    First
 | 
			
		||||
    =====
 | 
			
		||||
 | 
			
		||||
    First page.
 | 
			
		||||
 | 
			
		||||
.. note::
 | 
			
		||||
 | 
			
		||||
    Page ``:title:`` and sidebar's ``title`` in **settings.toml** item must be
 | 
			
		||||
    the same. Otherwise pagination not be displayed.
 | 
			
		||||
							
								
								
									
										52
									
								
								docs/content/index.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								docs/content/index.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
:title: reStructuredWeb
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
|rSW|
 | 
			
		||||
 | 
			
		||||
v0.1.2
 | 
			
		||||
 | 
			
		||||
reStructuredWeb (rSW, reSW or rstW) — is a highly customizable static site
 | 
			
		||||
generator for the *re*\ **Structured**\ *Text* markup language.
 | 
			
		||||
 | 
			
		||||
Why another site generator?
 | 
			
		||||
===========================
 | 
			
		||||
 | 
			
		||||
Hundreds of static site generators have been written with varying degrees of
 | 
			
		||||
shittyness. Here are just some of the shortcomings of existing solutions:
 | 
			
		||||
 | 
			
		||||
* Bad customization. If the task requires something that is not provided for
 | 
			
		||||
  in regular themes, then you have to strain. Editing a theme is an adventure.
 | 
			
		||||
* Some of the solutions are extremely primitive and only fit narrow cases.
 | 
			
		||||
  Others, on the contrary, are overcomplicated.
 | 
			
		||||
* There are very few generators with reStructuredText support.
 | 
			
		||||
 | 
			
		||||
Why is reStructuredWeb better?
 | 
			
		||||
==============================
 | 
			
		||||
 | 
			
		||||
* **Small codebase**. About ~300 lines in total.
 | 
			
		||||
* **Doesn't depend on the presentation layer**. rSW just takes data from
 | 
			
		||||
  files and allows you to insert it into templates.
 | 
			
		||||
 | 
			
		||||
That's all. In fact, this is enough for a static site generator.
 | 
			
		||||
 | 
			
		||||
**rSW** is built on |Docutils|_ and |Jinja2|_.
 | 
			
		||||
 | 
			
		||||
.. |rSW| image::
 | 
			
		||||
   /rsw/img/rsw.svg
 | 
			
		||||
   :alt: [rSW]
 | 
			
		||||
   :align: middle
 | 
			
		||||
   :height: 3em
 | 
			
		||||
 | 
			
		||||
.. |Docutils| image::
 | 
			
		||||
   /rsw/img/rst.png
 | 
			
		||||
   :alt: Docutils
 | 
			
		||||
   :align: middle
 | 
			
		||||
   :width: 7em
 | 
			
		||||
.. _Docutils: https://docutils.sourceforge.io/
 | 
			
		||||
 | 
			
		||||
.. |Jinja2| image::
 | 
			
		||||
   /rsw/img/jinja.png
 | 
			
		||||
   :alt: Jinja2
 | 
			
		||||
   :align: middle
 | 
			
		||||
   :width: 3em
 | 
			
		||||
.. _Jinja2: https://jinja.palletsprojects.com/
 | 
			
		||||
							
								
								
									
										48
									
								
								docs/content/install.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								docs/content/install.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
:title: Installation
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
============
 | 
			
		||||
Installation
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
From PyPI
 | 
			
		||||
=========
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    pip install reSW
 | 
			
		||||
 | 
			
		||||
From tarball
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
1. `Download`_ tarball (`alterntive link </rsw/downloads/reSW-0.1.2.tar.gz>`_)
 | 
			
		||||
   with prebuilt Python package.
 | 
			
		||||
2. Install via pip:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    pip install ./reSW-0.1.2.tar.gz
 | 
			
		||||
 | 
			
		||||
From Source
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
1. `Download`_ source or clone Git repo:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    git clone https://git.nxhs.cloud/ge/rSW.git && cd rSW
 | 
			
		||||
 | 
			
		||||
2. Install build deps:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    pip install --update build
 | 
			
		||||
 | 
			
		||||
3. Build and install Python package:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    make
 | 
			
		||||
    make install
 | 
			
		||||
 | 
			
		||||
.. _Download: https://git.nxhs.cloud/ge/rSW/releases
 | 
			
		||||
							
								
								
									
										13
									
								
								docs/content/overview.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docs/content/overview.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
:title: Overview
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
========
 | 
			
		||||
Overview
 | 
			
		||||
========
 | 
			
		||||
 | 
			
		||||
On this page, I will list the important features of the application that you
 | 
			
		||||
may be looking for.
 | 
			
		||||
 | 
			
		||||
* You can create two types of pages: blog posts and standalone pages.
 | 
			
		||||
* Any page can use its own layout (template).
 | 
			
		||||
* You can pass arbitrary data to templates. See `Data Sources </rsw/data_sources.html>`_
 | 
			
		||||
							
								
								
									
										70
									
								
								docs/content/quick_start.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								docs/content/quick_start.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
:title: Quick Start
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
===========
 | 
			
		||||
Quick Start
 | 
			
		||||
===========
 | 
			
		||||
 | 
			
		||||
After installation you must have these file structure::
 | 
			
		||||
 | 
			
		||||
    ./
 | 
			
		||||
    ├── content/
 | 
			
		||||
    ├── layouts/
 | 
			
		||||
    ├── Makefile
 | 
			
		||||
    ├── settings.toml
 | 
			
		||||
    └── static/
 | 
			
		||||
 | 
			
		||||
Articles mst be placed into content/ dir and have .rst extension.
 | 
			
		||||
 | 
			
		||||
Also you can place article into subdirectory as following::
 | 
			
		||||
 | 
			
		||||
    ./
 | 
			
		||||
    └── content/
 | 
			
		||||
        └── hello_world/
 | 
			
		||||
            └── index.rst
 | 
			
		||||
 | 
			
		||||
You need to create page template first.
 | 
			
		||||
 | 
			
		||||
Create **layouts/template.jinja2** with content:
 | 
			
		||||
 | 
			
		||||
.. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
    <!DOCTYPE html>
 | 
			
		||||
    <html lang="en">
 | 
			
		||||
      <head>
 | 
			
		||||
        <meta charset="utf-8">
 | 
			
		||||
        <title>{{ page.title }}</title>
 | 
			
		||||
      </head>
 | 
			
		||||
    <body>
 | 
			
		||||
       {{ html | safe }}
 | 
			
		||||
    </body>
 | 
			
		||||
    </html>
 | 
			
		||||
 | 
			
		||||
Now create first page **content/index.rst**:
 | 
			
		||||
 | 
			
		||||
.. code-block:: rst
 | 
			
		||||
 | 
			
		||||
    :title: Hello, World!
 | 
			
		||||
    :date: 1970-01-01
 | 
			
		||||
 | 
			
		||||
    =============
 | 
			
		||||
    Hello, World!
 | 
			
		||||
    =============
 | 
			
		||||
 | 
			
		||||
    Hello, there! This is my first site built with *re*\ **Structured**\ *Web*!
 | 
			
		||||
 | 
			
		||||
Build your site with command:
 | 
			
		||||
 | 
			
		||||
.. code-block:: shell
 | 
			
		||||
 | 
			
		||||
    rsw build
 | 
			
		||||
    # OR
 | 
			
		||||
    make
 | 
			
		||||
 | 
			
		||||
build/ directory will be created. Run local HTTP-server to view site:
 | 
			
		||||
 | 
			
		||||
.. code-block:: text
 | 
			
		||||
 | 
			
		||||
    make serve
 | 
			
		||||
 | 
			
		||||
Local server will be started at `http://127.0.0.1:8080/ <http://127.0.0.1:8080/>`_.
 | 
			
		||||
							
								
								
									
										47
									
								
								docs/content/rst_extensions.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								docs/content/rst_extensions.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
:title: rST Extensions
 | 
			
		||||
:date: 2022-09-29
 | 
			
		||||
 | 
			
		||||
===========================
 | 
			
		||||
reStructuredText Extensions
 | 
			
		||||
===========================
 | 
			
		||||
 | 
			
		||||
rSW includes support for a few directives and roles that are not part of
 | 
			
		||||
Docutils.
 | 
			
		||||
 | 
			
		||||
code-block
 | 
			
		||||
==========
 | 
			
		||||
 | 
			
		||||
Example:
 | 
			
		||||
 | 
			
		||||
.. code-block:: text
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
        if __name__ == "__main__":
 | 
			
		||||
            # [initialize]
 | 
			
		||||
            app.start(":8000")
 | 
			
		||||
            # [initialize]
 | 
			
		||||
 | 
			
		||||
Result:
 | 
			
		||||
 | 
			
		||||
.. code-block:: python
 | 
			
		||||
 | 
			
		||||
    if __name__ == "__main__":
 | 
			
		||||
        # [initialize]
 | 
			
		||||
        app.start(":8000")
 | 
			
		||||
        # [initialize]
 | 
			
		||||
 | 
			
		||||
TODO
 | 
			
		||||
====
 | 
			
		||||
 | 
			
		||||
In plan:
 | 
			
		||||
 | 
			
		||||
* Fully featured ``code-block`` (as in `Sphinx`_)
 | 
			
		||||
* Deleted text (`<del>`)
 | 
			
		||||
* Inserted text (`<ins>`)
 | 
			
		||||
* Keystrokes mark (``:kbd:``)
 | 
			
		||||
* Spoilers (`<details>`, `<summary>`)
 | 
			
		||||
* Table of Contents (``toctree``)
 | 
			
		||||
* Abbreviations (``:abbr:``)
 | 
			
		||||
 | 
			
		||||
.. _Sphinx: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block
 | 
			
		||||
							
								
								
									
										130
									
								
								docs/content/variables.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								docs/content/variables.rst
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,130 @@
 | 
			
		||||
:title: Variables
 | 
			
		||||
:date: 2022-09-22
 | 
			
		||||
 | 
			
		||||
=========
 | 
			
		||||
Variables
 | 
			
		||||
=========
 | 
			
		||||
 | 
			
		||||
The following variables are passed to the template. Еach variable corresponds
 | 
			
		||||
to a data source, which is described in the previous article.
 | 
			
		||||
 | 
			
		||||
``page``: dict
 | 
			
		||||
    Dictonary with article attributes. Data structure example:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
        page = {
 | 
			
		||||
            'title': 'Variables',
 | 
			
		||||
            'date': '2022-09-22',
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    Note that the ``type`` and ``template`` keys are missing. These keys are
 | 
			
		||||
    added implicitly. The ``page`` dict will always contain only the data
 | 
			
		||||
    specified directly in the article.
 | 
			
		||||
 | 
			
		||||
    Here ``type`` and ``template`` fallbacks to defaults:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: text
 | 
			
		||||
 | 
			
		||||
        'template': `template.jinja2`
 | 
			
		||||
        'type': 'page',
 | 
			
		||||
 | 
			
		||||
    Usage example:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
        <h1>{{ page.title }}</h1>
 | 
			
		||||
 | 
			
		||||
``site``: dict
 | 
			
		||||
    Dict of values from ``site`` section from **settings.toml**. The structure
 | 
			
		||||
    and data types can be arbitrary.
 | 
			
		||||
 | 
			
		||||
    This data can be used to add custom elements common to the entire site.
 | 
			
		||||
    Below is an example of adding a list of links.
 | 
			
		||||
 | 
			
		||||
    .. code-block:: toml
 | 
			
		||||
 | 
			
		||||
        [site]
 | 
			
		||||
        title = 'My awesome site'
 | 
			
		||||
        description = 'Awesome site about awesome things'
 | 
			
		||||
 | 
			
		||||
            [[site.links]]
 | 
			
		||||
            title = 'GitHub'
 | 
			
		||||
            url = 'https://github.com/username'
 | 
			
		||||
 | 
			
		||||
            [[site.links]]
 | 
			
		||||
            title = 'Twitter'
 | 
			
		||||
            url = 'https://twitter.com/username'
 | 
			
		||||
 | 
			
		||||
    This data is serialized into a dictionary with the following structure:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
        site = {
 | 
			
		||||
            'title': 'My awesome site',
 | 
			
		||||
            'description': 'Awesome site about awesome things',
 | 
			
		||||
            'links': [
 | 
			
		||||
                {
 | 
			
		||||
                    'title': 'GitHub',
 | 
			
		||||
                    'url': 'https://github.com/username',
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    'title': 'Twitter',
 | 
			
		||||
                    'url': 'https://twitter.com/username',
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    In template:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
        {% for link in site.links %}
 | 
			
		||||
            <a href="{{ link.url }}">{{ link.title }} </a>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
 | 
			
		||||
``aggr``: dict
 | 
			
		||||
    This dictonary contains list of posts and list of pages. The elements of
 | 
			
		||||
    each list consist of dictionaries with strings.
 | 
			
		||||
 | 
			
		||||
    Structure of the ``aggr`` dictonary:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
        aggr = {
 | 
			
		||||
            'posts': [
 | 
			
		||||
                {
 | 
			
		||||
                    'title': 'Hello, World!',
 | 
			
		||||
                    'date': '1970-01-01',
 | 
			
		||||
                    'type': 'post'
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    'title': 'reStructuredText Example',
 | 
			
		||||
                    'date': '1970-01-01',
 | 
			
		||||
                    'type': 'post'
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            'pages': [
 | 
			
		||||
                {
 | 
			
		||||
                    'title': 'Variables',
 | 
			
		||||
                    'date': '2022-09-22'
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    These lists are applicable, for example, to display a list of posts on the
 | 
			
		||||
    blog's main page.
 | 
			
		||||
 | 
			
		||||
``pygments_theme``: str
 | 
			
		||||
    A string containing the name of the Pygments theme. In **settings.toml**:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: toml
 | 
			
		||||
 | 
			
		||||
        [pygments]
 | 
			
		||||
        theme = 'rrt'
 | 
			
		||||
 | 
			
		||||
    The default theme is ``default``. An example of usage in a template:
 | 
			
		||||
 | 
			
		||||
    .. code-block:: jinja
 | 
			
		||||
 | 
			
		||||
        <link rel="stylesheet" href="/css/pygments/{{ pygments_theme }}.css">
 | 
			
		||||
		Reference in New Issue
	
	Block a user