Simple Compass+HAML webserver - ruby

I love compass (SASS) and HAML. I've been using staticmatic for building static web pages. Staticmatic seams outdated (no updates, bugs). What are the alternatives?
What I would like:
$ preview .
> Server started ad port XXXX
> Now you can use Compass and HAML
:). So... no configuratio, no directory structure, just haml and sass files.

I am currently using Compass/Sass/Haml with middleman. https://github.com/tdreyno/middleman It is very easy to use, and runs a sinatra in the background so you can see your changes live in your web browser.
After you are done editing and previewing your markup it builds static HTML from your stack of Compass/Sass/Haml. See https://github.com/tdreyno/middleman/wiki for usage.
This requires no conf at all except to tell it which templating engines you are using at setup so I think it is exactly what you are looking for.

You can try jekyll. I think it doesn't work with sass and haml out of the box but you can look at plugins

Don't forget Nanoc. While it is a little involved, it has some slightly more powerful features than StaticMatic. It does depend on a directory however. :/

There are just a ton of static generators around, most of them in Ruby. I'm planning to use Frank for the next few static projects.
It uses Tilt to support a ton of template engines
It has a concept of layouts, which go in a separate layouts folder, and templates can have a metadata header, but other than that it's very minimal.

Related

How to compress assets without Rails or Sprockets?

I'm writing a Sinatra app and I'm quite tired of Sprockets (because it's hard to configure and doesn't support some libs). I'm thinking of moving to Compass for stylesheet management but I haven't found anything similar to it when it comes to scripts. Now I can manually compile coffeescript into Javascript and concatenate the resulting files, but how do I compress them for less size? Thank you very much.
You may take a look at Gulp. Here is the good article about using Gulp with Rails (but it would work for Sinatra too).

How do I integrate nanoc and Twitter Bootstrap/Zurb Foundation?

I am making a fairly big website. Mostly on culture of a particular place.
Are static sites a good idea?
How do I integrate nanoc and some framework? There are a couple of github repos on this, but I wanted to this from scratch in order to learn. Otherwise, I am afraid I might not be able to fix something that goes wrong later.
PLease help~
I've recently decided to make a reasonably sized site using nanoc and Zurb Foundation myself, so I can tell you my thoughts on this:
A static site is a good idea in many situations, but they do have obvious limitations (with everything being static!). The typical use of a static generator like nanoc is for a blog, for which most of the limitations aren't a problem (especially with services like Disqus for comments). I personally decided to use nanoc to save hosting/maintenance costs initially (using Amazon S3 to host a static site is cheap and scalable compared to a VPS), because I don't need any of the dynamic stuff yet, and to learn something new!
I've written a few posts on my blog (link in my profile) about how I've integrated foundation from scratch with nanoc. I can't comment for bootstrap, but my steps were:
Use the nanoc tutorial to create a site
Use compass to integrate foundation into your site, by creating a compass.rb that has a require "zurb-foundation" line as well as config for your asset paths (mine is here)
Run a compass install foundation -c compass.rb to populate the foundation stylesheets, images and javascripts into your asset directories
Update your Rules file to include compass, and process the stylesheets accordingly
That is a high-level overview - there's step-by-step detail on my blog if you're interested in going the foundation route.

SASS and Jekyll integration

