Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

education.05.blog.md 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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 for a blog.
  11. Estimated completion time: 20 minutes.
  12. **Table of contents**
  13. * [01. Blog](#blog)
  14. * [02. Investigate `pskov.cfg` file](#cfg)
  15. * [03. Investigate item templates of the blog](#item)
  16. * [04. Investigate preview templates](#preview)
  17. * [05. Investigate templates of preview pages](#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 regularly share your thoughts with the world as blog posts.
  25. You set on to create the following [directory structure][03-files]:
  26. * `pskov.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 `pskov.cfg` file
  68. `pskov.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. You already met `input` and `item` keys. Let's see into new ones:
  83. | Key | Description |
  84. |---|---|
  85. | `preview` | Points to an HTML template that is used to generate HTML preview out of the first `previewSize` (approximately) characters for each Markdown file |
  86. | `index` | Points to an HTML template that is used to generate preview page to host previews |
  87. | `paginationPrev` | Points to an HTML template that is used to generate pagination section to navigate backwards |
  88. | `paginationNext` | Points to an HTML template that is used to generate pagination section to navigate forward |
  89. | `paginationPrevNext` | Points to an HTML template that is used to generate pagination section |
  90. | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate a preview |
  91. | `previewEnding` | String to use at the end of each preview |
  92. | `previewsPerPage` | Maximum number of previews hosted by a preview page |
  93. | `previewsPageBaseName` | Base file name for preview pages |
  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. * preview pages host `3` previews maximum
  98. * preview pages 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 the first preview page in `blog` directory
  165. * title is referenced inside `contents` section as a link pointing to a complete blog post
  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` | Value of `Date` key of the page's Markdown file |
  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 preview pages.
  200. Preview itself is referenced by `PSKOV_PREVIEW` constant:
  201. | PSKOV constant | Description |
  202. |---|---|
  203. | `PSKOV_PREVIEW` | Provides contents of a Markdown file limited by `previewSize` characters (approximately) |
  204. <a name="index"/>
  205. ## 05. Investigate templates of preview pages
  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. Here are new **PSKOV** constants explained:
  260. | PSKOV constant | Description |
  261. |---|---|
  262. | `PSKOV_INDEX_URL` | Provides generated preview page file name: `<previewsPageBaseName><id>.html` |
  263. | `PSKOV_PREVIEWS` | Provides a set of previews |
  264. | `PSKOV_PAGINATION` | Provides pagination section to navigate preview pages |
  265. <a name="pagination"/>
  266. ## 06. Investigate pagination templates
  267. Pagination templates represent HTML sections to navigate preview pages.
  268. There are free pagination templates:
  269. | Pagination template | Description |
  270. |---|---|
  271. | Previous | A visitor can only go backwards |
  272. | Next | A visitor can only go forward |
  273. | Both | A visitor can either go backwards, or forward |
  274. Let's look at English pagination templates:
  275. * `en/blog/pagination.prev.template` contents:
  276. ```
  277. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  278. <p>
  279. <a href="PSKOV_PREV_PAGE_URL">« Newer</a>
  280. </p>
  281. ```
  282. * `en/blog/pagination.next.template` contents:
  283. ```
  284. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  285. <p>
  286. <a href="PSKOV_NEXT_PAGE_URL">Older »</a>
  287. </p>
  288. ```
  289. * `en/blog/pagination.template` contents:
  290. ```
  291. <p>Page PSKOV_PAGE_ID of PSKOV_PAGES_COUNT</p>
  292. <p>
  293. <a href="PSKOV_PREV_PAGE_URL">« Newer</a>
  294. <a href="PSKOV_NEXT_PAGE_URL">Older »</a>
  295. </p>
  296. ```
  297. Russian counterparts look similar. Here's `ru/blog/pagination.template` contents:
  298. ```
  299. <p>Страница PSKOV_PAGE_ID из PSKOV_PAGES_COUNT</p>
  300. <p>
  301. <a href="PSKOV_PREV_PAGE_URL">« Новее</a>
  302. <a href="PSKOV_NEXT_PAGE_URL">Старее »</a>
  303. </p>
  304. ```
  305. Here are new **PSKOV** constants we used:
  306. | PSKOV constant | Description |
  307. |---|---|
  308. | `PSKOV_PAGE_ID` | Provides preview page id starting from `1` |
  309. | `PSKOV_PAGES_COUNT` | Provides total number of generated preview pages |
  310. | `PSKOV_PREV_PAGE_URL` | Provides previous preview page file name |
  311. | `PSKOV_NEXT_PAGE_URL` | Provides next preview page file name |
  312. <a name="md"/>
  313. ## 07. Investigate Markdown files
  314. Markdown files represent blog posts and they look almost like Markdown files for pages. Here's `en/blog/1885.md` contents:
  315. ```
  316. Title: Bullocks
  317. Date: 1885
  318. Slug: 1885.01.bullocks
  319. ![Bullocks][bullocks]
  320. I've been painting "Bullocks" sketch while I was staying in Odessa at Kuznetsov's in 1885.
  321. [bullocks]: https://upload.wikimedia.org/wikipedia/commons/c/cb/Walentin_Aleksandrovich_Serov_Bullocks.jpg
  322. ```
  323. Date is used to sort blog posts by date in descending order:
  324. | Header key | Description |
  325. |---|---|
  326. | `Date` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown |
  327. <a name="gen"/>
  328. ## 08. Launch LFSA and generate the site
  329. Launch [LFSA][lfsa] so that it points to directory with the files we just observed:
  330. ```
  331. $ /path/to/lfsa_1.0.0.py /path/to/dir/03.Blog
  332. ```
  333. Generate the site:
  334. * Go to [Tool][tool] page
  335. * Press `Generate` button
  336. * Open generated `en/blog/index.html` or `ru/blog/index.html` from the site's directory locally
  337. * Navigate preview pages to make sure everything works fine
  338. <a name="summary"/>
  339. ## 09. Summary
  340. You have successfully generated a web site with "dynamic" blog posts. [Check out the result][03-sample].
  341. Introduced PSKOV constants include:
  342. | PSKOV constant | Description |
  343. |---|---|
  344. | `PSKOV_ITEM_DATE` | Value of `Date` key of the page's Markdown file |
  345. | `PSKOV_PREVIEW` | Provides contents of a Markdown file limited by `previewSize` characters (approximately) |
  346. | `PSKOV_INDEX_URL` | Provides generated preview page file name: `<previewsPageBaseName><id>.html` |
  347. | `PSKOV_PREVIEWS` | Provides a set of previews |
  348. | `PSKOV_PAGINATION` | Provides pagination section to navigate preview pages |
  349. | `PSKOV_PAGE_ID` | Provides preview page id starting from `1` |
  350. | `PSKOV_PAGES_COUNT` | Provides total number of generated preview pages |
  351. | `PSKOV_PREV_PAGE_URL` | Provides previous preview page file name |
  352. | `PSKOV_NEXT_PAGE_URL` | Provides next preview page file name |
  353. Introduced configuration keys include:
  354. | Key | Description |
  355. |---|---|
  356. | `preview` | Points to an HTML template that is used to generate HTML preview out of the first `previewSize` (approximately) characters for each Markdown file |
  357. | `index` | Points to an HTML template that is used to generate preview page to host previews |
  358. | `paginationPrev` | Points to an HTML template that is used to generate pagination section to navigate backwards |
  359. | `paginationNext` | Points to an HTML template that is used to generate pagination section to navigate forward |
  360. | `paginationPrevNext` | Points to an HTML template that is used to generate pagination section |
  361. | `previewSize` | How many characters (approximately) to take out of a Markdown file to generate a preview |
  362. | `previewEnding` | String to use at the end of each preview |
  363. | `previewsPerPage` | Maximum number of previews hosted by a preview page |
  364. | `previewsPageBaseName` | Base file name for preview pages |
  365. Introduced header keys include:
  366. | Header key | Description |
  367. |---|---|
  368. | `Date` | Provides value for `PSKOV_ITEM_DATE` constant when generating HTML out of Markdown |
  369. This was the final document to make you proficient in generating static sites with **PSKOV**. If you like what we do, join us at [VK][vk], [Twitter][tw], or [Facebook][fb].
  370. Now use **PSKOV** to generate your very own web site!
  371. </div><div class="contents">
  372. | < Back | Index | Next > |
  373. |---|---|---|
  374. | [04. Language][prev] | [Education][index] | Not available |
  375. [index]: education.html
  376. [prev]: education.04.lang.html
  377. [03-files]: https://github.com/OGStudio/site-pskov-sample/tree/master/03.Blog
  378. [03-sample]: http://opengamestudio.org/pskov/sample/03.Blog/en/blog/index.html
  379. [lfsa]: http://opengamestudio.org/lfsa
  380. [tool]: http://opengamestudio.org/pskov
  381. [vk]: https://vk.com/opengamestudo
  382. [tw]: https://twitter.com/OpenGameStudio
  383. [fb]: https://www.facebook.com/groups/162611230470183