1
0

index.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .. Blogit documentation master file, created by
  2. sphinx-quickstart on Wed Feb 17 16:38:24 2016.
  3. You can adapt this file completely to your liking,
  4. but it should at least
  5. contain the root `toctree` directive.
  6. Welcome to blogit's documentation!
  7. ==================================
  8. About blogit:
  9. ^^^^^^^^^^^^^
  10. Blogit is a Python3 static site generator. It uses the markdown2 parser,
  11. and the Jinja2 template engine. It is a small code base, and does
  12. gradual builds of your content. Thus it is quick! New posts are added by
  13. demand, without the need to re-parse and rebuild all the content every
  14. time.
  15. Oh no, why another static site generator?
  16. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  17. Well, I looked into a few of them already a couple of years ago, and non
  18. made me happy. I wanted a tool written in Python so I could read the code
  19. and improve it. But, the ones I looked into where simply to big to just do
  20. what I needed - a simple and fast static site generator.
  21. Take a look for example at nikola, which has ~14,000 lines of code(!), or
  22. Pelican, which is smaller, but still has ~7600 lines of code. One of the mostly
  23. used static site generator, jekyll is written in Ruby, and has only a mere ~4800
  24. lines of code [#]_.
  25. Blogit, does all what they do, with a humble ~320 lines of code, in beautiful
  26. Python. A simple code, which is simply a wrapper around Jinja2 and
  27. Markdown. That is Unixy. It does not invent it's own template language, rather
  28. it uses the really good and established `Jinja2 template engine <http://jinja.pocoo.org/>`_.
  29. It does not include it's own markdown parser, it uses the excellent, feature rich and speedy
  30. `markdown2 <https://github.com/trentm/python-markdown2>`_ parser.
  31. It sticks to the following philosophy - less code equals less bugs.
  32. Installing
  33. ^^^^^^^^^^
  34. You can obtain blogit using pip::
  35. $ pip3 install blogit
  36. Getting started
  37. ^^^^^^^^^^^^^^^
  38. To use blogit you should create an empty directory containing a simple
  39. configuration file ``conf.py``, the file has the following content for a start::
  40. CONFIG = {
  41. 'content_root': 'content', # where the markdown files are
  42. 'output_to': '.',
  43. 'templates': 'templates',
  44. 'http_port': 3030,
  45. 'content_encoding': 'utf-8',
  46. 'author': 'Oz Nahum Tiram',
  47. 'ARCHIVE_SIZE': 10,
  48. 'INDEX_SIZE': 10
  49. }
  50. GLOBAL_TEMPLATE_CONTEXT = {
  51. 'media_base': '/media/',
  52. 'media_url': '../media/',
  53. 'site_url': 'http://oz123.github.com',
  54. }
  55. And that is it. It's pretty clear what you need to customize here for your own
  56. needs. Blogit configuration is a Python module, with two dictionaries. You
  57. don't to be a Python expert to modify this file. This is not the only project
  58. that chooses this configuration style. Other well known projects,
  59. like sphinx or django, chose Python code as a configuration language,
  60. instead of choosing the ini, yaml formats or what ever DSL for configuration.
  61. Next, you need to create some Jinja templates inside the templates directory
  62. and some markdown files inside the content directory. When you are done, you
  63. can build your blog with::
  64. $ blogit -b
  65. You can preview the HTML generated files using::
  66. $ blogit -p
  67. And that is all in a quick way. To learn more, your probably need to know
  68. some Jinja2 and maybe some HTML to get a good looking website. Alas, you can
  69. use the existing example `blogit-mir` theme to quickly get started. To use this
  70. theme there is the `quick-start` option, just create a directory where you want
  71. your files to exist and issue::
  72. $ blogit --quick-start
  73. This command will create in your directory the following structure::
  74. .
  75. ├── conf.py
  76. ├── content
  77. │   ├── pages
  78. │   │   └── about.md
  79. │   └── posts
  80. │   ├── 1865-11-26-down-the-rabbit-hole.md
  81. │   ├── 1871-03-18-looking-glass-house.md
  82. │   ├── 1912-07-24-out-to-sea.md
  83. │   ├── 1948-12-12-the-purpose-of-education.md
  84. │   ├── 1963-08-28-i-have-a-dream.md
  85. │   └── 2014-08-12-the-businessman-and-fisherman.md
  86. ├── media
  87. │   ├── css
  88. │   │   ├── bootstrap.min.css
  89. │   │   ├── bootstrap-theme.min.css
  90. │   │   ├── print.css
  91. │   │   ├── pygments_style.css
  92. │   │   ├── site.css
  93. │   │   ├── style.css
  94. │   │   └── tipsy.css
  95. │   ├── img
  96. │   │   ├── about.png
  97. │   │   ├── body_bg.png
  98. │   │   ├── code_top_bg.png
  99. │   │   ├── flickr.png
  100. │   │   ├── github.png
  101. │   │   ├── g+.png
  102. │   │   ├── home.png
  103. │   │   ├── in.png
  104. │   │   ├── noise.png
  105. │   │   ├── rss.png
  106. │   │   └── twitter.png
  107. │   └── js
  108. │   ├── bootstrap.min.js
  109. │   ├── googlefonts.js
  110. │   ├── highlight.pack.js
  111. │   ├── jquery.js
  112. │   ├── jquery.min.js
  113. │   ├── jquery.tipsy.js
  114. │   └── scripts.js
  115. ├── __pycache__
  116. │   └── conf.cpython-35.pyc
  117. ├── README.md
  118. └── templates
  119. ├── about.html
  120. ├── archive_index.html
  121. ├── atom.xml
  122. ├── base.html
  123. ├── discuss.html
  124. ├── entry.html
  125. ├── entry_index.html
  126. ├── explorer.html
  127. ├── google_analytics.html
  128. ├── sidebar.html
  129. └── tag_index.html
  130. 9 directories, 46 files
  131. You can now build the example blog and start the demo webserver in one command::
  132. $ blogit -bp
  133. Rendering website now...
  134. entries:
  135. posts/1963-08-28-i-have-a-dream.md
  136. posts/2014-08-12-the-businessman-and-fisherman.md
  137. posts/1948-12-12-the-purpose-of-education.md
  138. posts/1912-07-24-out-to-sea.md
  139. posts/1865-11-26-down-the-rabbit-hole.md
  140. pages/about.md
  141. updating tag speeches
  142. updating tag fiction
  143. updating tag fiction
  144. updating tag fables
  145. Updating index
  146. Updating archive
  147. and ready to test at http://127.0.0.1:3030
  148. Hit Ctrl+C to exit
  149. The next time you will add a new post **only** that post will be build. Other,
  150. pages that will be updated are the posts tags, the archive and the main index.
  151. Everything else remains unchanged. Hence, the speed up in build times.
  152. If you modify a file, while you needed to edit something. blogit will detect it,
  153. and will add it to the build::
  154. $ touch -m content/posts/1912-07-24-out-to-sea.md
  155. $ ~/Software/t $ blogit -b
  156. Rendering website now...
  157. entries:
  158. posts/1912-07-24-out-to-sea.md
  159. updating tag fiction
  160. Updating index
  161. Updating archive
  162. Contributing
  163. ^^^^^^^^^^^^
  164. Bug reports and pull requests are most welcome in https://github.com/oz123/blogit.
  165. If you happen to create a new theme you can also submit it. Porting jekyll themes
  166. isn't that hard too.
  167. .. rubric:: Footnotes
  168. .. [#] generated using David A. Wheeler's 'SLOCCount'.