blogit/README.md

115 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

2014-01-23 01:12:17 +01:00
Blogit
======
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
This script aims at building a static blog above a git repo. This way, you can
use git abilities to have full archives and backups of your blog. Many scripts
aims at doing this, and this is just one more. I needed something more personal
and fitted to my needs, so I came up with this code. It's not very beautiful,
can mostly be optimized but it's working for me. It may not be fitted to your
needs, but it's up to you to see it.
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
This script is just a python script that should be run as a git hook. You can
see a working version at http://phyks.me and the repository behind it is
2014-04-20 22:51:57 +02:00
publicly viewable at http://git.phyks.me/Blog. You should browse this
repository for example configuration and usage if you are interested by this
script.
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
This script has been developped by Phyks (phyks@phyks.me). For any suggestion
or remark, please send me an e-mail.
2014-01-23 00:59:44 +01:00
## Installation
1. Clone this repo.
2014-01-23 01:04:18 +01:00
2. Clear the .git directory and initialize a new empty git repo to store your
blog.
2014-01-23 00:59:44 +01:00
3. Move the `pre-commit.py` script to `.git/hooks/pre-commit`
4. Edit the `raw/params` and edit it to fit your needs.
2014-01-23 01:04:18 +01:00
5. The `raw` folder comes with an example of blog architecture. Delete it and
make your own.
2014-01-23 00:59:44 +01:00
6. You are ready to go !
## Params
Available options in `raw/params` are :
2014-01-23 01:04:18 +01:00
* `BLOG_TITLE` : The title of the blog, to display in the <title> element
in rendered pages.
2014-01-23 00:59:44 +01:00
* `NB_ARTICLES_INDEX` : Number of articles to display on index page.
* `BLOG_URL` : Your blog base URL.
* `IGNORE_FILES` : A comma-separated list of files to ignore.
* `WEBMASTER` : Webmaster e-mail to put in RSS feed.
* `LANGUAGE` : Language param to put in RSS feed.
* `DESCRIPTION` : Blog description, for the RSS feed.
* `COPYRIGHT` : Copyright information, for the RSS feed.
2014-01-23 01:04:18 +01:00
* `SEARCH` : comma-separated list of elements to search for and replaced
(custom regex, see code for more info)
2014-01-23 00:59:44 +01:00
* `REPLACE` : corresponding elements for replacement.
## Usage
This script will use three folders:
* `raw/` will contain your raw files
2014-01-23 01:04:18 +01:00
* `blog/` will contain the fully generated files to serve _via_ your http
server
2014-01-23 00:59:44 +01:00
* `gen/` will store temporary intermediate files
2014-01-23 01:04:18 +01:00
All the files you have to edit are located in the `raw/` folder. It contains by
default an example version of a blog. You should start by renaming it and
making your own.
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
Articles can be edited in HTML directly or in Markdown. They must be located in
a `raw/year/month` folder, according to their date of publication and end with
.html for html articles and .md for markdown articles. The basic content of an
article is: ```` <!-- @author=AUTHOR_NAME @date=DDMMYYYY-HHMM @title=TITLE
@tags=TAGS --> CONTENT ````
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
where TAGS is a comma-separated list. Tags are automatically created if they do
not exist yet. The HTML comment *must* be at the beginning of the document and
is parsed to set the metadata of the article.
2014-01-23 00:59:44 +01:00
CONTENT is then either a HTML string or a markdown formatted one.
2014-01-23 01:04:18 +01:00
You can ignore an article to not make it publicly visible during redaction,
simply by adding a .ignore extension.
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
When you finish editing your article, you can add the files to git and commit,
to launch the script. You can also manually call the script with the
`--force-regen` option if you want to rebuild your entire blog.
2014-01-23 00:59:44 +01:00
## Header file
2014-01-23 01:04:18 +01:00
You can use the `@blog_url` syntax anywhere. It will be replaced by the URL of
the blog, as defined in the parameters (and this is useful to include CSS
etc.).
2014-01-23 00:59:44 +01:00
2014-01-23 01:04:18 +01:00
You can also use `@tags` that will be replaced by the list of tags and
`@articles` for the list of last articles.
2014-01-23 00:59:44 +01:00
## Static files
2014-01-23 01:04:18 +01:00
In static files, in raw folder (such as `divers.html` in the demo code), you
can use `#base_url` that will be replaced by the base url of the blog, as
defined in the parameters. This is useful to make some links.
2014-01-23 00:59:44 +01:00
2014-01-23 01:03:22 +01:00
## Alternatives
2014-01-23 01:04:18 +01:00
There exist many alternatives to this script, but they didn't fit my needs (and
were not all tested) :
2014-01-23 01:03:22 +01:00
* fugitive : http://shebang.ws/fugitive-readme.html
* Jekyll : http://jekyllrb.com/ and Oktopress : http://octopress.org/
* Blogofile : http://www.blogofile.com/
2014-01-23 00:59:44 +01:00
## LICENSE
2014-01-23 01:03:22 +01:00
--------------------------------------------------------------------------------
2014-01-23 01:04:18 +01:00
"THE NO-ALCOHOL BEER-WARE LICENSE" (Revision 42): Phyks
(webmaster@phyks.me) wrote this file. As long as you retain this notice you
can do whatever you want with this stuff (and you can also do whatever you
want with this stuff without retaining it, but that's not cool...). If we
meet some day, and you think this stuff is worth it, you can buy me a
<del>beer</del> soda in return. Phyks
2014-01-23 01:03:22 +01:00
---------------------------------------------------------------------------------