├── swg ├── __init__.py ├── core │ ├── __init__.py │ ├── authormanager.py │ ├── authorparser.py │ ├── tagmanager.py │ ├── templatemanager.py │ ├── pageparser.py │ ├── pager.py │ ├── categorymanager.py │ ├── config.py │ └── itemparser.py ├── entities │ ├── __init__.py │ ├── tag.py │ ├── category.py │ ├── author.py │ ├── page.py │ └── item.py ├── basic │ ├── db │ │ ├── categories.txt │ │ ├── pages │ │ │ ├── 2.txt │ │ │ ├── 0.txt │ │ │ └── 1.txt │ │ └── Your Name Here.txt │ ├── robots.txt │ ├── images │ │ ├── bg.jpg │ │ ├── bg.png │ │ ├── arrow.png │ │ ├── bg.jpg.1 │ │ ├── bg.png.1 │ │ ├── boat.jpg │ │ ├── date.png │ │ ├── edit.png │ │ ├── tags.png │ │ ├── arrow.png.1 │ │ ├── arrow.png.2 │ │ ├── author.png │ │ ├── author.png.1 │ │ ├── author.png.2 │ │ ├── bg-meta.gif │ │ ├── category.png │ │ ├── comments.png │ │ ├── date.png.1 │ │ ├── edit.png.1 │ │ ├── menubar.png │ │ ├── category.png.1 │ │ ├── comments.png.1 │ │ ├── contentbg.png │ │ ├── search-bg.png │ │ ├── search-go.png │ │ ├── contentbg.png.1 │ │ ├── header-bg-sm.jpg │ │ └── your-name-here.png │ ├── swg.cfg │ ├── templates │ │ ├── footer.tpl │ │ ├── feed.tpl │ │ ├── post.tpl │ │ ├── index.tpl │ │ ├── tag.tpl │ │ ├── category.tpl │ │ ├── sidebar.tpl │ │ ├── author.tpl │ │ ├── sitemap.tpl │ │ └── header.tpl │ └── css │ │ └── style.css ├── swg ├── swg-wordpress └── engine.py ├── .gitignore ├── MANIFEST.in ├── setup.py ├── README.md └── LICENSE /swg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /swg/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /swg/entities/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /swg/basic/db/categories.txt: -------------------------------------------------------------------------------- 1 | Personal 2 | Experience 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.swp 3 | dist 4 | build 5 | swg.egg-info 6 | -------------------------------------------------------------------------------- /swg/basic/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | Sitemap: /sitemap.xml 4 | 5 | -------------------------------------------------------------------------------- /swg/basic/images/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/bg.jpg -------------------------------------------------------------------------------- /swg/basic/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/bg.png -------------------------------------------------------------------------------- /swg/basic/images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/arrow.png -------------------------------------------------------------------------------- /swg/basic/images/bg.jpg.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/bg.jpg.1 -------------------------------------------------------------------------------- /swg/basic/images/bg.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/bg.png.1 -------------------------------------------------------------------------------- /swg/basic/images/boat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/boat.jpg -------------------------------------------------------------------------------- /swg/basic/images/date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/date.png -------------------------------------------------------------------------------- /swg/basic/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/edit.png -------------------------------------------------------------------------------- /swg/basic/images/tags.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/tags.png -------------------------------------------------------------------------------- /swg/basic/images/arrow.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/arrow.png.1 -------------------------------------------------------------------------------- /swg/basic/images/arrow.png.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/arrow.png.2 -------------------------------------------------------------------------------- /swg/basic/images/author.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/author.png -------------------------------------------------------------------------------- /swg/basic/images/author.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/author.png.1 -------------------------------------------------------------------------------- /swg/basic/images/author.png.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/author.png.2 -------------------------------------------------------------------------------- /swg/basic/images/bg-meta.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/bg-meta.gif -------------------------------------------------------------------------------- /swg/basic/images/category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/category.png -------------------------------------------------------------------------------- /swg/basic/images/comments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/comments.png -------------------------------------------------------------------------------- /swg/basic/images/date.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/date.png.1 -------------------------------------------------------------------------------- /swg/basic/images/edit.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/edit.png.1 -------------------------------------------------------------------------------- /swg/basic/images/menubar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/menubar.png -------------------------------------------------------------------------------- /swg/basic/images/category.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/category.png.1 -------------------------------------------------------------------------------- /swg/basic/images/comments.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/comments.png.1 -------------------------------------------------------------------------------- /swg/basic/images/contentbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/contentbg.png -------------------------------------------------------------------------------- /swg/basic/images/search-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/search-bg.png -------------------------------------------------------------------------------- /swg/basic/images/search-go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/search-go.png -------------------------------------------------------------------------------- /swg/basic/images/contentbg.png.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/contentbg.png.1 -------------------------------------------------------------------------------- /swg/basic/images/header-bg-sm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/header-bg-sm.jpg -------------------------------------------------------------------------------- /swg/basic/images/your-name-here.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilsocket/SWG/HEAD/swg/basic/images/your-name-here.png -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | exclude *.pyc .DS_Store .gitignore MANIFEST.in 2 | include setup.py 3 | include distribute_setup.py 4 | recursive-include swg *.py 5 | recursive-include swg/basic *.* 6 | recursive-include swg/importers *.* 7 | -------------------------------------------------------------------------------- /swg/basic/db/pages/2.txt: -------------------------------------------------------------------------------- 1 | Date: 2011-04-24 17:34:00 2 | Author: Your Name Here 3 | Categories: Personal, Experience 4 | Tags: swg, test, post, basic, website, structure 5 | Title: Worth A Thousand Words 6 | 7 |

8 | 9 |

10 | 11 | 12 | -------------------------------------------------------------------------------- /swg/basic/swg.cfg: -------------------------------------------------------------------------------- 1 | editor = vim 2 | 3 | siteurl = http://www.swg-example-website.com 4 | sitename = SWG Example Website 5 | charset = utf-8 6 | language = en 7 | keywords = swg,example,website,static,static website,generator,static website generator 8 | 9 | basepath = 10 | page_ext = html 11 | 12 | outputpath = output-website 13 | pager = true 14 | 15 | copypaths = css, images, robots.txt 16 | -------------------------------------------------------------------------------- /swg/basic/db/pages/0.txt: -------------------------------------------------------------------------------- 1 | Date: 2011-04-25 17:34:00 2 | Author: Your Name Here 3 | Categories: Personal, Experience 4 | Tags: swg, test, post, basic, website, structure 5 | Title: Hello World 6 | 7 |

8 | Hello world! 9 | 10 | This is your new static website installation, to read the instructions on how to customize everything, please click on the Instructions 11 | link on top menu. 12 |

13 | 14 | -------------------------------------------------------------------------------- /swg/basic/templates/footer.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | <%include file="sidebar.tpl"/> 4 |
5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /swg/basic/templates/feed.tpl: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | ${config.sitename} 13 | 14 | ${config.siteurl} 15 | If you can't understand it, it doesn't mean it's wrong ... 16 | ${config.now.strftime("%a, %d %b %Y %H:%M:%S GMT")} 17 | it 18 | hourly 19 | 1 20 | 21 | %for page in pages[0:25]: 22 | 23 | ${page.title | h} 24 | 25 | ${config.siteurl}${page.url} 26 | ${page.datetime.strftime("%a, %d %b %Y %H:%M:%S GMT")} 27 | ${page.author.username | h} 28 | ${config.siteurl}${page.url} 29 | %for category in page.categories: 30 | 31 | %endfor 32 | 33 | %endfor 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /swg/core/authormanager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import os 22 | 23 | from swg.core.authorparser import AuthorParser 24 | from swg.core.config import Config 25 | 26 | class AuthorManager: 27 | __instance = None 28 | 29 | def __init__(self): 30 | self.authors = {} 31 | 32 | def get( self, username ): 33 | id = username.lower() 34 | if not self.authors.has_key(id): 35 | self.authors[id] = AuthorParser().parse( os.path.join( Config.getInstance().dbpath, ( "%s.txt" % (username) ) ) ) 36 | 37 | return self.authors[id] 38 | 39 | @classmethod 40 | def getInstance(cls): 41 | if cls.__instance is None: 42 | cls.__instance = AuthorManager() 43 | return cls.__instance 44 | -------------------------------------------------------------------------------- /swg/basic/templates/post.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | <%include file="header.tpl"/> 3 |
4 |

${page.title | h}

5 | 6 |
7 |
8 | ${page.datetime.strftime("%d/%m/%Y")} 9 | Posted by ${page.author.username | h} 10 |
11 |
12 |
13 | 14 |
15 | ${page.content} 16 |
17 | 18 |
19 |
20 | Categories: 21 | % for i, c in enumerate( page.categories ): 22 | ${c.title | h} 23 | % if i != len(page.categories) - 1: 24 | , 25 | % endif 26 | % endfor 27 | 28 |
29 | Tags: 30 | % for i, t in enumerate( page.tags ): 31 | ${t.title | h} 32 | % if i != len(page.tags) - 1: 33 | , 34 | % endif 35 | % endfor 36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 | 44 | <%include file="footer.tpl"/> 45 | -------------------------------------------------------------------------------- /swg/basic/db/Your Name Here.txt: -------------------------------------------------------------------------------- 1 | username: Your Name Here 2 | avatar: /images/your-name-here.png 3 | email: your-email-here@gmail.com 4 | website: http://www.swg-example-website.com 5 | 6 |

7 | Put a description of yourself here, you can edit and rename the file db/Your Name Here.txt. 8 |
9 |
10 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 11 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? 12 |

13 | -------------------------------------------------------------------------------- /swg/entities/tag.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import os 22 | 23 | from swg.entities.item import Item 24 | from swg.core.config import Config 25 | from swg.core.templatemanager import TemplateManager 26 | 27 | class Tag(Item): 28 | def __init__( self, title ): 29 | Item.__init__( self, Config.getInstance().basepath + os.sep + 'tags', title, Config.getInstance().page_ext ) 30 | self.title = title 31 | self.items = [] 32 | self.template = TemplateManager.getInstance().get('tag.tpl') 33 | self.sorted = False 34 | 35 | def render( self ): 36 | if not self.sorted: 37 | self.items.sort( reverse=True, key=lambda item: item.datetime ) 38 | self.sorted = True 39 | 40 | return TemplateManager.render( template = self.template, tag = self, **self.objects ) 41 | -------------------------------------------------------------------------------- /swg/core/authorparser.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | from swg.core.itemparser import ItemParser 22 | from swg.entities.author import Author 23 | 24 | class AuthorParser(ItemParser): 25 | MANDATORY_FIELDS = { 26 | 'username' : 'string', 27 | 'avatar' : 'string', 28 | 'email' : 'string', 29 | 'website' : 'string' 30 | } 31 | 32 | def __init__(self): 33 | ItemParser.__init__(self) 34 | 35 | def parse( self, filename ): 36 | ItemParser.parse( self, AuthorParser.MANDATORY_FIELDS, filename ) 37 | 38 | object = Author( self.info['username'] ) 39 | object.avatar = self.info['avatar'] 40 | object.email = self.info['email'] 41 | object.website = self.info['website'] 42 | object.content = self.body 43 | object.abstract = self.abstract 44 | 45 | return object 46 | -------------------------------------------------------------------------------- /swg/core/tagmanager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | from swg.entities.tag import Tag 22 | 23 | class TagManager: 24 | __instance = None 25 | 26 | def __init__(self): 27 | self.tags = {} 28 | self.sorted = None 29 | 30 | def get( self, title = None ): 31 | if title != None: 32 | id = title.lower() 33 | if not self.tags.has_key(id): 34 | self.tags[id] = Tag(title) 35 | 36 | return self.tags[id] 37 | else: 38 | if self.sorted is None: 39 | self.sorted = self.tags.values() 40 | self.sorted.sort( reverse=True, key=lambda t: len(t.items) ) 41 | 42 | return self.sorted 43 | 44 | @classmethod 45 | def getInstance(cls): 46 | if cls.__instance is None: 47 | cls.__instance = TagManager() 48 | return cls.__instance 49 | -------------------------------------------------------------------------------- /swg/entities/category.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import os 22 | 23 | from swg.entities.item import Item 24 | from swg.core.config import Config 25 | from swg.core.templatemanager import TemplateManager 26 | 27 | class Category(Item): 28 | def __init__( self, title ): 29 | Item.__init__( self, Config.getInstance().basepath + os.sep + 'categories.txt', title, Config.getInstance().page_ext ) 30 | self.title = title 31 | self.items = [] 32 | self.children = [] 33 | self.template = TemplateManager.getInstance().get('category.tpl') 34 | self.sorted = False 35 | 36 | def render( self ): 37 | if not self.sorted: 38 | self.items.sort( reverse=True, key=lambda item: item.datetime ) 39 | self.sorted = True 40 | 41 | return TemplateManager.render( template = self.template, category = self, **self.objects ) 42 | -------------------------------------------------------------------------------- /swg/entities/author.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import os 22 | 23 | from swg.entities.item import Item 24 | from swg.core.config import Config 25 | from swg.core.templatemanager import TemplateManager 26 | 27 | class Author(Item): 28 | def __init__( self, username ): 29 | Item.__init__( self, Config.getInstance().basepath + os.sep + 'members', username, Config.getInstance().page_ext ) 30 | self.username = username 31 | self.items = [] 32 | self.avatar = "" 33 | self.email = "" 34 | self.website = "" 35 | self.abstract = "" 36 | self.content = "" 37 | self.template = TemplateManager.getInstance().get('author.tpl') 38 | self.sorted = False 39 | 40 | def render( self ): 41 | if not self.sorted: 42 | self.items.sort( reverse=True, key=lambda item: item.datetime ) 43 | self.sorted = True 44 | 45 | return TemplateManager.render( template = self.template, author = self, **self.objects ) 46 | 47 | -------------------------------------------------------------------------------- /swg/basic/templates/index.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | <%include file="header.tpl"/> 3 | % for page in pager.getCurrentPages(): 4 |
5 |

