Title: Education: 05. Blog Date: 2019-05-22 00:00 Category: Page Slug: education.05.blog Lang: en | < Back | Index | Next > | |---|---|---| | [04. Language][prev] | [Education][index] | Not available |
In this document we create "dynamic" pages like blog posts. Estimated completion time: 20 minutes. **Table of contents** * [01. Blog](#blog) * [02. Investigate `cfg` file](#cfg) * [03. Investigate item templates of the blog](#item) * [04. Investigate preview templates](#preview) * [05. Investigate index (summary) templates](#index) * [06. Investigate pagination templates](#pagination) * [07. Investigate Markdown files](#md) * [08. Launch LFSA and generate the site](#gen) * [09. Summary](#summary) ## 01. Blog So, you have your web site in both English and Russian. You start to feel the need to constantly share your thoughts with the world as blog posts. You set on to create the following [directory structure][03-files]: * `cfg` * `en/blog/` * `item.template` * `index.template` * `preview.template` * `pagination.template` * `pagination.prev.template` * `pagination.next.template` * `1885.md` * `1886.01.md` * `1886.02.md` * `1887.01.md` * `1887.02.md` * `1888.md` * `1896.md` * `1899.md` * `en/page/` * `item.template` * `about.md` * `cv.md` * `ru/blog/` * `item.template` * `index.template` * `preview.template` * `pagination.template` * `pagination.prev.template` * `pagination.next.template` * `1885.md` * `1886.01.md` * `1886.02.md` * `1887.01.md` * `1887.02.md` * `1888.md` * `1896.md` * `1899.md` * `ru/page/` * `item.template` * `about.md` * `cv.md` Let's look at the contents of these files closer. ## 02. Investigate `cfg` file `cfg` file has the following contents: ``` input = en/page;ru/page;en/blog;ru/blog item = item.template preview = preview.template index = index.template paginationPrev = pagination.prev.template paginationNext = pagination.next.template paginationPrevNext = pagination.template previewSize = 200 previewEnding = . . . previewsPerPage = 3 previewPageBaseName = index ``` Apart from already used `input` and `item` keys, we have quite a lot of new ones. Let's break them down: | Key | Description | |---|---| | `preview` | Points to an HTML template file that is used to generate HTML previews out of the first `previewSize` (approximately) characters of Markdown files | | `index` | Points to an HTML template file that is used to generate HTML index (summary) files to host previews | | `paginationPrev` | Points to an HTML template file that is used to generate pagination section used by the *last* index (summary) file | | `paginationNext` | Points to an HTML template file that is used to generate pagination section used by the *first* index (summary) file | | `paginationPrevNext` | Points to an HTML template file that is used to generate pagination section used by index (summary) files *except the ones at the beginning and at the end* | | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate an HTML preview | | `previewEnding` | String to use at the end of HTML previews | | `previewsPerPage` | Number of HTML previews hosted by single index (summary) file | | `previewsPageBaseName` | Index (summary) file base name | In our case: * we restrict previews to `200` characters in size (approximately) * we use `. . .` string at the end of each preview * index (summary) files host `3` previews maximum * index (summary) files are saved as `index.html`, `index2.html`, `index3.html`, etc. ## 03. Investigate item templates of the blog * `en/blog/item.template` contents: ``` - - - - Collapsed for brevity - - - -

In the blog...

PSKOV_ITEM_TITLE

PSKOV_ITEM_DATE

PSKOV_ITEM_CONTENTS
- - - - Collapsed for brevity - - - - ``` * `ru/blog/item.template` contents: ``` - - - - Collapsed for brevity - - - -

В блоге...

PSKOV_ITEM_TITLE

PSKOV_ITEM_DATE

PSKOV_ITEM_CONTENTS
- - - - Collapsed for brevity - - - - ``` **Note**: beginning and ending were collapsed for brevity. As you can see, both files look similar to `item.template` files we saw [before][prev]. The changes include: * new URLs to reference pages in `page` directory and first index (summary) file in `blog` directory * title is now referenced inside `contents` section as a link to complete page * date is referenced to highlight relationship among different blog posts in time Date reference uses new `PSKOV_ITEM_DATE` constant: | PSKOV constant | Description | |---|---| | `PSKOV_ITEM_DATE` | Provides date from `Date:` part of page's header section | ## 04. Investigate preview templates * `en/blog/preview.template` contents: ```

PSKOV_ITEM_TITLE

PSKOV_ITEM_DATE

PSKOV_PREVIEW
``` * `ru/blog/preview.template` contents: ```

PSKOV_ITEM_TITLE

PSKOV_ITEM_DATE

PSKOV_PREVIEW
``` Previews have no ``, ``, and similar full page HTML tags. Previews represent sections inserted into index (summary) files. Preview itself is referenced by `PSKOV_PREVIEW` constant: | PSKOV constant | Description | |---|---| | `PSKOV_PREVIEW` | Provides contents from a Markdown file limited by `previewSize` characters (approximately) | ## 05. Investigate index (summary) templates * `en/blog/index.template` contents: ``` - - - - Collapsed for brevity - - - -

Blog

PSKOV_PREVIEWS PSKOV_PAGINATION
- - - - Collapsed for brevity - - - - ``` * `ru/blog/index.template` contents: ``` - - - - Collapsed for brevity - - - -

Блог

PSKOV_PREVIEWS PSKOV_PAGINATION
- - - - Collapsed for brevity - - - - ``` **Notes**: * beginning and ending were collapsed for brevity * `PSKOV_INDEX_URL` constant is used to provide language selection Index (summary) files are used to host previews. Here are new **PSKOV** constants explained: | PSKOV constant | Description | |---|---| | `PSKOV_INDEX_URL` | Provides generated page's file name: `.html` | | `PSKOV_PREVIEWS` | Provides a combination of `PSKOV_PREVIEW` sections | | `PSKOV_PAGINATION` | Provides pagination section to navigate index (summary) pages | ## 06. Investigate pagination templates Pagination templates represent sections used to navigate index (summary) pages. There are free pagination templates: | Pagination template | Description | |---|---| | prev | Is used for the last index (summary) page because we can only go backwards | | next | Is used for the first index (summary) page because we can only go forward | | both | Is used for intermediate index (summary) pages because we can either go backwards, or forward | Let's look at English pagination templates: * `en/blog/pagination.prev.template` contents: ```

Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT

« Newer

``` * `en/blog/pagination.next.template` contents: ```

Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT

Older »

``` * `en/blog/pagination.template` contents: ```

Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT

« Newer Older »

``` Russian counterparts look similar. Here's `ru/blog/pagination.template` contents: ```

Страница PSKOV_PAGE_ID из PSKOV_PAGES_COUNT

« Новее Старее »

``` Here are new **PSKOV** constants we used: | PSKOV constant | Description | |---|---| | `PSKOV_PAGE_ID` | Provides index (summary) page id starting from `1` | | `PSKOV_PAGES_COUNT` | Provides total number of index (summary) pages generated | | `PSKOV_PREV_PAGE_URL` | Provides previous index (summary) page file name | | `PSKOV_NEXT_PAGE_URL` | Provides next index (summary) page file name | ## 07. Investigate Markdown files Markdown files represent blog posts and they look almost like Markdown files for pages. Here's `en/blog/1885.md` contents: ``` Title: Bullocks Date: 1885 Slug: 1885.01.bullocks ![Bullocks][bullocks] I've been painting "Bullocks" sketch while I was staying in Odessa at Kuznetsov's in 1885. [bullocks]: https://upload.wikimedia.org/wikipedia/commons/c/cb/Walentin_Aleksandrovich_Serov_Bullocks.jpg ``` Date is used to sort blog posts by date in ascending order: | Header constant | Description | |---|---| | `Date:` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown | ## 08. Launch LFSA and generate the site Launch [LFSA][lfsa] so that it points to directory with the files we just observed: ``` $ /path/to/lfsa-201905.py /path/to/dir/03.Blog ``` Generate the site: * Go to [Tool][tool] page * Press `Generate` button * Open generated `en/blog/index.html` or `ru/blog/index.html` from the site's directory locally * Navigate index (summary) pages to make sure everything works fine ## 09. Summary You have successfully generated a web site with "constant" and "dynamic" pages. [Check out the result][03-sample]. Introduced PSKOV constants include: | PSKOV constant | Description | |---|---| | `PSKOV_ITEM_DATE` | Provides date from `Date:` part of page's header section | | `PSKOV_PREVIEW` | Provides contents from a Markdown file limited by `previewSize` characters (approximately) | | `PSKOV_INDEX_URL` | Provides generated page's file name: `.html` | | `PSKOV_PREVIEWS` | Provides a combination of `PSKOV_PREVIEW` sections | | `PSKOV_PAGINATION` | Provides pagination section to navigate index (summary) pages | | `PSKOV_PAGE_ID` | Provides index (summary) page id starting from `1` | | `PSKOV_PAGES_COUNT` | Provides total number of index (summary) pages generated | | `PSKOV_PREV_PAGE_URL` | Provides previous index (summary) page file name | | `PSKOV_NEXT_PAGE_URL` | Provides next index (summary) page file name | Introduced configuration keys include: | Key | Description | |---|---| | `preview` | Points to an HTML template file that is used to generate HTML previews out of the first `previewSize` (approximately) characters of Markdown files | | `index` | Points to an HTML template file that is used to generate HTML index (summary) files to host previews | | `paginationPrev` | Points to an HTML template file that is used to generate pagination section used by the *last* index (summary) file | | `paginationNext` | Points to an HTML template file that is used to generate pagination section used by the *first* index (summary) file | | `paginationPrevNext` | Points to an HTML template file that is used to generate pagination section used by index (summary) files *except the ones at the beginning and at the end* | | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate an HTML preview | | `previewEnding` | String to use at the end of HTML previews | | `previewsPerPage` | Number of HTML previews hosted by single index (summary) file | | `previewsPageBaseName` | Index (summary) file base name | Introduced header constants include: | Header constant | Description | |---|---| | `Date:` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown | This was the final document to make you proficient in generating static sites with **PSKOV**. If you like what we do, support us by joining our group at [Twitter][tw], [Facebook][fb], or [VK][vk]. Now use **PSKOV** to generate your very own web site!
| < Back | Index | Next > | |---|---|---| | [04. Language][prev] | [Education][index] | Not available | [index]: education.html [prev]: education.04.lang.html [03-files]: https://github.com/OGStudio/site-pskov-sample/tree/master/03.Blog [03-sample]: http://opengamestudio.org/pskov/sample/03.Blog/en/blog/index.html [lfsa]: http://opengamestudio.org/lfsa [tool]: http://opengamestudio.org/pskov [tw]: https://twitter.com/OpenGameStudio [fb]: https://www.facebook.com/groups/162611230470183 [vk]: https://vk.com/opengamestudo