Skip to content

Commit

Permalink
Releasing 1.2.7, static pages support and bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Apr 29, 2011
1 parent 50a1afd commit b82f5b8
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 249 deletions.
10 changes: 4 additions & 6 deletions README.md
Expand Up @@ -2,8 +2,6 @@ SWG - Static Website Generator
==============================

Copyleft by Simone Margaritelli <evilsocket@gmail.com>
http://www.evilsocket.net/
http://www.github.com/evilsocket

What is SWG ?
-------------
Expand Down Expand Up @@ -63,15 +61,15 @@ To a display the complete list.
Importing from another platform
-------------------------------

Right now, in the 'importers' directory of the project, there's a script to convert a WordPress XML backup file to the
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:

::

python wordpress.py --help
swg-wordpress --help
- SWG Wordpress Backup Importer -

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


Options:
Expand All @@ -95,7 +93,7 @@ will use the command line:

::

python wordpress.py -i wp.xml -u http://www.example-site.com -o 'example-site.com' -I 'example-site.com/images'
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
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Expand Up @@ -12,7 +12,7 @@ def find_package_data( where = '.',
exclude = ( '*.pyc', '*~', '*.bak', '*.swp*', '.*'),
exclude_directories = ('.*', 'CVS', '_darcs', './build', './dist', 'EGG-INFO', '*.egg-info'),
only_in_packages = True,
show_ignored = False):
show_ignored = False ):

