index.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 reparse 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 hubmle ~320 lines of code, in beatiful
  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. It does not
  29. include it's own markdown parser, it uses the excellent, feature rich and speedy
  30. 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 contating 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.
  70. .. rubric:: Footnotes
  71. .. [#] generated using David A. Wheeler's 'SLOCCount'.