Skip to content
This repository

A simple blog engine written with Flask.

tag: v0.2

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 simblin
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.mkd
Octocat-spinner-32 TODO
Octocat-spinner-32 initdb.py
Octocat-spinner-32 run.py
Octocat-spinner-32 setup.py
Octocat-spinner-32 simblin.wsgi
README.mkd

Simblin

*Sim*ple *B*log Eng*in*e - A blog engine written with Flask and SQLAlchemy.

Simblin is built to be used by only one author. Simblin has no dashboard, no plugin support and no theme support although the templates and css can be modified by hand, of course. Simblin does not provide its own comment system but has support for Disqus.

On the other hand Simblin delivers most features that are needed to provide a good blogging experience. Simblin has

  • tags and categories
  • markdown support
  • archives
  • source code highlighting

See the changelog to see what featueres a specific version provides.

In order to run Simblin locally first create a database by running python initdb.py and after that run python run.py and head over to http://localhost:5000/. Drive your mouse to the top right corner to login. You are going to be redirected to a registration page. Once registered you are logged in with your credentials.

Deployment

At first put your real settings in a file settings.py in the same folder where the README is. You can look at simblin/default-settings.cfg to get an idea on how to structure it.

Use a python shell to create a secret key:

>>> import os
>>> os.urandom(24)
'\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8' 

setup.py and MANIFEST.in are already configured for use with distribute.

Before you deploy Simblin you should create a virtual environment in your server's project folder. Then you can use Fabric to deploy Simblin. An exemplary fabfile can look like this:

from fabric.api import *

# the user to use for the remote commands
env.user = 'youruser'
# the servers where the commands are executed
env.hosts = ['yourhost']
# the project dir (should be an absolute path)
project_dir = '/var/www/simblin/'

def pack():
    # create a new source distribution as tarball
    local('python setup.py sdist --formats=gztar', capture=False)

def deploy():
    # figure out the release name and version
    dist = local('python setup.py --fullname').strip()
    # upload the source tarball to the temporary folder on the server
    put('dist/%s.tar.gz' % dist, '/tmp/simblin.tar.gz')

    # create a place where we can unzip the tarball, then enter
    # that directory and unzip it
    run('mkdir -p /tmp/simblin')
    with cd('/tmp/simblin'):
        run('tar xzf /tmp/simblin.tar.gz')
    # You have to be inside the folder where 'setup.py' resides
    with cd('/tmp/simblin/%s' % dist):
        # now setup the package with our virtual environment's
        # python interpreter
        run(project_dir+'env/bin/python setup.py install')
    # now that all is set up, delete the folder again
    run('rm -rf /tmp/simblin /tmp/simblin.tar.gz')

    ### Configuration files ###
    put('initdb.py', project_dir+'initdb.py')
    put('settings.py', project_dir+'settings.py')
    put('simblin.wsgi', project_dir+'simblin.wsgi')
    ### Database initialization ###
    # the environment variable needs to be set to create the database
    # at the specified uri in settings.py
    # note that the run command cannot be split into two commands because
    # the environment variable will not be preserved
    run('export SIMBLIN_SETTINGS='+project_dir+'settings.py;'+
        project_dir+'env/bin/python '+project_dir+'initdb.py')
    # so that the database is writable!!
    run('chmod -R g+w %s*' % project_dir)

    # finally touch the .wsgi file so that mod_wsgi triggers
    # a reload of the application
    run('touch '+project_dir+'simblin.wsgi')

Run fab pack deploy to deploy Simblin on your server. Of course you can do it manually, too, so you don't need to hassle with fabric.

Use nosetests test to run tests.

If you want to learn more about deployment and configuration of flask apps head over to the Flask Documentation.

Q&A

How do I login/create a post?

If you didn't change the default template you can drive your mouse to the top right corner of the web page and a login link should appear. Once logged in you can find a compose and a logout link there.

How to create pages?

Pages are just blog posts. Just "hardcode" the link to a specific blog post in your template. For example, if you want to have an About page put

"{{ url_for('show_post', slug='about') }}"

in the href attribute of the link in your template to the About page.

This is not needed but I would recommend to put all blog posts which are supposed to be pages in the category Pages and additionally I would disable comments on them.

How to use source code highlighting?

Source code highlighting is enabled by the CodeColor extension of Markdown2 and you don't have to be afraid to use underscores in your code thanks to the CodeFriendly extension.

What's the difference between categories and tags in Simblin?

Tags ought to describe the content of a blog post (what is it about?). Categories on the other hand ought to state where a blog post belongs in. Sometimes, however, the distinction between categories and tags is not clear.

Suppose you create a programming tutorial. One possibility is to not put it in a category at all and instead tag it with programming and tutorial. Another possiblity is to put it in the category programming and tag it with tutorial. I, however, would put the post in the categories programming and tutorial and add tags like django if, for instance, the tutorial is about django.

Since a blog post, in my world view, can belong in different places it should be able to be attached to several categories, too. Therefore categories are essentially implemented like tags. However, tags are deleted automatically when no posts reference a tag anymore. Categories are not.

How to change username/password/email?

Once you registered you can go to http://yourblog.com/register to "reregister" with new credentials. You must be logged in to do this. Beware: If you forget to register with new credentials anybody who visits the blog can register as the admin.

Why another blog engine?

  1. Learn about web programming in general
  2. Become more experienced with the excellent Flask framework
  3. Have a perfectly tailored blog for my website

Do you really think anybody but you will use this shit?

No :), but I like to document my projects in a way as if they were meant for others. This way I write more precise documentation which will be invaluable for me after several weeks without working on the project.

Used libraries/frameworks

Something went wrong with that request. Please try again.