diff options
32 files changed, 355 insertions, 87 deletions
@@ -1 +1 @@ -rvm 1.9.2 +rvm use 1.9.2 diff --git a/.themes/classic/sass/base/_layout.scss b/.themes/classic/sass/base/_layout.scss index 40240fff..f9f3a41a 100644 --- a/.themes/classic/sass/base/_layout.scss +++ b/.themes/classic/sass/base/_layout.scss @@ -14,6 +14,10 @@ $sidebar-width-wide: 300px !default; $indented-lists: false !default; +$header-font-size: 1em !default; +$header-padding-top: 1.5em !default; +$header-padding-bottom: 1.5em !default; + .group { @include pie-clearfix; } @mixin collapse-sidebar { @@ -44,7 +48,7 @@ body { max-width: $max-width; position: relative; margin: 0 auto; - > header, > nav, > footer, #content > article, #content > div > article, #content > div > section, nav.pagination { + > header, > nav, > footer, #content > article, #content > div > article, #content > div > section { @extend .group; padding-left: $pad-min; padding-right: $pad-min; @@ -61,10 +65,27 @@ body { padding-right: $pad-wide; } } + div.pagination { + @extend .group; + margin-left: $pad-min; + margin-right: $pad-min; + @media only screen and (min-width: 480px) { + margin-left: $pad-narrow; + margin-right: $pad-narrow; + } + @media only screen and (min-width: 768px) { + margin-left: $pad-medium; + margin-right: $pad-medium; + } + @media only screen and (min-width: 992px) { + margin-left: $pad-wide; + margin-right: $pad-wide; + } + } > header { - font-size: 1em; - padding-top: 1.5em; - padding-bottom: 1.5em; + font-size: $header-font-size; + padding-top: $header-padding-top; + padding-bottom: $header-padding-bottom; } } @@ -98,14 +119,14 @@ body.sidebar-footer { } @media only screen and (min-width: 550px) { - body > header { font-size: 1em; } + body > header { font-size: $header-font-size; } } @media only screen and (min-width: 750px) { aside.sidebar { @include collapse-sidebar; } } @media only screen and (min-width: 768px) { body { -webkit-text-size-adjust: auto; } - body > header { font-size: 1.2em; } + body > header { font-size: $header-font-size * 1.2; } #main { @extend .group; padding: 0; @@ -142,7 +163,7 @@ body.sidebar-footer { } @media only screen and (min-width: 992px) { - body > header { font-size: 1.3em; } + body > header { font-size: $header-font-size * 1.3; } #content { margin-right: $sidebar-width-wide; } #content { > div, > article { diff --git a/.themes/classic/sass/base/_theme.scss b/.themes/classic/sass/base/_theme.scss index e5539b1f..62e06890 100644 --- a/.themes/classic/sass/base/_theme.scss +++ b/.themes/classic/sass/base/_theme.scss @@ -23,6 +23,8 @@ $type-border: #ddd !default; /* Navigation */ $nav-bg: #ccc !default; +$nav-bg-front: image-url('noise.png') !default; +$nav-bg-back: linear-gradient(lighten($nav-bg, 8), $nav-bg, darken($nav-bg, 11)) !default; $nav-color: darken($nav-bg, 38) !default; $nav-color-hover: darken($nav-color, 25) !default; $nav-placeholder: desaturate(darken($nav-bg, 10), 15) !default; @@ -46,6 +48,8 @@ $twitter-status-link: lighten($sidebar-link-color-subdued, 15) !default; $footer-color: #888 !default; $footer-bg: #ccc !default; +$footer-bg-front: image-url('noise.png') !default; +$footer-bg-back: linear-gradient(lighten($footer-bg, 8), $footer-bg, darken($footer-bg, 11)) !default; $footer-color: darken($footer-bg, 38) !default; $footer-color-hover: darken($footer-color, 10) !default; $footer-border-top: lighten($footer-bg, 15) !default; diff --git a/.themes/classic/sass/base/_typography.scss b/.themes/classic/sass/base/_typography.scss index 60556752..b68753fa 100644 --- a/.themes/classic/sass/base/_typography.scss +++ b/.themes/classic/sass/base/_typography.scss @@ -1,21 +1,30 @@ $blockquote: $type-border !default; -$mono: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace; +$sans: "PT Sans", "Helvetica Neue", Arial, sans-serif !default; +$serif: "PT Serif", Georgia, Times, "Times New Roman", serif !default; +$mono: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace !default; +$heading-font-family: "PT Serif", "Georgia", "Helvetica Neue", Arial, sans-serif !default; +$header-title-font-family: $heading-font-family !default; +$header-subtitle-font-family: $heading-font-family !default; // Fonts .heading { - font-family: "PT Serif", "Georgia", "Helvetica Neue", Arial, sans-serif; + font-family: $heading-font-family; } -.sans { font-family: "PT Sans", "Helvetica Neue", Arial, sans-serif; } -.serif { font-family: "PT Serif", Georgia, Times, "Times New Roman", serif; } +.sans { font-family: $sans; } +.serif { font-family: $serif; } .mono { font-family: $mono; } body > header h1 { font-size: 2.2em; @extend .heading; + font-family: $header-title-font-family; font-weight: normal; line-height: 1.2em; margin-bottom: 0.6667em; } +body > header h2 { + font-family: $header-subtitle-font-family; +} body { line-height: 1.5em; @@ -56,12 +65,12 @@ h6, section h5, section section h4, section section section h3 { p, blockquote, ul, ol { margin-bottom: 1.5em; } ul { list-style-type: disc; - ul { list-style-type: circle; - ul { list-style-type: square; }}} + ul { list-style-type: circle; margin-bottom: 0px; + ul { list-style-type: square; margin-bottom: 0px; }}} ol { list-style-type: decimal; - ol { list-style-type: lower-alpha; - ol { list-style-type: lower-roman; }}} + ol { list-style-type: lower-alpha; margin-bottom: 0px; + ol { list-style-type: lower-roman; margin-bottom: 0px; }}} ul, ol { &, ul, ol { margin-left: 1.3em; }} diff --git a/.themes/classic/sass/custom/_colors.scss b/.themes/classic/sass/custom/_colors.scss index cf0ab29e..740266a8 100644 --- a/.themes/classic/sass/custom/_colors.scss +++ b/.themes/classic/sass/custom/_colors.scss @@ -5,9 +5,14 @@ //$header-bg: #263347; //$subtitle-color: lighten($header-bg, 58); //$nav-bg: desaturate(lighten(#8fc17a, 18), 5); +//$nav-bg-front: image-url('noise.png'); +//$nav-bg-back: linear-gradient(lighten($nav-bg, 8), $nav-bg, darken($nav-bg, 11)); //$sidebar-bg: desaturate(#eceff5, 8); //$sidebar-link-color: saturate(#526f9a, 10); //$sidebar-link-color-hover: darken(#7ab662, 9); +//$footer-bg: #ccc !default; +//$footer-bg-front: image-url('noise.png'); +//$footer-bg-back: linear-gradient(lighten($footer-bg, 8), $footer-bg, darken($footer-bg, 11)); /* To use the light Solarized highlighting theme uncomment the following line */ diff --git a/.themes/classic/sass/custom/_fonts.scss b/.themes/classic/sass/custom/_fonts.scss new file mode 100644 index 00000000..1a6b2a06 --- /dev/null +++ b/.themes/classic/sass/custom/_fonts.scss @@ -0,0 +1,10 @@ +// Here you can easily change font faces which are used in your site. +// To give it a try, uncomment some of the lines below rebuild your blog, and see how it works. your sites's. +// If you love to use Web Fonts, you also need to add some lines to source/_includes/custom/head.html + +//$sans: "Optima", sans-serif; +//$serif: "Baskerville", serif; +//$mono: "Courier", monospace; +//$heading-font-family: "Verdana", sans-serif; +//$header-title-font-family: "Futura", sans-serif; +//$header-subtitle-font-family: "Futura", sans-serif; diff --git a/.themes/classic/sass/custom/_layout.scss b/.themes/classic/sass/custom/_layout.scss index 53173115..74c7de9d 100644 --- a/.themes/classic/sass/custom/_layout.scss +++ b/.themes/classic/sass/custom/_layout.scss @@ -1,6 +1,10 @@ // Here you can easily change your sites's layout. // To give it a try, uncomment some of the lines below, make changes, rebuild your blog, and see how it works. +//$header-font-size: 1em; +//$header-padding-top: 1.5em; +//$header-padding-bottom: 1.5em; + //$max-width: 1350px; //$indented-lists: true; diff --git a/.themes/classic/sass/partials/_blog.scss b/.themes/classic/sass/partials/_blog.scss index 63e4ee40..d3ba48a3 100644 --- a/.themes/classic/sass/partials/_blog.scss +++ b/.themes/classic/sass/partials/_blog.scss @@ -73,7 +73,7 @@ article { @extend .sans; p.meta { margin-bottom: .8em; - font-size: .85em + font-size: .85em; clear: both; overflow: hidden; } @@ -123,14 +123,12 @@ article + article { display: inline-block; } -#content nav.pagination { +#content div.pagination { text-align: center; font-size: .95em; - div { - position: relative; - background: $img-border top left repeat-x; - padding: {top: 1.5em; bottom: 1.5em;} - } + position: relative; + background: $img-border top left repeat-x; + padding: {top: 1.5em; bottom: 1.5em;} a { text-decoration: none; color: $text-color-light; diff --git a/.themes/classic/sass/partials/_footer.scss b/.themes/classic/sass/partials/_footer.scss index e750342c..37411225 100644 --- a/.themes/classic/sass/partials/_footer.scss +++ b/.themes/classic/sass/partials/_footer.scss @@ -4,7 +4,7 @@ body > footer { color: $footer-color; text-shadow: lighten($footer-bg, 5) 0 1px; background-color: $footer-bg; - @include background(image-url('noise.png'), linear-gradient(lighten($footer-bg, 8), $footer-bg, darken($footer-bg, 11))); + @include background($footer-bg-front, $footer-bg-back); border-top: 1px solid $footer-border-top; position: relative; padding-top: 1em; diff --git a/.themes/classic/sass/partials/_navigation.scss b/.themes/classic/sass/partials/_navigation.scss index c05819ad..68a15ce0 100644 --- a/.themes/classic/sass/partials/_navigation.scss +++ b/.themes/classic/sass/partials/_navigation.scss @@ -1,7 +1,7 @@ body > nav { position: relative; background-color: $nav-bg; - @include background(image-url('noise.png'), linear-gradient(lighten($nav-bg, 8), $nav-bg, darken($nav-bg, 11))); + @include background($nav-bg-front, $nav-bg-back); border: { top: 1px solid $nav-border-top; bottom: 1px solid $nav-border-bottom; } diff --git a/.themes/classic/sass/partials/_sidebar.scss b/.themes/classic/sass/partials/_sidebar.scss index ac790e04..eec540ba 100644 --- a/.themes/classic/sass/partials/_sidebar.scss +++ b/.themes/classic/sass/partials/_sidebar.scss @@ -1,4 +1,5 @@ @import "sidebar/base"; @import "sidebar/twitter"; +@import "sidebar/googleplus"; @import "sidebar/pinboard"; @import "sidebar/delicious"; diff --git a/.themes/classic/sass/partials/sidebar/_googleplus.scss b/.themes/classic/sass/partials/sidebar/_googleplus.scss new file mode 100644 index 00000000..c2a693ee --- /dev/null +++ b/.themes/classic/sass/partials/sidebar/_googleplus.scss @@ -0,0 +1,26 @@ +.googleplus { + h1 { + -moz-box-shadow: none !important; + -webkit-box-shadow: none !important; + -o-box-shadow: none !important; + box-shadow: none !important; + border-bottom: 0px none !important; + } + a { + text-decoration: none; + white-space: normal !important; + line-height: 32px; + + img { + float: left; + margin-right: 0.5em; + border: 0 none; + } + } +} + +.googleplus-hidden { + position: absolute; + top: -1000em; + left: -1000em; +} diff --git a/.themes/classic/sass/screen.scss b/.themes/classic/sass/screen.scss index f08da4c2..1899f608 100644 --- a/.themes/classic/sass/screen.scss +++ b/.themes/classic/sass/screen.scss @@ -3,6 +3,7 @@ @include reset-html5; @import "custom/colors"; +@import "custom/fonts"; @import "custom/layout"; @import "base"; @import "partials"; diff --git a/.themes/classic/source/_includes/after_footer.html b/.themes/classic/source/_includes/after_footer.html index b17f5463..08b8e340 100644 --- a/.themes/classic/source/_includes/after_footer.html +++ b/.themes/classic/source/_includes/after_footer.html @@ -2,5 +2,4 @@ {% include facebook_like.html %} {% include google_plus_one.html %} {% include twitter_sharing.html %} -{% include google_analytics.html %} {% include custom/after_footer.html %} diff --git a/.themes/classic/source/_includes/asides/googleplus.html b/.themes/classic/source/_includes/asides/googleplus.html new file mode 100644 index 00000000..00a0aa85 --- /dev/null +++ b/.themes/classic/source/_includes/asides/googleplus.html @@ -0,0 +1,11 @@ +{% if site.googleplus_user %} +<section class="googleplus{% if site.googleplus_hidden %} googleplus-hidden{% endif %}"> + <h1> + <a href="https://plus.google.com/{{ site.googleplus_user }}?rel=author"> + <img src="http://www.google.com/images/icons/ui/gprofile_button-32.png" width="32" height="32"> + Google+ + </a> + </h1> +</section> +{% endif %} + diff --git a/.themes/classic/source/_includes/disqus.html b/.themes/classic/source/_includes/disqus.html index a58512b5..eb308779 100644 --- a/.themes/classic/source/_includes/disqus.html +++ b/.themes/classic/source/_includes/disqus.html @@ -1,7 +1,6 @@ {% comment %} Load script if disquss comments are enabled and `page.comments` is either empty (index) or set to true {% endcomment %} {% if site.disqus_short_name and page.comments != false %} <script type="text/javascript"> - var disqus_shortname = '{{ site.disqus_short_name }}'; {% if page.comments == true %} {% comment %} `page.comments` can be only be set to true on pages/posts, so we embed the comments here. {% endcomment %} diff --git a/.themes/classic/source/_includes/facebook_like.html b/.themes/classic/source/_includes/facebook_like.html index 6c4c2788..74f91307 100644 --- a/.themes/classic/source/_includes/facebook_like.html +++ b/.themes/classic/source/_includes/facebook_like.html @@ -1,3 +1,4 @@ +{% if site.facebook_like %} <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; @@ -6,3 +7,4 @@ js.src = "//connect.facebook.net/en_US/all.js#appId=212934732101925&xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> +{% endif %} diff --git a/.themes/classic/source/_includes/head.html b/.themes/classic/source/_includes/head.html index fd7e2365..0fdc4019 100644 --- a/.themes/classic/source/_includes/head.html +++ b/.themes/classic/source/_includes/head.html @@ -8,7 +8,7 @@ <meta name="author" content="{{ site.author }}"> {% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %} - <meta name="description" content="{{ description | strip_newlines | strip_html | truncate:150 }}"> + <meta name="description" content="{{ description | strip_html | condense_spaces | truncate:150 }}"> {% if page.keywords %}<meta name="keywords" content="{{ page.keywords }}">{% endif %} <!-- http://t.co/dKP3o1e --> @@ -16,7 +16,7 @@ <meta name="MobileOptimized" content="320"> <meta name="viewport" content="width=device-width, initial-scale=1"> - {% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %} + {% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %} <link rel="canonical" href="{{ canonical }}"> <link href="{{ root_url }}/favicon.png" rel="icon"> <link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> @@ -25,4 +25,5 @@ <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"> {% include custom/head.html %} + {% include google_analytics.html %} </head> diff --git a/.themes/classic/source/_includes/post/date.html b/.themes/classic/source/_includes/post/date.html index dbfa67ae..ecf1ad71 100644 --- a/.themes/classic/source/_includes/post/date.html +++ b/.themes/classic/source/_includes/post/date.html @@ -1,12 +1,15 @@ {% capture date %}{{ page.date }}{{ post.date }}{% endcapture %} +{% capture date_formatted %}{{ page.date_formatted }}{{ post.date_formatted }}{% endcapture %} {% capture has_date %}{{ date | size }}{% endcapture %} + {% capture updated %}{{ page.updated }}{{ post.updated }}{% endcapture %} +{% capture updated_formatted %}{{ page.updated_formatted }}{{ post.updated_formatted }}{% endcapture %} {% capture was_updated %}{{ updated | size }}{% endcapture %} {% if has_date != '0' %} - {% capture time %}<time datetime="{{ date | datetime | date_to_xmlschema }}" pubdate {% if updated %} data-updated="true" {% endif %}>{{ date | ordinalize }}</time>{% endcapture %} + {% capture time %}<time datetime="{{ date | datetime | date_to_xmlschema }}" pubdate{% if updated %} data-updated="true"{% endif %}>{{ date_formatted }}</time>{% endcapture %} {% endif %} {% if was_updated != '0' %} - {% capture updated %}<time class="updated" datetime="{{ updated | datetime | date_to_xmlschema }}">Updated {{ updated | ordinalize }}</time>{% endcapture %} -{% else %}{% assign updated = false %}{% endif %} + {% capture updated %}<time datetime="{{ updated | datetime | date_to_xmlschema }}" class="updated">Updated {{ updated_formatted }}</time>{% endcapture %} +{% else %}{% assign updated = false %}{% endif %}
\ No newline at end of file diff --git a/.themes/classic/source/_layouts/post.html b/.themes/classic/source/_layouts/post.html index f61d52a8..d3c42e37 100644 --- a/.themes/classic/source/_layouts/post.html +++ b/.themes/classic/source/_layouts/post.html @@ -16,10 +16,10 @@ single: true {% include post/sharing.html %} {% endunless %} <p class="meta"> - {% if page.previous.url %} + {% if page.previous.url %} <a class="basic-alignment left" href="{{page.previous.url}}" title="Previous Post: {{page.previous.title}}">« {{page.previous.title}}</a> {% endif %} - {% if page.next.url %} + {% if page.next.url %} <a class="basic-alignment right" href="{{page.next.url}}" title="next Post: {{page.next.title}}">{{page.next.title}} »</a> {% endif %} </p> diff --git a/.themes/classic/source/index.html b/.themes/classic/source/index.html index e2eb6211..a114e5a8 100644 --- a/.themes/classic/source/index.html +++ b/.themes/classic/source/index.html @@ -10,17 +10,15 @@ layout: default {% include article.html %} </article> {% endfor %} - <nav class="pagination"> - <div> - {% if paginator.next_page %} - <a class="prev" href="{{paginator.next_page}}">← Older</a> - {% endif %} - <a href="/blog/archives">Blog Archives</a> - {% if paginator.previous_page %} - <a class="next" href="{{paginator.previous_page}}">Newer →</a> - {% endif %} - </div> - </nav> + <div class="pagination"> + {% if paginator.next_page %} + <a class="prev" href="{{paginator.next_page}}">← Older</a> + {% endif %} + <a href="/blog/archives">Blog Archives</a> + {% if paginator.previous_page %} + <a class="next" href="{{paginator.previous_page}}">Newer →</a> + {% endif %} + </div> </div> <aside class="sidebar"> {% if site.blog_index_asides.size %} diff --git a/.themes/classic/source/javascripts/github.js b/.themes/classic/source/javascripts/github.js index 82e11607..678775a9 100644 --- a/.themes/classic/source/javascripts/github.js +++ b/.themes/classic/source/javascripts/github.js @@ -15,7 +15,8 @@ var github = (function(){ , error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); } , success: function(data) { var repos = []; - for (var i = 0; i < data.repositories.length; i++){ + if (!data || !data.repositories) { return; } + for (var i = 0; i < data.repositories.length; i++) { if (options.skip_forks && data.repositories[i].fork) { continue; } repos.push(data.repositories[i]); } @@ -30,7 +31,7 @@ var github = (function(){ if (options.count) { repos.splice(options.count); } render(options.target, repos); } - }) + }); } }; })(); @@ -12,6 +12,7 @@ group :development do gem 'rubypants' gem 'rb-fsevent' gem 'stringex' + gem 'liquid', '2.2.2' end gem 'sinatra', '1.2.6' diff --git a/Gemfile.lock b/Gemfile.lock index 0ae80bc7..63506982 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,7 @@ DEPENDENCIES compass (>= 0.11) haml (>= 3.1) jekyll + liquid (= 2.2.2) pygments.rb rack rake @@ -59,7 +59,7 @@ task :watch do raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) puts "Starting to watch source with Jekyll and Compass." system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css") - jekyllPid = Process.spawn("jekyll --auto") + jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto") compassPid = Process.spawn("compass watch") trap("INT") { @@ -75,7 +75,7 @@ task :preview do raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}" system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css") - jekyllPid = Process.spawn("jekyll --auto") + jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto") compassPid = Process.spawn("compass watch") rackupPid = Process.spawn("rackup --port #{server_port}") @@ -207,6 +207,13 @@ end desc "Default deploy task" task :deploy do + # Check if preview posts exist, which should not be published + if File.exists?(".preview-mode") + puts "## Found posts in preview mode, regenerating files ..." + File.delete(".preview-mode") + Rake::Task[:generate].execute + end + Rake::Task[:copydot].invoke(source_dir, public_dir) Rake::Task["#{deploy_default}"].execute end @@ -237,7 +244,7 @@ multitask :push do (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } Rake::Task[:copydot].invoke(public_dir, deploy_dir) puts "\n## copying #{public_dir} to #{deploy_dir}" - cp_r "#{public_dir}/*", deploy_dir + cp_r "#{public_dir}/.", deploy_dir cd "#{deploy_dir}" do system "git add ." system "git add -u" diff --git a/_config.yml b/_config.yml index f90307ac..91fa0183 100644 --- a/_config.yml +++ b/_config.yml @@ -8,6 +8,12 @@ subtitle: A blogging framework for hackers. author: Your Name simple_search: http://google.com/search +# Default date format is "ordinal" (resulting in "July 22nd 2007") +# You can customize the format as defined in +# http://www.ruby-doc.org/core-1.9.2/Time.html#method-i-strftime +# Additionally, %o will give you the ordinal representation of the day +date_format: "ordinal" + # RSS / Email (optional) subscription links (change if using something like Feedburner) subscribe_rss: /atom.xml subscribe_email: @@ -38,7 +44,7 @@ titlecase: true # Converts page and post titles to tilecase # list each of the sidebar modules you want to include, in the order you want them to appear. # To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html' -default_asides: [asides/recent_posts.html, asides/github.html, asides/twitter.html, asides/delicious.html, asides/pinboard.html] +default_asides: [asides/recent_posts.html, asides/github.html, asides/twitter.html, asides/delicious.html, asides/pinboard.html, asides/googleplus.html] # Each layout uses the default asides, but they can have their own asides instead. Simply uncomment the lines below # and add an array with the asides you want to use. @@ -64,10 +70,15 @@ twitter_follow_button: true twitter_show_follower_count: false twitter_tweet_button: true -# Google Plus -google_plus_one: true +# Google +1 +google_plus_one: false google_plus_one_size: medium +# Google Plus Profile +# Hidden: No visible button, just add author information to search results +googleplus_user: +googleplus_hidden: false + # Pinboard pinboard_user: pinboard_count: 3 @@ -82,6 +93,6 @@ disqus_show_comment_count: false # Google Analytics google_analytics_tracking_id: - + # Facebook Like -facebook_like: true +facebook_like: false diff --git a/plugins/date.rb b/plugins/date.rb new file mode 100644 index 00000000..b864f3e9 --- /dev/null +++ b/plugins/date.rb @@ -0,0 +1,98 @@ +module Octopress + module Date + + # Returns a datetime if the input is a string + def datetime(date) + if date.class == String + date = Time.parse(date) + end + date + end + + # Returns an ordidinal date eg July 22 2007 -> July 22nd 2007 + def ordinalize(date) + date = datetime(date) + "#{date.strftime('%b')} #{ordinal(date.strftime('%e').to_i)}, #{date.strftime('%Y')}" + end + + # Returns an ordinal number. 13 -> 13th, 21 -> 21st etc. + def ordinal(number) + if (11..13).include?(number.to_i % 100) + "#{number}<span>th</span>" + else + case number.to_i % 10 + when 1; "#{number}<span>st</span>" + when 2; "#{number}<span>nd</span>" + when 3; "#{number}<span>rd</span>" + else "#{number}<span>th</span>" + end + end + end + + # Formats date either as ordinal or by given date format + # Adds %o as ordinal representation of the day + def format_date(date, format) + date = datetime(date) + if format.nil? || format.empty? || format == "ordinal" + date_formatted = ordinalize(date) + else + date_formatted = date.strftime(format) + date_formatted.gsub!(/%o/, ordinal(date.strftime('%e').to_i)) + end + date_formatted + end + + end +end + + +module Jekyll + + class Post + include Octopress::Date + + # Convert this post into a Hash for use in Liquid templates. + # + # Returns <Hash> + def to_liquid + date_format = self.site.config['date_format'] + self.data.deep_merge({ + "title" => self.data['title'] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '), + "url" => self.url, + "date" => self.date, + # Monkey patch + "date_formatted" => format_date(self.date, date_format), + "updated_formatted" => self.data.has_key?('updated') ? format_date(self.data['updated'], date_format) : nil, + "id" => self.id, + "categories" => self.categories, + "next" => self.next, + "previous" => self.previous, + "tags" => self.tags, + "content" => self.content }) + end + end + + class Page + include Octopress::Date + + # Initialize a new Page. + # + # site - The Site object. + # base - The String path to the source. + # dir - The String path between the source and the file. + # name - The String filename of the file. + def initialize(site, base, dir, name) + @site = site + @base = base + @dir = dir + @name = name + + self.process(name) + self.read_yaml(File.join(base, dir), name) + # Monkey patch + date_format = self.site.config['date_format'] + self.data['date_formatted'] = format_date(self.data['date'], date_format) if self.data.has_key?('date') + self.data['updated_formatted'] = format_date(self.data['updated'], date_format) if self.data.has_key?('updated') + end + end +end
\ No newline at end of file diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index ac5ee3c6..74dd3b37 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -71,7 +71,13 @@ module Jekyll def get_gist_from_web(gist, file) gist_url = get_gist_url_for gist, file raw_uri = URI.parse gist_url - https = Net::HTTP.new raw_uri.host, raw_uri.port + proxy = ENV['http_proxy'] + if proxy + proxy_uri = URI.parse(proxy) + https = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new raw_uri.host, raw_uri.port + else + https = Net::HTTP.new raw_uri.host, raw_uri.port + end https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new raw_uri.request_uri diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index ef8c1fb2..a5bb235c 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -2,6 +2,7 @@ require './plugins/backtick_code_block' require './plugins/post_filters' require './plugins/raw' +require './plugins/date' require 'rubypants' module OctopressFilters @@ -33,6 +34,8 @@ end module OctopressLiquidFilters + include Octopress::Date + # Used on the blog index to split posts on the <!--more--> marker def excerpt(input) if input.index(/<!--\s*more\s*-->/i) @@ -76,6 +79,33 @@ module OctopressLiquidFilters end end + # Improved version of Liquid's truncate: + # - Doesn't cut in the middle of a word. + # - Uses typographically correct ellipsis (…) insted of '...' + def truncate(input, length) + if input.length > length && input[0..(length-1)] =~ /(.+)\b.+$/im + $1.strip + ' …' + else + input + end + end + + # Improved version of Liquid's truncatewords: + # - Uses typographically correct ellipsis (…) insted of '...' + def truncatewords(input, length) + truncate = input.split(' ') + if truncate.length > length + truncate[0..length-1].join(' ').strip + ' …' + else + input + end + end + + # Condenses multiple spaces and tabs into a single space + def condense_spaces(input) + input.gsub(/\s{2,}/, ' ') + end + # Removes trailing forward slash from a string for easily appending url segments def strip_slash(input) if input =~ /(.+)\/$|^\/$/ @@ -96,33 +126,6 @@ module OctopressLiquidFilters input.titlecase end - # Returns a datetime if the input is a string - def datetime(date) - if date.class == String - date = Time.parse(date) - end - date - end - - # Returns an ordidinal date eg July 22 2007 -> July 22nd 2007 - def ordinalize(date) - date = datetime(date) - "#{date.strftime('%b')} #{ordinal(date.strftime('%e').to_i)}, #{date.strftime('%Y')}" - end - - # Returns an ordinal number. 13 -> 13th, 21 -> 21st etc. - def ordinal(number) - if (11..13).include?(number.to_i % 100) - "#{number}<span>th</span>" - else - case number.to_i % 10 - when 1; "#{number}<span>st</span>" - when 2; "#{number}<span>nd</span>" - when 3; "#{number}<span>rd</span>" - else "#{number}<span>th</span>" - end - end - end end Liquid::Template.register_filter OctopressLiquidFilters diff --git a/plugins/preview_unpublished.rb b/plugins/preview_unpublished.rb new file mode 100644 index 00000000..321ffd6f --- /dev/null +++ b/plugins/preview_unpublished.rb @@ -0,0 +1,48 @@ +# Monkeypatch for Jekyll +# Introduce distinction between preview/productive site generation +# so posts with YAML attribute `published: false` can be previewed +# on localhost without being published to the productive environment. + +module Jekyll + + class Site + # Read all the files in <source>/<dir>/_posts and create a new Post + # object with each one. + # + # dir - The String relative path of the directory to read. + # + # Returns nothing. + def read_posts(dir) + base = File.join(self.source, dir, '_posts') + return unless File.exists?(base) + entries = Dir.chdir(base) { filter_entries(Dir['**/*']) } + + # first pass processes, but does not yet render post content + entries.each do |f| + if Post.valid?(f) + post = Post.new(self, self.source, dir, f) + + # Monkeypatch: + # On preview environment (localhost), publish all posts + if ENV.has_key?('OCTOPRESS_ENV') && ENV['OCTOPRESS_ENV'] == 'preview' && post.data.has_key?('published') && post.data['published'] == false + post.published = true + # Set preview mode flag (if necessary), `rake generate` will check for it + # to prevent pushing preview posts to productive environment + File.open(".preview-mode", "w") {} + end + + if post.published && (self.future || post.date <= self.time) + self.posts << post + post.categories.each { |c| self.categories[c] << post } + post.tags.each { |c| self.tags[c] << post } + end + end + end + + self.posts.sort! + + # limit the posts if :limit_posts option is set + self.posts = self.posts[-limit_posts, limit_posts] if limit_posts + end + end +end
\ No newline at end of file diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb index c009df9f..1676a3e0 100644 --- a/plugins/pygments_code.rb +++ b/plugins/pygments_code.rb @@ -21,11 +21,11 @@ module HighlightCode if File.exist?(path) highlighted_code = File.read(path) else - highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html') + highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'}) File.open(path, 'w') {|f| f.print(highlighted_code) } end else - highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html') + highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'}) end highlighted_code end diff --git a/plugins/titlecase.rb b/plugins/titlecase.rb index 3ad39b1f..7648932c 100644 --- a/plugins/titlecase.rb +++ b/plugins/titlecase.rb @@ -11,8 +11,8 @@ class String # capitalize first and last words x.first.to_s.smart_capitalize! x.last.to_s.smart_capitalize! - # small words after colons or periods are capitalized - x.join(" ").gsub(/(:|\.)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " } + # small words are capitalized after colon, period, exclamation mark, question mark + x.join(" ").gsub(/(:|\.|!|\?)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " } end def titlecase! |