Merge branch 'master' of https://github.com/fhemberger/octopress into fhemberger-master

Conflicts:
	plugins/category_generator.rb
This commit is contained in:
Brandon Mathis 2011-09-04 08:37:22 -05:00
commit ed0c220523
9 changed files with 33 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{% capture category %}{{ post.categories | size }}{% endcapture %} {% capture category %}{{ post.categories | size }}{% endcapture %}
<h1><a href="{{ root_url }}{{ post.url }}">{{post.title}}</a></h1> <h1><a href="{{ root_url }}{{ post.url }}">{{post.title}}</a></h1>
<time datetime="{{ post.date | datetime }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time> <time datetime="{{ post.date | datetime | date_to_xmlschema }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time>
{% if category != '0' %} {% if category != '0' %}
<footer> <footer>
<span class="categories">posted in {{ post.categories | category_links }}</span> <span class="categories">posted in {{ post.categories | category_links }}</span>

View File

@ -4,7 +4,7 @@
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]--> <!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{site.title}}{% if page.title %}: {{page.title}}{% endif %}</title> <title>{% if page.title %}{{page.title}} « {% endif %}{{site.title}}</title>
<meta name="author" content="{{site.author}}"> <meta name="author" content="{{site.author}}">
{% if page.description %} {% if page.description %}
<meta name="description" content="{{page.description}}"/> <meta name="description" content="{{page.description}}"/>
@ -26,8 +26,5 @@
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script> <script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script> <script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml"/> <link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
{% include google_analytics.html %}
{% include google_plus_one.html %}
{% include twitter_sharing.html %}
{% include custom/head.html %} {% include custom/head.html %}
</head> </head>

View File

@ -3,8 +3,8 @@
{% capture updated %}{{ page.updated }}{{ post.updated }}{% endcapture %} {% capture updated %}{{ page.updated }}{{ post.updated }}{% endcapture %}
{% capture was_updated %}{{ updated | size }}{% endcapture %} {% capture was_updated %}{{ updated | size }}{% endcapture %}
{% if has_date != '0' %} {% if has_date != '0' %}
<time datetime="{{ date | datetime }}" pubdate {% if updated %} updated {% endif %}>{{ date | ordinalize }}</time> <time datetime="{{ date | datetime | date_to_xmlschema }}" pubdate {% if updated %} data-updated="true" {% endif %}>{{ date | ordinalize }}</time>
{% endif %} {% endif %}
{% if was_updated != '0' %} {% if was_updated != '0' %}
<time class="updated" datetime="{{ updated | datetime }}">{{ updated | ordinalize }}</time> <time class="updated" datetime="{{ updated | datetime | date_to_xmlschema }}">{{ updated | ordinalize }}</time>
{% endif %} {% endif %}

View File

@ -3,6 +3,6 @@
<a href="http://twitter.com/share" class="twitter-share-button" data-url="{{ site.url }}{{ page.url }}" data-via="{{ site.twitter_user }}" data-counturl="{{ site.url }}{{ page.url }}" >Tweet</a> <a href="http://twitter.com/share" class="twitter-share-button" data-url="{{ site.url }}{{ page.url }}" data-via="{{ site.twitter_user }}" data-counturl="{{ site.url }}{{ page.url }}" >Tweet</a>
{% endif %} {% endif %}
{% if site.google_plus_one %} {% if site.google_plus_one %}
<g:plusone size="{{ site.google_plus_one_size }}"></g:plusone> <div class="g-plusone" data-size="{{ site.google_plus_one_size }}"></div>
{% endif %} {% endif %}
</div> </div>

View File

@ -9,5 +9,8 @@
</div> </div>
</div> </div>
<footer>{% include footer.html %}</footer> <footer>{% include footer.html %}</footer>
{% include google_analytics.html %}
{% include google_plus_one.html %}
{% include twitter_sharing.html %}
</body> </body>
</html> </html>

View File

@ -11,3 +11,4 @@ gem 'compass', '>= 0.11'
gem 'rubypants' gem 'rubypants'
gem 'rb-fsevent' gem 'rb-fsevent'
gem 'stringex' gem 'stringex'
gem 'unicode_utils'

View File

@ -42,6 +42,7 @@ GEM
sass (3.1.7) sass (3.1.7)
stringex (1.3.0) stringex (1.3.0)
syntax (1.0.0) syntax (1.0.0)
unicode_utils (1.0.0)
PLATFORMS PLATFORMS
ruby ruby
@ -58,3 +59,4 @@ DEPENDENCIES
rdiscount rdiscount
rubypants rubypants
stringex stringex
unicode_utils

View File

@ -27,6 +27,9 @@ server_port = "4000" # port for preview server eg. localhost:4000
desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]" desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
task :install, :theme do |t, args| task :install, :theme do |t, args|
if File.directory?(source_dir) || File.directory?("sass")
abort("rake aborted!") if ask("A theme is already installed, proceeding will overwrite existing files. Are you sure?", ['y', 'n']) == 'n'
end
# copy theme into working Jekyll directories # copy theme into working Jekyll directories
theme = args.theme || 'classic' theme = args.theme || 'classic'
puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass" puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass"
@ -301,6 +304,20 @@ def ok_failed(condition)
end end
end end
def get_stdin(message)
print message
STDIN.gets.chomp
end
def ask(message, valid_options)
if valid_options
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
else
answer = get_stdin(message)
end
answer
end
desc "list tasks" desc "list tasks"
task :list do task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}" puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"

View File

@ -16,8 +16,9 @@
# - category_dir: The subfolder to build category pages in (default is 'categories'). # - category_dir: The subfolder to build category pages in (default is 'categories').
# - category_title_prefix: The string used before the category name in the page title (default is # - category_title_prefix: The string used before the category name in the page title (default is
# 'Category: '). # 'Category: ').
module Jekyll require "unicode_utils"
module Jekyll
# The CategoryIndex class creates a single category page for the specified category. # The CategoryIndex class creates a single category page for the specified category.
class CategoryIndex < Page class CategoryIndex < Page
@ -68,7 +69,7 @@ module Jekyll
if self.layouts.key? 'category_index' if self.layouts.key? 'category_index'
dir = self.config['category_dir'] || 'categories' dir = self.config['category_dir'] || 'categories'
self.categories.keys.each do |category| self.categories.keys.each do |category|
self.write_category_index(File.join(dir, category.gsub(/[_\W]/, '-').gsub(/-{2,}/, '-')), category) self.write_category_index(File.join(dir, UnicodeUtils.nfkd(category).gsub(/[^\x00-\x7F]/, '').gsub(/_|\W/, '-').gsub(/-{2,}/, '-').to_s), category)
end end
# Throw an exception if the layout couldn't be found. # Throw an exception if the layout couldn't be found.
@ -105,7 +106,7 @@ module Jekyll
def category_links(categories) def category_links(categories)
dir = @context.registers[:site].config['category_dir'] dir = @context.registers[:site].config['category_dir']
categories = categories.sort!.map do |item| categories = categories.sort!.map do |item|
"<a class='category' href='/#{dir}/#{item.gsub(/[_\W]/, '-').gsub(/-{2,}/, '-')}/'>#{item}</a>" "<a class='category' href='/#{dir}/#{UnicodeUtils.nfkd(item).gsub(/[^\x00-\x7F]/, '').gsub(/_|\W/, '-').gsub(/-{2,}/, '-').to_s}/'>#{item}</a>"
end end
case categories.length case categories.length