Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch to JS highlighter

  • Loading branch information...
commit 6881316bbfb35898d3605d74d92ba047d9496e38 1 parent 671f04a
@tdreyno tdreyno authored
Showing with 103 additions and 202 deletions.
  1. +1 −3 Gemfile
  2. +0 −8 config.rb
  3. +2 −2 helpers/guide_helpers.rb
  4. +1 −1  source/.htaccess
  5. +0 −2  source/advanced/dynamic-pages.html.markdown
  6. +0 −7 source/advanced/file-size-optimization.html.markdown
  7. +0 −2  source/advanced/improving-cacheability.html.markdown
  8. +1 −16 source/{extensions → advanced}/localization.html.markdown
  9. +0 −5 source/advanced/pretty-urls.html.markdown
  10. +0 −2  source/advanced/rack-middleware.html.markdown
  11. +0 −2  source/advanced/speeding-up.html.markdown
  12. +0 −13 source/extensions/blog.html.markdown
  13. +0 −13 source/extensions/custom.html.markdown
  14. +1 −2  source/extensions/livereload.html.markdown
  15. +1 −5 source/extensions/remote-api.html.markdown
  16. +0 −10 source/getting-started/welcome.html.markdown
  17. +1 −0  source/javascripts/highlight.pack.js
  18. +4 −0 source/layouts/layout.erb
  19. +0 −3  source/metadata/local-data.html.markdown
  20. +0 −1  source/metadata/sitemap.html.markdown
  21. +0 −1  source/metadata/yaml-frontmatter.html.markdown
  22. +0 −65 source/stylesheets/_pygments/_solarized.scss
  23. +1 −3 source/stylesheets/site.css.scss
  24. +90 −0 source/stylesheets/solarized_light.scss
  25. +0 −18 source/templates/helpers.html.markdown
  26. +0 −1  source/templates/sass-and-compass.html.markdown
  27. +0 −17 source/templates/templates-layouts-partials.html.markdown