I'm just wondering if there is a way to integrate SASS into Jekyll. All that I need is an automatic .scss compilation into .css when I launch Jekyll.
I don't see anything wrong with compiling assets when you launch (which I take to mean run) jekyll. The whole point of running jekyll is to pre-compile your site, which is good for performance.
As for asset conversion-- there are many plugins available that focus on this. I like the Jekyll Asset Pipeline gem, which supports any language (e.g. Scss, Less, CoffeeScript, Erb, etc.) and has a bunch of features (e.g. asset tagging, compression, gzipping, etc.) that set it apart. It also seems to be the fastest growing Jekyll-related gem these days, which I take to mean that it is gaining traction in the community.
If you want to keep it as simple as compass watch you can use the Guard gem along with guard-jekyll and guard-compass (and if you like style injection, guard-livereload).
Guard bundles multiple 'watch' actions under a single terminal window, and is much easier to set up than a robust asset pipeline. Install the gems, configure the .guardfile according to the guard-compass and guard-jekyll instructions, cd to your directory and type guard. Any time a relevant file changes your sass files and/or jekyll site will be recompiled.
Native Sass, and CoffeeScript, processing debuted in Jekyll v2.0:
http://jekyllrb.com/docs/assets/#sassscss
Full disclosure: I am the lead dev behind this project.
The easiest way I've seen to setup Sass with Jekyll is with jekyll-compass. This gem will do exactly as you describe: Any time jekyll builds your website (jekyll build, jekyll serve, etc) your Sass will be compiled into the output folder along with the rest of your website. Check out the readme linked above for full usage details.
There's also some work under way currently by the Jekyll guys to get Sass support into the core of Jekyll so that everyone will have at least basic access to Sass and the wonderful feature-set it provides.

Best way to create a blog with static pages in Ruby

I just visited the Static Website Generation on Ruby toolbox and I don't know which of applications listed there is best suited for a little blog engine. Basically I need:
an index page with 1..5 of latest articles with shortened content;
possibility to add few main pages and a menu to access them (breadcrumb optional);
show articles
show/search archives
commenting system - Disqus Ok
tag-list cloud - optional
Look&Feel via layout
Important all content will be translated in 3 languages!
I can host on my own server, so side processing is possible.
Update:
First I'll try nanoc => blog's source on github
I think nanoc worth a try it has everything you specified, even if is not the best ranked on ruby toolbox its actively developed and highly customizable.
nanoc is a tool that runs on your local computer and compiles documents written in formats such as Markdown, Textile, Haml… into a static web site consisting of simple HTML files, ready for uploading to any web server.
and thats true :) I use it for a while not specially for a blog, but it has also helpers for that...
check out jekyll, it should work well for this.
Try my own "serious" - apart from archive search and tag cloud, it has everything you specified, plus the basic install should take you something like 5 minutes on heroku (and maybe 10 on your own server via Rack). It also has syntax highlighting, Disqus comments, Google Analytics and other goodies.
http://github.com/colszowka/serious
gem install serious
Disclaimer: It does not produce static html pages you can upload to your php vhost, though. But it uses caching and is really easy to setup and works on the free plan on heroku.

Fastest and most efficient way of converting **haml** and **scss** files? (Ruby on Windows)

I'm a ruby/haml/sass-beginner. I just installed ruby and rails for windows, haml, and sass (stand alone and plugin for rails).
I know how to convert and haml file into a html file (and vice versa):
haml index.haml > output.html
and how to convert a scss fiel into a css file (and vice versa):
sass --watch style.scss:style.css
I save more time converting scss files because every time I save a scss file the corresponding css file is automatically updated (i think that's the suppose of the watch command)
but for the haml files, I'm still doing it manually (haml index.haml > output.html).
I believe there's other ways to save time converting haml and scss files.
Any suggestions?
When you setup Rails to work with Haml, then start your development server, the Haml in your views get converted into HTML for you on-the-fly, so there's no need to watch for changes to your Haml separately.
However, if you're creating prototypes using just Haml and SCSS and not using the Rails stack at this stage, then there are a couple of useful tools you can use that automatically render your Haml and SCSS on page refresh:
Serve
http://github.com/jlong/serve
StaticMatic
http://github.com/staticmatic/staticmatic
Of these two, Serve is easier to use, but is not as powerful as StaticMatic. With Serve, all you need to do is install it (gem install serve) and type serve at the command line in the directory containing your Haml files. Then point your browser at http://localhost:4000. Full details here.
You can also hook-up Serve to make use of Compass the Sass meta-framework (which is awesome). There's a full tutorial here.
Oh, there's also dynamicmatic now too which might be good as well to look into. Basically similar to staticmatic but with some obvious differences that might be useful. I've used SM quite a lot recently and really like it. Very easy to use, very simple to set up and really does most things I need it to.

Resources