Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

education.05.blog.md 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. Title: Education: 05. Blog
  2. Date: 2019-05-22 00:00
  3. Category: Page
  4. Slug: education.05.blog
  5. Lang: en
  6. | < Back | Index | Next > |
  7. |---|---|---|
  8. | [04. Language][prev] | [Education][index] | Not available |
  9. </div><div class="contents">
  10. In this document we create "dynamic" pages like blog posts.
  11. Estimated completion time: 20 minutes.
  12. **Table of contents**
  13. * [01. Blog](#blog)
  14. * [02. Investigate `cfg` file](#cfg)
  15. * [03. Investigate item templates of the blog](#item)
  16. * [04. Investigate preview templates](#preview)
  17. * [05. Investigate index (summary) templates](#index)
  18. * [06. Investigate pagination templates](#pagination)
  19. * [07. Investigate Markdown files](#md)
  20. * [08. Launch LFSA and generate the site](#gen)
  21. * [09. Summary](#summary)
  22. <a name="blog"/>
  23. ## 01. Blog
  24. 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.
  25. You set on to create the following [directory structure][03-files]:
  26. * `cfg`
  27. * `en/blog/`
  28. * `item.template`
  29. * `index.template`
  30. * `preview.template`
  31. * `pagination.template`
  32. * `pagination.prev.template`
  33. * `pagination.next.template`
  34. * `1885.md`
  35. * `1886.01.md`
  36. * `1886.02.md`
  37. * `1887.01.md`
  38. * `1887.02.md`
  39. * `1888.md`
  40. * `1896.md`
  41. * `1899.md`
  42. * `en/page/`
  43. * `item.template`
  44. * `about.md`
  45. * `cv.md`
  46. * `ru/blog/`
  47. * `item.template`
  48. * `index.template`
  49. * `preview.template`
  50. * `pagination.template`
  51. * `pagination.prev.template`
  52. * `pagination.next.template`
  53. * `1885.md`
  54. * `1886.01.md`
  55. * `1886.02.md`
  56. * `1887.01.md`
  57. * `1887.02.md`
  58. * `1888.md`
  59. * `1896.md`
  60. * `1899.md`
  61. * `ru/page/`
  62. * `item.template`
  63. * `about.md`
  64. * `cv.md`
  65. Let's look at the contents of these files closer.
  66. <a name="cfg"/>
  67. ## 02. Investigate `cfg` file
  68. `cfg` file has the following contents:
  69. ```
  70. input = en/page;ru/page;en/blog;ru/blog
  71. item = item.template
  72. preview = preview.template
  73. index = index.template
  74. paginationPrev = pagination.prev.template
  75. paginationNext = pagination.next.template
  76. paginationPrevNext = pagination.template
  77. previewSize = 200
  78. previewEnding = . . .
  79. previewsPerPage = 3
  80. previewPageBaseName = index
  81. ```
  82. Apart from already used `input` and `item` keys, we have quite a lot of new ones. Let's break them down:
  83. | Key | Description |
  84. |---|---|
  85. | `preview` | Points to an HTML template file that is used to generate HTML previews out of the first `previewSize` (approximately) characters of Markdown files |
  86. | `index` | Points to an HTML template file that is used to generate HTML index (summary) files to host previews |
  87. | `paginationPrev` | Points to an HTML template file that is used to generate pagination section used by the *last* index (summary) file |
  88. | `paginationNext` | Points to an HTML template file that is used to generate pagination section used by the *first* index (summary) file |
  89. | `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* |
  90. | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate an HTML preview |
  91. | `previewEnding` | String to use at the end of HTML previews |
  92. | `previewsPerPage` | Number of HTML previews hosted by single index (summary) file |
  93. | `previewsPageBaseName` | Index (summary) file base name |
  94. In our case:
  95. * we restrict previews to `200` characters in size (approximately)
  96. * we use `. . .` string at the end of each preview
  97. * index (summary) files host `3` previews maximum
  98. * index (summary) files are saved as `index.html`, `index2.html`, `index3.html`, etc.
  99. <a name="item"/>
  100. ## 03. Investigate item templates of the blog
  101. * `en/blog/item.template` contents:
  102. ```
  103. - - - - Collapsed for brevity - - - -
  104. <body>
  105. <div id="header">
  106. <strong>Serov</strong>
  107. <a href="../../en/blog/index.html">Blog</a>
  108. <a href="../../en/page/about.html">About me</a>
  109. <a href="../../en/page/cv.html">CV</a>
  110. <div id="lang">
  111. <a href="../../en/blog/PSKOV_ITEM_URL">EN</a>
  112. <a href="../../ru/blog/PSKOV_ITEM_URL">RU</a>
  113. </div>
  114. </div>
  115. <center>
  116. <h1>In the blog...</h1>
  117. <div class="contents">
  118. <h2 class="itemTitle">
  119. <a href="PSKOV_ITEM_URL">PSKOV_ITEM_TITLE</a>
  120. </h2>
  121. <p class="itemDate">PSKOV_ITEM_DATE</p>
  122. PSKOV_ITEM_CONTENTS
  123. </div>
  124. <div id="footer">
  125. This sample web site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>.
  126. </div>
  127. </center>
  128. </body>
  129. - - - - Collapsed for brevity - - - -
  130. ```
  131. * `ru/blog/item.template` contents:
  132. ```
  133. - - - - Collapsed for brevity - - - -
  134. <body>
  135. <div id="header">
  136. <strong>Серов</strong>
  137. <a href="../../ru/blog/index.html">Блог</a>
  138. <a href="../../ru/page/about.html">Обо мне</a>
  139. <a href="../../ru/page/cv.html">Резюме</a>
  140. <div id="lang">
  141. <a href="../../en/blog/PSKOV_ITEM_URL">EN</a>
  142. <a href="../../ru/blog/PSKOV_ITEM_URL">RU</a>
  143. </div>
  144. </div>
  145. <center>
  146. <h1>В блоге...</h1>
  147. <div class="contents">
  148. <h2 class="itemTitle">
  149. <a href="PSKOV_ITEM_URL">PSKOV_ITEM_TITLE</a>
  150. </h2>
  151. <p class="itemDate">PSKOV_ITEM_DATE</p>
  152. PSKOV_ITEM_CONTENTS
  153. </div>
  154. <div id="footer">
  155. Этот пример сайта сгенерирован <a href="http://opengamestudio.org/pskov">ПСКОВОМ</a>.
  156. </div>
  157. </center>
  158. </body>
  159. - - - - Collapsed for brevity - - - -
  160. ```
  161. **Note**: beginning and ending were collapsed for brevity.
  162. As you can see, both files look similar to `item.template` files we saw [before][prev].
  163. The changes include:
  164. * new URLs to reference pages in `page` directory and first index (summary) file in `blog` directory
  165. * title is now referenced inside `contents` section as a link to complete page
  166. * date is referenced to highlight relationship among different blog posts in time
  167. Date reference uses new `PSKOV_ITEM_DATE` constant:
  168. | PSKOV constant | Description |
  169. |---|---|
  170. | `PSKOV_ITEM_DATE` | Provides date from `Date:` part of page's header section |
  171. <a name="preview"/>
  172. ## 04. Investigate preview templates
  173. * `en/blog/preview.template` contents:
  174. ```
  175. <div class="contents">
  176. <h2 class="itemTitle">
  177. <a href="PSKOV_ITEM_URL">PSKOV_ITEM_TITLE</a>
  178. </h2>
  179. <p class="itemDate">PSKOV_ITEM_DATE</p>
  180. PSKOV_PREVIEW
  181. <div class="itemMore">
  182. <a href="PSKOV_ITEM_URL">Continue reading</a>
  183. </div>
  184. </div>
  185. ```
  186. * `ru/blog/preview.template` contents:
  187. ```
  188. <div class="contents">
  189. <h2 class="itemTitle">
  190. <a href="PSKOV_ITEM_URL">PSKOV_ITEM_TITLE</a>
  191. </h2>
  192. <p class="itemDate">PSKOV_ITEM_DATE</p>
  193. PSKOV_PREVIEW
  194. <div class="itemMore">
  195. <a href="PSKOV_ITEM_URL">Читать дальше</a>
  196. </div>
  197. </div>
  198. ```
  199. Previews have no `<head>`, `<body>`, and similar full page HTML tags. Previews represent sections inserted into index (summary) files.
  200. Preview itself is referenced by `PSKOV_PREVIEW` constant:
  201. | PSKOV constant | Description |
  202. |---|---|
  203. | `PSKOV_PREVIEW` | Provides contents from a Markdown file limited by `previewSize` characters (approximately) |
  204. <a name="index"/>
  205. ## 05. Investigate index (summary) templates
  206. * `en/blog/index.template` contents:
  207. ```
  208. - - - - Collapsed for brevity - - - -
  209. <body>
  210. <div id="header">
  211. <strong>Serov</strong>
  212. <a href="../../en/blog/index.html">Blog</a>
  213. <a href="../../en/page/about.html">About me</a>
  214. <a href="../../en/page/cv.html">CV</a>
  215. <div id="lang">
  216. <a href="../../en/blog/PSKOV_INDEX_URL">EN</a>
  217. <a href="../../ru/blog/PSKOV_INDEX_URL">RU</a>
  218. </div>
  219. </div>
  220. <center>
  221. <h1>Blog</h1>
  222. PSKOV_PREVIEWS
  223. PSKOV_PAGINATION
  224. <div id="footer">
  225. This sample web site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>.
  226. </div>
  227. </center>
  228. </body>
  229. - - - - Collapsed for brevity - - - -
  230. ```
  231. * `ru/blog/index.template` contents:
  232. ```
  233. - - - - Collapsed for brevity - - - -
  234. <body>
  235. <div id="header">
  236. <strong>Серов</strong>
  237. <a href="../../ru/blog/index.html">Блог</a>
  238. <a href="../../ru/page/about.html">Обо мне</a>
  239. <a href="../../ru/page/cv.html">Резюме</a>
  240. <div id="lang">
  241. <a href="../../en/blog/PSKOV_INDEX_URL">EN</a>
  242. <a href="../../ru/blog/PSKOV_INDEX_URL">RU</a>
  243. </div>
  244. </div>
  245. <center>
  246. <h1>Блог</h1>
  247. PSKOV_PREVIEWS
  248. PSKOV_PAGINATION
  249. <div id="footer">
  250. Этот пример сайта сгенерирован <a href="http://opengamestudio.org/pskov">ПСКОВОМ</a>.
  251. </div>
  252. </center>
  253. </body>
  254. - - - - Collapsed for brevity - - - -
  255. ```
  256. **Notes**:
  257. * beginning and ending were collapsed for brevity
  258. * `PSKOV_INDEX_URL` constant is used to provide language selection
  259. Index (summary) files are used to host previews.
  260. Here are new **PSKOV** constants explained:
  261. | PSKOV constant | Description |
  262. |---|---|
  263. | `PSKOV_INDEX_URL` | Provides generated page's file name: `<previewsPageBaseName><id>.html` |
  264. | `PSKOV_PREVIEWS` | Provides a combination of `PSKOV_PREVIEW` sections |
  265. | `PSKOV_PAGINATION` | Provides pagination section to navigate index (summary) pages |
  266. <a name="pagination"/>
  267. ## 06. Investigate pagination templates
  268. Pagination templates represent sections used to navigate index (summary) pages.
  269. There are free pagination templates:
  270. | Pagination template | Description |
  271. |---|---|
  272. | prev | Is used for the last index (summary) page because we can only go backwards |
  273. | next | Is used for the first index (summary) page because we can only go forward |
  274. | both | Is used for intermediate index (summary) pages because we can either go backwards, or forward |
  275. Let's look at English pagination templates:
  276. * `en/blog/pagination.prev.template` contents:
  277. ```
  278. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  279. <p>
  280. <a href="PSKOV_PREV_PAGE_URL">« Newer</a>
  281. </p>
  282. ```
  283. * `en/blog/pagination.next.template` contents:
  284. ```
  285. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  286. <p>
  287. <a href="PSKOV_NEXT_PAGE_URL">Older »</a>
  288. </p>
  289. ```
  290. * `en/blog/pagination.template` contents:
  291. ```
  292. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  293. <p>
  294. <a href="PSKOV_PREV_PAGE_URL">« Newer</a>
  295. <a href="PSKOV_NEXT_PAGE_URL">Older »</a>
  296. </p>
  297. ```
  298. Russian counterparts look similar. Here's `ru/blog/pagination.template` contents:
  299. ```
  300. <p>Страница PSKOV_PAGE_ID из PSKOV_PAGES_COUNT</p>
  301. <p>
  302. <a href="PSKOV_PREV_PAGE_URL">« Новее</a>
  303. <a href="PSKOV_NEXT_PAGE_URL">Старее »</a>
  304. </p>
  305. ```
  306. Here are new **PSKOV** constants we used:
  307. | PSKOV constant | Description |
  308. |---|---|
  309. | `PSKOV_PAGE_ID` | Provides index (summary) page id starting from `1` |
  310. | `PSKOV_PAGES_COUNT` | Provides total number of index (summary) pages generated |
  311. | `PSKOV_PREV_PAGE_URL` | Provides previous index (summary) page file name |
  312. | `PSKOV_NEXT_PAGE_URL` | Provides next index (summary) page file name |
  313. <a name="md"/>
  314. ## 07. Investigate Markdown files
  315. Markdown files represent blog posts and they look almost like Markdown files for pages. Here's `en/blog/1885.md` contents:
  316. ```
  317. Title: Bullocks
  318. Date: 1885
  319. Slug: 1885.01.bullocks
  320. ![Bullocks][bullocks]
  321. I've been painting "Bullocks" sketch while I was staying in Odessa at Kuznetsov's in 1885.
  322. [bullocks]: https://upload.wikimedia.org/wikipedia/commons/c/cb/Walentin_Aleksandrovich_Serov_Bullocks.jpg
  323. ```
  324. Date is used to sort blog posts by date in ascending order:
  325. | Header constant | Description |
  326. |---|---|
  327. | `Date:` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown |
  328. <a name="gen"/>
  329. ## 08. Launch LFSA and generate the site
  330. Launch [LFSA][lfsa] so that it points to directory with the files we just observed:
  331. ```
  332. $ /path/to/lfsa-201905.py /path/to/dir/03.Blog
  333. ```
  334. Generate the site:
  335. * Go to [Tool][tool] page
  336. * Press `Generate` button
  337. * Open generated `en/blog/index.html` or `ru/blog/index.html` from the site's directory locally
  338. * Navigate index (summary) pages to make sure everything works fine
  339. <a name="summary"/>
  340. ## 09. Summary
  341. You have successfully generated a web site with "constant" and "dynamic" pages. [Check out the result][03-sample].
  342. Introduced PSKOV constants include:
  343. | PSKOV constant | Description |
  344. |---|---|
  345. | `PSKOV_ITEM_DATE` | Provides date from `Date:` part of page's header section |
  346. | `PSKOV_PREVIEW` | Provides contents from a Markdown file limited by `previewSize` characters (approximately) |
  347. | `PSKOV_INDEX_URL` | Provides generated page's file name: `<previewsPageBaseName><id>.html` |
  348. | `PSKOV_PREVIEWS` | Provides a combination of `PSKOV_PREVIEW` sections |
  349. | `PSKOV_PAGINATION` | Provides pagination section to navigate index (summary) pages |
  350. | `PSKOV_PAGE_ID` | Provides index (summary) page id starting from `1` |
  351. | `PSKOV_PAGES_COUNT` | Provides total number of index (summary) pages generated |
  352. | `PSKOV_PREV_PAGE_URL` | Provides previous index (summary) page file name |
  353. | `PSKOV_NEXT_PAGE_URL` | Provides next index (summary) page file name |
  354. Introduced configuration keys include:
  355. | Key | Description |
  356. |---|---|
  357. | `preview` | Points to an HTML template file that is used to generate HTML previews out of the first `previewSize` (approximately) characters of Markdown files |
  358. | `index` | Points to an HTML template file that is used to generate HTML index (summary) files to host previews |
  359. | `paginationPrev` | Points to an HTML template file that is used to generate pagination section used by the *last* index (summary) file |
  360. | `paginationNext` | Points to an HTML template file that is used to generate pagination section used by the *first* index (summary) file |
  361. | `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* |
  362. | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate an HTML preview |
  363. | `previewEnding` | String to use at the end of HTML previews |
  364. | `previewsPerPage` | Number of HTML previews hosted by single index (summary) file |
  365. | `previewsPageBaseName` | Index (summary) file base name |
  366. Introduced header constants include:
  367. | Header constant | Description |
  368. |---|---|
  369. | `Date:` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown |
  370. 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].
  371. Now use **PSKOV** to generate your very own web site!
  372. </div><div class="contents">
  373. | < Back | Index | Next > |
  374. |---|---|---|
  375. | [04. Language][prev] | [Education][index] | Not available |
  376. [index]: education.html
  377. [prev]: education.04.lang.html
  378. [03-files]: https://github.com/OGStudio/site-pskov-sample/tree/master/03.Blog
  379. [03-sample]: http://opengamestudio.org/pskov/sample/03.Blog/en/blog/index.html
  380. [lfsa]: http://opengamestudio.org/lfsa
  381. [tool]: http://opengamestudio.org/pskov
  382. [tw]: https://twitter.com/OpenGameStudio
  383. [fb]: https://www.facebook.com/groups/162611230470183
  384. [vk]: https://vk.com/opengamestudo