Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install swg

How to install swg

  1. Download and install ActivePython
  2. Buy and install the Business Edition license from account.activestate.com
  3. Open Command Prompt
  4. Type pypm install swg

swg contains builds that are only available via PyPM when you have a current ActivePython Business Edition subscription.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.2.6 Available View build log
1.2.5 Available View build log
Windows (64-bit)
1.2.6 Available View build log
1.2.5 Available View build log
Mac OS X (10.5+)
1.2.6 Available View build log
1.2.5 Available View build log
Linux (32-bit)
1.2.6 Available View build log
1.2.5 Available View build log
Linux (64-bit)
1.2.6 Available View build log
1.2.5 Available View build log

Copyleft by Simone Margaritelli <evilsocket@gmail.com>

What is SWG ?

SWG is a new generation static website generator, featured by the Mako (http://www.makotemplates.org/) template system, born from the need to have both performances and "WEB 2.0" contents and capabilities.

Given a set of files, one for each page/article, one for each author and one for the categories hyerarchy, SWG will read the configuration file you specify from command line and generate a complete static website, with tags and categories indexing.


To get the latest released version:

pip install swg

Create a new website

To start a new website, type:

swg --create website-folder-name

An example site with a basic structure will be created inside the 'website-folder-name' directory. Then you can type:

cd website-folder-name
swg --serve

To test the website locally. The first article is about customization and basic configuration, so read it carefully.

Generate your website

Once you are in the directory containing your website definition (with a swg.cfg file in it), just run:

swg --generate

To start website generation, other options are available, use

swg --help

To a display the complete list.

Importing from another platform

Right now, there's the swg-wordpress script you can use to convert a WordPress XML backup file to the SWG format, to use it consider the following:

swg-wordpress --help
- SWG Wordpress Backup Importer -

Usage: swg-wordpress -i wordpress-backup.xml -u 'http://www.your-site-url.com' <options>

  -h, --help            show this help message and exit
                        The Wordpress XML backup file.
                        URL of the destination website.
  -o OUTDIR, --output=OUTDIR
                        Output directory, default is the current working
  -e FILEEXT, --extension=FILEEXT
                        Output file extension, default is txt.
  -I IMGDIR, --images=IMGDIR
                        If specified, it's the path where the importer will
                        try to download images referenced by articles.

So let's say for instance, that you have your wp.xml file and you want to export it to the 'example-site.com' directory, downloading images referenced by the articles into the 'example-site.com/images' directory (the import will replace properly image urls), you will use the command line:

swg-wordpress -i wp.xml -u http://www.example-site.com -o 'example-site.com' -I 'example-site.com/images'

And it's all done! Now you just have to create the templates, fix the categories hyerarchy inside the file 'example-site.com/db/categories.txt', customize your own description inside 'example-site.com/db/your-nickname.txt' and make the configuration file following the example below.

An example configuration file

# DB files extension
dbitem_ext = txt
# URL of the site you are going to generate
siteurl    = http://www.example-site.com
# Site name / description
sitename   = An example site generated by SWG
# Site charset
charset    = utf-8
# Site language
language   = it
# Comma separated site keywords
keywords   = some, html, keywords, here
# Site destination basepath
basepath   =
# Site page files output extension
page_ext   = html
# Generated site output path
outputpath = out
# Items (dirs or files) to copy from datapath to outputpath (eg. static files, css, etc)
copypaths  = css, images, .htaccess
# Command to execute once the generation is finished, for instance an rsync :)
transfer   = rsync -ravz out/* -e ssh user@example-site.com:/var/www/example-site.com/htdocs/
# Enable or disable the pager on categories, index, tags and author pages
pager      = true
# If pager is enabled, this is the maximum number of items per page
items_per_page = 10
# Compress pages (ie. index.html.gz) and create (or update) .htaccess file to serve them as html files
gzip       = true
# Compression level, 0 to 9
compression = 9
# Clean output html with TIDY
tidyfy = true

Pretty self explanatory isn't it ? :)

Testing your website locally

From version 1.2.4, SWG offers the possibility to test your website locally, once you are in the directory containing your website definition (with a swg.cfg file in it), run the following command:

swg --serve

This will start the website generation and a test webserver on http://localhost:8080/ .

Example project

For an example site, look at my personal blog github repo located here https://github.com/evilsocket/evilsocket.net

Enjoy ^^

Subscribe to package updates

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.