out = {}
stack = [(convert_path(where), '', package, only_in_packages)]
Expand Down Expand Up @@ -68,8 +68,9 @@ def find_package_data( where = '.',
packages = find_packages(),
include_package_data = True,
package_data = find_package_data( package = 'swg', only_in_packages = False ),
install_requires = ( 'mako >= 0.4.1', 'pytidylib >= 0.2.1' ),
scripts = [ 'swg/swg' ],
install_requires = ( 'mako >= 0.4.1', 'utidylib' ),
dependency_links = [ 'http://cctools.svn.sourceforge.net/svnroot/cctools/vendorlibs/utidylib/#egg=utidylib-0.2-cvs' ],
scripts = [ 'swg/swg', 'swg/swg-wordpress' ],
license = 'GPL',
zip_safe = False,
classifiers = [
Expand Down
147 changes: 4 additions & 143 deletions swg/basic/db/pages/0.txt
Expand Up @@ -2,151 +2,12 @@ Date: 2011-04-25 17:34:00
Author: Your Name Here
Categories: Personal, Experience
Tags: swg, test, post, basic, website, structure
Title: Hello World / Instructions
Title: Hello World

<p align="justify">
Hello world!

This is your new static website installation, to read the instructions on how to customize everything, please click on the <b>Read More</b>
link.

<break>

<ul>
<li><a href="#intro0">Changing website main properties</a></li>
<li><a href="#intro1">Setting up your author name</a></li>
<li><a href="#intro2">Defining site categories</a></li>
<li><a href="#intro3">Customizing the templates</a></li>
<li><a href="#intro4">Creating a new article</a></li>
<li><a href="#intro5">Add comment capabilities to each article</a></li>
<li><a href="#final"><b>!!! Final Note !!!</b></a></li>
</ul>

<h2><a name="intro0">Changing website main properties</a></h2>
You can change those properties by editing the <b>swg.cfg</b> file inside the folder of the site project, the main properties you are probably
interested in are:

<pre>
siteurl = http://www.swg-example-website.com
sitename = SWG Example Website
charset = utf-8
language = en
keywords = swg,example,website,static,static website,generator,static website generator
</pre>

Where siteurl is the url of your website, sitename the name displayed in the header, then you can define the html charset and language and finally the
keywords to be used in the meta html fields.

<h2><a name="intro1">Setting up your author name</a></h2>
The first thing you wanna do, is to change the main author name, because as you have noticed it's set to '<b>Your Name Here</b>' right now ... pretty ugly isn't it?

Open the file <b>db/Your Name Here.txt</b> with your favourite text editor (better if it supports HTML syntax highlighting) and edit the first four rows with your
own details, for instance:

<pre>
username: Joe Black
avatar: /images/myavatar.png
email: joeblack@gmail.com
website: http://www.example-website.com
</pre>

Leave the next line empty and write something about yourself (HTML allowed), this description will be the one displayed in the <b>About Me</b> section.
Now <b>rename</b> the file with the username you've just used in those fields, so it will be renamed (following the example) like so:

<pre>
db/Your Name Here.txt ---> renamed to ---> db/Joe Black.txt
</pre>

Also you will have to replace the string <b>your-name-here</b> with <b>joe-black</b> inside <b>templates/sidebar.tpl</b> and <b>templates/header.tpl</b> to fix
the links to your profile.

<h2><a name="intro2">Defining site categories</a></h2>
To define the hierarchy of your categories, open the file <b>db/categories.txt</b> and edit it.
Each line must begin with one root category, so for instance:

<pre>
Personal
Experience
</pre>

Are two root categories.
To add a new one, simply add a new line with the name of the new category.

If you want to define a <b>sub category</b>, you shall use the following syntax:

<pre>
Personal: Projects, Work
Experience
</pre>

So that <b>Projects</b> and <b>Work</b> are now sub categories of <b>Personal</b>.

<h2><a name="intro3">Customizing the templates</a></h2>
SWG uses the <a href="http://www.makotemplates.org/" target="_blank">Mako Template Engine</a> to render the html contents, so you might want to follow its
<a href="http://www.makotemplates.org/docs/" target="_blank">documentation</a> to fully understand how to customize the tpl files inside the <b>templates</b>
directory.

Anyway, if you just want to edit the html, reading the Mako documentation is not needed, you can edit the templates just as normal html files :)

<h2><a name="intro4">Creating a new article</a></h2>
Once you are in your website SWG folder, you can use the command:

<pre>
swg --new
</pre>

or

<pre>
swg -N
</pre>

To create a new entry.
The editor you've configured in your swg.cfg file will then be available to edit the new entry and you will have to fill the first lines:

<pre>
Date: 2011-04-25 17:34:00
Author: Joe Black
Categories: Personal, Experience
Tags: put, some, comma, separated, tag, here
Title: Hello World again, put the title here.
</pre>

Leave the following line blank and start inserting the content.
If you want to split the abstract of the article and the body itself, you can use the optional <b>&lt;break&gt;</b> tag, for instance:

<pre>
Date: 2011-04-25 17:34:00
Author: Joe Black
Categories: Personal, Experience
Tags: put, some, comma, separated, tag, here
Title: Hello World again, put the title here.

&lt;p&gt;
This is the abstract.
<b>&lt;break&gt;</b>
And this is the rest of the article that will be shown only in the article page itself.
&lt;/p&gt;
</pre>

<h2><a name="intro5">Add comment capabilities to each article</a></h2>
You can easily add a comment feature to each article using the <a href="http://disqus.com/" target="_blank">DISQUS</a> free service,
just register your website and edit the file <b>templates/page.tpl</b> adding the DISQUS javascript code where you want the comments
to be shown.

<h2><a name="final">Final Note</a></h2>
After <b>every</b> modification to the site, do not forget to regenerate it with the:

<pre>
swg --generate
</pre>

command executed inside the website folder, or, to test it locally:

<pre>
swg --serve
</pre>

Then you will be able to browse it at the address <em>http://localhost:8080</em> .

This is your new static website installation, to read the instructions on how to customize everything, please click on the <b>Instructions</b>
link on top menu.
</p>

150 changes: 150 additions & 0 deletions swg/basic/db/pages/1.txt
@@ -0,0 +1,150 @@
Date: 2011-04-25 17:34:00
Static: true
Author: Your Name Here
Categories: Personal, Experience
Tags: swg, test, post, basic, website, structure, instructions, howto, doc, documentation
Title: Instructions

<p align="justify">

<break>

<ul>
<li><a href="#intro0">Changing website main properties</a></li>
<li><a href="#intro1">Setting up your author name</a></li>
<li><a href="#intro2">Defining site categories</a></li>
<li><a href="#intro3">Customizing the templates</a></li>
<li><a href="#intro4">Creating a new article</a></li>
<li><a href="#intro5">Add comment capabilities to each article</a></li>
<li><a href="#final"><b>!!! Final Note !!!</b></a></li>
</ul>

<h2><a name="intro0">Changing website main properties</a></h2>
You can change those properties by editing the <b>swg.cfg</b> file inside the folder of the site project, the main properties you are probably
interested in are:

<pre>
siteurl = http://www.swg-example-website.com
sitename = SWG Example Website
charset = utf-8
language = en
keywords = swg,example,website,static,static website,generator,static website generator
</pre>

Where siteurl is the url of your website, sitename the name displayed in the header, then you can define the html charset and language and finally the
keywords to be used in the meta html fields.

<h2><a name="intro1">Setting up your author name</a></h2>
The first thing you wanna do, is to change the main author name, because as you have noticed it's set to '<b>Your Name Here</b>' right now ... pretty ugly isn't it?

Open the file <b>db/Your Name Here.txt</b> with your favourite text editor (better if it supports HTML syntax highlighting) and edit the first four rows with your
own details, for instance:

<pre>
username: Joe Black
avatar: /images/myavatar.png
email: joeblack@gmail.com
website: http://www.example-website.com
</pre>

Leave the next line empty and write something about yourself (HTML allowed), this description will be the one displayed in the <b>About Me</b> section.
Now <b>rename</b> the file with the username you've just used in those fields, so it will be renamed (following the example) like so:

<pre>
db/Your Name Here.txt ---> renamed to ---> db/Joe Black.txt
</pre>

Also you will have to replace the string <b>your-name-here</b> with <b>joe-black</b> inside <b>templates/sidebar.tpl</b> and <b>templates/header.tpl</b> to fix
the links to your profile.

<h2><a name="intro2">Defining site categories</a></h2>
To define the hierarchy of your categories, open the file <b>db/categories.txt</b> and edit it.
Each line must begin with one root category, so for instance:

<pre>
Personal
Experience
</pre>

Are two root categories.
To add a new one, simply add a new line with the name of the new category.

If you want to define a <b>sub category</b>, you shall use the following syntax:

<pre>
Personal: Projects, Work
Experience
</pre>

So that <b>Projects</b> and <b>Work</b> are now sub categories of <b>Personal</b>.

<h2><a name="intro3">Customizing the templates</a></h2>
SWG uses the <a href="http://www.makotemplates.org/" target="_blank">Mako Template Engine</a> to render the html contents, so you might want to follow its
<a href="http://www.makotemplates.org/docs/" target="_blank">documentation</a> to fully understand how to customize the tpl files inside the <b>templates</b>
directory.

Anyway, if you just want to edit the html, reading the Mako documentation is not needed, you can edit the templates just as normal html files :)

