Git Product home page Git Product logo

benjen's Introduction

Benjen

Benjen is a tiny static blog generator. At its heart is a <100 line Python script, which takes in your templates and blog entries and produces a static site.

Installation

easy_install benjen

Usage

From within a blog directory, simply run benjen and your site's output will be in the directory specified in your config file.

Creating a new blog

Create a new directory with the following structure:

  • yourblog/
    • entries/
    • static/
    • templates/
    • config.yaml

The entries directory contains all your blog entries as Markdown files. These should, however, contain the following lines at the beginning:

#title Entry Title Goes Here
#date YYYY-MM-DD

The templates directory contains Mako templates. There are three templates in use, with the following parameters passed in.

  • index.html -- Used for index pages
    • page -- Current page number
    • pages -- Total number of pages
    • prev -- None or filename to the previous page
    • next -- None or filename to the next page
    • posts -- List of post objects for this page
    • recent_posts -- List of the most recent posts
  • post.html
    • post -- Current post object
  • archive.html
    • posts -- List of all posts

Post objects are dicts containing the following values:

  • title -- Entry title
  • date -- Entry date
  • raw -- Markdown text
  • html -- HTML version
  • link -- Filename for the post

The static directory contains any static data to copy into the output path. This is where you'll want to put your CSS. Note: the Markdown output will be using Pygments for code highlighting, so you'll need to add the appropriate CSS rules for it (see also: https://github.com/richleland/pygments-css).

The config.yaml file describes a dict with the following values:

  • path -- Path for Benjen to output files (this can be absolute or relative from the blog directory)
  • per_page -- How many posts to show per index page
  • recent_posts -- How many elements to put in the recent_posts list for index pages

Git Hook

If you want to generate your blog automatically on your server when you push updates, you can set up a Git repo and hook to do this.

Basic steps:

Once you've done this, you need to add a file called post-receive to barerepo/hooks/ and make it executable. Sample hook:

#!/bin/bash
unset GIT_DIR
cd /path/to/realrepo/blog/directory/
git pull origin master
benjen

When you push to the server's repository, it will automatically pull the latest contents into realrepo and then run Benjen. Make sure you change the repository names/paths accordingly.

That's all!

If you have issues, contact me at [email protected] or use Github's issue tracker.

benjen's People

Contributors

daeken avatar jamieknight avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.