From eefe29e5d0b6caab2f6bfcab7a10dbf43e208ac3 Mon Sep 17 00:00:00 2001 From: B Mathis Date: Wed, 10 Mar 2010 12:23:30 -0600 Subject: [PATCH] now Octopress uses partials --- Rakefile | 36 +++++----- source/_helpers.rb | 5 +- source/_includes/config.haml | 17 +++++ source/_includes/delicious.haml | 3 + source/_includes/disqus_hook.haml | 11 +++ source/_includes/disqus_thread.haml | 5 ++ source/_includes/footer.haml | 7 ++ source/_includes/google_analytics.haml | 10 +++ source/_includes/head.haml | 21 ++++++ source/_includes/header.haml | 8 +++ source/_includes/navigation.haml | 8 +++ source/_includes/post.haml | 8 +++ source/_includes/sidebar.haml | 2 + source/_includes/twitter.haml | 4 ++ source/_layouts/blog_post.haml | 32 +++++++++ source/_layouts/default.haml | 97 +++----------------------- source/index.haml | 16 +++-- 17 files changed, 176 insertions(+), 114 deletions(-) create mode 100644 source/_includes/config.haml create mode 100644 source/_includes/delicious.haml create mode 100644 source/_includes/disqus_hook.haml create mode 100644 source/_includes/disqus_thread.haml create mode 100644 source/_includes/footer.haml create mode 100644 source/_includes/google_analytics.haml create mode 100644 source/_includes/head.haml create mode 100644 source/_includes/header.haml create mode 100644 source/_includes/navigation.haml create mode 100644 source/_includes/post.haml create mode 100644 source/_includes/sidebar.haml create mode 100644 source/_includes/twitter.haml create mode 100644 source/_layouts/blog_post.haml diff --git a/Rakefile b/Rakefile index 4e0b263..1ee4153 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,12 @@ require 'active_support' -site_url = "http://yoursite.com" # deployed site url for sitemap.xml generator -port = "4000" # preview project port eg. http://localhost:4000 -site = "site" # compiled site directory -source = "source" # source file directory -stash = "_stash" -posts = "_posts" +site_url = "http://yoursite.com" # deployed site url for sitemap.xml generator +port = "4000" # preview project port eg. http://localhost:4000 +site = "site" # compiled site directory +source = "source" # source file directory +stash = "_stash" # directory to stash posts for speedy generation +posts = "_posts" # directory for blog files +post_format = "markdown" # file format for new posts when using the post rake task ## -- Rsync Deploy config -- ## ssh_user = "user@host.com" # for rsync deployment @@ -29,11 +30,15 @@ end ## if you're deploying with github, change the default deploy to deploy_github desc "default deploy task" -task :deploy => :deploy_rsync do +task :deploy => [:deploy_rsync] do +end + +desc "Generate and deploy task" +task :generate_deploy => [:integrate, :generate, :clean_debug, :deploy] do end desc "generate website in output directory" -task :default => [:generate_site, :generate_style] do +task :generate => [:generate_site, :generate_style] do puts ">>> Site Generating Complete! <<<\n\n" end @@ -41,8 +46,7 @@ end desc "Begin a new post in #{source}/_posts" task :post, :filename do |t, args| args.with_defaults(:filename => 'new-post') - #system "touch #{source}/_posts/#{Time.now.strftime('%Y-%m-%d_%H-%M')}-#{args.filename}.markdown" - open("#{source}/_posts/#{Time.now.strftime('%Y-%m-%d_%H-%M')}-#{args.filename.gsub(/[ _]/, '-')}.markdown", 'w') do |post| + open("#{source}/_posts/#{Time.now.strftime('%Y-%m-%d_%H-%M')}-#{args.filename.downcase.gsub(/[ _]/, '-')}.#{post_format}", 'w') do |post| post.puts "---" post.puts "title: \"#{args.filename.gsub(/[-_]/, ' ').titlecase}\"" post.puts "---" @@ -126,13 +130,13 @@ task :watch do end desc "generate and deploy website via rsync" -multitask :deploy_rsync => [:integrate, :default, :clean_debug] do +multitask :deploy_rsync do puts ">>> Deploying website to #{site_url} <<<" ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}") end desc "generate and deploy website to github user pages" -multitask :deploy_github => [:integrate, :default, :clean_debug] do +multitask :deploy_github do puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<" require 'git' repo = Git.open('.') @@ -173,13 +177,13 @@ task :stop_serve do end desc "preview the site in a web browser" -multitask :preview => [:default, :start_serve] do +multitask :preview => [:start_serve] do system "open http://localhost:#{port}" end desc "Build an XML sitemap of all html files." -task :sitemap => :default do +task :sitemap do html_files = FileList.new("#{site}/**/*.html").map{|f| f[("#{site}".size)..-1]}.map do |f| if f.ends_with?("index.html") f[0..(-("index.html".size + 1))] @@ -194,14 +198,14 @@ task :sitemap => :default do priority = case f when %r{^/$} 1.0 - when %r{^/blog} + when %r{^/articles} 0.9 else 0.8 end sitemap.puts %Q{ } sitemap.puts %Q{ #{site_url}#{f}} - sitemap.puts %Q{ #{Time.now.to_s('%Y-%m-%d')}} + sitemap.puts %Q{ #{Time.now.strftime('%Y-%m-%d')}} sitemap.puts %Q{ weekly} sitemap.puts %Q{ #{priority}} sitemap.puts %Q{ } diff --git a/source/_helpers.rb b/source/_helpers.rb index b171456..11d7852 100644 --- a/source/_helpers.rb +++ b/source/_helpers.rb @@ -111,8 +111,6 @@ module Helpers end include TagHelper - # My added helpers - def to_html_email(address) email = string_to_html(address) "#{email}" @@ -165,7 +163,7 @@ module Helpers # A very hackish way to handle partials. We'll go with it till it breaks... def include(partial_name) file_ext = partial_name[(partial_name.index('.') + 1)..partial_name.length] - contents = IO.read("_includes/#{partial_name}") + contents = IO.read("source/_includes/#{partial_name}") case file_ext when 'haml' Haml::Engine.new(contents).render(binding) @@ -180,6 +178,7 @@ module Helpers end include PartialsHelper + end class String diff --git a/source/_includes/config.haml b/source/_includes/config.haml new file mode 100644 index 0000000..7ac49a8 --- /dev/null +++ b/source/_includes/config.haml @@ -0,0 +1,17 @@ +--- +blog_title: My Octopress Blog + +twitter_user: +tweet_count: 3 +show_replies: false + +delicious_user: +delicious_count: 3 + +full_url: +disqus_short_name: + +google_custom_search_id: +google_analytics_tracking_id: + +--- \ No newline at end of file diff --git a/source/_includes/delicious.haml b/source/_includes/delicious.haml new file mode 100644 index 0000000..6f1d63d --- /dev/null +++ b/source/_includes/delicious.haml @@ -0,0 +1,3 @@ +%h4 My Delicious more → +#delicious + %script(type="text/javascript" src="http://feeds.delicious.com/v2/js/#{page.delicious_user}?title=&count=#{page.delicious_count}&sort=date&extended") \ No newline at end of file diff --git a/source/_includes/disqus_hook.haml b/source/_includes/disqus_hook.haml new file mode 100644 index 0000000..60e2d3d --- /dev/null +++ b/source/_includes/disqus_hook.haml @@ -0,0 +1,11 @@ +:javascript + (function() { + var links = document.getElementsByTagName('a'); + var query = '?'; + for(var i = 0; i < links.length; i++) { + if(links[i].href.indexOf('#disqus_thread') >= 0) { + query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&'; + } + } + document.write('