View
4 Gemfile
@@ -2,6 +2,4 @@ source :rubygems
gem "redcarpet"
gem "builder"
-gem "middleman", "3.0.0.rc.4"
-gem "rack-codehighlighter", :git => "git://github.com/wbzyl/rack-codehighlighter.git"
-gem "pygments.rb"
+gem "middleman", "3.0.0"
View
8 config.rb
@@ -5,14 +5,6 @@
set :markdown, :tables => true, :autolink => true
set :markdown_engine, :redcarpet
-require 'rack/codehighlighter'
-require "pygments"
-use Rack::Codehighlighter,
- :pygments,
- :element => "pre>code",
- :pattern => /\A:::([-_+\w]+)\s*\n/,
- :markdown => true
-
# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
View
4 helpers/guide_helpers.rb
@@ -23,8 +23,8 @@ def pages_for_group(group_name)
return pages unless group
if group.directory
- pages << sitemap.resources.select { |r|
- r.path.include? group.directory
+ pages << sitemap.resources.select { |r|
+ r.path.include?(group.directory) && !r.data.hidden
}.map do |r|
::Middleman::Util.recursively_enhance({
:title => r.data.title,
View
2  source/.htaccess
@@ -6,12 +6,12 @@ RewriteRule ^guides/frontend-optimization/?$ /advanced/frontend-optimization [R=
RewriteRule ^guides/pretty-urls/?$ /advanced/pretty-urls [R=301,L]
RewriteRule ^guides/rack-middleware/?$ /advanced/rack-middleware [R=301,L]
RewriteRule ^guides/speeding-up/?$ /advanced/speeding-up [R=301,L]
+RewriteRule ^guides/localization/?$ /advanced/localization [R=301,L]
# Extensions
RewriteRule ^guides/blog/?$ /extensions/blog [R=301,L]
RewriteRule ^guides/extensions/?$ /extensions/custom [R=301,L]
RewriteRule ^guides/livereload/?$ /extensions/livereload [R=301,L]
-RewriteRule ^guides/localization/?$ /extensions/localization [R=301,L]
RewriteRule ^guides/remote-api/?$ /extensions/remote-api [R=301,L]
# Getting Started
View
2  source/advanced/dynamic-pages.html.markdown
@@ -6,7 +6,6 @@ title: Dynamic Pages
Middleman has the ability to generate pages which do not have a one-to-one relationship with their template files. What this means is that you can have a single template which generates multiple files based on variables. Here's an example `config.rb` setup:
- :::ruby
["tom", "dick", "harry"].each do |name|
page "/about/#{name}.html", :proxy => "/about/template.html" do
@person_name = name
@@ -22,7 +21,6 @@ When this project is built, four files will be output:
In most cases, you will not want to generate the template itself without the @person_name variable, so you can tell Middleman to ignore it:
- :::ruby
["tom", "dick", "harry"].each do |name|
page "/about/#{name}.html", :proxy => "/about/template.html", :ignore => true do
@person_name = name
View
7 source/advanced/file-size-optimization.html.markdown
@@ -10,7 +10,6 @@ Middleman handles CSS minification and Javascript compression so you don't have
In your `config.rb`, activate the `minify_css` and `minify_javascript` features during the build of your site.
- :::ruby
configure :build do
activate :minify_css
activate :minify_javascript
@@ -20,7 +19,6 @@ If you are already using a compressed file that includes `.min` in its filename,
You can customize how the JavaScript compressor works by setting the `:compressor` option when activating the `:minify_javascript` extension in `config.rb` to a custom instance of Uglifier. See (Uglifier's docs)[https://github.com/lautis/uglifier] for details. For example, you could enable unsafe optimizations and mangle top-level variable names like this:
- :::ruby
set :js_compressor, Uglifier.new(:toplevel => true, :unsafe => true)
If you want to exclude any files from being minified, pass the `:ignore` option when activating these extensions, and give it one or more globs, regexes, or procs that identify the files to ignore. Likewise, you can pass an `:exts` option to change which file extensions are renamed.
@@ -29,7 +27,6 @@ If you want to exclude any files from being minified, pass the `:ignore` option
It's a good idea to [serve compressed files](http://developer.yahoo.com/performance/rules.html#gzip) to user agents that can handle it. Many web servers have the ability to gzip files on the fly, but that requires CPU work every time the file is served, and as a result most servers don't perform the maximum compression. Middleman can produce gripped versions of your HTML, CSS, and JavaScript alongside your regular files, and you can instruct your web server to serve those pre-gzipped files directly. First, enable the `:gzip` extension:
- :::ruby
activate :gzip
Then configure your server to serve those files. If you use Nginx, check out [the gzip_static](http://wiki.nginx.org/NginxHttpGzipStaticModule) module. For Apache, you'll have to do something a little trickier - see [this Gist](https://gist.github.com/2200790) for an example.
@@ -40,17 +37,13 @@ If you also want to compress images on build, you can use the [Middleman Smusher
To install:
- :::bash
gem install middleman-smusher
Then activate in your `config.rb`:
- :::ruby
configure :build do
activate :smusher
end
-
-
[Middleman Smusher extension]: https://github.com/middleman/middleman-smusher
[Yahoo's Smush.it tool]: http://www.smushit.com/ysmush.it/
View
2  source/advanced/improving-cacheability.html.markdown
@@ -10,7 +10,6 @@ To make your website render as quickly as possible, you should serve any assets,
The most effective technique for preventing users from using outdated files is to change the asset's filename every time you change one of your assets. Since that would be a pain to do by hand, Middleman comes with an `:asset_hash` extension that does it for you. First, activate the extension in your `config.rb`:
- :::ruby
activate :asset_hash
Now, refer to your assets as normal, with their original filename. You can use helpers like `image_tag` as well. However, when your site is built, each asset will be produced with a bit of extra text at the end of the filename that is tied to the content of the file, and all of your other files (HTML, CSS, JavaScript, etc) will be changed to reference that unique-ified filename instead of the original one. Now you can serve your assets with a "never expire" policy, but be sure that when you change them, they'll show up as a different filename.
@@ -23,7 +22,6 @@ If you want to exclude any files from being renamed, pass the `:ignore` option w
The second approach is to append a value to the end of URLs that reference your assets. For example, instead of referencing `my_image.png` you'd reference `my_image.png?1234115152`. The extra info at the end of the URL is enough to tell many (but not all) browsers and proxies to cache that file separately from the same file with a different cache buster value. To use this, activate the `:cache_buster` extension in your `config.rb`:
- :::ruby
activate :cache_buster
Now, to use cache-safe URLs, you must use [asset path helpers](http://www.padrinorb.com/api/Padrino/Helpers/AssetTagHelpers.html) like `image_path` or `javascript_include_tag`. Make sure to use [Compass helpers](http://compass-style.org/reference/compass/helpers/urls/) in your SASS too (`image-url`, etc.). For JavaScript, you'll need to make ERb templates like `my script.js.erb` and call asset helpers via ERb tags to output the right values. If you forget one, your users will still get the file (since the copy on the server just has a normal name) but they might not see changes.
View
17 source/extensions/localization.html.markdown → source/advanced/localization.html.markdown
@@ -4,35 +4,26 @@ title: Localization (i18n)
# Localization (i18n)
-Middleman 2.1 ships with an official extension to support basic localization which allows you to build pages for multiple languages with a single set of templates. Simply install the gem:
+The extension provides an api for enabling localization in your `config.rb`:
- :::bash
- gem install middleman-i18n
-
-The extension provides a new api for enabling localization in your `config.rb`:
-
- :::ruby
activate :i18n
By default this will search the `locales` folder in the root of your project for YAML files representing each locale you want to support. The YAML file is a set of keys and values for each string you need to localize in your site. The keys, which is how you will refer to these strings in your templates, must be the same in each locale, but the values will change. Here are two example YAML files.
`locales/en.yml`:
- :::yaml
---
en:
hello: "Hello"
`locales/es.yml`:
- :::yaml
---
es:
hello: "Hola"
Localizable templates live in the `source/localizable` folder by default (see below on how to change this option). Each template in that folder will have access to the `I18n` helper. Using this helper, you can refer to keys from your YAML files and inject the language-specific values into your template. Here's a simple `source/localizable/hello_world.html.erb` template:
- :::erb
<%= I18n.t(:hello) %> World
This would output two files:
@@ -50,7 +41,6 @@ Each individual language is accessible in its own namespaced path. By default, t
You can change this with the `:path` option, but remember: the URL will always include the name of the YAML file:
- :::ruby
activate :i18n, :path => "/langs/:locale/"
Now the paths would be:
@@ -61,7 +51,6 @@ Now the paths would be:
If you are unhappy using the YAML file names as part of your path, you can remap them to different values.
- :::ruby
activate :i18n, :path => "/langs/:locale/",
:lang_map => { :en => :english, :es => :spanish, :fr => :french }
@@ -82,7 +71,6 @@ Let's say we have a file `source/localizable/hello.html.erb`. By default, this w
If we want to rename that file to `hola.html` for Spanish only, we can use the `paths` key in `locales/es.yml`:
- :::yaml
---
es:
hello: "Hola"
@@ -98,7 +86,6 @@ Now, the files would be output as:
By default, the contents of `source/localizable` will be built in multiple languages while the rest of your templates will continue to work normally. The name of this folder can be changed with the `:templates_dir` option:
- :::ruby
# Look in `source/language_specific` instead
activate :i18n, :templates_dir => "language_specific"
@@ -106,7 +93,6 @@ By default, the contents of `source/localizable` will be built in multiple langu
If you'd prefer specify a list of supported languages rather than automatically discovering files in `locales/`, you can use the `:langs` option:
- :::ruby
activate :i18n, :langs => [:en] # Ignore all languages except :en
## Default (Root) Language
@@ -119,7 +105,6 @@ By default, the first language (either specified by `:langs` or discovered in yo
You can change the default or disable mounting a specific language at the root entirely using the `:mount_at_root` option:
- :::ruby
activate :i18n, :mount_at_root => :es # Mount spanish at root instead
# or
activate :i18n, :mount_at_root => false # All languages will be prefixed
View
5 source/advanced/pretty-urls.html.markdown
@@ -14,7 +14,6 @@ This makes sense for a static website, but many find the .html distasteful and w
If you are using a Rack-based web-server, you can use the `Rack::TryStatic` middleware found in the [rack-contrib] project. In your `config.ru` (or Rails Rack configuration), add the following:
- :::ruby
require "rack/contrib/try_static"
use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['.html']
@@ -28,7 +27,6 @@ However, serving your site via Rack somewhat defeats the purpose of generating a
If you are not using a Rack-based web-server, you can use the Directory Indexes feature to tell Middleman to create a folder for each `.html` file and place the built template file as the index of that folder. In your `config.rb`:
- :::ruby
activate :directory_indexes
Now when the above project is built, the `about-us.html.erb` file will be output as `about-us/index.html`. When placed in an Apache compatible web-server, the page would be available at:
@@ -37,19 +35,16 @@ Now when the above project is built, the `about-us.html.erb` file will be output
If you prefer a different file be output, you can use the `index_file` variable. For example, IIS uses default.html:
- :::ruby
set :index_file, "default.html"
Or, you may want a PHP file:
- :::ruby
set :index_file, "index.php"
### Opt-out
If there are pages which you don't want automatically renamed, you can opt-out:
- :::ruby
page "/i-really-want-the-extension.html", :directory_index => false
`page` works with regexes or file globs if you want to turn off indexes for many files at once.
View
2  source/advanced/rack-middleware.html.markdown
@@ -12,7 +12,6 @@ Middleman has full access to Rack Middleware which opens up an expansive univers
This site is written in Middleman and features many code blocks which have syntax highlighting. This syntax highlighting is accomplished outside the scope of Middleman. This site renders `<code>` blocks and then Rack Middleware takes over an enhances those blocks with syntax highlight. The middleware in use is called [`Rack::Codehighlighter`](https://github.com/wbzyl/rack-codehighlighter). Here's how it can be used in your `config.rb`:
- :::ruby
require 'rack/codehighlighter'
require "pygments"
use Rack::Codehighlighter,
@@ -23,7 +22,6 @@ This site is written in Middleman and features many code blocks which have synta
Make sure you add the right dependencies to your `Gemfile` to make those work:
- :::ruby
gem "rack-codehighlighter", :git => "git://github.com/wbzyl/rack-codehighlighter.git"
gem "pygments.rb"
View
2  source/advanced/speeding-up.html.markdown
@@ -14,7 +14,6 @@ The latest version of Ruby, version 1.9.3, is much faster than its predecessor.
Use `therubyracer` which uses the Google Chrome engine to compile Javascript. Using a faster JSON parser can also speed up Javascript minification. In your Gemfile:
- :::ruby
gem 'therubyracer' # faster ExecJS
gem 'oj' # faster JSON
# gem 'yajl-ruby' # if 'oj' doesn't work for you
@@ -25,7 +24,6 @@ Don't forget to run `bundle install`!
Middleman includes `maruku` for rendering Markdown by default, but you can use the `redcarpet` gem for a speed boost (and some nice features):
- :::ruby
# in Gemfile
gem 'redcarpet' # faster ExecJS
View
13 source/extensions/blog.html.markdown
@@ -6,24 +6,20 @@ title: Blogging Extension
Middleman has an official extension to support blogging, articles and tagging. `middleman-blog` ships as an extension and must be installed to use. Simply specify the gem in your `Gemfile`:
- :::ruby
gem "middleman-blog"
Or install it by hand if you're not using Bundler:
- :::bash
gem install middleman-blog
Then activate the extension in your `config.rb`:
- :::ruby
activate :blog do |blog|
# set options on blog
end
Alternatively, you can generate a fresh project already setup for blogging:
- :::bash
middleman init MY_BLOG_PROJECT --template=blog
If you already have a Middleman project, you can re-run `middleman init` with the blog template option to generate the sample [`index.html`](https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/template/source/index.html.erb), [`tag.html`](https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/template/source/tag.html.erb), [`calendar.html`](https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/template/source/calendar.html.erb), and [`feed.xml`](https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/template/source/feed.xml.builder), or you can write those yourself. You can see [what gets generated](https://github.com/middleman/middleman-blog/tree/master/lib/middleman-blog/template/source) on GitHub.
@@ -48,14 +44,12 @@ As a shortcut, you can run `middleman article TITLE` and Middleman will create a
The base path for your blog defaults to `/` (the root of your website) but can be overridden in `config.rb`:
- :::ruby
activate :blog do |blog|
# set options on blog
end
The permalink for viewing your posts can be easily changed as well:
- :::ruby
activate :blog do |blog|
blog.permalink = "blog/:year/:title.html"
end
@@ -68,7 +62,6 @@ By default, articles can be truncated when viewed outside their permalink page.
This can be changed in `config.rb`:
- :::ruby
activate :blog do |blog|
blog.summary_separator = /SPLIT_SUMMARY_BEFORE_THIS/
end
@@ -93,7 +86,6 @@ Now you can find this article listed on `tags/blogging.html`.
This path can be changed in `config.rb`:
- :::ruby
activate :blog do |blog|
blog.taglink = "categories/:tag.html"
end
@@ -112,7 +104,6 @@ In templates, you can use the [`blog_year_path`](http://rubydoc.info/github/midd
You can set a specific [layout](/templates/templates-layouts-partials) to be used for all articles in your `config.rb`:
- :::ruby
activate :blog do |blog|
blog.layout = "blog_layout"
end
@@ -127,7 +118,6 @@ Each [`BlogArticle`](http://rubydoc.info/github/middleman/middleman-blog/master/
For example, the following shows the 5 most-recent articles and their summary:
- :::erb
<% blog.articles[0...5].each do |article| %>
<article>
<h1>
@@ -143,7 +133,6 @@ For example, the following shows the 5 most-recent articles and their summary:
You can also get access to the tag data for a tag archive:
- :::erb
<ul>
<% blog.tags.each do |tag, articles| %>
<li>
@@ -158,7 +147,6 @@ You can also get access to the tag data for a tag archive:
Or similarly for a calendar list:
- :::erb
<ul>
<% blog.articles.group_by {|a| a.date.year }.each do |year, articles| %>
<li>
@@ -174,7 +162,6 @@ Or similarly for a calendar list:
Or if you added a `published` flag to your front matter:
- :::erb
<h1>Published Articles</h1>
<% blog.articles.select {|a| a.page.data[:published] }.each do |article| %>
...
View
13 source/extensions/custom.html.markdown
@@ -8,7 +8,6 @@ Middleman extensions are Ruby classes which can hook into various points of the
The most basic extension looks like:
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -24,7 +23,6 @@ This module must be accessible to your `config.rb` file. Either define it direct
Finally, once your module is included, you must activate it in `config.rb`:
- :::ruby
activate :my_feature
The [`register`](http://rubydoc.info/github/middleman/middleman/master/Middleman/Extensions#register-class_method) method lets you choose the name your extension is activated with. It can also take a block if you want to require files only when your extension is activated.
@@ -33,7 +31,6 @@ In the `MyFeature` extension, the `registered` method will be called as soon as
`activate` can also take an options hash (which are passed to `register`) or a block which can be used to configure your extension.
- :::ruby
module MyFeature
# All the options for this extension
class Options < Struct.new(:foo, :bar); end
@@ -58,7 +55,6 @@ Passing options to `activate` is generally preferred to setting global variables
The [`Middleman::Application`](http://rubydoc.info/github/middleman/middleman/Middleman/Application) class can be used to change global settings (variables using the `set` command) that can be used in your extension.
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -70,7 +66,6 @@ The [`Middleman::Application`](http://rubydoc.info/github/middleman/middleman/Mi
You can also use this ability to create new settings which can be accessed later in your extension.
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -93,7 +88,6 @@ You can also use this ability to create new settings which can be accessed later
Methods available inside `config.rb` as simply class methods of `Middleman::Application`. Let's add a new method to be used in the `config.rb`:
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -115,7 +109,6 @@ By extending the `Middleman::Application` class, available as `app`, we've added
Sometimes you will want to wait until the `config.rb` has been executed to run code. For example, if you rely on the `:css_dir` variable, you should wait until it has been set. For this, we'll use a callback:
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -132,7 +125,6 @@ Sometimes you will want to wait until the `config.rb` has been executed to run c
Similarly, if you're extension relies on variable and settings within Compass to be ready, use the `compass_config` callback.
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -149,7 +141,6 @@ Similarly, if you're extension relies on variable and settings within Compass to
Helpers are methods available inside your template. To add helper methods, we do the following:
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -167,7 +158,6 @@ Helpers are methods available inside your template. To add helper methods, we do
Now, inside your templates, you will have access to a `make_a_link` method. Here's an example using an ERb template:
- :::erb
<h1><%= make_a_link("http://example.com", "Click me") %></h1>
## Request Callback
@@ -176,7 +166,6 @@ The request callback allows you to do processing before Middleman renders the pa
Here's an example:
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -195,7 +184,6 @@ The above sets the `:currently_requested_path` value at the beginning of each re
You can modify or add pages in the [sitemap](/metadata/sitemap) by creating a Sitemap extension. The [`:directory_indexes`](/advanced/pretty-urls) extension uses this feature to reroute normal pages to their directory-index version, and the [blog extension](/extensions/blog/) uses several plugins to generate tag and calendar pages. See [the `Sitemap::Store` class](http://rubydoc.info/github/middleman/middleman/Middleman/Sitemap/Store#register_resource_list_manipulator-instance_method) for more details.
- :::ruby
module MyFeature
class << self
def registered(app)
@@ -227,7 +215,6 @@ You can modify or add pages in the [sitemap](/metadata/sitemap) by creating a Si
This callback is used to execute code after the build process has finished. The [middleman-smusher] extension uses this feature to compress all the images in the build folder after it has been built. It's also conceivable to integrate a deployment script after build.
- :::ruby
module MyFeature
class << self
def registered(app)
View
3  source/extensions/livereload.html.markdown
@@ -1,17 +1,16 @@
---
title: LiveReload
+hidden: true
---
# LiveReload
Middleman provides an official extension to support for the LiveReload browser extension. Simply install the gem:
- :::bash
gem install middleman-livereload
If you have installed [the LiveReload extension] in your browser, you can have Middleman automatically tell the browser to refresh upon changes to your source code. To do this, you will need to start the Middleman server in LiveReload mode:
- :::bash
middleman server --livereload
Now, browsers using the LiveReload extension can connect to Middleman and automatically refresh after you update your code.
View
6 source/extensions/remote-api.html.markdown
@@ -1,5 +1,6 @@
---
title: Remote API Proxy Extension
+hidden: true
---
# Remote API Proxy Extension
@@ -8,25 +9,21 @@ Middleman 2.1 ships with an official extension to support loading remote APIs du
The Remote API Proxy allows you to mount a remote API, Twitter Search for example, inside your domain during development. Simply install the gem:
- :::bash
gem install middleman-proxy
Then activate the extension in your `config.rb`:
- :::ruby
require "middleman-proxy"
activate :proxy
Next, we will mount the Twitter Search API inside our app in `config.rb`:
- :::ruby
proxy "/api_path", :to => "your-api-hostname.com"
proxy "/ssl_api_path", :to => "your-other-api-hostname.com", :secure => true
Finally, from our front-end we can now do local AJAX to get remote search results. Here's an example using jQuery:
- :::javascript
$.get("/twitter/search.json", { q: "@middlemanapp" }, function(data) {
// Handle the search results for @middlemanapp
});
@@ -47,7 +44,6 @@ If you own the API you are connecting to, you can also provide support for CORS
For example, with a Sinatra application:
- :::ruby
headers 'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, PUT, POST, OPTIONS, HEAD, DELETE, PATCH',
'Access-Control-Allow-Headers' => 'Content-Type, Authorization',
View
10 source/getting-started/welcome.html.markdown
@@ -16,7 +16,6 @@ Mac OS X comes prepackaged with both Ruby and Rubygems, however, some of the Mid
Once you have Ruby and RubyGems up and running, execute the following from the command line:
- :::bash
gem install middleman --pre
This will install Middleman, its dependencies and the command-line tools for using Middleman.
@@ -35,7 +34,6 @@ To get started we will need to create a project folder for Middleman to work out
Simply point the command at the folder for your new site and Middleman will build a skeleton project in that folder (or create the folder for you).
- :::bash
middleman init my_new_project
### The Skeleton
@@ -56,26 +54,22 @@ A config.ru file describes how the site should be loaded by a Rack-enabled webse
To include a boilerplate `config.ru` file in your project, add the `--rack` flag to the init command:
- :::bash
middleman init my_new_project --rack
### Project Templates
In addition to the default basic skeleton, Middleman comes with an optional project template based on the [HTML5 Boilerplate] project. Alternative templates can be accessed using the `-t` or `--template` command-line flags. For example, to start a new project based on HTML5 Boilerplate, run this command:
- :::bash
middleman init my_new_boilerplate_project --template=html5
Finally, you can create your own custom template skeletons by creating folders in the `~/.middleman/` folder. For example, I can create a folder at `~/.middleman/mobile/` and fill it with files I intend to use on mobile projects.
If you run middleman init with the help flag, you will see a list of all the possible templates it has detected:
- :::bash
middleman init --help
This will list my custom mobile framework and I can create new projects based on it as before:
- :::bash
middleman init my_new_mobile_project --template=mobile
## The Development Cycle (middleman server)
@@ -86,7 +80,6 @@ The vast majority of time spent using Middleman will be in the Development Cycle
From the command-line, start the preview web-server from inside your project folder:
- :::bash
cd my_project
bundle exec middleman server
@@ -100,7 +93,6 @@ You can stop the preview server from the command-line using CTRL-C.
Running `middleman` without any commands is the same as starting a server.
- :::bash
bundle exec middleman
This will do exactly the same thing as `middleman server`.
@@ -109,7 +101,6 @@ This will do exactly the same thing as `middleman server`.
Under some circumstances(one known case is under Windows, see [here](https://github.com/middleman/middleman/issues/101)), `middleman` might not work as expected, try using a full command instead:
- :::bash
middleman server -p 4567 -e development
Under some circumstances(say if your config file has gone wild), middleman server might not be able to boot itself, and no error output can be seen on the console, don't panic, just try `middleman build` to see the full trace of the problem and fix it.
@@ -118,7 +109,6 @@ Under some circumstances(say if your config file has gone wild), middleman serve
Finally, when you are ready to deliver static code or, in the case of "blog mode", host a static blog, you will need to build the site. Using the command-line, from the project folder, run `middleman build`:
- :::bash
cd my_project
bundle exec middleman build
View
1  source/javascripts/highlight.pack.js
@@ -0,0 +1 @@
+var hljs=new function(){function m(p){return p.replace(/&/gm,"&amp;").replace(/</gm,"&lt;")}function c(r,q,p){return RegExp(q,"m"+(r.cI?"i":"")+(p?"g":""))}function j(r){for(var p=0;p<r.childNodes.length;p++){var q=r.childNodes[p];if(q.nodeName=="CODE"){return q}if(!(q.nodeType==3&&q.nodeValue.match(/\s+/))){break}}}function g(t,s){var r="";for(var q=0;q<t.childNodes.length;q++){if(t.childNodes[q].nodeType==3){var p=t.childNodes[q].nodeValue;if(s){p=p.replace(/\n/g,"")}r+=p}else{if(t.childNodes[q].nodeName=="BR"){r+="\n"}else{r+=g(t.childNodes[q])}}}if(/MSIE [678]/.test(navigator.userAgent)){r=r.replace(/\r/g,"\n")}return r}function a(s){var q=s.className.split(/\s+/);q=q.concat(s.parentNode.className.split(/\s+/));for(var p=0;p<q.length;p++){var r=q[p].replace(/^language-/,"");if(d[r]||r=="no-highlight"){return r}}}function b(p){var q=[];(function(s,t){for(var r=0;r<s.childNodes.length;r++){if(s.childNodes[r].nodeType==3){t+=s.childNodes[r].nodeValue.length}else{if(s.childNodes[r].nodeName=="BR"){t+=1}else{if(s.childNodes[r].nodeType==1){q.push({event:"start",offset:t,node:s.childNodes[r]});t=arguments.callee(s.childNodes[r],t);q.push({event:"stop",offset:t,node:s.childNodes[r]})}}}}return t})(p,0);return q}function l(y,z,x){var r=0;var w="";var t=[];function u(){if(y.length&&z.length){if(y[0].offset!=z[0].offset){return(y[0].offset<z[0].offset)?y:z}else{return z[0].event=="start"?y:z}}else{return y.length?y:z}}function s(C){var D="<"+C.nodeName.toLowerCase();for(var A=0;A<C.attributes.length;A++){var B=C.attributes[A];D+=" "+B.nodeName.toLowerCase();if(B.value!==undefined&&B.value!==false&&B.value!==null){D+='="'+m(B.value)+'"'}}return D+">"}while(y.length||z.length){var v=u().splice(0,1)[0];w+=m(x.substr(r,v.offset-r));r=v.offset;if(v.event=="start"){w+=s(v.node);t.push(v.node)}else{if(v.event=="stop"){var p,q=t.length;do{q--;p=t[q];w+=("</"+p.nodeName.toLowerCase()+">")}while(p!=v.node);t.splice(q,1);while(q<t.length){w+=s(t[q]);q++}}}}return w+m(x.substr(r))}function i(){function p(w,u,x){if(w.compiled){return}var t;if(!x){w.bR=c(u,w.b?w.b:"\\B|\\b");if(!w.e&&!w.eW){w.e="\\B|\\b"}if(w.e){w.eR=c(u,w.e)}}if(w.i){w.iR=c(u,w.i)}if(w.r===undefined){w.r=1}if(w.k){w.lR=c(u,w.l||hljs.IR,true);for(var v in w.k){if(!w.k.hasOwnProperty(v)){continue}if(w.k[v] instanceof Object){t=w.k[v]}else{t=w.k;v="keyword"}for(var s in t){if(!t.hasOwnProperty(s)){continue}w.k[s]=[v,t[s]]}}}if(!w.c){w.c=[]}w.compiled=true;for(var r=0;r<w.c.length;r++){if(w.c[r]=="self"){w.c[r]=w}p(w.c[r],u,false)}if(w.starts){p(w.starts,u,false)}}for(var q in d){if(!d.hasOwnProperty(q)){continue}p(d[q].dM,d[q],true)}}function e(J,D){if(!i.called){i();i.called=true}function z(r,M){for(var L=0;L<M.c.length;L++){if(M.c[L].bR.test(r)){return M.c[L]}}}function w(L,r){if(C[L].e&&C[L].eR.test(r)){return 1}if(C[L].eW){var M=w(L-1,r);return M?M+1:0}return 0}function x(r,L){return L.i&&L.iR.test(r)}function A(O,N){var M=[];for(var L=0;L<O.c.length;L++){M.push(O.c[L].b)}var r=C.length-1;do{if(C[r].e){M.push(C[r].e)}r--}while(C[r+1].eW);if(O.i){M.push(O.i)}return c(N,"("+M.join("|")+")",true)}function s(M,L){var N=C[C.length-1];if(!N.t){N.t=A(N,H)}N.t.lastIndex=L;var r=N.t.exec(M);if(r){return[M.substr(L,r.index-L),r[0],false]}else{return[M.substr(L),"",true]}}function p(N,r){var L=H.cI?r[0].toLowerCase():r[0];var M=N.k[L];if(M&&M instanceof Array){return M}return false}function F(M,O){M=m(M);if(!O.k){return M}var N="";var P=0;O.lR.lastIndex=0;var L=O.lR.exec(M);while(L){N+=M.substr(P,L.index-P);var r=p(O,L);if(r){t+=r[1];N+='<span class="'+r[0]+'">'+L[0]+"</span>"}else{N+=L[0]}P=O.lR.lastIndex;L=O.lR.exec(M)}return N+M.substr(P,M.length-P)}function K(r,M){if(M.sL&&d[M.sL]){var L=e(M.sL,r);t+=L.keyword_count;return L.value}else{return F(r,M)}}function I(M,r){var L=M.cN?'<span class="'+M.cN+'">':"";if(M.rB){q+=L;M.buffer=""}else{if(M.eB){q+=m(r)+L;M.buffer=""}else{q+=L;M.buffer=r}}C.push(M);B+=M.r}function E(O,L,Q){var R=C[C.length-1];if(Q){q+=K(R.buffer+O,R);return false}var M=z(L,R);if(M){q+=K(R.buffer+O,R);I(M,L);return M.rB}var r=w(C.length-1,L);if(r){var N=R.cN?"</span>":"";if(R.rE){q+=K(R.buffer+O,R)+N}else{if(R.eE){q+=K(R.buffer+O,R)+N+m(L)}else{q+=K(R.buffer+O+L,R)+N}}while(r>1){N=C[C.length-2].cN?"</span>":"";q+=N;r--;C.length--}var P=C[C.length-1];C.length--;C[C.length-1].buffer="";if(P.starts){I(P.starts,"")}return R.rE}if(x(L,R)){throw"Illegal"}}var H=d[J];var C=[H.dM];var B=0;var t=0;var q="";try{var y,v=0;H.dM.buffer="";do{y=s(D,v);var u=E(y[0],y[1],y[2]);v+=y[0].length;if(!u){v+=y[1].length}}while(!y[2]);if(C.length>1){throw"Illegal"}return{r:B,keyword_count:t,value:q}}catch(G){if(G=="Illegal"){return{r:0,keyword_count:0,value:m(D)}}else{throw G}}}function f(t){var r={keyword_count:0,r:0,value:m(t)};var q=r;for(var p in d){if(!d.hasOwnProperty(p)){continue}var s=e(p,t);s.language=p;if(s.keyword_count+s.r>q.keyword_count+q.r){q=s}if(s.keyword_count+s.r>r.keyword_count+r.r){q=r;r=s}}if(q.language){r.second_best=q}return r}function h(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"<br>")}return r}function o(u,x,q){var y=g(u,q);var s=a(u);var w,r;if(s=="no-highlight"){return}if(s){w=e(s,y)}else{w=f(y);s=w.language}var p=b(u);if(p.length){r=document.createElement("pre");r.innerHTML=w.value;w.value=l(p,b(r),y)}w.value=h(w.value,x,q);var t=u.className;if(!t.match("(\\s|^)(language-)?"+s+"(\\s|$)")){t=t?(t+" "+s):s}if(/MSIE [678]/.test(navigator.userAgent)&&u.tagName=="CODE"&&u.parentNode.tagName=="PRE"){r=u.parentNode;var v=document.createElement("div");v.innerHTML="<pre><code>"+w.value+"</code></pre>";u=v.firstChild.firstChild;v.firstChild.cN=r.cN;r.parentNode.replaceChild(v.firstChild,r)}else{u.innerHTML=w.value}u.className=t;u.result={language:s,kw:w.keyword_count,re:w.r};if(w.second_best){u.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function k(){if(k.called){return}k.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p<r.length;p++){var q=j(r[p]);if(q){o(q,hljs.tabReplace)}}}function n(){if(window.addEventListener){window.addEventListener("DOMContentLoaded",k,false);window.addEventListener("load",k,false)}else{if(window.attachEvent){window.attachEvent("onload",k)}else{window.onload=k}}}var d={};this.LANGUAGES=d;this.highlight=e;this.highlightAuto=f;this.fixMarkup=h;this.highlightBlock=o;this.initHighlighting=k;this.initHighlightingOnLoad=n;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="\\b(0[xX][a-fA-F0-9]+|(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BINARY_NUMBER_RE="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BINARY_NUMBER_MODE={cN:"number",b:this.BINARY_NUMBER_RE,r:0};this.inherit=function(p,s){var r={};for(var q in p){r[q]=p[q]}if(s){for(var q in s){r[q]=s[q]}}return r}}();hljs.LANGUAGES.bash=function(){var d={"true":1,"false":1};var c={cN:"variable",b:"\\$([a-zA-Z0-9_]+)\\b"};var a={cN:"variable",b:"\\$\\{(([^}])|(\\\\}))+\\}",c:[hljs.CNM]};var f={cN:"string",b:'"',e:'"',i:"\\n",c:[hljs.BE,c,a],r:0};var b={cN:"string",b:"'",e:"'",r:0};var e={cN:"test_condition",b:"",e:"",c:[f,b,c,a,hljs.CNM],k:{literal:d},r:0};return{dM:{k:{keyword:{"if":1,then:1,"else":1,fi:1,"for":1,"break":1,"continue":1,"while":1,"in":1,"do":1,done:1,echo:1,exit:1,"return":1,set:1,declare:1},literal:d},c:[{cN:"shebang",b:"(#!\\/bin\\/bash)|(#!\\/bin\\/sh)",r:10},c,a,hljs.HCM,hljs.CNM,f,b,hljs.inherit(e,{b:"\\[ ",e:" \\]",r:0}),hljs.inherit(e,{b:"\\[\\[ ",e:" \\]\\]"})]}}}();hljs.LANGUAGES.ruby=function(){var c="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var i="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var a={keyword:{and:1,"false":1,then:1,defined:1,module:1,"in":1,"return":1,redo:1,"if":1,BEGIN:1,retry:1,end:1,"for":1,"true":1,self:1,when:1,next:1,until:1,"do":1,begin:1,unless:1,END:1,rescue:1,nil:1,"else":1,"break":1,undef:1,not:1,"super":1,"class":1,"case":1,require:1,yield:1,alias:1,"while":1,ensure:1,elsif:1,or:1,def:1},keymethods:{__id__:1,__send__:1,abort:1,abs:1,"all?":1,allocate:1,ancestors:1,"any?":1,arity:1,assoc:1,at:1,at_exit:1,autoload:1,"autoload?":1,"between?":1,binding:1,binmode:1,"block_given?":1,call:1,callcc:1,caller:1,capitalize:1,"capitalize!":1,casecmp:1,"catch":1,ceil:1,center:1,chomp:1,"chomp!":1,chop:1,"chop!":1,chr:1,"class":1,class_eval:1,"class_variable_defined?":1,class_variables:1,clear:1,clone:1,close:1,close_read:1,close_write:1,"closed?":1,coerce:1,collect:1,"collect!":1,compact:1,"compact!":1,concat:1,"const_defined?":1,const_get:1,const_missing:1,const_set:1,constants:1,count:1,crypt:1,"default":1,default_proc:1,"delete":1,"delete!":1,delete_at:1,delete_if:1,detect:1,display:1,div:1,divmod:1,downcase:1,"downcase!":1,downto:1,dump:1,dup:1,each:1,each_byte:1,each_index:1,each_key:1,each_line:1,each_pair:1,each_value:1,each_with_index:1,"empty?":1,entries:1,eof:1,"eof?":1,"eql?":1,"equal?":1,"eval":1,exec:1,exit:1,"exit!":1,extend:1,fail:1,fcntl:1,fetch:1,fileno:1,fill:1,find:1,find_all:1,first:1,flatten:1,"flatten!":1,floor:1,flush:1,for_fd:1,foreach:1,fork:1,format:1,freeze:1,"frozen?":1,fsync:1,getc:1,gets:1,global_variables:1,grep:1,gsub:1,"gsub!":1,"has_key?":1,"has_value?":1,hash:1,hex:1,id:1,include:1,"include?":1,included_modules:1,index:1,indexes:1,indices:1,induced_from:1,inject:1,insert:1,inspect:1,instance_eval:1,instance_method:1,instance_methods:1,"instance_of?":1,"instance_variable_defined?":1,instance_variable_get:1,instance_variable_set:1,instance_variables:1,"integer?":1,intern:1,invert:1,ioctl:1,"is_a?":1,isatty:1,"iterator?":1,join:1,"key?":1,keys:1,"kind_of?":1,lambda:1,last:1,length:1,lineno:1,ljust:1,load:1,local_variables:1,loop:1,lstrip:1,"lstrip!":1,map:1,"map!":1,match:1,max:1,"member?":1,merge:1,"merge!":1,method:1,"method_defined?":1,method_missing:1,methods:1,min:1,module_eval:1,modulo:1,name:1,nesting:1,"new":1,next:1,"next!":1,"nil?":1,nitems:1,"nonzero?":1,object_id:1,oct:1,open:1,pack:1,partition:1,pid:1,pipe:1,pop:1,popen:1,pos:1,prec:1,prec_f:1,prec_i:1,print:1,printf:1,private_class_method:1,private_instance_methods:1,"private_method_defined?":1,private_methods:1,proc:1,protected_instance_methods:1,"protected_method_defined?":1,protected_methods:1,public_class_method:1,public_instance_methods:1,"public_method_defined?":1,public_methods:1,push:1,putc:1,puts:1,quo:1,raise:1,rand:1,rassoc:1,read:1,read_nonblock:1,readchar:1,readline:1,readlines:1,readpartial:1,rehash:1,reject:1,"reject!":1,remainder:1,reopen:1,replace:1,require:1,"respond_to?":1,reverse:1,"reverse!":1,reverse_each:1,rewind:1,rindex:1,rjust:1,round:1,rstrip:1,"rstrip!":1,scan:1,seek:1,select:1,send:1,set_trace_func:1,shift:1,singleton_method_added:1,singleton_methods:1,size:1,sleep:1,slice:1,"slice!":1,sort:1,"sort!":1,sort_by:1,split:1,sprintf:1,squeeze:1,"squeeze!":1,srand:1,stat:1,step:1,store:1,strip:1,"strip!":1,sub:1,"sub!":1,succ:1,"succ!":1,sum:1,superclass:1,swapcase:1,"swapcase!":1,sync:1,syscall:1,sysopen:1,sysread:1,sysseek:1,system:1,syswrite:1,taint:1,"tainted?":1,tell:1,test:1,"throw":1,times:1,to_a:1,to_ary:1,to_f:1,to_hash:1,to_i:1,to_int:1,to_io:1,to_proc:1,to_s:1,to_str:1,to_sym:1,tr:1,"tr!":1,tr_s:1,"tr_s!":1,trace_var:1,transpose:1,trap:1,truncate:1,"tty?":1,type:1,ungetc:1,uniq:1,"uniq!":1,unpack:1,unshift:1,untaint:1,untrace_var:1,upcase:1,"upcase!":1,update:1,upto:1,"value?":1,values:1,values_at:1,warn:1,write:1,write_nonblock:1,"zero?":1,zip:1}};var d={cN:"yardoctag",b:"@[A-Za-z]+"};var k=[{cN:"comment",b:"#",e:"$",c:[d]},{cN:"comment",b:"^\\=begin",e:"^\\=end",c:[d],r:10},{cN:"comment",b:"^__END__",e:"\\n$"}];var e={cN:"subst",b:"#\\{",e:"}",l:c,k:a};var g=[hljs.BE,e];var f=[{cN:"string",b:"'",e:"'",c:g,r:0},{cN:"string",b:'"',e:'"',c:g,r:0},{cN:"string",b:"%[qw]?\\(",e:"\\)",c:g,r:10},{cN:"string",b:"%[qw]?\\[",e:"\\]",c:g,r:10},{cN:"string",b:"%[qw]?{",e:"}",c:g,r:10},{cN:"string",b:"%[qw]?<",e:">",c:g,r:10},{cN:"string",b:"%[qw]?/",e:"/",c:g,r:10},{cN:"string",b:"%[qw]?%",e:"%",c:g,r:10},{cN:"string",b:"%[qw]?-",e:"-",c:g,r:10},{cN:"string",b:"%[qw]?\\|",e:"\\|",c:g,r:10}];var h={cN:"function",b:"\\bdef\\s+",e:" |$|;",l:c,k:a,c:[{cN:"title",b:i,l:c,k:a},{cN:"params",b:"\\(",e:"\\)",l:c,k:a}].concat(k)};var j={cN:"identifier",b:c,l:c,k:a,r:0};var b=k.concat(f.concat([{cN:"class",b:"\\b(class|module)\\b",e:"$|;",k:{"class":1,module:1},c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+hljs.IR+"::)?"+hljs.IR}]}].concat(k)},h,{cN:"constant",b:"(::)?([A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:f.concat([j]),r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},j,{b:"("+hljs.RSR+")\\s*",c:k.concat([{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[hljs.BE]}]),r:0}]));e.c=b;h.c[1].c=b;return{dM:{l:c,k:a,c:b}}}();hljs.LANGUAGES.javascript={dM:{k:{keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"var":1,"new":1,"function":1,"do":1,"return":1,"void":1,"else":1,"break":1,"catch":1,"instanceof":1,"with":1,"throw":1,"case":1,"default":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1},literal:{"true":1,"false":1,"null":1}},c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM,hljs.CNM,{b:"("+hljs.RSR+"|case|return|throw)\\s*",k:{"return":1,"throw":1,"case":1},c:[hljs.CLCM,hljs.CBLCLM,{cN:"regexp",b:"/",e:"/[gim]*",c:[{b:"\\\\/"}]}],r:0},{cN:"function",b:"\\bfunction\\b",e:"{",k:{"function":1},c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM]}]}]}};hljs.LANGUAGES.css=function(){var a={cN:"function",b:hljs.IR+"\\(",e:"\\)",c:[{eW:true,eE:true,c:[hljs.NM,hljs.ASM,hljs.QSM]}]};return{cI:true,dM:{i:"[=/|']",c:[hljs.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:{"font-face":1,page:1}},{cN:"at_rule",b:"@",e:"[{;]",eE:true,k:{"import":1,page:1,media:1,charset:1},c:[a,hljs.ASM,hljs.QSM,hljs.NM]},{cN:"tag",b:hljs.IR,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[hljs.CBLCLM,{cN:"rule",b:"[^\\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\\s]",starts:{cN:"value",eW:true,eE:true,c:[a,hljs.NM,hljs.QSM,hljs.ASM,hljs.CBLCLM,{cN:"hexcolor",b:"\\#[0-9A-F]+"},{cN:"important",b:"!important"}]}}]}]}]}}}();hljs.LANGUAGES.xml=function(){var b="[A-Za-z0-9\\._:-]+";var a={eW:true,c:[{cN:"attribute",b:b,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:{style:1}},c:[a],starts:{cN:"css",e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:{script:1}},c:[a],starts:{cN:"javascript",e:"<\/script>",rE:true,sL:"javascript"}},{cN:"vbscript",b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},a]}]}}}();hljs.LANGUAGES.coffeescript=function(){var d={keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"new":1,"do":1,"return":1,"else":1,"break":1,"catch":1,"instanceof":1,"throw":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1,"debugger":1,"class":1,"extends":1,"super":1,then:1,unless:1,until:1,loop:2,of:2,by:1,when:2,and:1,or:1,is:1,isnt:2,not:1},literal:{"true":1,"false":1,"null":1,"undefined":1,yes:1,no:1,on:1,off:1},reserved:{"case":1,"default":1,"function":1,"var":1,"void":1,"with":1,"const":1,let:1,"enum":1,"export":1,"import":1,"native":1,__hasProp:1,__extends:1,__slice:1,__bind:1,__indexOf:1}};var a="[A-Za-z$_][0-9A-Za-z$_]*";var b={cN:"subst",b:"#\\{",e:"}",k:d,c:[hljs.CNM,hljs.BINARY_NUMBER_MODE]};var c={cN:"string",b:'"',e:'"',r:0,c:[hljs.BE,b]};var h={cN:"string",b:'"""',e:'"""',c:[hljs.BE,b]};var g={cN:"comment",b:"###",e:"###"};var f={cN:"regexp",b:"///",e:"///",c:[hljs.HCM]};var i={cN:"function",b:a+"\\s*=\\s*(\\(.+\\))?\\s*[-=]>",rB:true,c:[{cN:"title",b:a},{cN:"params",b:"\\(",e:"\\)"}]};var e={cN:"javascript",b:"`",e:"`",eB:true,eE:true,sL:"javascript"};return{dM:{k:d,c:[hljs.CNM,hljs.BINARY_NUMBER_MODE,hljs.ASM,h,c,g,hljs.HCM,f,e,i]}}}();
View
4 source/layouts/layout.erb
@@ -51,6 +51,10 @@
</div>
</div>
+ <%= javascript_include_tag "highlight.pack" %>
+ <%= stylesheet_link_tag "solarized_light" %>
+ <script>hljs.initHighlightingOnLoad();</script>
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/javascripts/jquery-1.7.2.js"><\/script>')</script>
View
3  source/metadata/local-data.html.markdown
@@ -8,7 +8,6 @@ Sometimes it is useful to extract the data content of a page from the rendering.
Here's an example file at `data/people.yml` with the contents:
- :::yaml
friends:
- Tom
- Dick
@@ -16,7 +15,6 @@ Here's an example file at `data/people.yml` with the contents:
Now, anywhere in our template files, we will have access to this data:
- :::erb
<h1>Friends</h1>
<ol>
<% data.people.friends.each do |f| %>
@@ -26,7 +24,6 @@ Now, anywhere in our template files, we will have access to this data:
Which will render:
- :::html
<h1>Friends</h1>
<ol>
<li>Tom</li>
View
1  source/metadata/sitemap.html.markdown
@@ -20,7 +20,6 @@ Each page can also find other pages related to it in the site hierarchy. The `pa
You can use the sitemap information to create new [dynamic pages] from `config.rb` (this is how the [blog extension](/extensions/blog) creates tag pages), but you need to be a little careful, because the sitemap isn't populated until *after* `config.rb` has already been run. To get around this, you need to register a callback for the application's `ready` event. As an example, let's say we've added a "category" element to the [frontmatter] of our pages, and we want to create category pages dynamically for each category. To do that, we'd add this to `config.rb`:
- :::ruby
ready do
sitemap.pages.group_by {|p| p.data["category"] }.each do |category, pages|
page "/categories/#{category}.html", :proxy => "category.html" do
View
1  source/metadata/yaml-frontmatter.html.markdown
@@ -8,7 +8,6 @@ YAML Frontmatter is similar to the [Local YAML Data] feature, except it works on
Let's take a simple ERb template, adding some YAML variables and change the layout for this specific page.
- :::erb
---
layout: "custom"
my_list:
View
65 source/stylesheets/_pygments/_solarized.scss
@@ -1,65 +0,0 @@
-.hll { background-color: #ffffcc }
-.c { color: #93a1a1; font-style: italic } /* Comment */
-.g { color: #d33682 } /* Generic */
-.k { color: #859900 } /* Keyword */
-.l { color: #2aa198 } /* Literal */
-.n { color: #268bd2 } /* Name */
-.cm { color: #93a1a1; font-style: italic } /* Comment.Multiline */
-.cp { color: #93a1a1; font-style: italic } /* Comment.Preproc */
-.c1 { color: #93a1a1; font-style: italic } /* Comment.Single */
-.cs { color: #93a1a1; font-style: italic } /* Comment.Special */
-.gd { color: #d33682 } /* Generic.Deleted */
-.ge { color: #d33682 } /* Generic.Emph */
-.gr { color: #d33682 } /* Generic.Error */
-.gh { color: #d33682 } /* Generic.Heading */
-.gi { color: #d33682 } /* Generic.Inserted */
-.go { color: #d33682 } /* Generic.Output */
-.gp { color: #d33682 } /* Generic.Prompt */
-.gs { color: #d33682 } /* Generic.Strong */
-.gu { color: #d33682 } /* Generic.Subheading */
-.gt { color: #d33682 } /* Generic.Traceback */
-.kc { color: #859900; font-weight: bold } /* Keyword.Constant */
-.kd { color: #859900 } /* Keyword.Declaration */
-.kn { color: #dc322f; font-weight: bold } /* Keyword.Namespace */
-.kp { color: #859900 } /* Keyword.Pseudo */
-.kr { color: #859900 } /* Keyword.Reserved */
-.kt { color: #859900; font-weight: bold } /* Keyword.Type */
-.ld { color: #2aa198 } /* Literal.Date */
-.m { color: #2aa198; font-weight: bold } /* Literal.Number */
-.s { color: #2aa198 } /* Literal.String */
-.na { color: #268bd2 } /* Name.Attribute */
-.nb { color: #cb4b16 } /* Name.Builtin */
-.nc { color: #cb4b16 } /* Name.Class */
-.no { color: #268bd2 } /* Name.Constant */
-.nd { color: #268bd2 } /* Name.Decorator */
-.ni { color: #268bd2 } /* Name.Entity */
-.ne { color: #268bd2 } /* Name.Exception */
-.nf { color: #268bd2 } /* Name.Function */
-.nl { color: #268bd2 } /* Name.Label */
-.nn { color: #268bd2 } /* Name.Namespace */
-.nx { color: #268bd2 } /* Name.Other */
-.py { color: #268bd2 } /* Name.Property */
-.nt { color: #268bd2; font-weight: bold } /* Name.Tag */
-.nv { color: #268bd2 } /* Name.Variable */
-.ow { color: #859900 } /* Operator.Word */
-.w { color: #586e75 } /* Text.Whitespace */
-.mf { color: #2aa198; font-weight: bold } /* Literal.Number.Float */
-.mh { color: #2aa198; font-weight: bold } /* Literal.Number.Hex */
-.mi { color: #2aa198; font-weight: bold } /* Literal.Number.Integer */
-.mo { color: #2aa198; font-weight: bold } /* Literal.Number.Oct */
-.sb { color: #2aa198 } /* Literal.String.Backtick */
-.sc { color: #2aa198 } /* Literal.String.Char */
-.sd { color: #2aa198 } /* Literal.String.Doc */
-.s2 { color: #2aa198 } /* Literal.String.Double */
-.se { color: #2aa198 } /* Literal.String.Escape */
-.sh { color: #2aa198 } /* Literal.String.Heredoc */
-.si { color: #2aa198 } /* Literal.String.Interpol */
-.sx { color: #2aa198 } /* Literal.String.Other */
-.sr { color: #2aa198 } /* Literal.String.Regex */
-.s1 { color: #2aa198 } /* Literal.String.Single */
-.ss { color: #2aa198 } /* Literal.String.Symbol */
-.bp { color: #cb4b16 } /* Name.Builtin.Pseudo */
-.vc { color: #268bd2 } /* Name.Variable.Class */
-.vg { color: #268bd2 } /* Name.Variable.Global */
-.vi { color: #268bd2 } /* Name.Variable.Instance */
-.il { color: #2aa198; font-weight: bold } /* Literal.Number.Integer.Long */
View
4 source/stylesheets/site.css.scss
@@ -12,7 +12,7 @@ $blueprint-grid-columns: 22;
@import "blueprint";
@include blueprint-typography;
-tt, code {
+tt {
font-size: .95em;
background: #F8F8F8;
@include border-radius(4px);
@@ -109,8 +109,6 @@ aside {
}
}
-@import "_pygments/solarized";
-
footer {
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
font-size: 10px;
View
90 source/stylesheets/solarized_light.scss
@@ -0,0 +1,90 @@
+/*
+
+Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
+
+*/
+
+/*pre code {
+ display: block; padding: 0.5em;
+ background: #fdf6e3; color: #657b83;
+}*/
+
+pre .comment,
+pre .template_comment,
+pre .diff .header,
+pre .doctype,
+pre .lisp .string,
+pre .javadoc {
+ color: #93a1a1;
+ font-style: italic;
+}
+
+pre .keyword,
+pre .css .rule .keyword,
+pre .winutils,
+pre .javascript .title,
+pre .method,
+pre .addition,
+pre .css .tag,
+pre .lisp .title {
+ color: #859900;
+}
+
+pre .number,
+pre .command,
+pre .string,
+pre .tag .value,
+pre .phpdoc,
+pre .tex .formula,
+pre .regexp,
+pre .hexcolor {
+ color: #2aa198;
+}
+
+pre .title,
+pre .localvars,
+pre .function .title,
+pre .chunk,
+pre .decorator,
+pre .builtin,
+pre .built_in,
+pre .lisp .title,
+pre .identifier,
+pre .title .keymethods,
+pre .id {
+ color: #268bd2;
+}
+
+pre .attribute,
+pre .variable,
+pre .instancevar,
+pre .lisp .body,
+pre .smalltalk .number,
+pre .constant,
+pre .class .title,
+pre .parent,
+pre .haskell .label {
+ color: #b58900;
+}
+
+pre .preprocessor,
+pre .pi,
+pre .shebang,
+pre .symbol,
+pre .diff .change,
+pre .special,
+pre .keymethods,
+pre .attr_selector,
+pre .important,
+pre .subst,
+pre .cdata {
+ color: #cb4b16;
+}
+
+pre .deletion {
+ color: #dc322f;
+}
+
+pre .tex .formula {
+ background: #eee8d5;
+}
View
18 source/templates/helpers.html.markdown
@@ -10,26 +10,22 @@ Template helpers are methods which can be used in your dynamic templates to simp
Padrino provides a `link_to` function that you can use to make link tags. At its most basic, `link_to` takes the name and URL of a link:
- :::erb
<%= link_to 'My Site', 'http://mysite.com' %>
`link_to` can also take a block, allowing you to provide more complex content for the link:
- :::erb
<%= link_to 'http://mysite.com' do %>
<%= image_tag 'mylogo.png' %>
<% end %>
Middleman enhances the `link_to` helper to be aware of the [sitemap](/metadata/sitemap). If you refer to pages in your source folder (with their file extension minus all the template extensions) then `link_to` will generate the correct link, even if you have extensions like [`:directory_indexes`](/advanced/pretty-urls) on. For example, if you had a file `source/about.html` and `:directory_indexes` on, you could link to it like this:
- :::erb
<%= link_to 'About', '/about.html' %>
Produces: <a href='/about/'>About</a>
You can also refer to source paths relative to your current page. Some people want their links to be relative to the current page. Pass `:relative => true` to `link_to` to get a relative URL.
- :::erb
From within source/foo/index.html.erb, with :directory_indexes on
<%= link_to 'About', '/about.html', :relative => true %>
@@ -37,7 +33,6 @@ You can also refer to source paths relative to your current page. Some people wa
If you want all URLs generated by `link_to` to be relative, add this to `config.rb`:
- :::ruby
set :relative_links, true
You can still override individual links to not be relative by adding `:relative => false`.
@@ -48,14 +43,12 @@ Output helpers are a collection of important methods for managing, capturing and
The `content_for` functionality supports capturing content and then rendering this into a different place such as within a layout. One such example is including assets onto the layout from a template:
- :::erb
<% content_for :assets do %>
<%= stylesheet_link_tag 'index', 'custom' %>
<% end %>
Added to a template, this will capture the includes from the block and allow them to be yielded into the layout:
- :::erb
<head>
<title>Example</title>
<%= stylesheet_link_tag 'style' %>
@@ -66,14 +59,12 @@ This will automatically insert the contents of the block (in this case a stylesh
You can also check if a `content_for` block exists for a given key using `content_for?`:
- :::erb
<% if content_for?(:assets) %>
<div><%= yield_content :assets %></div>
<% end %>
Also supports arguments yielded to the content block
- :::erb
yield_content :head, param1, param2
content_for(:head) { |param1, param2| ...content... }
@@ -83,7 +74,6 @@ Tag helpers are the basic building blocks used to construct html "tags" within a
The tag and `content_tag` are for building arbitrary html tags with a name and specified options. If the tag contains "content" within then `content_tag` is used. For example:
- :::erb
<%= tag :img, :src => "/my_image.png" %>
# => <img src='/my_image.png'>
@@ -94,7 +84,6 @@ The tag and `content_tag` are for building arbitrary html tags with a name and s
The input_tag is used to build tags that are related to accepting input from the user:
- :::ruby
input_tag :text, :class => "demo"
# => <input type='text' class='demo'>
input_tag :password, :value => "secret", :class => "demo"
@@ -104,7 +93,6 @@ The input_tag is used to build tags that are related to accepting input from the
Asset helpers are intended to help insert useful html onto a view template such as hyperlinks, mail_to links, images, stylesheets and javascript. An example of their uses would be on a simple view template:
- :::erb
<html>
<head>
<%= stylesheet_link_tag 'layout' %>
@@ -124,7 +112,6 @@ Asset helpers are intended to help insert useful html onto a view template such
Form helpers are the "standard" form tag helpers you would come to expect when building forms. A simple example of constructing a non-object form would be:
- :::erb
<% form_tag '/destroy', :class => 'destroy-form', :method => 'delete' do %>
<% field_set_tag do %>
<p>
@@ -157,14 +144,12 @@ The four format helpers are `escape_html`, `distance_of_time_in_words`, `time_ag
The `escape_html` and `js_escape_html` function are for taking an html string and escaping certain characters.
`escape_html` will escape ampersands, brackets and quotes to their HTML/XML entities. This is useful to sanitize user content before displaying this on a template. `js_escape_html` is used for passing javascript information from a js template to a javascript function.
- :::ruby
escape_html('<hello>&<goodbye>') # => &lt;hello&gt;&amp;&lt;goodbye&gt;
There is also an alias for `escape_html` called `h` for even easier usage within templates.
Format helpers also includes a number of useful text manipulation functions such as `simple_format`, `pluralize`, `word_wrap`, and `truncate`.
- :::ruby
simple_format("hello\nworld")
# => "<p>hello<br/>world</p>"
pluralize(2, 'person')
@@ -212,7 +197,6 @@ In addition to the helpers provided by Middleman out of the box, you can also ad
To define a helper method, use the `helpers` block in `config.rb`:
- :::ruby
helpers do
def some_method
# ...do something here...
@@ -221,7 +205,6 @@ To define a helper method, use the `helpers` block in `config.rb`:
Alternatively, you can created external Ruby modules which contain helpers and include them. You can put files in the `lib` directory. For example, if you were to extract the above helpers into a file named `lib/custom_helpers.rb`, you could create a module:
- :::ruby
module CustomHelpers
def some_method
# ...do something here...
@@ -230,7 +213,6 @@ Alternatively, you can created external Ruby modules which contain helpers and i
Then in `config.rb`:
- :::ruby
require "lib/custom_helpers"
helpers CustomHelpers
View
1  source/templates/sass-and-compass.html.markdown
@@ -37,7 +37,6 @@ The same styles could also be expressed in the CSS-superset SCSS format in a fil
Both of these files will compile to the following `build/stylesheets/login.css` file:
- :::css
body {
background: white;
color: black; }
View
17 source/templates/templates-layouts-partials.html.markdown
@@ -14,12 +14,10 @@ All template files in Middleman include the extension of that templating languag
To begin, this file would just contain normal HTML:
- :::erb
<h1>Welcome</h1>
If we wanted to get fancy, we could add a loop:
- :::erb
<h1>Welcome</h1>
<ul>
<% 5.times do |num| %>
@@ -63,7 +61,6 @@ Stylus | .styl | ruby-stylus
[Markdown](http://daringfireball.net/projects/markdown/) is a popular template language that is readable even as plain text. Middleman's default Markdown renderer is [Maruku](http://maruku.rubyforge.org/), though [RedCarpet is suggested](/advanced/speeding-up) for speed and extra features. You can customize you Markdown options in `config.rb`:
- :::ruby
set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true,
:autolink => true,
@@ -79,7 +76,6 @@ The most basic layout has some shared content and a `yield` call where templates
Here is an example layout using ERb:
- :::erb
<html>
<head>
<title>My Site</title>
@@ -91,12 +87,10 @@ Here is an example layout using ERb:
Given a page template in ERb:
- :::erb
<h1>Hello World</h1>
The combined final output in HTML will be:
- :::erb
<html>
<head>
<title>My Site</title>
@@ -122,7 +116,6 @@ The default layout file lives in the `source` folder and is called "layout" and
To create a new layout for admin, add another file to your `source` folder called "admin.erb". Let's assume the contents are:
- :::erb
<html>
<head>
<title>Admin Area</title>
@@ -134,14 +127,12 @@ To create a new layout for admin, add another file to your `source` folder calle
Now, you need to specify which pages use this alternative layout. You can do this in two ways. If you want to apply this layout to a large group of pages, you can use the "page" command in your `config.rb`. Let's assume you have a folder called "admin" in your `source` folder and all the templates in admin should use the admin layout. The `config.rb` would look like:
- :::ruby
page "/admin/*", :layout => "admin"
This uses a wildcard in the page path to specify that any page under the admin folder should use the admin layout.
You can also reference pages directly. For example, let's say we have a `login.html.erb` template which lives in the source folder, but should also have the admin layout. Let's use this example page template:
- :::erb
<h1>Login</h1>
<form>
<input type="text" placeholder="Email">
@@ -151,12 +142,10 @@ You can also reference pages directly. For example, let's say we have a `login.h
Now you can specify that this specific page has a custom template like this:
- :::ruby
page "/login.html", :layout => "admin"
Which would make the login page use the admin layout. As an alternative to specifying everything in the `config.rb`, you can set the layout on individual pages in their template file using [Individual Page Configuration]. Here is an example `login.html.erb` page which specifies its own layout.
- :::erb
---
layout: admin
---
@@ -173,7 +162,6 @@ Which would make the login page use the admin layout. As an alternative to speci
In some cases, you may not want to use a layout at all. This can be accomplished by setting the default layout to false in your `config.rb`:
- :::ruby
disable :layout
## Partials
@@ -182,14 +170,12 @@ Partials are a way of sharing content across pages to avoid duplication. Partial
Partial files are prefixed with an underscore and include the templating language extension you are using. Here is an example footer partial named `_footer.erb` that lives in the `source` folder:
- :::erb
<footer>
Copyright 2011
</footer>
Now, we can include this partial in the default layout using the "partial" method:
- :::erb
<html>
<head>
<title>My Site</title>
@@ -202,7 +188,6 @@ Now, we can include this partial in the default layout using the "partial" metho
And in the admin layout:
- :::erb
<html>
<head>
<title>Admin Area</title>
@@ -219,13 +204,11 @@ If you find yourself copying and pasting content into multiple pages or layouts,
After you start using partials, you may find you want to call it in different ways by passing variables. You can do this by:
- :::erb
<%= partial(:paypal_donate_button, :locals => {:amount => 1, :amount_text => "Pay $1"}) %>
<%= partial(:paypal_donate_button, :locals => {:amount => 2, :amount_text => "Pay $2}) %>
Then, within the partial, you can set the text appropriately as follows:
- :::erb
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="amount" type="hidden" value="<%= "#{amount}.00" %>" >
<input type="submit" value=<%= amount_text %> >
Please sign in to comment.
Something went wrong with that request. Please try again.