A basic blog for the compass website.

This commit is contained in:
Chris Eppstein 2011-04-17 01:48:44 -07:00
parent 3c86dfa0b3
commit b1b718e78a
12 changed files with 116 additions and 2 deletions

View File

@ -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

View File

@ -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]

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
%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]

View File

@ -0,0 +1,6 @@
body#blog-archive {
.timestamp {
margin-right: 1em;
font-size: 12px;
}
}

View File

@ -1,4 +1,4 @@
$min-width: 680px;
$min-width: 700px;
$side-nav-width: 160px;
$main-min-width: $min-width - $side-nav-width;

View File

@ -17,6 +17,7 @@
@import "partials/code";
@import "partials/example";
@import "partials/install";
@import "partials/blog";
@import "syntax/syntax-theme";

View File

@ -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"}

17
doc-src/layouts/blog.haml Normal file
View File

@ -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]} &laquo; Previous Post
- if n
%a{:href => n.rep_named(:default).path, :title => n[:title]} Next Post &raquo;
#page
= yield
%footer(role="contentinfo")= render "partials/footer"
= @item[:content_for_javascripts]
= render "partials/analytics"

View File

@ -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"

View File

@ -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

View File

@ -0,0 +1,5 @@
- render "blog" do
%h1= @item[:title]
%h2 By #{@item[:author]}
= yield
-#comments= render "partials/disqus_comments"

26
doc-src/lib/blog.rb Normal file
View File

@ -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