ssc

A simple static website compiler

npm install ssc
9 downloads in the last week
36 downloads in the last month

Installation

Run npm install ssc -g from your shell. You may need to run it as root, sudo npm install ssc -g.

Usage

Getting Started

To start, generate a new project with ssc init. You will start in your master branch. Initially this branch is empty, it will be populated when you run the deploy process. Switch to the source branch with git checkout source. You can run grunt from anywhere in this branch. The default task will watch for any changes and compile your site. A simple server is spun up on port 8080 which you can access via http://localhost:8080/

Deploying Your Site

Once you are happy with your site, commit all your changes in the source branch. Then, in the root of your project, run ssc deploy. This will switch to your master branch, clean out the folder, and then copy over the contents of your ./public folder in your source branch. From here, run git add . and then git commit -a -m "Your message". Lastly, push your changes to your git repository with git push.

Command Line Flags

SSC has several flags you can use. ssc <flag>

  • build or b: Runs the compiler, be sure to run this command from the root directory of the project.
  • deploy or d: If you are in your source branch, and everything has been added / committed, this will switch to your master branch and check out your ./public folder.
  • init or i: Downloads the SSC starter project from GitHub.

Notes

When using SSC, there are some keywords you should keep in mind.

  • Partials: @partial Is a chunk of code that gets imported into a page. If you do not specify an ID the name of the file will be used.
  • Layout: @layout These are used to define the structure of a page. Automatically set by the folder, can be overwritten in <data> tags.
  • Placing: @place Used in conjunction with @layout to place the content of a page. Automatically set by the folder, can be overwritten in <data> tags.
  • Templates: Are handled by MustacheJS {{}}. Every file is processed for these before being compiled.
  • Data: Is meta data of the file. It will get parsed out and tagged on to the file's object.
  • Import: Anything withing these tags will get executed during the processing step. The scope will be the file object.

Assumptions:

  • You are running git as your version control. Your repository also should have a source branch and a master branch. source houses your un-compiled content, and master is the output of the compilation. SSC is designed to publish easily to git / GitHub.
  • Reading in a folder gives a default layout to all files within the folder. If the folder ends in 's/' (ie: anything plural) the trailing 's/' will be removed. For example, the 'posts/' folder will give a default layout of 'post'
  • Using Mustache.js for templates
  • The assets folder will be copied over untouched to the public folder
  • If you have an .htaccess file in the root directory, it will be copied over to the public directory.
  • All folders will end in a / except the root folder.
  • You have GruntJS installed globally.

Paths...

You can define several variables in the settings.js file. If you leave them as they are when generating an initial site, your site will be compiled to the ./public folder in the root of your project.

TODO

  • When processing links, a '~' will get replaced by the root directory
  • Fix title bug
  • Comments (Disqus)
  • Compilation step for pre-processors?
  • Develop module integration
npm loves you