Skip to content

Commit

Permalink
Use SSI for the sidebar, which really cuts down on regeneration.
Browse files Browse the repository at this point in the history
Conflicts:

	.htaccess
  • Loading branch information
belkadan committed Jul 10, 2011
1 parent fbf8f60 commit 72e170a
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Options +MultiViews -Indexes +Includes

XBitHack on
67 changes: 2 additions & 65 deletions _layouts/with_sidebar.html
Original file line number Diff line number Diff line change
@@ -1,71 +1,8 @@
---
layout: base
dependencies: *
uses_ssi: true
---
<div id="content" class="narrowcolumn" role="main">
{{ content }}
</div>
<div id="sidebar" class="shadow-box small-shadow" role="complementary">
<ul>
{% if_include_exists blurb.md %}
<li>
{% include blurb.md %}
</li>
{% end_include_exists %}

<li>
<form id="search_area" action="{{ site.baseurl }}/search" method="get">
<input id="search" type="search" name="query" placeholder="Search archives&#x2026;" />
</form>
</li>

<li>
<h2>Archives</h2>
<ul class="meta">
{% for month in site.months %}
<li>
<a href="{{ site.baseurl }}/{{ site.current-year }}/{{ month.num | pad }}">{{ month.num | month_to_name }} {{ site.current-year }}</a>
<span class="metadata">({{ month.count }})</span>
</li>
{% endfor %}
{% for year in site.years %}
<li>
<a href="{{ site.baseurl }}/{{ year.num }}">Posts from {{ year.num }}</a>
<span class="metadata">({{ year.count }})</span></li>
{% endfor %}
</ul>
</li>

<li>
<h2>Taxonomy</h2>
<ul class="meta">
{% for category in site.iterable.categories %}
{% unless category.name == '' %}
<li>
<a href="{{ site.baseurl }}/{{ category.name | xml_id }}" class="category">{{ category.name | taxonomy_name }}</a>
<span class="metadata">({{ category.posts.size }})</span>
</li>
{% endunless %}
{% endfor %}
{% if site.min_tag_size %}
{% assign min_tag_size = site.min_tag_size %}
{% else %}
{% assign min_tag_size = 1 %}
{% endif %}
{% for tag in site.iterable.tags %}
{% if tag.posts.size >= min_tag_size %}
<li>
<a href="{{ site.baseurl }}/tags/{{ tag.name | xml_id }}" class="tag">{{ tag.name | taxonomy_name }}</a>
<span class="metadata">({{ tag.posts.size }})</span>
</li>
{% endif %}
{% endfor %}
{% if site.iterable.tags.size > 0 %}
<li>
<a href="{{ site.baseurl }}/tags">(see all tags)</a>
</li>
{% endif %}
</ul>
</li>
</ul>
</div>
<!--#include virtual="{{ site.baseurl | no_domain }}/sidebar.html" -->
4 changes: 4 additions & 0 deletions _plugins/filters.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$: << File.dirname(__FILE__)
require 'truncate'
require 'uri'

module ExtendedFilters

Expand Down Expand Up @@ -45,6 +46,9 @@ def resolve(input, base)
end
end

def no_domain(input)
URI::parse(input).path
end
end

class String
Expand Down
26 changes: 26 additions & 0 deletions _plugins/shtml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Jekyll
module Convertible
def shadowbox_shtml_uses_ssi?
return true if self.data['uses_ssi']

layout = self.site.layouts[self.data['layout']]
layout.shadowbox_shtml_uses_ssi? if layout
end
end

class Post
alias_method :shadowbox_shtml_write, :write
def write(dest)
shadowbox_shtml_write(dest)
File.chmod(0755, destination(dest)) if shadowbox_shtml_uses_ssi?
end
end

class Page
alias_method :shadowbox_shtml_write, :write
def write(dest)
shadowbox_shtml_write(dest)
File.chmod(0755, destination(dest)) if shadowbox_shtml_uses_ssi?
end
end
end
67 changes: 67 additions & 0 deletions sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
dependencies: *
---
<div id="sidebar" class="shadow-box small-shadow" role="complementary">
<ul>
{% if_include_exists blurb.md %}
<li>
{% include blurb.md %}
</li>
{% end_include_exists %}

<li>
<form id="search_area" action="{{ site.baseurl }}/search" method="get">
<input id="search" type="search" name="query" placeholder="Search archives&#x2026;" />
</form>
</li>

<li>
<h2>Archives</h2>
<ul class="meta">
{% for month in site.months %}
<li>
<a href="{{ site.baseurl }}/{{ site.current-year }}/{{ month.num | pad }}">{{ month.num | month_to_name }} {{ site.current-year }}</a>
<span class="metadata">({{ month.count }})</span>
</li>
{% endfor %}
{% for year in site.years %}
<li>
<a href="{{ site.baseurl }}/{{ year.num }}">Posts from {{ year.num }}</a>
<span class="metadata">({{ year.count }})</span></li>
{% endfor %}
</ul>
</li>

<li>
<h2>Taxonomy</h2>
<ul class="meta">
{% for category in site.iterable.categories %}
{% unless category.name == '' %}
<li>
<a href="{{ site.baseurl }}/{{ category.name | xml_id }}" class="category">{{ category.name | taxonomy_name }}</a>
<span class="metadata">({{ category.posts.size }})</span>
</li>
{% endunless %}
{% endfor %}
{% if site.min_tag_size %}
{% assign min_tag_size = site.min_tag_size %}
{% else %}
{% assign min_tag_size = 1 %}
{% endif %}
{% for tag in site.iterable.tags %}
{% if tag.posts.size >= min_tag_size %}
<li>
<a href="{{ site.baseurl }}/tags/{{ tag.name | xml_id }}" class="tag">{{ tag.name | taxonomy_name }}</a>
<span class="metadata">({{ tag.posts.size }})</span>
</li>
{% endif %}
{% endfor %}
{% if site.iterable.tags.size > 0 %}
<li>
<a href="{{ site.baseurl }}/tags">(see all tags)</a>
</li>
{% endif %}
</ul>
</li>
</ul>
</div>

0 comments on commit 72e170a

Please sign in to comment.