A python
based static site html
stitcher.
Generate a static site via python
from content-only .html
and .md
pages that are stitched together along with patch (e.g. nav.html
, footer.html
) files onto a main site quilt.html
file.
Assuming the directory structure is set up correctly, quilting is quite easy. Quilt a site located at path/to/site/source/files
from inside python.
from quilt.QuiltingRoom import QuiltingRoom q = QuiltingRoom('path/to/site/source/files') q.quilt()
The project also includes a __main__.py
to execute from command-line.
machine:~ user$ python quilt path/to/site/source/files
TBD, just run from a directory at the moment.
Used to quilt a whole site together.
source
to users directory containing the appropriate files (default output is quilted_
+ source
)config.json
and override default configurationquilt.html
patches/
pages/
, templates/
, and assets/
directoriesposts/
exists and configured to build a blog create [Blog
object]{#Blog}assets/
to outputfavicon.ico
+css
files into one +js
files into one +Quilter
object]{#Quilter}Blog
objectatom
feed and/or rss
feedindex.html
robot.txt
search.json
, a word to url index for typeahead
sitemap.xml
site_files/
config.json
quilt.html
assets/
css/
site.css
bootstrap.css
js/
site.js
jquery.js
imgs/
favicon.png
icon.png
fonts/
pages/
index.html
about.html
blog/
post1.md
post2.html
patches/
quilted_site_files/
index.html
about.html
blog/
post1.html
post2.html
sitemap.xml
sitemapindex.xml
css/
site.css
bootstrap.css
js/
site.js
jquery.js
imgs/
favicon.png
icon.png
fonts/
# default config, overridden by config.json in source directory DEFAULT_CONFIG = { # project variables # ----------------------------------------------------------------------------------- "name" : "some name", # site or project name "domain" : "some_name.com", # site domain "title" : "some default title", # default page title "author" : "you", # site author "email" : "you@some_name.com", # site author's email "description" : "default description", # default page description "keywords" : [], # default page keywords "categories" : [], # page categories "tags" : [], # page tags "changefreq" : "monthly", # sitemap changefreq "priority" : 0.5, # sitemap priority "blogname" : "quilt news", # atom id "atomid" : "randomid", # atom id "rssid" : "randomid", # rss id # configuration # ----------------------------------------------------------------------------------- "local" : False, # use local disk paths as urls (dev) "patchcomment": True, # comment identifying patch "quiltcomment": True, # head comment with page info "assetcomment": True, # comment asset source when combining "pagecomment" : True, # put page variables in head comment "pageobject" : True, # put page variables in js object "copymd" : True, # copy original markdown to output "combinecss" : True, # combine all `css` into one "combinejs" : True, # combine all `js` into one "vendorfycss" : True, # auto add vendor prefixes "minimizecss" : True, # minimize `css` "minimizejs" : True, # minimize `js` "buildindex" : True, # add `index.html` to directories w/o it "buildrobot" : True, # add robot.txt "buildsearch" : True, # build words to url index (for `typeahead`) "buildsitemap": True, # create sitemap "buildblog" : True, # add blog abilities to `posts/` directory "buildatom" : True, # create atom feed "buildrss" : True, # create rss feed "buildicon" : True, # create favicon "iconsizes" : [64, 60, 76, 120, 152], # image sizes to create "spellignore" : ["maths", "codehilite"],# classes to ignore spelling # file and directory names # ----------------------------------------------------------------------------------- "quilt" : "quilt.html", # name of quilt file "patches" : "patches", # patches directory "pages" : "pages", # pages directory "templates" : "templates", # templates directory "assets" : "assets", # assets directory "posts" : "posts", # post directory in `pages/` directory "iconfile" : "icon.png", # image for favicon # file types # ----------------------------------------------------------------------------------- "patch_ext" : ["*.html"], # allowable patch extension "page_ext" : ["*.html", "*.md"], # allowable page extension "template_ext": ["*.html"], # allowable template extension "asset_ext" : ["*.*"] # allowable resource extension }
Used to stitch one page together with a quilt file, patch files, and a page file.
patch#id
tags in quilt with a patch/id.html
filekey: value
page variable header (optional)[A-Za-z0-9_-]+
until :
, value = a string per line (mulitlines become array) until next keyhtml
or markdown
page content<script>
page script (optional)markdown
page if file ends with .md
or .markdown
){{.*}}
, in content with page or site variablesposts/
directory, tags
and categories
variables are linked and appended to page contentalt
attributes for <a>
and <img>
tags# set quilting page defaults page_defaults = { # internal variables used by quilt (auto-generated, but may be used in content) # ----------------------------------------------------------------------------------- "url" : "", # absolure url of page "relativepath" : "", # relative path of page "rootpath" : "", # absolute path of output directory "source" : "", # absolute local path of page source "output" : "", # absolute local path of page output "domain" : config["domain"], # site domain "directory" : "/", # parent directory "patchcomment" : config["patchcomment"], # print comment showing patch source "quiltcomment" : config["quiltcomment"], # print quilt comment in header "pagecomment" : config["pagecomment"], # print page var comment in header "latestpost" : "", # filename of latest post "page_path" : "", # breadcrumb path of post "next_post" : "", # url of next post "next_title" : "", # title of next post "disable_next" : "disabled", # set if last post "last_post" : "", # url of previous post "last_title" : "", # title of last post "disable_last" : "disabled", # set if first post # content page variables (intended to be overriden) # ----------------------------------------------------------------------------------- "name" : config["name"], # site/project name "title" : config["name"], # page title "author" : config["author"], # page author 'email' : config["email"], # page email "description" : config["description"], # page description "categories" : config["categories"], # page categories (for pages in posts/) "tags" : config["tags"], # page tags (for pages in posts/) "keywords" : [], # page keywords = tags + categories "date" : config["now"]["fulldate"] # created date (useful for posts/) }
quilt.html
):§<!doctype html> <html> <head></head> <body> <patch id="nav"></patch> <patch id="page"></patch> <patch id="footer"></patch> <patch id="templates"></patch> <patch id="scripts"></patch> </body> </html>
head.html
):§<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>{{title}}</title> <meta name="author" content="{{author}}"> <meta name="description" content="{{description}}"> <meta name="keywords" content="{{keywords}}"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="favicon" href="apple-touch-icon.png"> <link rel="apple-touch-icon" href="apple-touch-icon.png"> <link rel="stylesheet" href="{{relativepath}}css/bootstrap.css"> <link rel="stylesheet" href="{{relativepath}}css/quilt.css"> <link rel="stylesheet" href="{{relativepath}}css/colorful.css"> </head>
index.html
):§title: quilt project example index.html
description: an example page file with pagevar header, page html, & page script
author: haha
name: this is already defined in a sites variables, this will override it...
uniquepagevar: make a page variable
<div id="page" class="container-fluid"> <div class="jumbotron text-center"> <h1>{{name}}</h1> <p> A <code>python</code> based static site <code>html</code> <em>stitcher</em>. </p> {{uniquepagevar}} </div> </div>
<script> /* unique to this page, NOT inserted with patch#page but appended after global scripts */ alert('page script'); </script>
index.md
):§title: quilt project example index.html
description: an example page file with pagevar header, page html, & page script
author: haha
name: this is already defined in a sites variables, this will override it...
uniquepagevar: make a page variable
{{name}} ========= A `python` based static site `html` _stitcher_. --------------------------------------------------
<script> /* unique to this page, NOT inserted with patch#page but appended after global scripts */ alert('page script'); </script>
Used to add dynamic blog abilities to posts/
directory under pages/
source
to posts/
along with unique or default quilt and patchesQuiltingRoom
loops over pages append page data from Quilter
to Blog
atom
feed and/or rss
feedSee feature+todo.
version | date | note |
---|---|---|
0.1.0 | 03/0½013 | initial release |
0.1.1 | 03/09/2013 | change page variable header from json to key: value plaintext pair |
See news.
Copyright © 2015 Timothy Davenport
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.