Goldblog is inspired by Quoins (http://quoins.net/). Like Quoins, Goldblog is a blogging system that can be incorporated into a TurboGears project. I chose to develop my own system as an exercise to develop my Python and TurboGears skills.
Goldblog was written by Bruce Webber (self@brucewebber.us, http://www.brucewebber.us).
Goldblog is licensed under a BSD style license. See LICENSE.txt for details.
Follow these steps to install Goldblog.
Set up your TurboGears 1.0 project. Use identity.
Install and configure TurboMail.
Create your project tables with the command:
tg-admin sql create
Easy install the goldblog egg.
Run the command:
tg-admin goldblog create
This will create the additional tables needed by Goldblog.
Create a folder under your templates directory called blog, and copy the templates from install-in-project/templates. Edit the templates as needed. You may choose to copy your master template into the blog directory and include it in the blog templates.
In your master template, include the following in the <head> section for feed auto-discovery (change the path if necessary):
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/blog/rss2.0" />
Copy CSS files from install-in-project/css to your css directory. Edit the CSS file as needed.
Copy the image files from install-in-project/images to your images directory.
Download TinyMCE and copy the tiny_mce folder from tinymce/jscripts into your javascript folder.
Add the following line to your controllers.py file:
from goldblog import blog_controller
Add the following line in your Root controller:
blog = blog_controller.BlogController(path='/blog')
(The path keyword must match the subcontroller mount point name.)
In app.cfg, add the following line (change “secret” to a strong password):
goldblog.key = 'secret'
In app.cfg, add the following line (change “my_package” to the name of your TurboGears project name):
goldblog.parent_package = 'my_package'
In app.cfg, uncomment the following line to enable sessions:
session_filter.on = True
Create the groups and users in your TG project for Goldblog. Launch the tg-admin shell:
tg-admin shell
In the shell, enter the following commands (change the usernames, email addresses and passwords):
u1 = User(u'user1', u'email1@in.valid', u'Full Name 1', u'password1')
session.add(u1)
u2 = User(u'user2', u'email2@in.valid', u'Full Name 2', u'password2')
session.add(u2)
bloggers = Group(u'bloggers', u'Bloggers')
session.add(bloggers)
blogadmins = Group(u'blogadmin', u'Blog Administrators')
session.add(blogadmins)
blogadmins.users.append(u1)
bloggers.users.append(u2)
In your application, log in as a user in the blogadmin group, go to the Administration page, and set the blog information.
The subcontroller provides a RESTful interface for blog posts. If the arguments are not sufficient for a given operation, it defaults to listing the blog posts.
Assuming this controller is mounted at /blog, the following URIs are provided:
| URI | function |
|---|---|
| /blog | list all blog entries |
| /blog/index | list all blog entries |
| /blog/admin | view the blog administration screen |
| /blog/edit | edit the blog information |
| /blog/addcategory | add a new blog category |
| /blog/newpost | create a new blog post |
| /blog/category/1 | list blog posts with blog category 1 |
| /blog/category/1/edit | edit blog category 1 |
| /blog/category/1/delete | delete blog category 1 |
| /blog/month/200812 | list blog posts from December 2008 |
| /blog/post/20081225131030 | view a specific blog post |
| /blog/post/20081225131030/edit | edit a specific blog post |
| /blog/post/20081225131030/delete | delete a specific blog post |
| /blog/post/20081225131030/comment | post a comment about a specific blog post |
| /blog/rssfeed | RSS 2.0 feed |
| /blog/comment/1/accept | accept a comment about a specific blog post |
| /blog/comment/1/delete | delete a comment about a specific blog post |
The subcontroller provides a method called get_latest_posts(), which returns a list of the latest n published posts, where n is an integer. This allows you to include recent blog post summaries in your home page, for example.
Here is a simple index() method which uses blognav and get_latest_posts():
def index(self):
self.blog.update_blognav(blog_controller.blognav)
return dict(blognav=blog_controller.blognav,
latest_posts=self.blog.get_latest_posts(3))
Goldblog provides a simple text based CAPTCHA scheme employed when a visitor enters a comment. The visitor is prompted to enter the correct number from a list of numbers.