<h2><a name="intro4">Creating a new article</a></h2>
Once you are in your website SWG folder, you can use the command:

<pre>
swg --new
</pre>

or

<pre>
swg -N
</pre>

To create a new entry.
The editor you've configured in your swg.cfg file will then be available to edit the new entry and you will have to fill the first lines:

<pre>
Date: 2011-04-25 17:34:00
Author: Joe Black
Categories: Personal, Experience
Tags: put, some, comma, separated, tag, here
Title: Hello World again, put the title here.
</pre>

Leave the following line blank and start inserting the content.
If you want to split the abstract of the article and the body itself, you can use the optional <b>&lt;break&gt;</b> tag, for instance:

<pre>
Date: 2011-04-25 17:34:00
Author: Joe Black
Categories: Personal, Experience
Tags: put, some, comma, separated, tag, here
Title: Hello World again, put the title here.

&lt;p&gt;
This is the abstract.
<b>&lt;break&gt;</b>
And this is the rest of the article that will be shown only in the article page itself.
&lt;/p&gt;
</pre>

<h2><a name="intro5">Add comment capabilities to each article</a></h2>
You can easily add a comment feature to each article using the <a href="http://disqus.com/" target="_blank">DISQUS</a> free service,
just register your website and edit the file <b>templates/page.tpl</b> adding the DISQUS javascript code where you want the comments
to be shown.

<h2><a name="final">Final Note</a></h2>
After <b>every</b> modification to the site, do not forget to regenerate it with the:

<pre>
swg --generate
</pre>

command executed inside the website folder, or, to test it locally:

<pre>
swg --serve
</pre>

Then you will be able to browse it at the address <em>http://localhost:8080</em> .

</p>

11 changes: 11 additions & 0 deletions swg/basic/db/pages/2.txt
@@ -0,0 +1,11 @@
Date: 2011-04-24 17:34:00
Author: Your Name Here
Categories: Personal, Experience
Tags: swg, test, post, basic, website, structure
Title: Worth A Thousand Words

<p align="justify">
<img src='/images/boat.jpg'/>
</p>


Binary file added swg/basic/images/boat.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion swg/basic/templates/author.tpl
Expand Up @@ -13,7 +13,7 @@
<br/>
<h3 class="entrytitle">I wrote ${len(author.items)} articles:</h3>
<br/>
% for page in pager.getCurrentPages():
% for page in pager.getCurrentPages( includeStatic = True ):
<div class="post post-index" id="post" >
<h2 class="entry-title index-entry-title"><a href="${config.siteurl}${page.url}" title="${page.title | h}">${page.title | h}</a> </h2>

Expand Down

0 comments on commit b82f5b8

Please sign in to comment.