${page.title | h}

6 | 7 |
8 |
9 | ${page.datetime.strftime("%d/%m/%Y")} 10 | Posted by ${page.author.username | h} 11 |
12 |
13 |
14 | 15 |
16 | ${page.abstract} 17 |
18 | 19 |
20 |
21 | Categories: 22 | % for i, category in enumerate( page.categories ): 23 | ${category.title | h} 24 | % if i != len(page.categories) - 1: 25 | , 26 | % endif 27 | % endfor 28 | 29 |
30 | 31 | 32 |
33 |
34 |
35 | % endfor 36 | 37 | % if pager.getTotalPages() > 1: 38 | 51 | % endif 52 | 53 | <%include file="footer.tpl"/> 54 | -------------------------------------------------------------------------------- /swg/basic/templates/tag.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | <%include file="header.tpl"/> 3 |
4 |

Archive for tag ${tag.title | h}

5 | 6 | % for page in pager.getCurrentPages(): 7 |
8 |

${page.title | h}

9 | 10 |
11 |
12 | ${page.datetime.strftime("%d/%m/%Y")} 13 | Posted by ${page.author.username | h} 14 |
15 |
16 |
17 | 18 |
19 | ${page.abstract} 20 |
21 | 22 |
23 |
24 | Categories: 25 | % for i, c in enumerate( page.categories ): 26 | ${c.title | h} 27 | % if i != len(page.categories) - 1: 28 | , 29 | % endif 30 | % endfor 31 | 32 |
33 | 34 | 35 |
36 |
37 |
38 | % endfor 39 | 40 | % if pager.getTotalPages() > 1: 41 | 53 | % endif 54 | 55 | <%include file="footer.tpl"/> 56 | -------------------------------------------------------------------------------- /swg/basic/templates/category.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | <%include file="header.tpl"/> 3 |
4 |

Archive for category ${category.title | h}

5 | 6 | % for page in pager.getCurrentPages(): 7 |
8 |

${page.title | h}

9 | 10 |
11 |
12 | ${page.datetime.strftime("%d/%m/%Y")} 13 | Posted by ${page.author.username | h} 14 |
15 |
16 |
17 | 18 |
19 | ${page.abstract} 20 |
21 | 22 |
23 |
24 | Categories: 25 | % for i, c in enumerate( page.categories ): 26 | ${c.title | h} 27 | % if i != len(page.categories) - 1: 28 | , 29 | % endif 30 | % endfor 31 | 32 |
33 | 34 | 35 |
36 |
37 |
38 | % endfor 39 | 40 | % if pager.getTotalPages() > 1: 41 | 53 | % endif 54 | <%include file="footer.tpl"/> 55 | -------------------------------------------------------------------------------- /swg/basic/templates/sidebar.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 59 | -------------------------------------------------------------------------------- /swg/entities/page.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import os 22 | 23 | from swg.entities.item import Item 24 | from swg.core.config import Config 25 | from swg.core.templatemanager import TemplateManager 26 | 27 | class Page(Item): 28 | def __init__( self, title, template = None ): 29 | Item.__init__( self, Config.getInstance().basepath, title, Config.getInstance().page_ext ) 30 | self.datetime = None 31 | self.author = None 32 | self.categories = [] 33 | self.tags = [] 34 | self.abstract = "" 35 | self.content = "" 36 | self.static = False 37 | self.template = TemplateManager.getInstance().get( 'post.tpl' if template is None else template ) 38 | 39 | def render( self ): 40 | return TemplateManager.render( template = self.template, page = self, **self.objects ) 41 | 42 | def create( self ): 43 | Item.create(self) 44 | 45 | # create only authors not already done 46 | if self.author != None and not os.path.exists( os.path.join( Config.getInstance().outputpath, self.author.url ) ): 47 | self.author.create() 48 | 49 | for category in self.categories: 50 | # create only categories not already done 51 | if not os.path.exists( os.path.join( Config.getInstance().outputpath, category.url ) ): 52 | category.create() 53 | 54 | for tag in self.tags: 55 | # create only tags not already done 56 | if not os.path.exists( os.path.join( Config.getInstance().outputpath, tag.url ) ): 57 | tag.create() 58 | -------------------------------------------------------------------------------- /swg/basic/templates/author.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | <%include file="header.tpl"/> 3 |
4 |

${author.username | h}

5 | 6 | 7 |
8 | 9 | ${author.content} 10 |
11 |
email : ${author.email.replace( '@', ' [at] ' ).replace( '.', ' [dot] ')}
12 | 13 |
14 |

I wrote ${len(author.items)} articles:

15 |
16 | % for page in pager.getCurrentPages( includeStatic = True ): 17 |
18 |

${page.title | h}

