diff --git a/doc-src/Rules b/doc-src/Rules index 2be98d80..c5ba8d9e 100644 --- a/doc-src/Rules +++ b/doc-src/Rules @@ -47,6 +47,16 @@ compile '/reference/*/' do layout item[:layout] ? item[:layout] : "main" end +compile '/posts/*/' do + filter :erb + filter :rdiscount if item[:extension] == "markdown" + layout 'post' +end + +compile "/blog/atom/" do + filter :haml, :attr_wrapper => '"' +end + compile '*' do if item[:extension] == "markdown" filter :rdiscount @@ -56,6 +66,10 @@ compile '*' do layout item[:layout] ? item[:layout] : "main" end +route "/blog/atom/" do + "/blog/atom.xml" +end + route '/search-data/' do "#{SITE_ROOT}/javascripts"+item.identifier[0..-2]+".js" end @@ -89,6 +103,15 @@ route '/stylesheets/*/' do SITE_ROOT+item.identifier.chop + '.css' end +route '/posts/*/' do + if item.identifier =~ %r{^/posts/(\d{4})-(\d{2})-(\d{2})-(.*)/$} + "/blog/#{$1}/#{$2}/#{$3}/#{$4}/index.html" + else + puts "WARNING: malformed post name: #{item.identifier}" + nil + end +end + %w(markup stylesheet background).each do |ex_file| route "/examples/*/#{ex_file}/" do nil diff --git a/doc-src/content/blog/archive.haml b/doc-src/content/blog/archive.haml new file mode 100644 index 00000000..67faea8f --- /dev/null +++ b/doc-src/content/blog/archive.haml @@ -0,0 +1,14 @@ +--- +layout: blog +--- +%h1 Compass Blog Archive + +- for post in blog_posts_in_order.reverse + .post-snippet + %h2 + - time = blog_date(post) + %span.timestamp= time.strftime("%Y/%m/%d") + %a{:href => post.rep_named(:default).path}= post[:title] + %p= post[:intro] || post[:description] + + diff --git a/doc-src/content/blog/atom.haml b/doc-src/content/blog/atom.haml new file mode 100644 index 00000000..b328482b --- /dev/null +++ b/doc-src/content/blog/atom.haml @@ -0,0 +1,19 @@ + +%feed(xmlns="http://www.w3.org/2005/Atom") + %title Compass Blog + %link(href="http://compass-style.org/blog/atom.xml" rel="self") + %link(href="http://compass-style.org/blog/") + %updated= Time.now.xmlschema + %id http://compass-style.org/blog/ + %author + %name Compass Core Team + - for post in blog_posts_in_order.reverse + - full_url = "http://compass-style.org#{post.rep_named(:default).path}" + %entry + %title&= post[:title] + %link{:href=> full_url} + %updated= blog_date(post).localtime.xmlschema + %id= full_url[0..-2] + %content(type="html") + = post[:intro] || post[:description] + diff --git a/doc-src/content/stylesheets/partials/_blog.scss b/doc-src/content/stylesheets/partials/_blog.scss new file mode 100644 index 00000000..ac79d58d --- /dev/null +++ b/doc-src/content/stylesheets/partials/_blog.scss @@ -0,0 +1,6 @@ +body#blog-archive { + .timestamp { + margin-right: 1em; + font-size: 12px; + } +} \ No newline at end of file diff --git a/doc-src/content/stylesheets/partials/_layout.scss b/doc-src/content/stylesheets/partials/_layout.scss index d9d54150..5148ac89 100644 --- a/doc-src/content/stylesheets/partials/_layout.scss +++ b/doc-src/content/stylesheets/partials/_layout.scss @@ -1,4 +1,4 @@ -$min-width: 680px; +$min-width: 700px; $side-nav-width: 160px; $main-min-width: $min-width - $side-nav-width; diff --git a/doc-src/content/stylesheets/screen.scss b/doc-src/content/stylesheets/screen.scss index 48b4c998..1f240bdf 100644 --- a/doc-src/content/stylesheets/screen.scss +++ b/doc-src/content/stylesheets/screen.scss @@ -17,6 +17,7 @@ @import "partials/code"; @import "partials/example"; @import "partials/install"; +@import "partials/blog"; @import "syntax/syntax-theme"; diff --git a/doc-src/layouts/basic.haml b/doc-src/layouts/basic.haml index 20278c06..18c3670b 100644 --- a/doc-src/layouts/basic.haml +++ b/doc-src/layouts/basic.haml @@ -6,6 +6,7 @@ %meta{:content => "chrome=1", "http-equiv" => "X-UA-Compatible"} %meta(name="viewport" content="width=780") %link(rel="shortcut icon" type="image/png" href="/images/compass_icon.png") + %link{:href=>"/blog/atom.xml", :rel=>"alternate", :title=>"Compass Blog", :type=>"application/atom+xml"} %title #{@item[:title]} | Compass Documentation %link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"} diff --git a/doc-src/layouts/blog.haml b/doc-src/layouts/blog.haml new file mode 100644 index 00000000..48886078 --- /dev/null +++ b/doc-src/layouts/blog.haml @@ -0,0 +1,17 @@ +- render "basic" do + #wrap + = render "partials/main-navigation" + #sub-nav + - p = previous_post + - n = next_post + - if p || n + %nav#docs-nav{:role => "navigation"} + - if p + %a{:href => p.rep_named(:default).path, :title => p[:title]} « Previous Post + - if n + %a{:href => n.rep_named(:default).path, :title => n[:title]} Next Post » + #page + = yield + %footer(role="contentinfo")= render "partials/footer" + = @item[:content_for_javascripts] + = render "partials/analytics" diff --git a/doc-src/layouts/main.haml b/doc-src/layouts/main.haml index 4fa5f0f7..f287370f 100644 --- a/doc-src/layouts/main.haml +++ b/doc-src/layouts/main.haml @@ -18,7 +18,7 @@ Version: %a.number(href="/CHANGELOG/")= compass_version = yield - -#comments= render "partials/disqus_comments" + #comments= render "partials/disqus_comments" %footer(role="contentinfo")= render "partials/footer" = @item[:content_for_javascripts] = render "partials/analytics" diff --git a/doc-src/layouts/partials/main-navigation.haml b/doc-src/layouts/partials/main-navigation.haml index c8cef4d3..b6858d0b 100644 --- a/doc-src/layouts/partials/main-navigation.haml +++ b/doc-src/layouts/partials/main-navigation.haml @@ -10,6 +10,8 @@ %a{:href => "/reference/compass/", :rel => "documentation"} Reference %li %a{:href => "/help/", :rel=> "help"} Help + %li + %a{:href => "/blog/", :rel=> "blog"} Blog %li %a{:href => "/get-involved/", :rel=> "get-involved"} Get Involved %li diff --git a/doc-src/layouts/post.haml b/doc-src/layouts/post.haml new file mode 100644 index 00000000..8d114983 --- /dev/null +++ b/doc-src/layouts/post.haml @@ -0,0 +1,5 @@ +- render "blog" do + %h1= @item[:title] + %h2 By #{@item[:author]} + = yield + -#comments= render "partials/disqus_comments" \ No newline at end of file diff --git a/doc-src/lib/blog.rb b/doc-src/lib/blog.rb new file mode 100644 index 00000000..13f262d7 --- /dev/null +++ b/doc-src/lib/blog.rb @@ -0,0 +1,26 @@ +POST_NAME = %r{^/posts/(\d{4})-(\d{2})-(\d{2})-(.*)/$} +require 'time' + +def blog_posts_in_order + @blog_posts_in_order ||= @items.select {|i| i.identifier =~ %r{/posts} }.sort_by {|i| i.identifier } +end + +def previous_post(item = @item) + current_index = blog_posts_in_order.index(item) + if current_index && current_index > 0 + blog_posts_in_order[current_index - 1] + end +end + +def next_post(item = @item) + current_index = blog_posts_in_order.index(item) + if current_index && current_index < blog_posts_in_order.size - 1 + blog_posts_in_order[current_index + 1] + end +end + +def blog_date(item = @item) + if item.identifier =~ POST_NAME + Time.new($1.to_i, $2.to_i, $3.to_i) + end +end