Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update static site generator from StaticMatic to Middleman #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@
*.rbc
.rvmrc
.DS_Store
site/*.html
site/docs
site/stylesheets
/build
20 changes: 12 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
source :rubygems
source 'https://rubygems.org'

gem 'middleman', '~> 3.0.14'
gem 'haml', '~> 4.0.0'
gem 'haml-contrib'
gem 'compass', '~> 0.12.2'
gem 'rake'
gem 'yard'

gem 'middleman-livereload'
gem 'json', '~> 1.7.7' #required by middleman
gem 'rb-inotify', '~> 0.9'

gem "staticmatic"
gem "maruku"
gem "haml", "3.2.0.rc.1"
gem "haml-contrib"
gem "compass", "0.11.7"
gem "rake", "0.9.3.beta.1"
gem "yard"
133 changes: 114 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,37 +1,132 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
chunky_png (1.2.6)
compass (0.11.7)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
chunky_png (1.2.8)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
fssm (0.2.9)
haml (3.2.0.rc.1)
em-websocket (0.5.0)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.5.3)
eventmachine (1.0.3)
execjs (1.4.0)
multi_json (~> 1.0)
ffi (1.8.1)
fssm (0.2.10)
haml (4.0.3)
tilt
haml-contrib (0.0.1)
haml-contrib (1.0.0)
haml (>= 3.2.0.alpha.13)
hike (1.2.2)
http_parser.rb (0.5.3)
http_router (0.10.2)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
i18n (0.6.1)
json (1.7.7)
listen (0.7.3)
maruku (0.6.1)
syntax (>= 1.0.0)
rack (1.4.1)
rake (0.9.3.beta.1)
sass (3.2.1)
staticmatic (0.11.1)
compass (>= 0.10.0)
haml (>= 2.0.0)
middleman (3.0.14)
middleman-core (= 3.0.14)
middleman-more (= 3.0.14)
middleman-sprockets (~> 3.1.0)
middleman-core (3.0.14)
activesupport (~> 3.2.6)
bundler (~> 1.1)
listen (~> 0.7.3)
rack (~> 1.4.1)
rack-test (~> 0.6.1)
rb-fsevent (~> 0.9.3)
thor (~> 0.15.4)
tilt (~> 1.3.6)
middleman-livereload (3.1.0)
em-websocket (>= 0.2.0)
middleman-core (>= 3.0.2)
multi_json (~> 1.0)
rack-livereload
middleman-more (3.0.14)
coffee-script (~> 2.2.0)
coffee-script-source (~> 1.3.3)
compass (>= 0.12.2)
execjs (~> 1.4.0)
haml (>= 3.1.6)
i18n (~> 0.6.0, < 0.6.2)
maruku (~> 0.6.0)
middleman-core (= 3.0.14)
padrino-helpers (= 0.10.7)
sass (>= 3.1.20)
uglifier (~> 1.2.6)
middleman-sprockets (3.1.1)
middleman-core (>= 3.0.14)
padrino-helpers (= 0.10.7)
sprockets (~> 2.1)
sprockets-helpers (~> 1.0.0)
sprockets-sass (~> 1.0.0)
multi_json (1.7.3)
padrino-core (0.10.7)
activesupport (~> 3.2.0)
http_router (~> 0.10.2)
sinatra (~> 1.3.1)
thor (~> 0.15.2)
tilt (~> 1.3.0)
padrino-helpers (0.10.7)
i18n (~> 0.6)
padrino-core (= 0.10.7)
rack (1.4.5)
rack-livereload (0.3.15)
rack
rack-protection (1.5.0)
rack
rack-test (0.6.2)
rack (>= 1.0)
rake (10.0.4)
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
sass (3.2.9)
sinatra (1.3.6)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
sprockets (2.10.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-helpers (1.0.1)
sprockets (~> 2.0)
sprockets-sass (1.0.1)
sprockets (~> 2.0)
tilt (~> 1.1)
syntax (1.0.0)
tilt (1.3.3)
yard (0.8.2.1)
thor (0.15.4)
tilt (1.3.7)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
url_mount (0.2.1)
rack
yard (0.8.6.1)

PLATFORMS
ruby

DEPENDENCIES
compass (= 0.11.7)
haml (= 3.2.0.rc.1)
compass (~> 0.12.2)
haml (~> 4.0.0)
haml-contrib
maruku
rake (= 0.9.3.beta.1)
staticmatic
json (~> 1.7.7)
middleman (~> 3.0.14)
middleman-livereload
rake
rb-inotify (~> 0.9)
yard
37 changes: 19 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require "bundler/setup"
require 'rake'
require 'date'
Expand All @@ -11,33 +10,35 @@ if defined?(Encoding)
Encoding.default_internal = 'UTF-8'
end

def staticmatic(command)
require '.haml/lib/haml'
require 'staticmatic'
configuration = StaticMatic::Configuration.new
eval(File.read("config/site.rb"))
StaticMatic::Base.new(".", configuration).run(command)
end

desc "Build everything."
task :build => [:site, :yardoc]

desc "Use StaticMatic to build the site."
task(:site => :haml) {staticmatic "build"}
#mostly from https://github.com/middleman/middleman/blob/master/middleman-core/bin/middleman
def middleman(command)
require 'middleman-core/profiling'
Middleman::Profiling.start
require 'middleman-core/load_paths'
Middleman.setup_load_paths
require 'middleman-core/cli'
Middleman::Cli::Base.start([command])
end

desc "Use Middleman to build the site."
task(:site => :haml) { middleman 'build' }

desc "Preview the site with StaticMatic."
task(:preview => :haml) {staticmatic "preview"}
desc "Preview the site with Middleman."
task(:preview => :haml) { middleman 'server' }

desc "Sync files to web server"
task(:sync) { sh "rsync -e 'ssh -p 2233' -avz site/ haml.info:/var/sites/haml.info/"}
task(:sync) { sh "rsync -e 'ssh -p 2233' -avz build/ haml.info:/var/sites/haml.info/"}

desc "Build the YARD documentation."
task :yardoc => :haml do
require 'fileutils'
Dir.chdir(".haml") {sh %{rake doc ANALYTICS=UA-3592613-6 YARD_TITLE="Haml Documentation"}}
FileUtils.mkdir_p("site/docs")
FileUtils.rm_rf("site/docs/yardoc")
FileUtils.mv(".haml/doc", "site/docs/yardoc")
Dir.chdir(".haml") {sh %{bundle exec rake doc ANALYTICS=UA-3592613-6 YARD_TITLE="Haml Documentation"}}
FileUtils.mkdir_p("build/docs")
FileUtils.rm_rf("build/docs/yardoc")
FileUtils.mv(".haml/doc", "build/docs/yardoc")
end

task :haml => ".haml" do
Expand Down
88 changes: 88 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
###
# Compass
###

# Susy grids in Compass
# First: gem install susy
# require 'susy'

# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end

###
# Page options, layouts, aliases and proxies
###

# Per-page layout changes:
#
# With no layout
# page "/path/to/file.html", :layout => false
#
# With alternative layout
# page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end

# Proxy (fake) files
# page "/this-page-has-no-template.html", :proxy => "/template-file.html" do
# @which_fake_page = "Rendering a fake page with a variable"
# end

###
# Helpers
###

# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes

# Methods defined in the helpers block are available in templates
helpers do
def local_page
current_page.url.gsub(/\.html$/, '').gsub(/\/index$/, '').gsub(/^\//, '')
end

def page_title
(["Haml"] + local_page.capitalize.split(File::SEPARATOR)).join(" :: ")
end

def h_and_preserve(content = nil, &block)
return preserve CGI.escapeHTML(content) if content
return h_and_preserve capture_haml(&block).strip
end
end

set :css_dir, 'stylesheets'

set :js_dir, 'javascripts'

set :images_dir, 'images'

activate :livereload

# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
# activate :minify_css

# Minify Javascript on build
# activate :minify_javascript

# Enable cache buster
# activate :cache_buster

# Use relative URLs
# activate :relative_assets

# Compress PNGs after build
# First: gem install middleman-smusher
# require "middleman-smusher"
# activate :smusher

# Or use a different image path
# set :http_path, "/Content/images/"
end
25 changes: 0 additions & 25 deletions config/site.rb

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions source/_header.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%header.cell
= link_to image_tag('haml.png', alt: 'Haml'), '/', class: 'logo'
%ul
%li= link_to 'About', '/about.html'
%li= link_to 'Tutorial', '/tutorial.html'
%li= link_to 'Documentation', '/docs.html'
%li= link_to 'Blog', 'http://haml.tumblr.com/'
%li= link_to 'Help', '/help.html'
4 changes: 4 additions & 0 deletions source/_subnav.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%ul.subnav
%li= link_to 'Download', '/download.html'
%li= link_to 'Editors', '/editors.html'
%li= link_to 'Development', '/development.html'
2 changes: 1 addition & 1 deletion src/pages/about.haml → source/about.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.content
%h1
= img 'img-badge-about.png', alt: 'About'
= image_tag 'img-badge-about.png', alt: 'About'
About
= partial 'subnav'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/development.haml → source/development.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.content
%h1
= img 'img-badge-development.png', alt: 'Development'
= image_tag 'img-badge-development.png', alt: 'Development'
Development
= partial 'subnav'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/docs.haml → source/docs.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.content
%h1
= img 'img-badge-documentation.png', alt: 'Documentation'
= image_tag 'img-badge-documentation.png', alt: 'Documentation'
Documentation
= partial 'subnav'

Expand Down
Loading