19 | 20 |
21 |
22 | ${page.datetime.strftime("%d/%m/%Y")} 23 | Posted by ${page.author.username | h} 24 |
25 |
26 |
27 | 28 |
29 | ${page.abstract} 30 |
31 | 32 |
33 |
34 | Categories: 35 | % for i, c in enumerate( page.categories ): 36 | ${c.title | h} 37 | % if i != len(page.categories) - 1: 38 | , 39 | % endif 40 | % endfor 41 | 42 |
43 | 44 | 45 |
46 |
47 |
48 | % endfor 49 | 50 | % if pager.getTotalPages() > 1: 51 | 63 | % endif 64 | 65 | <%include file="footer.tpl"/> 66 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from swg.core.config import Config 2 | from setuptools import setup, find_packages 3 | from distutils.util import convert_path 4 | from fnmatch import fnmatchcase 5 | 6 | import shutil 7 | import os 8 | import sys 9 | 10 | def get_data_files(): 11 | data = [] 12 | for folder, subdirs, files in os.walk( 'swg/basic/db/' ): 13 | for fname in files: 14 | if fname[0] != '.' and fname.endswith('.swp') == False: 15 | data.append( os.path.join( folder, fname ) ) 16 | 17 | return data 18 | 19 | try: 20 | long_description = open( 'README.md', 'rt' ).read() 21 | except: 22 | long_description = 'SWG - A static website generator' 23 | 24 | setup( name = 'swg', 25 | version = Config.version, 26 | description = 'SWG - A static website generator', 27 | long_description = long_description, 28 | author = 'Simone Margaritelli', 29 | author_email = 'evilsocket@gmail.com', 30 | url = 'http://www.github.com/evilsocket/swg', 31 | packages = find_packages(), 32 | include_package_data = True, 33 | package_data = { 'swg': get_data_files() }, 34 | install_requires = ( 'mako >= 0.4.1', 'markdown' ), 35 | dependency_links = [ 'http://cctools.svn.sourceforge.net/svnroot/cctools/vendorlibs/utidylib/#egg=utidylib-0.2-cvs' ], 36 | scripts = [ 'swg/swg', 'swg/swg-wordpress' ], 37 | license = 'GPL', 38 | zip_safe = False, 39 | classifiers = [ 40 | 'Development Status :: 5 - Production/Stable', 41 | 'Environment :: Console', 42 | 'Intended Audience :: End Users/Desktop', 43 | 'Intended Audience :: Developers', 44 | 'Intended Audience :: System Administrators', 45 | 'Intended Audience :: Information Technology', 46 | 'License :: OSI Approved :: GNU General Public License (GPL)', 47 | 'Operating System :: MacOS :: MacOS X', 48 | 'Operating System :: Unix', 49 | 'Operating System :: POSIX', 50 | 'Operating System :: Microsoft :: Windows', 51 | 'Programming Language :: Python', 52 | 'Topic :: Software Development', 53 | 'Topic :: Software Development :: Build Tools', 54 | 'Topic :: Software Development :: Code Generators', 55 | 'Topic :: Internet', 56 | 'Topic :: Internet :: WWW/HTTP :: Site Management', 57 | 'Natural Language :: English' 58 | ] 59 | ) 60 | 61 | -------------------------------------------------------------------------------- /swg/core/templatemanager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | from mako.lookup import TemplateLookup 22 | from swg.core.config import Config 23 | 24 | import swg 25 | 26 | class TemplateManager: 27 | __instance = None 28 | 29 | def __init__(self): 30 | config = Config.getInstance() 31 | 32 | self.lookup = TemplateLookup( directories = [config.tplpath], 33 | output_encoding = 'utf-8', 34 | input_encoding = 'utf-8', 35 | encoding_errors = 'replace', 36 | cache_enabled = True, 37 | cache_type = 'file', 38 | cache_dir = config.tplcache, 39 | collection_size = 1024 40 | ) 41 | 42 | def get( self, name ): 43 | return self.lookup.get_template(name) 44 | 45 | @classmethod 46 | def render( cls, template, **kwargs ): 47 | return template.render( config = Config.getInstance(), 48 | categories = swg.core.categorymanager.CategoryManager.getInstance().get(), 49 | tags = swg.core.tagmanager.TagManager.getInstance().get(), 50 | **kwargs ) 51 | 52 | 53 | 54 | @classmethod 55 | def getInstance(cls): 56 | if cls.__instance is None: 57 | cls.__instance = TemplateManager() 58 | return cls.__instance 59 | -------------------------------------------------------------------------------- /swg/basic/templates/sitemap.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | 5 | 6 | ${config.siteurl}${index.url} 7 | ${config.now.strftime("%Y-%m-%d")} 8 | daily 9 | 1.0 10 | 11 | %for pagen in range( 2, pages[0].author.npages + 1 ): 12 | 13 | ${config.siteurl}/index-${pagen}.${config.page_ext} 14 | ${config.now.strftime("%Y-%m-%d")} 15 | daily 16 | 1.0 17 | 18 | %endfor 19 | 20 | 21 | ${config.siteurl}${pages[0].author.url} 22 | ${config.now.strftime("%Y-%m-%d")} 23 | daily 24 | 1.0 25 | 26 | %for pagen in range( 2, pages[0].author.npages + 1 ): 27 | 28 | ${config.siteurl}/members/${pages[0].author.name}-${pagen}.${config.page_ext} 29 | ${config.now.strftime("%Y-%m-%d")} 30 | daily 31 | 1.0 32 | 33 | %endfor 34 | 35 | %for category in categories: 36 | 37 | ${config.siteurl}${category.url} 38 | ${config.now.strftime("%Y-%m-%d")} 39 | daily 40 | 1.0 41 | 42 | %for pagen in range( 2, category.npages + 1 ): 43 | 44 | ${config.siteurl}/categories/${category.name}-${pagen}.${config.page_ext} 45 | ${config.now.strftime("%Y-%m-%d")} 46 | daily 47 | 1.0 48 | 49 | %endfor 50 | %endfor 51 | 52 | %for tag in tags: 53 | 54 | ${config.siteurl}${tag.url} 55 | ${config.now.strftime("%Y-%m-%d")} 56 | daily 57 | 1.0 58 | 59 | %for pagen in range( 2, tag.npages + 1 ): 60 | 61 | ${config.siteurl}/tags/${tag.name}-${pagen}.${config.page_ext} 62 | ${config.now.strftime("%Y-%m-%d")} 63 | daily 64 | 1.0 65 | 66 | %endfor 67 | %endfor 68 | 69 | %for page in pages: 70 | 71 | ${config.siteurl}${page.url} 72 | ${page.datetime.strftime("%Y-%m-%d")} 73 | monthly 74 | 0.2 75 | 76 | %endfor 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /swg/swg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # This file is part of SWG (Static Website Generator). 4 | # 5 | # Copyright(c) 2010-2011 Simone Margaritelli 6 | # evilsocket@gmail.com 7 | # http://www.evilsocket.net 8 | # http://www.backbox.org 9 | # 10 | # This file may be licensed under the terms of of the 11 | # GNU General Public License Version 2 (the ``GPL''). 12 | # 13 | # Software distributed under the License is distributed 14 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 15 | # express or implied. See the GPL for the specific language 16 | # governing rights and limitations. 17 | # 18 | # You should have received a copy of the GPL along with this 19 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 20 | # or write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | from swg.engine import Engine 23 | from swg.core.config import Config 24 | from optparse import OptionParser 25 | 26 | print "- SWG %s by Simone 'evilsocket' Margaritelli -\n" % Config.version 27 | 28 | oparser = OptionParser( usage = "usage: %prog \n" ) 29 | 30 | oparser.add_option( '-C', '--create', action = 'store_const', const = 'create', dest = 'action', help = 'Create a new website basic structure, require a folder name additional parameter.' ) 31 | oparser.add_option( '-N', '--new', action = 'store_const', const = 'new', dest = 'action', help = 'Create a new item and open an editor to edit it.' ) 32 | oparser.add_option( '-G', '--generate', action = 'store_const', const = 'generate', dest = 'action', help = 'Start website generation.' ) 33 | oparser.add_option( '-S', '--serve', action = 'store_const', const = 'serve', dest = 'action', help = 'Generate website and test it on http://localhost:8080/' ) 34 | 35 | (options, args) = oparser.parse_args() 36 | 37 | try: 38 | 39 | if options.action is None: 40 | oparser.error( "No action specified, use --help to see a list of available actions." ) 41 | elif options.action == 'create': 42 | if args == []: 43 | oparser.error( "No website folder specified, please use the syntax '--create website-folder-name'.") 44 | else: 45 | Engine().create( args[0].strip() ) 46 | elif options.action == 'new': 47 | Config.getInstance().load('swg.cfg') 48 | Engine().new() 49 | elif options.action == 'serve': 50 | Config.getInstance().load('swg.cfg') 51 | Engine().serve() 52 | elif options.action == 'generate': 53 | Config.getInstance().load('swg.cfg') 54 | Engine().generate() 55 | else: 56 | oparser.error( "%s invalid action!" % options.action ) 57 | 58 | except IOError as e: 59 | print "@ IO Error: %s" % e 60 | except Exception as e: 61 | raise 62 | -------------------------------------------------------------------------------- /swg/core/pageparser.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | from swg.entities.page import Page 22 | from swg.core.itemparser import ItemParser 23 | from swg.core.authormanager import AuthorManager 24 | from swg.core.categorymanager import CategoryManager 25 | from swg.core.tagmanager import TagManager 26 | 27 | class PageParser(ItemParser): 28 | MANDATORY_FIELDS = { 29 | 'date' : 'datetime', 30 | 'author' : 'string', 31 | 'categories' : 'array', 32 | 'tags' : 'array', 33 | 'title' : 'string' 34 | } 35 | 36 | OPTIONAL_FIELDS = { 37 | 'static' : 'boolean', 38 | 'template': 'string' 39 | } 40 | 41 | def __init__(self): 42 | ItemParser.__init__(self) 43 | 44 | def parse( self, filename ): 45 | ItemParser.parse( self, PageParser.MANDATORY_FIELDS, filename, PageParser.OPTIONAL_FIELDS ) 46 | 47 | page = Page( self.info['title'], "%s.tpl" % self.info['template'] if 'template' in self.info else None ) 48 | 49 | if 'static' in self.info: 50 | page.static = self.info['static'] 51 | 52 | author = AuthorManager.getInstance().get( self.info['author'] ) 53 | author.items.append(page) 54 | 55 | categories = [] 56 | for title in self.info['categories']: 57 | category = CategoryManager.getInstance().get(title) 58 | category.items.append(page) 59 | categories.append( category ) 60 | 61 | tags = [] 62 | for title in self.info['tags']: 63 | tag = TagManager.getInstance().get(title) 64 | tag.items.append(page) 65 | tags.append( tag ) 66 | 67 | page.datetime = self.info['date'] 68 | page.author = author 69 | page.categories = categories 70 | page.tags = tags 71 | page.abstract = self.abstract 72 | page.content = self.body 73 | 74 | # reset the state 75 | ItemParser.__init__(self) 76 | 77 | return page 78 | -------------------------------------------------------------------------------- /swg/core/pager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import math 22 | 23 | from swg.core.config import Config 24 | 25 | class Pager: 26 | def __init__( self, firstpage, format ): 27 | self.current = 0 28 | self.pagen = 0 29 | self.firstpage = firstpage 30 | self.format = format 31 | self.pages = [] 32 | self.max = 0 33 | self.left = 0 34 | self.total = 0 35 | self.config = Config.getInstance() 36 | 37 | def setPages( self, pages ): 38 | self.pages = pages 39 | self.max = len(pages) 40 | self.left = self.max 41 | self.total = math.ceil( self.max / self.config.items_per_page ) 42 | self.total += 1 if self.max % self.config.items_per_page != 0 else 0 43 | self.total = int(self.total) 44 | 45 | def getCurrentPageFilename(self): 46 | return self.format % self.pagen if self.pagen != 1 else self.firstpage 47 | 48 | def getCurrentPageNumber(self): 49 | return self.pagen 50 | 51 | def getTotalPages(self): 52 | return self.total 53 | 54 | def getCurrentPages( self, includeStatic = False ): 55 | begin = (self.pagen - 1) * self.config.items_per_page 56 | number = min( self.config.items_per_page, self.left ) 57 | end = begin + number 58 | 59 | if includeStatic: 60 | return self.pages[begin:end] 61 | else: 62 | done = 0 63 | current = [] 64 | 65 | for page in self.pages[begin:]: 66 | if page.static is False: 67 | current.append(page) 68 | done += 1 69 | if done >= number: 70 | break 71 | 72 | return current 73 | 74 | def goToNext(self): 75 | self.left = self.max - self.current 76 | if self.left <= 0: 77 | return False 78 | else: 79 | self.current += min( self.config.items_per_page, self.left ) 80 | return True 81 | 82 | def __iter__(self): 83 | return self 84 | 85 | def next(self): 86 | if self.goToNext() == False: 87 | raise StopIteration 88 | else: 89 | self.pagen += 1 90 | return self.getCurrentPageFilename() 91 | -------------------------------------------------------------------------------- /swg/core/categorymanager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import codecs 22 | 23 | from swg.entities.category import Category 24 | from swg.core.config import Config 25 | 26 | class CategoryManager: 27 | __instance = None 28 | 29 | def __init__(self): 30 | self.categories = {} 31 | self.hierarchy = [] 32 | 33 | def get( self, title = None ): 34 | if title != None: 35 | id = title.lower() 36 | if not self.categories.has_key(id): 37 | self.categories[id] = Category(title) 38 | 39 | return self.categories[id] 40 | else: 41 | if self.hierarchy == []: 42 | self.__build_hierarchy() 43 | 44 | return self.hierarchy 45 | 46 | def __find_category( self, title ): 47 | for category in self.categories.values(): 48 | if category.title == title: 49 | return category 50 | return None 51 | 52 | def __find_in_hyerarchy( self, title, node ): 53 | if node.title == title: 54 | return node 55 | 56 | for child in node.children: 57 | if child.title == title: 58 | return child 59 | else: 60 | found = self.__find_in_hyerarchy( title, child ) 61 | if found != None: 62 | return found 63 | 64 | return None 65 | 66 | # only for debug purpose 67 | def __print_hierarchy(self,node,tabs = 0): 68 | print "%s%s :" % ( "\t" * tabs, node.title ) 69 | for child in node.children: 70 | self.__print_hierarchy( child, tabs + 1 ) 71 | 72 | def __build_hierarchy(self): 73 | fd = codecs.open( Config.getInstance().hierarchy, "r", "utf-8" ) 74 | 75 | for line in iter(fd): 76 | line = line.strip() 77 | if line != '': 78 | if ':' in line: 79 | ( root, children ) = line.split( ':', 1 ) 80 | root = root.strip() 81 | children = [ s.strip() for s in children.strip().split(',') ] 82 | else: 83 | root = line 84 | children = [] 85 | 86 | h_root = None 87 | 88 | for category in self.hierarchy: 89 | h_root = self.__find_in_hyerarchy( root, category ) 90 | if h_root != None: 91 | break 92 | 93 | if h_root == None: 94 | h_root = self.__find_category(root) 95 | if h_root != None: 96 | self.hierarchy.append(h_root) 97 | 98 | for child in children: 99 | h_child = self.__find_category(child) 100 | if h_root is not None and h_child is not None: 101 | h_root.children.append(h_child) 102 | 103 | fd.close() 104 | 105 | @classmethod 106 | def getInstance(cls): 107 | if cls.__instance is None: 108 | cls.__instance = CategoryManager() 109 | return cls.__instance 110 | -------------------------------------------------------------------------------- /swg/core/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import datetime 22 | import codecs 23 | import os 24 | 25 | class Config: 26 | __instance = None; 27 | 28 | version = '1.2.8.1' 29 | 30 | def __init__(self): 31 | self.now = datetime.datetime.now() 32 | 33 | self.editor = 'vim' 34 | self.datapath = '.' 35 | self.dbpath = os.path.join( self.datapath, 'db' ) 36 | self.hierarchy = os.path.join( self.dbpath, 'categories.txt' ) 37 | self.tplpath = os.path.join( self.datapath, 'templates' ) 38 | self.tplcache = os.path.join( self.datapath, 'cache' ) 39 | self.outputpath = "output" 40 | self.copypaths = {} 41 | 42 | self.siteurl = "" 43 | self.sitename = "Generated with SWG " + self.version 44 | self.charset = "utf-8" 45 | self.language = "en" 46 | self.keywords = [] 47 | 48 | self.basepath = '/' 49 | self.page_ext = "html" 50 | self.pager = False 51 | self.items_per_page = 10 52 | self.transfer = None 53 | 54 | def load( self, filename ): 55 | fd = codecs.open( filename, "r", "utf-8" ) 56 | 57 | for line in iter(fd): 58 | line = line.strip() 59 | if line != '' and line[0] != '#': 60 | (key,value) = line.split( '=', 1 ) 61 | key = key.strip() 62 | value = value.strip() 63 | if key == 'siteurl': 64 | self.siteurl = value 65 | elif key == 'sitename': 66 | self.sitename = value 67 | elif key == 'charset': 68 | self.charset = value 69 | elif key == 'language': 70 | self.language = value 71 | elif key == 'basepath': 72 | self.basepath = value 73 | elif key == 'page_ext': 74 | self.page_ext = value 75 | elif key == 'editor': 76 | self.editor = value 77 | elif key == 'outputpath': 78 | self.outputpath = value 79 | elif key == 'pager': 80 | self.pager = True if value.lower() == 'true' else False 81 | elif key == 'items_per_page': 82 | self.items_per_page = int(value) 83 | elif key == 'copypaths': 84 | items = [ s.strip() for s in value.split(',') ] 85 | for item in items: 86 | self.copypaths[ os.path.join( self.datapath, item ) ] = os.path.join( self.outputpath, item ) 87 | elif key == 'keywords': 88 | self.keywords = [ s.strip() for s in value.split(',') ] 89 | elif key == 'transfer': 90 | self.transfer = value 91 | else: 92 | raise Exception( "Unknown configuration key '%s'" % key ) 93 | 94 | fd.close() 95 | 96 | @classmethod 97 | def getInstance(cls): 98 | if cls.__instance is None: 99 | cls.__instance = Config() 100 | return cls.__instance 101 | -------------------------------------------------------------------------------- /swg/entities/item.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import re 22 | import os 23 | import hashlib 24 | 25 | from swg.core.config import Config 26 | from swg.core.pager import Pager 27 | 28 | class Item: 29 | SLUGIFY_SPLIT_REGEXP = re.compile( r'[^\w]+' ) 30 | PAGER_ENABLED_CLASSES = ( 31 | 'swg.entities.category.Category', 32 | 'swg.entities.tag.Tag', 33 | 'swg.entities.author.Author' 34 | ) 35 | 36 | def __init__( self, path, title, extension ): 37 | self.path = path.replace( '//', '/' ) 38 | self.title = title.strip() 39 | self.extension = extension.strip() 40 | self.name = self.__generate_name() 41 | self.url = ("%s/%s.%s" % (self.path,self.name,self.extension)).replace( '//', '/' ) 42 | self.objects = {} 43 | self.npages = 1 44 | 45 | def __generate_name( self ): 46 | result = [] 47 | for word in Item.SLUGIFY_SPLIT_REGEXP.split( self.title.lower() ): 48 | result.extend( word.split() ) 49 | 50 | return '-'.join(result) 51 | 52 | def __save_contents( self, filename, contents ): 53 | fd = open( filename.encode('UTF-8'), "w+b" ) 54 | fd.write( contents ) 55 | fd.close() 56 | 57 | def addObject( self, name, value ): 58 | self.objects[name] = value 59 | 60 | if hasattr( self, 'author') and self.author is not None: 61 | self.author.addObject( name, value ) 62 | 63 | if hasattr( self, 'categories' ): 64 | for category in self.categories: 65 | category.addObject( name, value ) 66 | 67 | if hasattr( self, 'tags' ): 68 | for tag in self.tags: 69 | tag.addObject( name, value ) 70 | 71 | return self 72 | 73 | def addObjects( self, dictionary ): 74 | for name, value in dictionary.items(): 75 | self.addObject( name, value ) 76 | 77 | return self 78 | 79 | def create(self): 80 | config = Config.getInstance() 81 | path = "%s%s%s" % ( config.outputpath, os.sep, self.path ) 82 | 83 | if not os.path.exists( path ): 84 | os.mkdir(path) 85 | 86 | if config.pager == True and (self.title == 'index' or str(self.__class__) in Item.PAGER_ENABLED_CLASSES): 87 | pager = Pager( '%s.%s' % ( self.name, self.extension ), 88 | '%s-%%d.%s' % ( self.name, self.extension ) ) 89 | 90 | if hasattr( self, 'items' ): 91 | pager.setPages( self.items ) 92 | else: 93 | pager.setPages( self.objects['pages'] ) 94 | 95 | self.npages = pager.getTotalPages() 96 | 97 | self.addObject( 'pager', pager ) 98 | 99 | for filename in pager: 100 | filename = os.path.join( path, filename ) 101 | content = self.render() 102 | 103 | self.__save_contents( filename, content ) 104 | else: 105 | filename = os.path.join( path, "%s.%s" % (self.name, self.extension) ) 106 | content = self.render() 107 | 108 | self.__save_contents( filename, content ) 109 | -------------------------------------------------------------------------------- /swg/basic/templates/header.tpl: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | %if page != UNDEFINED and page.title != 'index': 10 | ${config.sitename | h} | ${page.title | h} 11 | %elif category != UNDEFINED: 12 | ${config.sitename | h} | ${category.title | h} 13 | %elif tag != UNDEFINED: 14 | ${config.sitename | h} | ${tag.title | h} 15 | %elif author != UNDEFINED: 16 | ${config.sitename | h} | ${author.username | h} 17 | %else: 18 | ${config.sitename | h} 19 | %endif 20 | 21 | %if pager != UNDEFINED and pager.getTotalPages() > 2 and pager.getCurrentPageNumber() != 1: 22 | | Page ${pager.getCurrentPageNumber()} 23 | %endif 24 | 25 | 26 | %if page != UNDEFINED and page.title != 'index': 27 | 28 | <% 29 | import re 30 | 31 | description = re.sub( r'<[^>]*?>', ' ', page.content ).strip()[:150] 32 | %> 33 | 34 | %else: 35 | 36 | 37 | %endif 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | %if page != UNDEFINED and page.title != 'index': 46 | 47 | %endif 48 | 49 | 50 | 51 |
52 | 53 |
54 | 59 |
60 | 61 |
62 | 63 | 105 | 106 |
107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SWG - Static Website Generator 2 | ============================== 3 | 4 | Copyleft by Simone Margaritelli 5 | 6 | What is SWG ? 7 | ------------- 8 | 9 | SWG is a new generation static website generator, featured by the Mako (http://www.makotemplates.org/) template system, born from the need to 10 | have both performances and "WEB 2.0" contents and capabilities. 11 | 12 | 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 13 | you specify from command line and generate a complete static website, with tags and categories indexing. 14 | 15 | Installation 16 | ------------ 17 | 18 | To get the latest released version: 19 | 20 | :: 21 | 22 | pip install swg 23 | 24 | Create a new website 25 | -------------------- 26 | 27 | To start a new website, type: 28 | 29 | :: 30 | 31 | swg --create website-folder-name 32 | 33 | An example site with a basic structure will be created inside the 'website-folder-name' directory. 34 | Then you can type: 35 | 36 | :: 37 | 38 | cd website-folder-name 39 | swg --serve 40 | 41 | To test the website locally. 42 | The first article is about customization and basic configuration, so read it carefully. 43 | 44 | Generate your website 45 | --------------------- 46 | 47 | Once you are in the directory containing your website definition (with a swg.cfg file in it), just run: 48 | 49 | :: 50 | 51 | swg --generate 52 | 53 | To start website generation, other options are available, use 54 | 55 | :: 56 | 57 | swg --help 58 | 59 | To a display the complete list. 60 | 61 | Importing from another platform 62 | ------------------------------- 63 | 64 | Right now, there's the swg-wordpress script you can use to convert a WordPress XML backup file to the 65 | SWG format, to use it consider the following: 66 | 67 | :: 68 | 69 | swg-wordpress --help 70 | - SWG Wordpress Backup Importer - 71 | 72 | Usage: swg-wordpress -i wordpress-backup.xml -u 'http://www.your-site-url.com' 73 | 74 | 75 | Options: 76 | -h, --help show this help message and exit 77 | -i WPBACKUP, --input=WPBACKUP 78 | The Wordpress XML backup file. 79 | -u SITEURL, --url=SITEURL 80 | URL of the destination website. 81 | -o OUTDIR, --output=OUTDIR 82 | Output directory, default is the current working 83 | directory. 84 | -e FILEEXT, --extension=FILEEXT 85 | Output file extension, default is txt. 86 | -I IMGDIR, --images=IMGDIR 87 | If specified, it's the path where the importer will 88 | try to download images referenced by articles. 89 | 90 | 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 91 | images referenced by the articles into the 'example-site.com/images' directory (the import will replace properly image urls), you 92 | will use the command line: 93 | 94 | :: 95 | 96 | swg-wordpress -i wp.xml -u http://www.example-site.com -o 'example-site.com' -I 'example-site.com/images' 97 | 98 | And it's all done! 99 | Now you just have to create the templates, fix the categories hyerarchy inside the file 'example-site.com/db/categories.txt', customize 100 | your own description inside 'example-site.com/db/your-nickname.txt' and make the configuration file following the example below. 101 | 102 | An example configuration file 103 | ----------------------------- 104 | 105 | :: 106 | 107 | # DB files extension 108 | dbitem_ext = txt 109 | # URL of the site you are going to generate 110 | siteurl = http://www.example-site.com 111 | # Site name / description 112 | sitename = An example site generated by SWG 113 | # Site charset 114 | charset = utf-8 115 | # Site language 116 | language = it 117 | # Comma separated site keywords 118 | keywords = some, html, keywords, here 119 | # Site destination basepath 120 | basepath = 121 | # Site page files output extension 122 | page_ext = html 123 | # Generated site output path 124 | outputpath = out 125 | # Items (dirs or files) to copy from datapath to outputpath (eg. static files, css, etc) 126 | copypaths = css, images, .htaccess 127 | # Command to execute once the generation is finished, for instance an rsync :) 128 | transfer = rsync -ravz out/* -e ssh user@example-site.com:/var/www/example-site.com/htdocs/ 129 | # Enable or disable the pager on categories, index, tags and author pages 130 | pager = true 131 | # If pager is enabled, this is the maximum number of items per page 132 | items_per_page = 10 133 | # Compress pages (ie. index.html.gz) and create (or update) .htaccess file to serve them as html files 134 | gzip = true 135 | # Compression level, 0 to 9 136 | compression = 9 137 | # Clean output html with TIDY 138 | tidyfy = true 139 | 140 | Pretty self explanatory isn't it ? :) 141 | 142 | Testing your website locally 143 | ---------------------------- 144 | 145 | From version 1.2.4, SWG offers the possibility to test your website locally, once you are in the directory containing your website definition 146 | (with a swg.cfg file in it), run the following command: 147 | 148 | :: 149 | 150 | swg --serve 151 | 152 | This will start the website generation and a test webserver on http://localhost:8080/ . 153 | 154 | Example project 155 | --------------- 156 | 157 | For an example site, look at my personal blog github repo located here https://github.com/evilsocket/evilsocket.net 158 | 159 | Enjoy ^^ 160 | -------------------------------------------------------------------------------- /swg/basic/db/pages/1.txt: -------------------------------------------------------------------------------- 1 | Date: 2011-04-25 17:34:00 2 | Static: true 3 | Author: Your Name Here 4 | Categories: Personal, Experience 5 | Tags: swg, test, post, basic, website, structure, instructions, howto, doc, documentation 6 | Title: Instructions 7 | 8 |

9 | 10 | 11 | 12 |

21 | 22 |

Changing website main properties

23 | You can change those properties by editing the swg.cfg file inside the folder of the site project, the main properties you are probably 24 | interested in are: 25 | 26 |
 27 | siteurl    = http://www.swg-example-website.com
 28 | sitename   = SWG Example Website
 29 | charset    = utf-8
 30 | language   = en
 31 | keywords   = swg,example,website,static,static website,generator,static website generator
 32 | 
33 | 34 | 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 35 | keywords to be used in the meta html fields. 36 | 37 |

Setting up your author name

38 | The first thing you wanna do, is to change the main author name, because as you have noticed it's set to 'Your Name Here' right now ... pretty ugly isn't it? 39 | 40 | Open the file db/Your Name Here.txt with your favourite text editor (better if it supports HTML syntax highlighting) and edit the first four rows with your 41 | own details, for instance: 42 | 43 |
 44 | username: Joe Black
 45 | avatar: /images/myavatar.png
 46 | email: joeblack@gmail.com
 47 | website: http://www.example-website.com
 48 | 
49 | 50 | Leave the next line empty and write something about yourself (HTML allowed), this description will be the one displayed in the About Me section. 51 | Now rename the file with the username you've just used in those fields, so it will be renamed (following the example) like so: 52 | 53 |
 54 | db/Your Name Here.txt  ---> renamed to ---> db/Joe Black.txt
 55 | 
56 | 57 | Also you will have to replace the string your-name-here with joe-black inside templates/sidebar.tpl and templates/header.tpl to fix 58 | the links to your profile. 59 | 60 |

Defining site categories

61 | To define the hierarchy of your categories, open the file db/categories.txt and edit it. 62 | Each line must begin with one root category, so for instance: 63 | 64 |
 65 | Personal
 66 | Experience
 67 | 
68 | 69 | Are two root categories. 70 | To add a new one, simply add a new line with the name of the new category. 71 | 72 | If you want to define a sub category, you shall use the following syntax: 73 | 74 |
 75 | Personal: Projects, Work
 76 | Experience
 77 | 
78 | 79 | So that Projects and Work are now sub categories of Personal. 80 | 81 |

Customizing the templates

82 | SWG uses the Mako Template Engine to render the html contents, so you might want to follow its 83 | documentation to fully understand how to customize the tpl files inside the templates 84 | directory. 85 | 86 | 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 :) 87 | 88 |

