From 358752272d22be4d8ac29b29ef0d63024c41f230 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 29 Apr 2011 17:00:25 -0700 Subject: [PATCH] rename old default template to xhtml, update new default to lean html5 --- lib/middleman/templates.rb | 3 + .../templates/default/views/layout.haml | 16 +++-- .../default/views/stylesheets/site.css.sass | 2 +- lib/middleman/templates/xhtml.rb | 16 +++++ lib/middleman/templates/xhtml/config.ru | 4 ++ lib/middleman/templates/xhtml/config.tt | 68 +++++++++++++++++++ .../templates/xhtml/views/index.html.haml | 4 ++ .../templates/xhtml/views/layout.haml | 13 ++++ .../xhtml/views/stylesheets/site.css.sass | 27 ++++++++ 9 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 lib/middleman/templates/xhtml.rb create mode 100644 lib/middleman/templates/xhtml/config.ru create mode 100755 lib/middleman/templates/xhtml/config.tt create mode 100755 lib/middleman/templates/xhtml/views/index.html.haml create mode 100644 lib/middleman/templates/xhtml/views/layout.haml create mode 100644 lib/middleman/templates/xhtml/views/stylesheets/site.css.sass diff --git a/lib/middleman/templates.rb b/lib/middleman/templates.rb index e97456c2..fb9840ca 100644 --- a/lib/middleman/templates.rb +++ b/lib/middleman/templates.rb @@ -29,6 +29,9 @@ end # Default template require "middleman/templates/default" +# XHMTL template +require "middleman/templates/xhtml" + # HTML5 template require "middleman/templates/html5" diff --git a/lib/middleman/templates/default/views/layout.haml b/lib/middleman/templates/default/views/layout.haml index cd9a5a47..e5a928c3 100644 --- a/lib/middleman/templates/default/views/layout.haml +++ b/lib/middleman/templates/default/views/layout.haml @@ -1,13 +1,21 @@ -!!! Strict -%html{ :xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en" } +!!! 5 +%html{ :lang => "en" } %head - %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %meta{ :charset => "utf-8" } + + / Always force latest IE rendering engine (even in intranet) & Chrome Frame + %meta{ :content => "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible" } + / Comment in layout + = stylesheet_link_tag "site.css" + :javascript // Comment in javascript + = yield_content :head %body{ :class => page_classes } - #frame + + #main{ :role => "main" } = yield \ No newline at end of file diff --git a/lib/middleman/templates/default/views/stylesheets/site.css.sass b/lib/middleman/templates/default/views/stylesheets/site.css.sass index 13e7359c..51fdfcc9 100644 --- a/lib/middleman/templates/default/views/stylesheets/site.css.sass +++ b/lib/middleman/templates/default/views/stylesheets/site.css.sass @@ -21,7 +21,7 @@ $blueprint-grid-margin: 20px a +link-colors($link-color, $link-hover-color, $link-focus-color, $link-active-color, $link-visited-color) -#frame +#main padding: 50px text-align: center +container diff --git a/lib/middleman/templates/xhtml.rb b/lib/middleman/templates/xhtml.rb new file mode 100644 index 00000000..1e3514ec --- /dev/null +++ b/lib/middleman/templates/xhtml.rb @@ -0,0 +1,16 @@ +class Middleman::Templates::Xhtml < Middleman::Templates::Base + def self.source_root + File.join(File.dirname(__FILE__), 'default') + end + + def build_scaffold + template "config.tt", File.join(location, "config.rb") + template "config.ru", File.join(location, "config.ru") + directory "views", File.join(location, "views") + empty_directory File.join(location, "public", options[:css_dir]) + empty_directory File.join(location, "public", options[:js_dir]) + empty_directory File.join(location, "public", options[:images_dir]) + end +end + +Middleman::Templates.register(:xhtml, Middleman::Templates::Xhtml) \ No newline at end of file diff --git a/lib/middleman/templates/xhtml/config.ru b/lib/middleman/templates/xhtml/config.ru new file mode 100644 index 00000000..9820e4d9 --- /dev/null +++ b/lib/middleman/templates/xhtml/config.ru @@ -0,0 +1,4 @@ +require 'rubygems' +require 'middleman' + +run Middleman::Server \ No newline at end of file diff --git a/lib/middleman/templates/xhtml/config.tt b/lib/middleman/templates/xhtml/config.tt new file mode 100755 index 00000000..48506304 --- /dev/null +++ b/lib/middleman/templates/xhtml/config.tt @@ -0,0 +1,68 @@ +# CodeRay syntax highlighting in Haml +# activate :code_ray + +# Automatic sitemaps (gem install middleman-slickmap) +# require "middleman-slickmap" +# activate :slickmap + +# Automatic image dimension calculations +# activate :automatic_image_sizes + +# Per-page layout changes +# With no layout +# page "/path/to/file.html", :layout => false +# With alternative layout +# page "/path/to/file.html", :layout => :otherlayout + +# Helpers +helpers do + def some_helper(*args) + "Helping" + end +end + +<% if options[:css_dir] != "stylesheets" -%> +set :css_dir, "<%= options[:css_dir] -%>" +<% else -%> +# Change the CSS directory +# set :css_dir, "alternative_css_directory" +<% end -%> + +<% if options[:js_dir] != "javascripts" -%> +set :js_dir, "<%= options[:js_dir] -%>" +<% else -%> +# Change the JS directory +# set :js_dir, "alternative_js_directory" +<% end -%> + +<% if options[:images_dir] != "images" -%> +set :images_dir, "<%= options[:images_dir] -%>" +<% else -%> +# Change the images directory +# set :images_dir, "alternative_image_directory" +<% end -%> + +# 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 (gem install middleman-smusher) + # require "middleman-smusher" + # activate :smusher + + # Generate ugly/obfuscated HTML from Haml + # activate :ugly_haml + + # Or use a different image path + # set :http_path, "/Content/images/" +end \ No newline at end of file diff --git a/lib/middleman/templates/xhtml/views/index.html.haml b/lib/middleman/templates/xhtml/views/index.html.haml new file mode 100755 index 00000000..8e4326e8 --- /dev/null +++ b/lib/middleman/templates/xhtml/views/index.html.haml @@ -0,0 +1,4 @@ +- content_for :head do + %title The Middleman! + +%h1 The Middleman is watching. \ No newline at end of file diff --git a/lib/middleman/templates/xhtml/views/layout.haml b/lib/middleman/templates/xhtml/views/layout.haml new file mode 100644 index 00000000..cd9a5a47 --- /dev/null +++ b/lib/middleman/templates/xhtml/views/layout.haml @@ -0,0 +1,13 @@ +!!! Strict +%html{ :xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + / Comment in layout + = stylesheet_link_tag "site.css" + :javascript + // Comment in javascript + = yield_content :head + + %body{ :class => page_classes } + #frame + = yield \ No newline at end of file diff --git a/lib/middleman/templates/xhtml/views/stylesheets/site.css.sass b/lib/middleman/templates/xhtml/views/stylesheets/site.css.sass new file mode 100644 index 00000000..13e7359c --- /dev/null +++ b/lib/middleman/templates/xhtml/views/stylesheets/site.css.sass @@ -0,0 +1,27 @@ +@import "compass" +@import "blueprint" + +$font-color: #2a2a2a +$link-color: #0388a6 +$link-hover-color: #009ce0 +$link-focus-color: $link-color +$link-active-color: $link-color +$link-visited-color: $link-color + +$blueprint-font-family: 'Century Gothic', 'Apple Gothic', 'Helvetica Neue', arial, sans-serif +$blueprint-font-size: 13px +$blueprint-grid-columns: 12 +$blueprint-grid-width: 60px +$blueprint-grid-margin: 20px + ++global-reset + ++blueprint-typography + +a + +link-colors($link-color, $link-hover-color, $link-focus-color, $link-active-color, $link-visited-color) + +#frame + padding: 50px + text-align: center + +container