There are two ways of get JUberblog:
You can either choose to download a prebuilt binary or you can build it from scratch.
The prebuilt binary download is here.
If you want to build from source you need some build tools as prerequisites:
First clone the repository:
$ git clone https://github.com/Weltraumschaf/JUberblog.git
Then build the project:
$ cd JUberblog $ mvn clean install
This will install the final binary (juberblog.jar) in the bin/ directory.
Your blog setup will consist of three components:
The basic idea is that you have a data storage where you put the content as Markdown files. Then you use the JUberblog command line tool to generate static HTML from these files. And finally your web server serves these static files.
JUberblog requires a particular directory layout as storage place of your blog content. You may configure this in various ways. But for the first steps you should use the defaults. To create this structure JUberblog provides the install sub command.
Create the initial scaffold directory for your blog data:
$ mkdir -p /where/you/want/to/store/your/blog $ juberblog install -l /where/you/want/to/store/your/blog $ cd /where/you/want/to/store/your/blog
An optional step is making this directory a version controlled repository. If you set up your blog only on a single machine (everything is done on this machine), then this is not necessary. But I recommend it because this gives you the “feature” of versioning of your content. In the examples here Git is used. You may use other tools like Subversion, Mercurial, Darcs etc.
(optional) Make the blog storage directory a repository:
$ git init $ git add -A $ git commit -m "Initial commit."
The scaffolded directory layout consists of four directories:
More information about a particular directory may be found in a README.md in that directory.
IMPORTANT: The configuration.properties must be encoded in iso-8859-1, unless umlauts and other special characters will be screwed.
The configuration file has two kinds of options: Some are basic options for the generated content such as the blog title and description etc. And some which tells JUBerblog where to find the directories where the Markdown files, the template files and the published files are.
To generate HTML from the Markdown files templates are used instead of plain converting it with a processor to HTML. This gives us the ability to assign variables from JUberblog or use other constructs known from template engines (includes, loops, conditional etc.). Under the hood the widely used Freemarker library is used.
All templates are in the scaffold directory templates, unless you configured an other location. There are several template files. There are two kinds of templates:
JUberblog brings some very basic templates to generate the static content. You can change them to adopt the static generated content to your own custom theme.
This is the template file which is used to generate the RSS feed XML. You should only change this template if you know what you do.
The available template variables are:
variable | description |
---|---|
blogTitle | This is the blog title from your configuration. |
link | This is the site URL from your configuration. |
blogDescription | This is the blog description from your configuration. |
lastBuildDate | This is the file creation date as ISO time stamp. |
items | This is a collection of objects representing a blog post. |
The objects in the list items have the properties:
property | description |
---|---|
title | The title of the blog post. |
description | This comes from from the preprocessor directive. |
pubDate | Publishing date in the format Fri, 19 Mar 2010 09:42:24 +0100. |
dcDate | Publishing date in the format 2010-03-19T09:42:24+01:00. |
This is the inner template for blog posts which will be inserted into lauout.ftl to the place where the variable ${content} is placed. All variables which are available in layout.ftl are also available here.
The available template variables are:
The available template variables are:
variable | description |
---|---|
posts | This is a collection of objects representing a blog post. |
The objects in the list posts have the properties:
property | description |
---|---|
link | Direct link to the blog post. |
title | Title of the blog post. |
pubDate | Publishing date as Java date object (formatting). |
This is the outer layout template. JUberblog uses a common pattern named two step layout: This means you have an outer template for the things all sites have in common and inside this template is a second one inserted for the different things. As schema you can imagine it as follows:
+--------------------+ | laout.ftl | | +--------------+ | | | index.ftl/ | | | | post.ftl/ | | | | site.ftl | | | +--------------+ | +--------------------+
The available template variables are:
variable | description |
---|---|
description | This comes from from the preprocessor directive. |
keywords | This comes from from the preprocessor directive. |
encoding | This is the encoding from your configuration. |
baseUrl | This is the site URL from your configuration. |
blogTitle | This is the blog title from your configuration. |
blogDescription | This is the blog description from your configuration. |
content | This is the rendered content from the inner template. |
This is the inner template for blog posts which will be inserted into lauout.ftl to the place where the variable ${content} is placed. All variables which are available in layout.ftl are also available here.
The available template variables are:
The available template variables are:
variable | description |
---|---|
content | The rendered blog post content. |
This is the inner template for blog posts which will be inserted into lauout.ftl to the place where the variable ${content} is placed. All variables which are available in layout.ftl are also available here.
The available template variables are:
variable | description |
---|---|
content | The rendered blog post content. |
This template is used to generate a site map XML for better search engine indexing. You should only change this template if you know what you do.
The available template variables are:
variable | description |
---|---|
encoding | This is the encoding from your configuration. |
urls | This is a collection of objects representing al URLs of your blog. |
The objects in the list urls have the properties:
property | description |
---|---|
loc | The URL of the content. |
lastmod | When the file was last published. |
changefreq | At the moment this is hardcoded to daily for posts and weekly for sites. |
priority | At the moment this is hardcoded to 0.8 for posts and 0.5 for sites. |
This template is used by the create sub command to produce an empty content file for you. It contains a pre processor block (see below) and the title given by the CLI options. There you place your content.
The available template variables are:
variable | description |
---|---|
title | The post/site title. |
Of course you can style your blog with simple CSS. You only have to put the CSS files somewhere in your public folder served by the web server. Recommended and default is public/css. If you prefer another location you must change the link in the layout.ftl.
But you can also use SASS. For this use case there is a directory called sass in the freshly created scaffold data directory. It also brings a a [normalizer][normalizer] script which sets some sane defaults for all browser. To generate CSS you need SASS installed and use this command from your scaffold dir:
$ sassls sassc sass/main.scss public/css/main.css
The content files for posts and sites support a preprocessor directive to add some meta data:
<?juberblog navigation: some navigation description: some description. keywords: some, keywords ?>
The syntax is the same as for XML preprocessor directives. So to start it use <?juberblog and to end the directive use ?>. The directive for JUberblog supports simple key-value pairs. The key must not contain any characters but letters and numbers. The value may contain any character but a colon or newline. The key and the value are separated by a colon. A key value pair is separated by newline. Also obviously you can’t use newlines in the value. The key values will be assigned to the layout template. Description and Keywords are used for the meta tags by default.
The three keys shown in the example above are also used internally for the content generation, but JUberblog will choose sane defaults if you don’t have them in your file.