Creating a new article

89 | Once you are in your website SWG folder, you can use the command: 90 | 91 |
 92 | swg --new
 93 | 
94 | 95 | or 96 | 97 |
 98 | swg -N
 99 | 
100 | 101 | To create a new entry. 102 | 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: 103 | 104 |
105 | Date: 2011-04-25 17:34:00
106 | Author: Joe Black
107 | Categories: Personal, Experience
108 | Tags: put, some, comma, separated, tag, here
109 | Title: Hello World again, put the title here.
110 | 
111 | 112 | Leave the following line blank and start inserting the content. 113 | If you want to split the abstract of the article and the body itself, you can use the optional <break> tag, for instance: 114 | 115 |
116 | Date: 2011-04-25 17:34:00
117 | Author: Joe Black
118 | Categories: Personal, Experience
119 | Tags: put, some, comma, separated, tag, here
120 | Title: Hello World again, put the title here.
121 | 
122 | <p>
123 |   This is the abstract.
124 |   <break>
125 |   And this is the rest of the article that will be shown only in the article page itself.
126 | </p>
127 | 
128 | 129 |

Add comment capabilities to each article

130 | You can easily add a comment feature to each article using the DISQUS free service, 131 | just register your website and edit the file templates/page.tpl adding the DISQUS javascript code where you want the comments 132 | to be shown. 133 | 134 |

Final Note

135 | After every modification to the site, do not forget to regenerate it with the: 136 | 137 |
138 | swg --generate
139 | 
140 | 141 | command executed inside the website folder, or, to test it locally: 142 | 143 |
144 | swg --serve
145 | 
146 | 147 | Then you will be able to browse it at the address http://localhost:8080 . 148 | 149 |

