Giter Club home page Giter Club logo

static's Introduction

Static is a simple static site generator written in Clojure. For a sample site build using static see nakkaya.com

Features

Static can parse org-mode and markdown files.

Dependencies

Static requires the leiningen build tool. Once installed, you can build Static with the following commands from within the project directory structure:

$ lein deps
$ lein uberjar

Usage

Creating a static site usually involves the following,

  • Set up the basic structure of the site
  • Create some posts
  • Run your site locally to see how it looks
  • Deploy your site

A basic static site usually looks something like this:

.
|-- config.clj
`-- resources
   |-- posts
   |   |-- 2009-04-17-back-up-and-restore-a-mysql-database.markdown
   |   |-- 2010-02-10-a-simple-clojure-irc-client.markdown
   |   `-- 2010-08-02-using-clojure-contrib-generic-interfaces.markdown
   |-- public
   |   `-- 404.html
   |-- site
   |   `-- index.markdown
   `-- templates
       `-- default.clj

An overview of what each of these does:

config.clj

Contains a vector of configuration options.

  • :site-title - Title of the site.
  • :site-description - Description of the site.
  • :site-url - URL of the site.
  • :author-name - Name of the author.
  • :author-email - E-mail address of the author.
  • :copyright-year - Year the pages were created/copyrighted.
  • :in-dir - Directory containing site content by default resources/
  • :out-dir - Directory to save compiled files.
  • :atomic-build - When set, will build the site on a temporary directory first then move that directory to :out-dir.
  • :default-template - Default template to use.
  • :encoding - Encoding to use for read write operations.
  • :posts-per-page - Number of posts in latest post pages.
  • :blog-as-index - If true use blog as index.
  • :emacs - path to emacs if you want to render .org files.
  • :emacs-eval - elisp code to be evaluated on the emacs process.
  • :host - remote host to deploy to.
  • :user - remote username
  • :deploy-dir - Remote directory to deploy to.
  • :rsync - path to rsync if you want to deploy with rsync.

The variables can later be reused (for example in your default template) as:

(:author-name (static.config/config))

posts/

Folder containing posts, the format of these files are important, as named as YEAR-MONTH-DATE-title.MARKDOWN.

public/

Folder containing static data such as images, css, javascript etc. Folder structure will be mirrored exactly.

site/

Folder containing pages that are not posts.

templates/

Folder containing templates that are used to render posts and pages with.

Markup

Supported markup languages,

  • markdown
  • org-mode (via emacs)
  • clojure (hiccup)
  • cssgen
  • html

Setting per page/post settings

Setting the template, title etc, for a page/post is done using a header placed at the top of the file,

org-mode

#+title: Blogging Like a Hacker
#+tags: clojure

Markdown

---
template: temp-en.clj
title: Blogging Like a Hacker
---

Clojure

{:title "Blogging Like a Hacker"}

cssgen

cssgen does not support file-specific settings.

Page/Post Settings

  • template - If set, this specifies the template file to use. Use the layout file name with file extension. Layout files must be placed in the templates directory.
  • title - Override the use of default title.
  • alias - Generates redirect pages for posts with aliases set. ([“/first-alias/index.html”, “/second-alias/index.html”]) Place the full path of the alias (place to redirect from) inside the destination post.

Any other setting you provide can be accessed from within your template.

Installation

You need to place the uberjar lein created to the folder containing config.clj.

Building the site

java -jar static-app.jar --build

Testing the site

You can test the site locally using jetty, which will launch on http://localhost:8080. The site will rebuild if you change any of the source files.

java -jar static-app.jar --watch

In order to run just jetty,

java -jar static-app.jar --jetty

Deploying the site

RSYNC

$ java -jar static-app.jar --rsync

Code

You can grab the latest version from the repo.

For bug reports/fixes/help, see contact.

Any feature requests are also welcome see contact.

License

Copyright (C) 2010 - 2017

