Permalink
Browse files

Add website

  • Loading branch information...
1 parent b341095 commit 82840b15548a375d15ff357b13ef161828c461ce @wycats wycats committed Jul 7, 2011
View
@@ -0,0 +1 @@
+require 'nanoc3/tasks'
View
@@ -0,0 +1,100 @@
+#!/usr/bin/env ruby
+
+# A few helpful tips about the Rules file:
+#
+# * The order of rules is important: for each item, only the first matching
+# rule is applied.
+#
+# * Item identifiers start and end with a slash (e.g. “/about/” for the file
+# “content/about.html”). To select all children, grandchildren, … of an
+# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
+# because “*” matches zero or more characters.
+
+require "cgi"
+
+class Nanoc3::Filter
+ class CodeBlocks < Nanoc3::Filter
+ LANGUAGES = { "ruby" => "ruby", "sql" => "sql", "javascript" => "javascript",
+ "css" => "css", "plain" => "plain", "erb" => "ruby; html-script: true",
+ "html" => "xml", "xml" => "xml", "shell" => "plain", "yaml" => "yaml" }
+
+ def run(content, params={})
+ @string = content.dup
+
+ @output = ""
+ @pending = ""
+
+ languages = LANGUAGES.keys.join("|")
+
+ until @string.empty?
+ match = scan_until /(\+(\S.*?\S?)\+|<(#{languages})(?: filename=["']([^"']*)["'])?>|\z)/m
+
+ @pending << match.pre_match
+
+ if match[2] # +foo+
+ @pending << "<notextile><tt>#{CGI.escapeHTML(match[2])}</tt></notextile>" if match[2]
+ elsif match[3] # <language>
+ flush
+ generate_brushes match[3], LANGUAGES[match[3]], match[4]
+ end
+ end
+
+ flush
+
+ @output
+ end
+
+ def scan_until(regex)
+ match = @string.match(regex)
+ return unless match
+ @string = match.post_match
+ match
+ end
+
+ def generate_brushes(tag, replace, filename)
+ match = scan_until %r{</#{tag}>}
+ @output << %{<div class="code_container">\n}
+ @output << %{<div class="filename">#{filename}</div>\n} if filename
+ @output << %{<pre class="brush: #{replace}; gutter: false; toolbar: false">\n} <<
+ CGI.escapeHTML(match.pre_match) << %{</pre></div>}
+ end
+
+ def flush
+ @output << @pending
+ @pending = ""
+ end
+ end
+end
+
+Nanoc3::Filter.register 'CodeBlocks', :code_blocks
+
+
+
+compile '/stylesheets/*' do
+ # don’t filter or layout
+end
+
+compile '/images/*' do
+end
+
+filters = {
+ :markdown => :kramdown
+}
+
+compile '*' do
+ filter :code_blocks
+ filter filters[item[:extension].to_sym] || item[:extension].to_sym
+ layout 'default'
+end
+
+route '*' do
+ if item.binary? || item[:extension] == 'css'
+ # /foo/ -> /foo.ext
+ item.identifier.chop + '.' + item[:extension]
+ else
+ # /foo/ -> /foo/index.html
+ item.identifier + 'index.html'
+ end
+end
+
+layout '*', :erb
View
@@ -0,0 +1,59 @@
+# A list of file extensions that nanoc will consider to be textual rather than
+# binary. If an item with an extension not in this list is found, the file
+# will be considered as binary.
+text_extensions: [ 'css', 'erb', 'haml', 'htm', 'html', 'js', 'less', 'markdown', 'md', 'php', 'rb', 'sass', 'scss', 'txt', 'xhtml', 'xml' ]
+
+# The path to the directory where all generated files will be written to. This
+# can be an absolute path starting with a slash, but it can also be path
+# relative to the site directory.
+output_dir: output
+
+# A list of index filenames, i.e. names of files that will be served by a web
+# server when a directory is requested. Usually, index files are named
+# “index.hml”, but depending on the web server, this may be something else,
+# such as “default.htm”. This list is used by nanoc to generate pretty URLs.
+index_filenames: [ 'index.html' ]
+
+# Whether or not to generate a diff of the compiled content when compiling a
+# site. The diff will contain the differences between the compiled content
+# before and after the last site compilation.
+enable_output_diff: false
+
+# The data sources where nanoc loads its data from. This is an array of
+# hashes; each array element represents a single data source. By default,
+# there is only a single data source that reads data from the “content/” and
+# “layout/” directories in the site directory.
+data_sources:
+ -
+ # The type is the identifier of the data source. By default, this will be
+ # `filesystem_unified`.
+ type: filesystem_unified
+
+ # The path where items should be mounted (comparable to mount points in
+ # Unix-like systems). This is “/” by default, meaning that items will have
+ # “/” prefixed to their identifiers. If the items root were “/en/”
+ # instead, an item at content/about.html would have an identifier of
+ # “/en/about/” instead of just “/about/”.
+ items_root: /
+
+ # The path where layouts should be mounted. The layouts root behaves the
+ # same as the items root, but applies to layouts rather than items.
+ layouts_root: /
+
+# Configuration for the “watch” command, which watches a site for changes and
+# recompiles if necessary.
+watcher:
+ # A list of directories to watch for changes. When editing this, make sure
+ # that the “output/” and “tmp/” directories are _not_ included in this list,
+ # because recompiling the site will cause these directories to change, which
+ # will cause the site to be recompiled, which will cause these directories
+ # to change, which will cause the site to be recompiled again, and so on.
+ dirs_to_watch: [ 'content', 'layouts', 'lib' ]
+
+ # A list of single files to watch for changes. As mentioned above, don’t put
+ # any files from the “output/” or “tmp/” directories in here.
+ files_to_watch: [ 'config.yaml', 'Rules' ]
+
+ # When to send notifications (using Growl or notify-send).
+ notify_on_compilation_success: true
+ notify_on_compilation_failure: true
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 82840b1

Please sign in to comment.