150 | 151 | -------------------------------------------------------------------------------- /swg/core/itemparser.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | import codecs 22 | import datetime 23 | 24 | from swg.core.config import Config 25 | 26 | class ItemParser: 27 | PARSE_NONE_STATE = 0 28 | PARSE_INFO_STATE = 1 29 | PARSE_BODY_STATE = 2 30 | PARSE_DONE_STATE = 3 31 | 32 | BODY_ABSTRACT_BREAK = u'' 33 | 34 | TIDY_OPTIONS = {'alt-text' : ' ', 35 | 'doctype' : 'transitional', 36 | 'bare' : 1, 37 | 'clean' : 0, 38 | 'hide-comments' : 1, 39 | 'join-classes' : 1, 40 | 'join-styles' : 1, 41 | 'output-xhtml' : 1, 42 | 'quote-nbsp' : 0, 43 | 'preserve-entities' : 1, 44 | 'show-errors' : 0, 45 | 'show-warnings' : 0, 46 | 'wrap' : 0, 47 | 'sort-attributes' : 'alpha', 48 | 'char-encoding' : 'utf8', 49 | 'input-encoding' : 'utf8', 50 | 'output-encoding' : 'utf8', 51 | 'indent' : 0, 52 | 'indent-spaces' : 0, 53 | 'newline' : 'LF', 54 | 'output-bom' : 0, 55 | 'force-output' : 1, 56 | 'quiet' : 1, 57 | 'tidy-mark' : 0, 58 | 'show-body-only' : 1 59 | } 60 | 61 | def __init__(self): 62 | self.info = {} 63 | self.abstract = "" 64 | self.body = "" 65 | self.state = ItemParser.PARSE_NONE_STATE 66 | self.lineno = 1 67 | 68 | def __parse_datetime( self, data ): 69 | return datetime.datetime.strptime( data, '%Y-%m-%d %H:%M:%S' ) 70 | 71 | def __parse_string( self, data ): 72 | return data 73 | 74 | def __parse_array( self, data ): 75 | return [ s.strip() for s in data.split(',') ] 76 | 77 | def __parse_boolean( self, data ): 78 | return True if data.lower() == 'true' else False 79 | 80 | def parse( self, mandatory_fields_map, filename, optional_fields_map = None ): 81 | fd = codecs.open( filename, "r", "utf-8" ) 82 | 83 | self.state = ItemParser.PARSE_INFO_STATE 84 | 85 | for line in iter(fd): 86 | if self.state == ItemParser.PARSE_INFO_STATE: 87 | line = line.strip() 88 | if line == '': 89 | self.state = ItemParser.PARSE_BODY_STATE 90 | else: 91 | ( info_id, info_data ) = line.split( ':', 1 ) 92 | info_id = info_id.strip().lower() 93 | info_data = info_data.strip() 94 | info_type = None 95 | 96 | try: 97 | info_type = mandatory_fields_map[info_id] 98 | except KeyError: 99 | try: 100 | info_type = optional_fields_map[info_id] 101 | except: 102 | raise Exception( "Unknown key %s on line %d." % ( info_id, self.lineno ) ) 103 | 104 | if info_type == 'datetime': 105 | self.info[info_id] = self.__parse_datetime(info_data) 106 | elif info_type == 'string': 107 | self.info[info_id] = self.__parse_string(info_data) 108 | elif info_type == 'array': 109 | self.info[info_id] = self.__parse_array(info_data) 110 | elif info_type == 'boolean': 111 | self.info[info_id] = self.__parse_boolean(info_data) 112 | 113 | elif self.state == ItemParser.PARSE_BODY_STATE: 114 | self.body += line 115 | else: 116 | raise Exception( "Unhandled parser state on line %d." % self.lineno ) 117 | 118 | self.lineno += 1 119 | 120 | fd.close() 121 | 122 | missing = filter( lambda x:x not in self.info.keys(), mandatory_fields_map.keys() ) 123 | if missing != []: 124 | raise Exception( "Missing mandatory fields : %s" % ', '.join(missing) ) 125 | 126 | # Parse markdown content 127 | if filename.endswith('.md') or filename.endswith('.markdown'): 128 | import markdown 129 | self.body = markdown.markdown( self.body, extensions=['headerid(level=2)'] ) 130 | 131 | if ItemParser.BODY_ABSTRACT_BREAK in self.body: 132 | ( self.abstract, therest ) = self.body.split( ItemParser.BODY_ABSTRACT_BREAK, 1 ) 133 | self.body = self.abstract.strip() + '

' + therest.strip() 134 | else: 135 | self.abstract = self.body 136 | 137 | # Fix pseudo attribute newlines 138 | self.body = self.body.replace( "\n\n", "

" ) 139 | self.abstract = self.abstract.replace( "\n\n", "