BSD 2-Clause License

Copyright (c) 2017, Nurullah Akkaya All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

static's People

Contributors

canassa avatar cndreisbach avatar fconcklin avatar hlatki avatar iantruslove avatar jasperla avatar nakkaya avatar nauhygon avatar rpkarlsson avatar tsiivola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

static's Issues

Documentation: Please Add "Use from Clojars" section

Hi, Nurullah*,

Your project seems very cool. I specially like the fact that it supports several parsing options (still looking for an option that supports MMD, though...).

I have just discovered there is a way to use this code from Clojars. However, there is no mention to this in the documentation. Could you please Add a "Use from Clojars" section?

Also, it would be nice if the README in the repo root was in fact a copy of the MD source of https://nakkaya.com/static.html :-)

Thanks in advance for tackling this, Nurullah!

Best,
Leandro

*@nakkaya

:blog-as-index broken?

Is there any addition magic needed apart from ":blog-as-index true" in config.clj?

I get the following when I try to build my site:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at clojure.lang.LazySeq.sval(LazySeq.java:47)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:450)
at clojure.core$seq.invoke(core.clj:122)
at clojure.core$r.invoke(core.clj:793)
at clojure.core$reverse.invoke(core.clj:806)
at static.core$create_latest_posts.invoke(core.clj:195)
at static.core$create.invoke(core.clj:292)
at static.core$_main.doInvoke(core.clj:325)
at clojure.lang.RestFn.applyTo(RestFn.java:138)
at static.core.main(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at clojure.lang.LazySeq.sval(LazySeq.java:47)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:450)
at clojure.lang.RT.countFrom(RT.java:499)
at clojure.lang.RT.count(RT.java:492)
at clojure.core$partition$fn__3793.invoke(core.clj:2373)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
... 10 more
Caused by: java.lang.NullPointerException
at clojure.lang.Numbers.ops(Numbers.java:1364)
at clojure.lang.Numbers.isPos(Numbers.java:103)
at clojure.core$take$fn__3720.invoke(core.clj:2158)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
... 16 more

documentation update

Hey, I was working on converting the doc to org-mode but there was some trouble with the directory hierarchy. Still, you should check out the updates to the documentation because there are some features currently not mentioned. Particularly:

  • :emacs config key
  • lein as dep and link
  • necessary build commands
  • testing with jetty (java -jar static.jar -j)

link: https://github.com/fconcklin/static/blob/master/readme.org

Fred Concklin

where is the "Public " dir and "Site" dir?

hi.
pls check below.but i don't find the "Public " dir and "Site" dir,where are they?
where is the root dir of the static site?

as3:/static/target# cp static-app.jar static.jar /static/src/static/
as3:
/static/target# cd /static/src/static/
as3:
/static/src/static# ls
config.clj core.clj io.clj static-app.jar static.jar
as3:
/static/src/static# java -jar static-app.jar --build
[+] INFO: Processing Public 0.002 secs
[+] INFO: Processing Site 0.004 secs
[+] INFO: Build took 0.008 secs
as3:/static/src/static# ls
config.clj core.clj html io.clj static-app.jar static.jar
as3:
/static/src/static# ls html
as3:/static/src/static# cd /static/
as3:
/static# ls
project.clj readme.org src target test
as3:
/static# ls target
classes stale static-app.jar static.jar
as3:/static# ls test
static
as3:
/static# ls test/static/
test
as3:/static# ls test/static/test
core.clj dummy_fs.clj
as3:
/static#

Dual licensing

I was wondering if it would be possible to add an other license than EPL. Sadly, some words in EPL makes it incompatible with the GPL (and other licenses).

Would it be possible to license it under a license like LGPL, MIT or the Simplified BSD Licence?

(By the way, thanks for that awesome software)

Code lacks a licence

Most, if not all code of static lacks a proper licence. It is unclear if one may derive works from this code as is.

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.