Package: bangtext
A static site generator, powersmarcyes.comYou run bang from the command line:$ bang command --project-dir=...1 minute getting startedFirst, install bang:$ pip install bangMake a new project:$ bang generate --project-dir=~/bang-quickstartThen compile your new project:$ bang compile --project-dir=~/bang-quickstartAnd start up the development server to take a look at your new project:$ bang serve --project-dir=~/bang-quickstartNow, open a browser and loadlocalhost:8000to see your masterpiece,
that’s it!Setup and ConfigurationA bang site can have any folder structure and bang will check each
folder for a markdown (extension.md) file, if it finds one namedindex.mdit will not treat it like a blog post but just compile the
folder to anindex.htmlfile. If it finds a markdown file with any
other name, then it is considered a blog post with the file’s name being
the title. So, if you have this file structure:project-dir/
  input/
    2014/
      001-this-is-the-slug/
        This is the title of the blog post.mdIt would compile down to a blog post with a titleThis is the title of
the blog postavailable at the uri:/2014/001-this-is-the-slugAny other files (images or whatnot) will just be copied over to their
respective locations.Project DirectoryYour project directory is where all the magic happens. It has to contain
a few folders:input (required)This is where everything you want to be in the final output folder
should go, this includes your blog posts and any other files/folders you
want yourlivestatic site to contain.template (required)This is where all yourJinjatemplates go,
they are used to compile your blog posts to their final form. Bang looks
for a few template files by default for blog posts:post.html- This contains the html for rendering a post’s
permalink page.posts.html- This contains the html for rendering a list of
posts.aux.html- The template for rendering any non-post markdown files
(index.md files)output (optional)This is the default output directory when thecompilecommand is
used with no--output-dirargument.bangfile.py (optional)You can add this file to configure bang when compiling:# /project_dir/bangfile.pyfrombangimportevent@event("config")defconfigure(event_name,conf):conf.name="your site name"conf.description="your site description"conf.host="example.com"Environment configurationIf you don’t want to bother with abangfile.pyin your project
directory, Bang can also be configured using environment variables,
basically, anyBANG_*environment variables wil be put into the
configuration, here are a couple you might want to set:BANG_HOST– the host of your website, this is used to generate
urls and stuff.BANG_SCHEME– the http method to use (eitherhttporhttps).You can also combine a bangfile with the environment, this makes it easy
to have different environments:# /project_dir/bangfile.pyimportosfrombangimportevent@event("config")defconfigure(event_name,conf):conf.name="your site name"conf.description="your site description"# change the host and scheme based on the environmentenv=os.environ.get("BANG_ENV","prod")ifenv=="prod":conf.host="example.com"conf.scheme="https"else:conf.host="localhost"conf.scheme="http"MarkdownFor the most part, Bang uses vanilla markdown, but there are some
enhancements you can take advantage of if you like:Easy FootnotesUsing the^nfootnote will just assign footnotes in order:first[^n] second[^n]

[^n]: this will be assigned to the "first" footnote
[^n]: this will be assigned to the "second" footnoteThat way you don’t have to worry about uniquely naming footnotes since
they are just assigned in order, but if you want to give your footnotes
unique names that works also.Easy linksSimilar to the footnotes, using thenreference name:[first][n]
[second][n]

[n]: http://first.com
[n]: http://second.comEasy imagesIf no title is used, then the alt becomes the title:![this will be the title](path/to/image.jpg)CommandscompileUse this to compile yourproject-dir/inputdirectory to the final
form in theoutput-dirdirectory.Compile your site using the default output directory:$ bang compile --project-dir=...That will place the compiled output toproject-dir/output, you can
also move the output directory to another location:$ bang compile --project-dir=... --output-dir=...serveUse this to fire up a local server so you can see your compiled site.
You can set the port with the--portflag.$ bang server --project-dir=... --port=8000watchThis is designed to be used on the remote server that will host your
site in a cron job, it will try and pull down the code using a git repo,
if there are changes, then it will compile the new changes, since it is
run in cron, you should include the full path:$ /usr/local/bin/bang watch --project-dir=...generateGenerate a site skeleton that you can use as a starting point to your
own bang site, this will take theproject_dirand make sure it
exists (or create it) and then addinputandtemplatedirs along
with skeleton template files.$ bang generate --project-dir=...EventsEvents are callbacks that are fired at specific times.The easiest way to hook these in to your site compiling is to define or
import them into yourbangfile.pyconfiguration file. You can see
examples of how they are used in thebang.pluginsmodule.Events are basically defined like this:frombangimportevent,echo@event("output.finish")defcallback(event_name,site):"""print all the post titles and urls to the screen"""forpinsite.posts:echo.out(p.title)echo.err(p.url)Some Common EventsconfigThis is called right after the bangfile is loaded in order to set
initial global configuration.output.finishThis event is fired after all the posts are compiled, right now it is
used to do things like generating RSS feeds and the sitemap.context.NAMEAnytime the configuration context changes, this event is called, when
the html pages are generated,context.webis the broadcast event,
the feed plugin will broacastcontext.feedand the sitemap plugin
will broadcastcontext.sitemap.frombangimportevent@event("context.web")defcallback(event_name,config):"""allows custom configuration for web context"""passTestingIf you cloned this repo, you can test out bang by running (from the repo
working directory:$ python -m bang generate -d /path/to/testsite/
$ python -m bang compile -d /path/to/testsite/
$ python -m bang serve -d /path/to/testsite/You can also run the unit tests:$ python -m unittest bang_testInstallUse pip:pip install bangtext