" ) 140 | -------------------------------------------------------------------------------- /swg/swg-wordpress: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # This file is part of SWG (Static Website Generator). 4 | # 5 | # Copyright(c) 2010-2011 Simone Margaritelli 6 | # evilsocket@gmail.com 7 | # http://www.evilsocket.net 8 | # http://www.backbox.org 9 | # 10 | # This file may be licensed under the terms of of the 11 | # GNU General Public License Version 2 (the ``GPL''). 12 | # 13 | # Software distributed under the License is distributed 14 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 15 | # express or implied. See the GPL for the specific language 16 | # governing rights and limitations. 17 | # 18 | # You should have received a copy of the GPL along with this 19 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 20 | # or write to the Free Software Foundation, Inc., 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | import os 23 | import re 24 | import sys 25 | import urllib 26 | import codecs 27 | from xml.dom import minidom 28 | from datetime import datetime 29 | from optparse import OptionParser 30 | 31 | def slugify_name( name ): 32 | result = [] 33 | for word in slugify.split( name.lower() ): 34 | result.extend( word.split() ) 35 | 36 | return '-'.join(result) 37 | 38 | print "- SWG Wordpress Backup Importer -\n" 39 | 40 | parser = OptionParser( usage = "usage: %prog -i wordpress-backup.xml -u 'http://www.your-site-url.com' \n" ) 41 | 42 | parser.add_option( "-i", "--input", action="store", dest="wpbackup", default=None, help="The Wordpress XML backup file." ) 43 | parser.add_option( "-u", "--url", action="store", dest="siteurl", default=None, help="URL of the destination website." ) 44 | parser.add_option( "-o", "--output", action="store", dest="outdir", default=".", help="Output directory, default is the current working directory." ) 45 | parser.add_option( "-e", "--extension", action="store", dest="fileext", default="txt", help="Output file extension, default is txt." ) 46 | parser.add_option( "-I", "--images", action="store", dest="imgdir", default=None, help="If specified, it's the path where the importer will try to download images referenced by articles." ) 47 | 48 | (o,args) = parser.parse_args() 49 | 50 | if o.wpbackup is None: 51 | parser.error( "Wordpress XML backup file not specified !") 52 | elif o.siteurl is None: 53 | parser.error( "URL of the destination website not specified !" ) 54 | 55 | wpbackup = o.wpbackup 56 | siteurl = o.siteurl 57 | fileext = o.fileext 58 | outdir = o.outdir 59 | imgdir = o.imgdir 60 | imgdownload = True if imgdir is not None else False 61 | 62 | print "@ Loading %s ..." % wpbackup 63 | 64 | doc = minidom.parse(wpbackup) 65 | items = doc.getElementsByTagName('item') 66 | domain = re.sub( '^(https?\://)?(www\.)?', '', siteurl ) 67 | imgtag = re.compile( '<\s*img[^/>]+src\s*=\s*[\'"]([^\'"]+' + re.escape(domain) + '[^\'"]+)[\'"]',re.IGNORECASE ) 68 | slugify = re.compile( r'[^\w]+' ) 69 | 70 | post_id = 0 71 | site_authors = [] 72 | site_categories = [] 73 | 74 | # create needed directories 75 | if not os.path.exists(outdir): 76 | os.mkdir( outdir ) 77 | 78 | try: 79 | os.makedirs( outdir + os.sep + 'db' + os.sep + 'pages' ) 80 | except: 81 | pass 82 | 83 | if imgdownload is True and not os.path.exists(imgdir): 84 | os.mkdir( imgdir ) 85 | 86 | for item in items: 87 | status = item.getElementsByTagName('wp:status')[0].firstChild.nodeValue 88 | type = item.getElementsByTagName('wp:post_type')[0].firstChild.nodeValue 89 | # import only published posts 90 | if status == 'publish' and type == 'post': 91 | title = item.getElementsByTagName('title')[0].firstChild.nodeValue 92 | date = item.getElementsByTagName('wp:post_date')[0].firstChild.nodeValue 93 | author = item.getElementsByTagName('dc:creator')[0].firstChild.nodeValue 94 | content = item.getElementsByTagName('content:encoded')[0].firstChild.nodeValue 95 | categories = [] 96 | tags = [] 97 | 98 | print "@ Processing '%s' ..." % title 99 | 100 | # get item categories and tags 101 | metas = item.getElementsByTagName('category') 102 | for meta in metas: 103 | domain = meta.attributes['domain'].value if meta.attributes.has_key('domain') else 'category' 104 | value = meta.firstChild.nodeValue.strip() 105 | 106 | if domain == 'category' and value not in categories: 107 | categories.append(value) 108 | elif domain == 'tag' and value not in tags: 109 | tags.append(value) 110 | 111 | # replace the 'more' pseudo tag in the content with swg 112 | content = content.replace( '', '' ) 113 | # make sure date is correct attempting to parse it 114 | date = datetime.strptime( date, '%Y-%m-%d %H:%M:%S' ) 115 | # search for images to download 116 | if imgdownload is True: 117 | images = imgtag.findall(content) 118 | for image in images: 119 | # update the html with the new image url and download it to the specified directory 120 | imgname = os.path.basename(image) 121 | content = content.replace( image, siteurl + '/' + os.path.basename(imgdir) + '/' + imgname ) 122 | imgfile = imgdir + os.sep + imgname 123 | if not os.path.exists(imgfile): 124 | print "\t- downloading '%s' to %s ..." % ( image, imgfile ) 125 | urllib.urlretrieve( image, imgfile ) 126 | 127 | data = """\ 128 | Date: %s 129 | Author: %s 130 | Categories: %s 131 | Tags: %s 132 | Title: %s\n\n""" % ( date.strftime('%Y-%m-%d %H:%M:%S'), author, ', '.join(categories), ', '.join(tags), title ) + content 133 | 134 | filename = outdir + os.sep + 'db' + os.sep + 'pages' + os.sep + "%d.%s" % ( post_id, fileext ) 135 | file = codecs.open( filename, "w+", "utf-8") 136 | file.write(data) 137 | file.close() 138 | 139 | print "@ Saved to %s ." % filename 140 | 141 | # save author if not already present in the list 142 | if author not in site_authors: 143 | site_authors.append(author) 144 | # same for the categories 145 | for category in categories: 146 | if category not in site_categories: 147 | site_categories.append(category) 148 | 149 | post_id += 1 150 | 151 | print 152 | # create files for categories and authors 153 | for author in site_authors: 154 | filename = outdir + os.sep + 'db' + os.sep + "%s.%s" % ( slugify_name(author), fileext ) 155 | 156 | print "@ Creating author file %s ..." % filename 157 | 158 | file = codecs.open( filename, "w+", "utf-8") 159 | file.write( """\ 160 | username: %s 161 | avatar: put your avatar url here 162 | email: put your email here 163 | website: %s 164 | 165 | put a description of yourself here""" % ( author, siteurl ) ) 166 | file.close() 167 | 168 | filename = outdir + os.sep + 'db' + os.sep + "categories.%s" % fileext 169 | file = codecs.open( filename, "w+", "utf-8") 170 | print "@ Creating categories file %s ..." % filename 171 | for category in site_categories: 172 | file.write( category + "\n" ) 173 | file.close() 174 | 175 | print "\n@ Done :)" 176 | -------------------------------------------------------------------------------- /swg/engine.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is part of SWG (Static Website Generator). 3 | # 4 | # Copyright(c) 2010-2011 Simone Margaritelli 5 | # evilsocket@gmail.com 6 | # http://www.evilsocket.net 7 | # http://www.backbox.org 8 | # 9 | # This file may be licensed under the terms of of the 10 | # GNU General Public License Version 2 (the ``GPL''). 11 | # 12 | # Software distributed under the License is distributed 13 | # on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either 14 | # express or implied. See the GPL for the specific language 15 | # governing rights and limitations. 16 | # 17 | # You should have received a copy of the GPL along with this 18 | # program. If not, go to http://www.gnu.org/licenses/gpl.html 19 | # or write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | 22 | import os 23 | import sys 24 | import time 25 | import os.path 26 | import re 27 | import shutil 28 | import SimpleHTTPServer 29 | import SocketServer 30 | 31 | from swg.core.config import Config 32 | from swg.core.pageparser import PageParser 33 | from swg.entities.page import Page 34 | 35 | class ProgressBar: 36 | def __init__( self, min_value = 0, max_value = 100, width = 77, char = '#' ): 37 | self.char = char 38 | self.bar = '' 39 | self.min = min_value 40 | self.max = max_value if max_value != None else 0 41 | self.span = self.max - self.min 42 | self.width = width 43 | self.amount = 0 44 | self.update_amount(0) 45 | 46 | def increment_amount(self, add_amount = 1): 47 | new_amount = self.amount + add_amount 48 | if new_amount < self.min: new_amount = self.min 49 | if new_amount > self.max: new_amount = self.max 50 | self.amount = new_amount 51 | self.build_bar() 52 | 53 | def update_amount(self, new_amount = None): 54 | if not new_amount: new_amount = self.amount 55 | if new_amount < self.min: new_amount = self.min 56 | if new_amount > self.max: new_amount = self.max 57 | self.amount = new_amount 58 | self.build_bar() 59 | 60 | def build_bar(self): 61 | diff = float(self.amount - self.min) 62 | percent_done = int(round((diff / float(self.span)) * 100.0)) if self.max != 0 else 100 63 | 64 | # figure the proper number of 'character' make up the bar 65 | all_full = self.width - 2 66 | num_hashes = int(round((percent_done * all_full) / 100)) 67 | 68 | self.bar = self.char * num_hashes + ' ' * (all_full-num_hashes) 69 | 70 | percent_str = str(percent_done) + "%" 71 | self.bar = '[ ' + self.bar + ' ] ' + percent_str 72 | 73 | def __str__(self): 74 | return str(self.bar) 75 | 76 | class Engine: 77 | __instance = None 78 | 79 | def __init__(self): 80 | self.config = Config.getInstance() 81 | self.dbdir = os.path.join( self.config.dbpath, 'pages' ) 82 | self.files = [] 83 | 84 | if os.path.exists( self.dbdir ): 85 | for folder, subdirs, files in os.walk( self.dbdir ): 86 | for fname in files: 87 | self.files.append( os.path.realpath( os.path.join( folder, fname ) ) ) 88 | 89 | self.path = os.path.dirname( os.path.realpath( __file__ ) ) 90 | self.pages = [] 91 | self.progress = None 92 | self.statics = None 93 | self.index = None 94 | self.e404 = None 95 | self.sitemap = None 96 | self.feed = None 97 | 98 | def getPageByTitle( self, title, caseSensitive = True ): 99 | lwr_title = title.lower() if caseSensitive is False else None 100 | for page in self.pages: 101 | if page.title == title or (caseSensitive is False and page.title.lower() == lwr_title): 102 | return page 103 | 104 | return None 105 | 106 | def getStaticPages( self ): 107 | if self.statics is None: 108 | self.statics = filter( lambda page: page.static is True, self.pages ) 109 | 110 | return self.statics 111 | 112 | def new( self ): 113 | newitem = os.path.join( self.dbdir, "%s.md" % self.config.now.strftime("%Y-%m-%d %H:%M:%S") ) 114 | fd = open( newitem, 'w+t' ) 115 | 116 | fd.write( """\ 117 | Date: %s 118 | Author: 119 | Categories: 120 | Tags: 121 | Title: 122 | 123 | """ % self.config.now.strftime("%Y-%m-%d %H:%M:%S") ) 124 | 125 | fd.close() 126 | 127 | os.system( "%s %s" % ( self.config.editor, newitem ) ) 128 | 129 | if os.path.exists( newitem ): 130 | print "@ Item '%s' created, you can now regenerate the website ." % newitem 131 | else: 132 | print "@ Item was not saved, quitting ." 133 | 134 | def create( self, destfolder ): 135 | if os.path.exists(destfolder): 136 | sys.exit( "@ The folder '%s' already exists, operation interrupted for security reasons." % destfolder ) 137 | else: 138 | print "@ Creating SWG basic website structure inside the '%s' folder ..." % destfolder 139 | 140 | shutil.copytree( os.path.join( self.path, 'basic' ), destfolder ) 141 | 142 | print """\ 143 | @ Basic website initialized, now run: 144 | 145 | cd %s 146 | swg --generate 147 | 148 | To generate the html contents or: 149 | 150 | cd %s 151 | swg --serve 152 | 153 | To test the website locally.""" % (destfolder,destfolder) 154 | 155 | def serve( self ): 156 | 157 | class SWGServer(SocketServer.TCPServer): 158 | allow_reuse_address = True 159 | 160 | self.config.siteurl = 'http://localhost:8080' 161 | self.generate() 162 | 163 | os.chdir( self.config.outputpath ) 164 | 165 | print "\n@ Serving the site on http://localhost:8080/ press ctrl+c to exit ..." 166 | 167 | try: 168 | SWGServer( ("",8080), SimpleHTTPServer.SimpleHTTPRequestHandler ).serve_forever() 169 | except KeyboardInterrupt: 170 | print "\n@ Bye :)" 171 | 172 | def generate( self ): 173 | start = time.time( ) 174 | parser = PageParser( ) 175 | 176 | print "@ Parsing pages ..." 177 | for file in self.files: 178 | if re.match( '^.+\..+$', file ): 179 | filename = os.path.join( self.dbdir, file ) 180 | page = parser.parse( filename ) 181 | self.pages.append(page) 182 | 183 | print "@ Sorting pages by date ..." 184 | self.pages.sort( reverse=True, key=lambda p: p.datetime ) 185 | 186 | # delete output directory and recreate it 187 | if os.path.exists(self.config.outputpath ): 188 | print "@ Removing old '%s' path ..." % self.config.outputpath 189 | shutil.rmtree( self.config.outputpath ) 190 | 191 | print "@ Creating '%s' path ..." % self.config.outputpath 192 | os.mkdir( self.config.outputpath ) 193 | 194 | for source, destination in self.config.copypaths.items(): 195 | print "@ Importing '%s' to '%s' ..." % (source, destination) 196 | if os.path.isfile(source): 197 | shutil.copy( source, destination ) 198 | elif os.path.isdir(source): 199 | shutil.copytree( source, destination ) 200 | else: 201 | raise Exception("Unexpected type of '%s' ." % source ) 202 | 203 | if os.path.exists( os.path.join( self.config.tplpath, 'index.tpl' ) ): 204 | print "@ Creating index file ..." 205 | self.index = Page( 'index', 'index.tpl' ) 206 | self.index.addObjects( { 'pages' : self.pages, 'swg' : self } ) 207 | self.index.create() 208 | else: 209 | raise Exception( "No index template found." ) 210 | 211 | if os.path.exists( os.path.join( self.config.tplpath, '404.tpl' ) ): 212 | print "@ Creating 404 file ..." 213 | self.e404 = Page( '404', '404.tpl' ) 214 | self.e404.addObjects( { 'pages' : self.pages, 'swg' : self } ) 215 | self.e404.create() 216 | 217 | if os.path.exists( os.path.join( self.config.tplpath, 'feed.tpl' ) ): 218 | print "@ Creating feed.xml file ..." 219 | self.feed = Page( 'feed', 'feed.tpl' ) 220 | self.feed.addObjects( { 'pages' : self.pages, 'swg' : self } ) 221 | self.feed.extension = 'xml' 222 | self.feed.create() 223 | 224 | self.progress = ProgressBar( 0, len(self.pages) ) 225 | 226 | for page in self.pages: 227 | page.addObjects( { 'pages' : self.pages, 'swg' : self } ).create() 228 | self.progress.increment_amount() 229 | sys.stdout.write( "@ Rendering %d pages : %s\r" % ( len(self.pages), self.progress ) ) 230 | sys.stdout.flush() 231 | 232 | self.progress.update_amount( len(self.pages) ) 233 | sys.stdout.write( "@ Rendering %d pages : %s\r" % ( len(self.pages), self.progress ) ) 234 | sys.stdout.flush() 235 | print "\n", 236 | 237 | if os.path.exists( os.path.join( self.config.tplpath, 'sitemap.tpl' ) ): 238 | print "@ Creating sitemap.xml file ..." 239 | self.sitemap = Page( 'sitemap', 'sitemap.tpl' ) 240 | self.sitemap.addObjects( { 'index' : self.index, 'pages' : self.pages, 'swg' : self } ) 241 | self.sitemap.extension = 'xml' 242 | self.sitemap.create() 243 | 244 | print "@ Website succesfully generated in %s .\n" % time.strftime('%H:%M:%S', time.gmtime( time.time() - start ) ) 245 | 246 | if self.config.transfer is not None: 247 | os.system( self.config.transfer.encode( "UTF-8" ) ) 248 | 249 | @classmethod 250 | def getInstance(cls): 251 | if cls.__instance is None: 252 | cls.__instance = Engine() 253 | return cls.__instance 254 | -------------------------------------------------------------------------------- /swg/basic/css/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Based on the WordPress Theme Lonelytree 3 | */ 4 | 5 | /* - BASIC CSS - */ 6 | 7 | *{ 8 | margin: 0; 9 | padding: 0; 10 | text-decoration: none; 11 | } 12 | 13 | html, body { 14 | line-height: 1; 15 | height: 100%; 16 | } 17 | 18 | code { 19 | background-color: #eee; 20 | padding: 2px; 21 | font: 1.1em 'Courier New', Courier, Fixed; 22 | } 23 | 24 | acronym, abbr, span.caps 25 | { 26 | font-size: 0.9em; 27 | letter-spacing: .07em; 28 | } 29 | 30 | 31 | body { 32 | background: url(/images/bg.png) repeat-y center; 33 | background-color:#ACACAC; 34 | color: #3e3033; 35 | font: 12px/18px "Helvetica Neue", Helvetica, Verdana, Arial, sans-serif; 36 | } 37 | 38 | a { 39 | /*text-decoration:none;*/ 40 | color:#060; 41 | outline: none; 42 | } 43 | a:hover { 44 | text-decoration:underline; 45 | color:#333 46 | } 47 | 48 | .additional-meta { 49 | font-size: x-small; 50 | background: #fff url(/images/bg-meta.gif) repeat-x left top; 51 | padding: 5px 5px 5px 5px; 52 | margin-bottom:5px; 53 | } 54 | 55 | .entry-meta { 56 | font-size: 90%; 57 | background: #fff url(/images/bg-meta.gif) repeat-x left top; 58 | margin-top:15px; 59 | padding: 5px 5px 5px 5px; 60 | clear:both; 61 | } 62 | .meta-date { 63 | float:left; 64 | } 65 | .meta-comments { 66 | background-repeat: no-repeat; 67 | float: right; 68 | padding: 0 0px 4px 17px; 69 | background: url(/images/comments.png) no-repeat 0px 0px; 70 | } 71 | 72 | .date{ 73 | padding: 0 0px 3px 17px; 74 | background: url(/images/date.png) no-repeat 0px 0px; 75 | } 76 | 77 | .author{ 78 | padding: 0 0px 3px 17px; 79 | background: url(/images/author.png) no-repeat 0px 0px; 80 | } 81 | 82 | .editblock{ 83 | background: url(/images/edit.png) no-repeat 0px 0px; 84 | padding: 0 0px 3px 17px; 85 | } 86 | 87 | .category{ 88 | background: url(/images/category.png) no-repeat 0px 0px; 89 | padding: 0 0px 3px 18px; 90 | } 91 | 92 | .tag{ 93 | background: url(/images/tags.png) no-repeat 0px 0px; 94 | padding: 0 0px 3px 18px; 95 | } 96 | 97 | blockquote { 98 | margin-top: 10px; 99 | margin-bottom: 10px; 100 | padding: 1em 1em; 101 | background: #f4f4f4; 102 | border: solid 1px #e1e1e1; 103 | font-style: italic; 104 | color: #939494; 105 | } 106 | 107 | blockquote p { 108 | color: #444444; 109 | padding: 1em 1em; 110 | } 111 | 112 | blockquote * { 113 | font-family: georgia, arial; 114 | line-height: 1.5em; 115 | } 116 | 117 | 118 | hr { display: block; 119 | border: none; 120 | margin: 0.5em auto; 121 | background-color: #888; 122 | } 123 | 124 | img{ 125 | border: 0; 126 | } 127 | 128 | p{ 129 | line-height: 140%; 130 | margin: .5em 0 1.3em; 131 | } 132 | 133 | table {border-collapse:collapse;} 134 | 135 | fieldset{ 136 | padding: 10px; 137 | } 138 | 139 | .clear {clear: both} 140 | 141 | /* -- LISTS -- */ 142 | 143 | ul { 144 | margin:0; 145 | padding:0; 146 | } 147 | ul li { 148 | margin-left:5px; 149 | padding:0; 150 | } 151 | li { 152 | list-style-type:none; 153 | /*margin-bottom: 4px;*/ 154 | } 155 | ol { 156 | list-style-type: decimal; 157 | } 158 | .disc {list-style-type:disc; 159 | } 160 | 161 | /* lists inside posts */ 162 | 163 | .entry-content ul ol { 164 | margin-left:0; 165 | } 166 | .entry-content ul li { 167 | margin-left:1.5em; 168 | list-style:disc; 169 | list-style-position:inside 170 | } 171 | .entry-content ul li ol { 172 | margin-left:1.5em; 173 | } 174 | .entry-content ol li { 175 | margin-left:1.5em; 176 | list-style: decimal; 177 | list-style-position:inside 178 | } 179 | .entry-content ol li li { 180 | margin-left:2em; 181 | } 182 | 183 | /* -- HEADINGS -- */ 184 | h1,h2,h3,h4,h5,h6 { 185 | margin:0;padding:0; 186 | line-height:1.8em; 187 | } 188 | 189 | h2.entry-title { 190 | font-size:180%; 191 | } 192 | 193 | h2#comments{ 194 | margin:20px auto 10px; 195 | font-size:140%; 196 | } 197 | 198 | /* headings inside posts */ 199 | 200 | .entry-content h3 { 201 | font-size:140%; 202 | } 203 | .entry-content h4 { 204 | font-size:120%; 205 | } 206 | .entry-content h5 { 207 | font-size:100%; 208 | } 209 | .entry-content h6 { 210 | font-size:90%; 211 | } 212 | 213 | /* -- MAIN DIV'S -- */ 214 | 215 | #wrapper { 216 | margin:0 auto 0; 217 | width: 1000px; 218 | min-height: 100%; 219 | height: 100%; 220 | } 221 | .menuStyle { 222 | background:#f8f8f8; 223 | height: 20px; 224 | padding: 10px 5px 6px; 225 | border-bottom: #333 1px solid; 226 | } 227 | .menuStyle li { 228 | float: left; 229 | list-style: none; 230 | } 231 | .menuStyle li a { 232 | color: #2e2f31; 233 | font: 12px arial; 234 | text-decoration: none; 235 | font-weight: bold; 236 | outline: none; 237 | text-align: center; 238 | padding: 6px; 239 | text-transform: uppercase; 240 | letter-spacing: 0; 241 | height: 25px; 242 | } 243 | .menuStyle li#current a, .menuStyle a:hover, li.current_page_item a { 244 | color: #fff; 245 | background-color: #333; 246 | -webkit-border-radius: 4px; 247 | -moz-border-radius: 4px; 248 | } 249 | #header { 250 | height:225px; 251 | background: url(/images/header-bg-sm.jpg) no-repeat top right; 252 | margin:0 auto; 253 | width: 1001px; 254 | } 255 | 256 | #header2{ 257 | background:url(/images/bg.jpg) repeat-x top; 258 | height:225px; 259 | } 260 | 261 | #footer { 262 | background:#2e2f31; 263 | color: #AAA; 264 | height:40px; 265 | overflow:hidden; 266 | clear:both; 267 | float:none; 268 | text-align:center; 269 | padding: 21px 0; 270 | width: 1002px; 271 | } 272 | 273 | #footer a:hover{ 274 | color:#FFF; 275 | text-decoration:none; 276 | } 277 | 278 | .container{ 279 | background:#f8f8f8 url(/images/contentbg.png) repeat-y; 280 | margin: 0px 0px; 281 | min-height: 65.5%; 282 | } 283 | 284 | #mainmenu{ 285 | background: #F8F8F8 url(/images/menubar.png) repeat-x top; 286 | height: 36px; 287 | margin: 0px 0px; 288 | width: 1002px; 289 | } 290 | 291 | #mainmenu .cat_e{ 292 | float:left; 293 | font-weight:bold; 294 | margin: 8px 6px; 295 | color:#DDD; 296 | } 297 | 298 | 299 | #mainmenu ul { 300 | float: left; 301 | list-style: none; 302 | margin: 0px; 303 | padding: 0px; 304 | } 305 | 306 | #mainmenu li { 307 | float: left; 308 | list-style: none; 309 | margin: 0px; 310 | padding: 0px; 311 | } 312 | 313 | #mainmenu li a, #mainmenu li a:link, #mainmenu li a:visited { 314 | display:block; 315 | color: #fff; 316 | font-weight: bold; 317 | margin: 0 3px; 318 | padding: 9px 10px 6px; 319 | text-decoration: none; 320 | } 321 | 322 | #mainmenu li a:hover, #mainmenu li.current-cat a{ 323 | color: #fff; 324 | margin: 0 3px; 325 | padding: 9px 10px 6px; 326 | text-decoration: none; 327 | background-color: #006000; 328 | } 329 | 330 | #mainmenu li li a, #mainmenu li li a:link, #mainmenu li li a:visited { 331 | background: #333; 332 | width: 160px; 333 | color: #fff; 334 | font-size: 11px; 335 | font-weight: normal; 336 | display: block; 337 | text-transform: uppercase; 338 | float: none; 339 | margin: 0px; 340 | padding: 8px 10px 7px 10px; 341 | border-bottom:1px solid #000; 342 | } 343 | 344 | #mainmenu li li a:hover, #mainmenu li li a:active { 345 | background: #111; 346 | color: #eee; 347 | padding: 8px 10px 7px 10px; 348 | } 349 | 350 | #mainmenu li ul { 351 | z-index: 9999; 352 | position: absolute; 353 | left: -999em; 354 | height: auto; 355 | width: 170px; 356 | margin: 0px; 357 | padding: 0px; 358 | } 359 | 360 | #mainmenu li li { 361 | } 362 | 363 | #mainmenu li ul a { 364 | width: 140px; 365 | } 366 | 367 | #mainmenu li ul ul { 368 | margin: -32px 0 0 170px; 369 | } 370 | 371 | #mainmenu li:hover ul ul, #mainmenu li:hover ul ul ul, 372 | #mainmenu li.sfhover ul ul, #mainmenu li.sfhover ul ul ul { 373 | left: -999em; 374 | } 375 | 376 | #mainmenu li:hover ul, #mainmenu li li:hover ul, 377 | #mainmenu li li li:hover ul, #mainmenu li.sfhover ul, 378 | #mainmenu li li.sfhover ul, #mainmenu li li li.sfhover ul { 379 | left: auto; 380 | } 381 | 382 | #mainmenu li:hover, #mainmenu li.sfhover { 383 | position: static; 384 | } 385 | 386 | /* -- Logo Area --*/ 387 | #logo{ 388 | float:left; 389 | width: 380px; 390 | height: 75px; 391 | display:block; 392 | margin-top: 55px; 393 | margin-left:60px; 394 | border: 0; 395 | } 396 | #logo h1 a{ 397 | font-size: 130%; 398 | font-weight: bold; 399 | letter-spacing: 2px; 400 | margin: 0 0 0 15px; 401 | padding: 0; 402 | color: #2e2f31; 403 | font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 404 | text-transform: capitalize; 405 | outline:none; 406 | } 407 | #logo h1 a:hover { 408 | text-decoration:none; 409 | } 410 | #logo h2{ 411 | letter-spacing: 1px; 412 | margin: 0 0 0 15px; 413 | font-size:14px; 414 | color:#8E8E8E; 415 | } 416 | /* -- POSTS -- */ 417 | .post-index { 418 | margin:0 0 10px; 419 | } 420 | #post-single { 421 | margin:0 0 20px; 422 | } 423 | .posts-wrap { 424 | float:left; 425 | clear:none; 426 | width:630px; 427 | padding: 0 15px; 428 | } 429 | /* -- SIDEBARS --*/ 430 | 431 | #sidebar { 432 | padding-top:10px; 433 | padding-right:15px; 434 | margin:0 auto; 435 | overflow:hidden; 436 | float:right; 437 | clear:none; 438 | width:320px; 439 | } 440 | 441 | /* -- 404-PAGE --*/ 442 | 443 | .error404 { 444 | margin:0; 445 | width:100%; 446 | } 447 | .error404 h1,.error404 h2 { 448 | margin: 10px auto; 449 | } 450 | 451 | /* -- COMMENTS -- */ 452 | 453 | #combox { 454 | border-top: 5px solid #989698; 455 | padding-top: 20px; 456 | padding-bottom: 20px; 457 | padding-left: 15px; 458 | padding-right: 15px; 459 | } 460 | 461 | h4#respond { 462 | font-size: 16px; 463 | font-weight: bold; 464 | letter-spacing: -1px; 465 | line-height: 1em; 466 | padding-bottom: 5px; 467 | margin-bottom: 2px; 468 | border-bottom: 1px dotted #ddd; 469 | } 470 | 471 | h3#comments { 472 | font-size: 16px; 473 | font-weight: bold; 474 | letter-spacing: -1px; 475 | line-height: 1em; 476 | padding-bottom: 5px; 477 | margin-bottom: 2px; 478 | border-bottom: 1px dotted #ddd; 479 | } 480 | 481 | form#commentform{ 482 | margin:10px; 483 | } 484 | 485 | ol.commentlist { 486 | list-style-type: none; 487 | margin-bottom: 20px; 488 | padding-bottom: 20px; 489 | border-bottom: 5px solid #323232; 490 | } 491 | 492 | ol.commentlist li { 493 | background: #f8fcef; 494 | border: 1px solid #eee; 495 | padding: 15px; 496 | margin-top: 20px; 497 | } 498 | 499 | ol.commentlist li.alt { 500 | background: #FFF; 501 | border: 1px solid #eee; 502 | padding: 15px; 503 | margin-top: 20px; 504 | } 505 | 506 | .avatar { 507 | float: left; 508 | display: inline; 509 | margin-right: 17px; 510 | border: 2px solid #999; 511 | } 512 | 513 | .avatar img { 514 | border: 2px solid #ddddd4; 515 | } 516 | 517 | #comment-meta2 { 518 | font-size: 11px; 519 | padding: 3px; 520 | background-color:#eee; 521 | } 522 | 523 | .comment-meta { 524 | font-size: 11px; 525 | color: #626262; 526 | margin-left: 17px; 527 | } 528 | 529 | cite, cite a { 530 | font-style: normal; 531 | font-size: 11px; 532 | font-weight: bold; 533 | color: #333; 534 | } 535 | 536 | .commentbody { 537 | float: left; 538 | display: inline; 539 | margin-left: 10px; 540 | width: 410px; 541 | } 542 | 543 | .commentbody em { 544 | font-size: 11px; 545 | } 546 | 547 | p.comment_author, p.comment_author a { 548 | font-weight: bold; 549 | color: #666; 550 | font-size: 11px; 551 | } 552 | 553 | p.comment_author a:hover { 554 | font-weight: bold; 555 | color: #006000; 556 | } 557 | 558 | p.comment_time { 559 | line-height: 1.5em; 560 | color: #999; 561 | font-size: 11px; 562 | font-family: tahoma; 563 | } 564 | 565 | .comment_text { 566 | line-height: 1.5em; 567 | color: #666; 568 | margin-top: 15px; 569 | font-size: 11px; 570 | } 571 | 572 | .reply form { 573 | width: 488px; 574 | } 575 | 576 | .reply p { 577 | margin-top: 10px; 578 | font-size: 11px; 579 | } 580 | 581 | .reply fieldset { 582 | vertical-align: middle; 583 | display: inline; 584 | } 585 | 586 | .reply input { 587 | vertical-align: middle; 588 | display: inline; 589 | font-size: 11px; 590 | } 591 | 592 | .reply textarea { 593 | vertical-align: middle; 594 | display: inline; 595 | font-size: 11px; 596 | } 597 | 598 | #reply label { 599 | vertical-align: middle; 600 | display: inline; 601 | font-size: 11px; 602 | font-weight: bold; 603 | font-family: tahoma; 604 | margin-left: 2px; 605 | } 606 | 607 | .replytext { 608 | border: 1px solid #989898; 609 | width: 200px; 610 | padding: 7px; 611 | margin: 5px; 612 | background-color:#E2ECF5; 613 | color: #366799; 614 | } 615 | 616 | .replytext:focus { 617 | background: #fffff9; 618 | } 619 | 620 | .replyarea { 621 | border: 1px solid #989898; 622 | line-height: 1.5em; 623 | padding: 5px; 624 | width: 95%; 625 | height: 120px; 626 | background-color:#E2ECF5; 627 | color: #37699B; 628 | } 629 | 630 | .replyarea:focus { 631 | background: #fffff9; 632 | } 633 | 634 | .replybutton { 635 | text-align: center; 636 | height: 35px; 637 | padding: 5px; 638 | font-weight: bold; 639 | color: #212121; 640 | cursor: pointer; 641 | margin-right:30px; 642 | } 643 | 644 | /* no border on smilies */ 645 | img.wp-smiley, .post img.wp-smiley{ 646 | padding: 0; 647 | margin: 0; 648 | border: 0; 649 | } 650 | 651 | /*-- table --*/ 652 | table{ 653 | margin: .5em 0 1em; 654 | border-bottom: 2px solid #d1d1d1; 655 | border-left: 1px solid #d1d1d1; 656 | } 657 | 658 | 659 | table td, table th{ 660 | text-align: center; 661 | padding: .3em .5em; 662 | border-top: 1px solid #d1d1d1; 663 | border-right: 1px solid #d1d1d1; 664 | } 665 | 666 | table th{ 667 | background-color: #d1d1d1; 668 | border-bottom: 2px solid #d1d1d1; 669 | } 670 | 671 | table tr.odd{ 672 | background-color: #E2E2E2; 673 | } 674 | 675 | table tr:hover{ 676 | background: #E2E2E2; 677 | } 678 | 679 | #column { 680 | float: left; 681 | width: 540px; 682 | margin-top: 5px; 683 | margin-right: 20px; 684 | background: #fff; 685 | } 686 | 687 | .post { 688 | margin-top: 10px; 689 | } 690 | .post-top { 691 | width: 540px; 692 | height: 10px; 693 | } 694 | 695 | .post-bottom { 696 | width: 540px; 697 | height: 10px; 698 | } 699 | 700 | .entry { 701 | background: #FFF; 702 | } 703 | 704 | .entry h2 { 705 | padding-left: 15px; 706 | padding-right: 15px; 707 | padding-top: 5px; 708 | line-height: 1.3em; 709 | font-size: 20px; 710 | font-weight: bold; 711 | } 712 | 713 | .entry h2 a { 714 | line-height: 1.3em; 715 | font-size: 20px; 716 | color: #006178; 717 | font-weight: bold; 718 | } 719 | 720 | .entry .date { 721 | display: block; 722 | margin-left: 15px; 723 | margin-right: 15px; 724 | color: #999; 725 | padding-bottom: 5px; 726 | font-size: 0.7em; 727 | line-height: 1.3em; 728 | } 729 | 730 | .comments a:hover{ 731 | color: #006178; 732 | } 733 | 734 | /* -- ALIGNMENTS --*/ 735 | img.alignright { 736 | float:right; 737 | clear:none; 738 | margin:0 0 1em 1em; 739 | } 740 | img.alignleft { 741 | float:left; 742 | clear:none; 743 | margin:0 1em 1em 0; 744 | } 745 | img.aligncenter { 746 | display: block; 747 | margin:1em auto; 748 | text-align:center; 749 | } 750 | img.alignnone { 751 | margin:0 0.5em 0 0; 752 | } 753 | 754 | /* -- NAVIGATION --*/ 755 | div.navigation { 756 | width:100%; 757 | height:auto; 758 | float:left; 759 | clear:both; 760 | padding: 10px 0px; 761 | } 762 | 763 | .navigation-index { 764 | } 765 | 766 | .nav-next { 767 | float:right; 768 | clear:none; 769 | width:48%; 770 | text-align:right; 771 | } 772 | 773 | pre { 774 | font-size: 90%; 775 | line-height: 1.1em; 776 | } 777 | 778 | .nav-prev { 779 | float:left; 780 | clear:none; 781 | width:48%; 782 | text-align:left; 783 | } 784 | 785 | .wp-caption { 786 | background-color:#EEE; 787 | border: 1px solid #E7E8E6; 788 | -moz-border-radius: 4px; 789 | padding-top:5px; 790 | margin:4px 10px; 791 | text-align:center; 792 | color: #8d8b8b; 793 | } 794 | 795 | .wp-caption img, .post .wp-caption img{ 796 | margin: 0; 797 | border: 0; 798 | padding: 0; 799 | } 800 | 801 | .wp-caption.alignleft{ 802 | margin-left: 0px; 803 | } 804 | 805 | .wp-caption.alignright{ 806 | margin-right: 0; 807 | } 808 | 809 | /** WIDGETS CSS */ 810 | 811 | .widget{ 812 | margin: 1em 0 1.8em 0; 813 | } 814 | 815 | .widget ul ul{ 816 | margin: .4em 0 1em .8em; 817 | } 818 | 819 | /*-- sidebar begins-- */ 820 | 821 | #sidebar h2, h3.widgettitle { 822 | text-align:right; 823 | font-style:oblique; 824 | border-bottom: 1px solid #999; 825 | } 826 | 827 | #sidebar ul, #sidebar ul ol { 828 | margin: 5px; 829 | padding: 0; 830 | } 831 | 832 | #sidebar ul li { 833 | list-style: none; 834 | list-style-image:none; 835 | margin-bottom: 10px; 836 | } 837 | 838 | #sidebar ul li ul li { 839 | margin-left: 2px; 840 | } 841 | 842 | #sidebar ul li ul li a, .widget ul li a{ 843 | padding-top: 5px; 844 | padding-bottom: 4px; 845 | padding-left:14px; 846 | background:url(/images/arrow.png) 0 6px no-repeat; 847 | margin-bottom: 1px; 848 | } 849 | 850 | #sidebar ul li.recentcomments a { 851 | background-image: none; 852 | padding-left: 0; 853 | } 854 | 855 | #sidebar ul li.recentcomments { 856 | background: url(/images/arrow.png) left center no-repeat; 857 | padding-left: 1.5em; 858 | } 859 | 860 | #sidebar ul p, #sidebar ul select { 861 | margin: 5px 0 8px; 862 | } 863 | 864 | #sidebar ul ul, #sidebar ul ol { 865 | margin: 5px 0 0 0px; 866 | } 867 | 868 | #sidebar ul ul ul, #sidebar ul ol { 869 | margin: 0 0 0 10px; 870 | } 871 | 872 | #sidebar ul ol li { 873 | list-style: decimal outside; 874 | } 875 | 876 | #sidebar ul ul li, #sidebar ul ol li { 877 | margin: 3px 0 0; 878 | padding: 0; 879 | } 880 | /*-- Sidebar end --*/ 881 | 882 | 883 | /* sidebar search */ 884 | #searchtab{ 885 | background: transparent url(/images/search-bg.png) no-repeat left top; 886 | } 887 | 888 | #searchtab .inside{ 889 | background: transparent url(/images/search-go.png) no-repeat right top; 890 | height: 30px; 891 | position: relative; 892 | } 893 | 894 | input#searchbox { 895 | width: 64%; 896 | overflow:hidden; 897 | border: 0; 898 | background: none; 899 | font-size: 12px; 900 | padding: 0px; 901 | } 902 | 903 | #searchtab input{ 904 | border: 0; 905 | background: none; 906 | font-size: 12px; 907 | padding: 0px; 908 | } 909 | 910 | #searchtab input.searchfield, #searchtab input#s{ 911 | position: absolute; 912 | top: 5px; 913 | left: 30px; 914 | color: #383838; 915 | padding: 1px 6px; 916 | margin: 0; 917 | } 918 | 919 | #searchtab input.searchfield:focus, #searchtab input#s:focus{ 920 | color: #111; 921 | } 922 | 923 | #searchtab input.searchbutton, #searchtab input#searchsubmit{ 924 | position: absolute; 925 | right: 5px; 926 | top: 5px; 927 | color: #D6D6D6; 928 | font-weight:bold; 929 | text-transform: uppercase; 930 | padding: 1px; 931 | margin: 0; 932 | cursor:pointer; 933 | width:65px; 934 | } 935 | 936 | #searchtab label{ 937 | display: none; 938 | } 939 | #searchtab input.searchbutton:hover{ 940 | color: #FFF; 941 | } 942 | 943 | /* Begin Calendar */ 944 | 945 | #wp-calendar { 946 | empty-cells: show; 947 | margin: 10px auto 0; 948 | width: 100%; 949 | } 950 | 951 | #wp-calendar caption { 952 | font-size: 120%; 953 | font-weight:bold; 954 | padding:2px; 955 | margin: 0 0 5px 0; 956 | background: #d1d1d1; 957 | text-align: center; 958 | width: 100%; 959 | } 960 | 961 | #wp-calendar #next a { 962 | padding-right: 10px; 963 | text-align: right; 964 | } 965 | 966 | #wp-calendar #prev a { 967 | padding-left: 10px; 968 | text-align: left; 969 | } 970 | 971 | #wp-calendar a { 972 | display: block; 973 | } 974 | 975 | #wp-calendar td { 976 | padding: 2px 0; 977 | text-align: center; 978 | } 979 | 980 | #wp-calendar td.pad:hover { /* Doesn't work in IE */ 981 | background-color: #fff; 982 | }/* End Calendar */ 983 | 984 | .meta_bot{ 985 | float:left; 986 | padding: 0 10px 0 0px; 987 | } 988 | 989 | .more{ 990 | float:right; 991 | font-weight:bold; 992 | } 993 | 994 | input:focus { 995 | outline: none; 996 | } 997 | 998 | .classname { 999 | text-shadow: #fff 0 0 0; 1000 | } 1001 | 1002 | #pagenavi, 1003 | #postnavi { 1004 | border-top:2px solid #006000; 1005 | margin:20px -5px 10px; 1006 | padding:20px 5px 10px; 1007 | } 1008 | #pagenavi { 1009 | font-size:11px; 1010 | } 1011 | #pagenavi .newer a, 1012 | #postnavi .prev a { 1013 | padding-left:22px; 1014 | float:left; 1015 | height:16px; 1016 | line-height:16px; 1017 | } 1018 | #pagenavi .older a, 1019 | #postnavi .next a { 1020 | padding-right:22px; 1021 | float:right; 1022 | height:16px; 1023 | line-height:16px; 1024 | } 1025 | /* alterbanner_css_start */ 1026 | 1027 | .alterbanner_300X250_on { 1028 | margin: auto; 1029 | padding: 5px 0 15px; 1030 | text-align: center; 1031 | } 1032 | 1033 | .alterbanner_300X250_off { 1034 | display: none; 1035 | } 1036 | 1037 | .alterwords_0X1_off { 1038 | display: none 1039 | } 1040 | 1041 | .alterbanner_728X90_on { 1042 | margin: auto; 1043 | padding: 10px 0 5px 0; 1044 | text-align: center; 1045 | } 1046 | 1047 | .alterbanner_728X90_off { 1048 | display: none; 1049 | } 1050 | 1051 | .alterbanner_0X1_off { 1052 | display: none; 1053 | } 1054 | 1055 | 1056 | 1057 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | 3 | Version 3, 29 June 2007 4 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 13 | 14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 15 | 16 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 17 | 18 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 19 | 20 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 21 | 22 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 23 | 24 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 25 | 26 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 27 | 28 | The precise terms and conditions for copying, distribution and modification follow. 29 | TERMS AND CONDITIONS 30 | 0. Definitions. 31 | 32 | ?This License? refers to version 3 of the GNU General Public License. 33 | 34 | ?Copyright? also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 35 | 36 | ?The Program? refers to any copyrightable work licensed under this License. Each licensee is addressed as ?you?. ?Licensees? and ?recipients? may be individuals or organizations. 37 | 38 | To ?modify? a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a ?modified version? of the earlier work or a work ?based on? the earlier work. 39 | 40 | A ?covered work? means either the unmodified Program or a work based on the Program. 41 | 42 | To ?propagate? a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 43 | 44 | To ?convey? a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 45 | 46 | An interactive user interface displays ?Appropriate Legal Notices? to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 47 | 1. Source Code. 48 | 49 | The ?source code? for a work means the preferred form of the work for making modifications to it. ?Object code? means any non-source form of a work. 50 | 51 | A ?Standard Interface? means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 52 | 53 | The ?System Libraries? of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A ?Major Component?, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 54 | 55 | The ?Corresponding Source? for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 56 | 57 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 58 | 59 | The Corresponding Source for a work in source code form is that same work. 60 | 2. Basic Permissions. 61 | 62 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 63 | 64 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 65 | 66 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | 69 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 70 | 71 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 72 | 4. Conveying Verbatim Copies. 73 | 74 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 75 | 76 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 77 | 5. Conveying Modified Source Versions. 78 | 79 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 80 | 81 | * a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 82 | * b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to ?keep intact all notices?. 83 | * c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 84 | * d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 85 | 86 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an ?aggregate? if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 87 | 6. Conveying Non-Source Forms. 88 | 89 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 90 | 91 | * a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 92 | * b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 93 | * c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 94 | * d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 95 | * e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 96 | 97 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 98 | 99 | A ?User Product? is either (1) a ?consumer product?, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, ?normally used? refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 100 | 101 | ?Installation Information? for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 102 | 103 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 104 | 105 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 106 | 107 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 108 | 7. Additional Terms. 109 | 110 | ?Additional permissions? are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 111 | 112 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 113 | 114 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 115 | 116 | * a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 117 | * b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 118 | * c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 119 | * d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 120 | * e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 121 | * f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 122 | 123 | All other non-permissive additional terms are considered ?further restrictions? within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 124 | 125 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 126 | 127 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 128 | 8. Termination. 129 | 130 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 131 | 132 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 133 | 134 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 135 | 136 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 137 | 9. Acceptance Not Required for Having Copies. 138 | 139 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 140 | 10. Automatic Licensing of Downstream Recipients. 141 | 142 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 143 | 144 | An ?entity transaction? is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 145 | 146 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 147 | 11. Patents. 148 | 149 | A ?contributor? is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's ?contributor version?. 150 | 151 | A contributor's ?essential patent claims? are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, ?control? includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 152 | 153 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 154 | 155 | In the following three paragraphs, a ?patent license? is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To ?grant? such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 156 | 157 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. ?Knowingly relying? means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 158 | 159 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 160 | 161 | A patent license is ?discriminatory? if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 162 | 163 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 164 | 12. No Surrender of Others' Freedom. 165 | 166 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 167 | 13. Use with the GNU Affero General Public License. 168 | 169 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 170 | 14. Revised Versions of this License. 171 | 172 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 173 | 174 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License ?or any later version? applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 175 | 176 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 177 | 178 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 179 | 15. Disclaimer of Warranty. 180 | 181 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ?AS IS? WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 182 | 16. Limitation of Liability. 183 | 184 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 185 | 17. Interpretation of Sections 15 and 16. 186 | 187 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 188 | 189 | END OF TERMS AND CONDITIONS 190 | How to Apply These Terms to Your New Programs 191 | 192 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 193 | 194 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the ?copyright? line and a pointer to where the full notice is found. 195 | 196 | 197 | Copyright (C) 198 | 199 | This program is free software: you can redistribute it and/or modify 200 | it under the terms of the GNU General Public License as published by 201 | the Free Software Foundation, either version 3 of the License, or 202 | (at your option) any later version. 203 | 204 | This program is distributed in the hope that it will be useful, 205 | but WITHOUT ANY WARRANTY; without even the implied warranty of 206 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 207 | GNU General Public License for more details. 208 | 209 | You should have received a copy of the GNU General Public License 210 | along with this program. If not, see . 211 | 212 | Also add information on how to contact you by electronic and paper mail. 213 | 214 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 215 | 216 | Copyright (C) 217 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 218 | This is free software, and you are welcome to redistribute it 219 | under certain conditions; type `show c' for details. 220 | 221 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an ?about box?. 222 | 223 | You should also get your employer (if you work as a programmer) or school, if any, to sign a ?copyright disclaimer? for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 224 | 225 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . 226 | 227 | --------------------------------------------------------------------------------