Giter Site home page Giter Site logo

haiku's Introduction

haiku

NPM

Another static site generator.

build status Dependency Status

Haiku compiles Markdown, Mustache, and any of your other assets to a static site via a CLI or a Node.js code API. This project is very much still a WIP. If you want to contribute hit me up on github or irc.

Install

With npm do:

npm install haiku -g

Example

API Methods

var haiku = require('haiku')

var h = haiku([src || options])

Create an instance of haiku using the src path or an options object, if the options or src are omitted the defaults described below are applied.

  • src: The source of the project or site, defaults to process.cwd()
  • content-dir: the content directory where the markdown content lives. Defaults to the cwd + '/content'
  • build-dir: where the compiled site will be saved to. Defaults to the cwd + '/build'
  • templates-dir: layouts and additional templates go here, Defaults to the cwd + '/templates'
  • public-dir: static content that does not need to be compiled can be saved, will get merged into the build directory at compile time. Defaults to the cwd + '/public'

h.opt(option[, value])

Sets or gets individual haiku options for this instance. For getting the value of an option:

h.opt('src') //=> /path/to/yoursite.com

For setting values pass in the option name and the value you want it set to:

h.opt('src', '/var/www')

h.get([url || name], callback)

Gets the page with the corresponding url or name. Callsback with error and page arguments.

h.get('/index.html', function(error, page){
  if (err) throw err
  console.log(page)
})

It is also possible to ask for pages by name:

h.get('/my-page.md', function(error, page){
  if (err) throw err
  console.log(page)
})

Contributing

Haiku is an OPEN Source Project so please help out by reporting bugs or forking and opening pull requests when possible.

License (MIT)

Copyright (c) Jason Campbell ("Author")

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.

haiku's People

Contributors

jxson avatar omarcito avatar

Stargazers

Leo avatar João Afonso Martins avatar Bret Comnes avatar Nazeeruddin Ikram avatar node-migrator-bot avatar Thomas avatar  avatar Daniel Yoder avatar

haiku's Issues

Configuration files

For things like:

  • Site title
  • Adding helpers for things like 'x' most recent posts
  • Letting haiku know about baseUrls

Asset Packaging

It would be nice to support...

exposing some of the internal events might help with this, we can have users hook into a 'post build' event which would allow them access to the internals of haiku to create any extra files they might need on the fly

The only other aspect to consider is how to get the layouts to know when to use packaged assets versus un-packaged, for example: compressed versus un-compressed css.

Some things I would like to see:

  • css compression should be smart about converting small background images to data uris
  • automatic png squeezing
  • uglify and bundle js

Use events to update the site index instead of reloading the site

Even though the in progress rewrite will help get rid of this intermittent problem with the server I thought it would be good to keep track

|(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
at [object Object].<anonymous> (events.js:139:15)
at [object Object].once (events.js:160:8)
at /Users/jxson/Code/spire.io/node_modules/haiku/lib/haiku/server.js:60:10
at callbacks (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/lib/router/index.js:272:11)
at param (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/lib/router/index.js:246:11)
at pass (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/lib/router/index.js:45:10)
at next (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/node_modules/connect/lib/http.js:203:15)
at Object.oncomplete (/Users/jxson/Code/spire.io/node_modules/haiku/node_modules/express/node_modules/connect/lib/middleware/static.js:150:11)

haiku ignore

should ignore dotfiles to avoid deploying things like the .gitignore (user and project), or vim swapfiles.

haiku In The Browser

It would be super nice to have haiku available in a small capacity browser side which would expose templates, and pieces of pages to the browser to help create more rich web applications...

As a proof of concept for the spire.io site I have hacked in support in the form of a haiku.json file that gets dumped into the public dir, this isn't ideal and really isn't scalable for larger sites since that file will get huge

Error handling

Error handling should happen through an nice handler that triggers an event and has some detailed info about what happened that the end user will know how to fix

A few small things

  • Content an Page constructors need a note about abs paths
  • Zap require.paths
  • Default layout for things inside site.options.contentDir, override with something like layout: false
  • Methods that require to be run post build should raise errs

command: haiku init

generator for creating a new haiku project which adds some stubs with documentation for getting started

Pages should watch themselves

Original Title: Too many files open

When there are many files opening because of the rendering of a webpage it throws up this error :

if (err) throw err;
^
Error: EMFILE, Too many open files

Markdown

The markdown processor being used in haiku isn't working as well as I had hoped. I would like to see one that supports or better supports:

  • inline html (for things like disqus js, gists, etc.)
  • doesn't nest things below list items
  • allows custom markdown tags to be added (for things like footnotes, or auto linking the site name, etc.)
  • auto anchors headings
  • generates meta info about the markup (for instance something that returns an object to construct a table of contents with)
  • smarty pants support http://daringfireball.net/projects/smartypants/
  • wrapping: wrap & in a span so they can be targeted http://www.alistapart.com/articles/emen

plugin system for parsers

make it easy so parsers can be set up by registering which extensions they operate on and setting a callback for parsing. The default parsers should use this system.

Default template parser

Currently haiku treats anything in site.content as if it were text and needs to be parsed by mustache.

To support the Rocket.ly use case of having everything in content directory (i.e. not needing to have a separate public directory) I think we can add a configuration option like:

defaultTemplateEngine: false

Which would turn off the behavior of assuming mustache is okay to run on any files in the content directory and only use a parser if it is called for in the file's name. So with defaultTemplateEngine set to false a directory like this:

. content
|-- favicon.ico
|-- index.html
`-- about.md.mustache

Would only have the about.md.mustache file run through Mustache and Markdown, the other would be left alone.

Also having a defaultTemplateEngine will allow one to set their default engine to Handlebars for instance once we add support for it and not require the .handlebars extension added to the end of every file

Show the posts as per the most recent date

Write now its been done like in blog.html

<% site.content.blog.posts.pages.sort_by(&:published).reverse[0..7].each do |post| %>

Blog.html

layout: all-posts
title: Blog

published: 2009-01-01

Latest Posts

<% site.content.blog.posts.pages.sort_by(&:published).reverse[0..7].each do |post| %>
  <div class="post box">
    <div class="box-content"> 
      <h4><a href='<%= post.url %>'>{{title}}</a></h4>
      <p class='left date'>{{published}}></p>
      <div class='clear'></div>    
      <p>{{excerpt}}</p>
      <div class="post-footer"> 
        <a href="<%= post.url %>#disqus_thread" class="comment-count" data-disqus-identifier="<%= post.name %>"></a> 
        <a href="<%= post.url %>" class="right">Continue reading &raquo;</a> 
        <div class="clear"><!-- --></div> 
      </div><!-- /.post-footer -->
    </div><!-- /.box -->
  </div><!-- /.post box -->
<% end %>

{{>blog-navigation}}

excerpt support

original title: yaml front matter doesn't allow multiline strings

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.