From 7c137e756172392f3a20748ad83a6413779e2e5e Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sat, 21 Jun 2014 22:37:55 -0500 Subject: [PATCH 01/18] replaced backtick-code-block with octopress-codefence --- .gitignore | 1 + Gemfile | 1 + Gemfile.lock | 6 +++++ plugins/backtick_code_block.rb | 43 ---------------------------------- plugins/octopress_filters.rb | 37 +++-------------------------- plugins/raw.rb | 24 ------------------- plugins/render_partial.rb | 18 ++++++++++---- 7 files changed, 24 insertions(+), 106 deletions(-) delete mode 100644 plugins/backtick_code_block.rb diff --git a/.gitignore b/.gitignore index 68a68305bf9..fddcefb0d9e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .sass-cache .gist-cache .pygments-cache +.code-highlighter-cache _deploy public sass.old diff --git a/Gemfile b/Gemfile index 9557d593b74..aa825897408 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ group :development do gem 'jekyll-page-hooks', '~> 1.2' gem 'jekyll-date-format', '~> 1.0' gem 'jekyll-sitemap' + gem 'octopress-codefence' gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2.9' gem 'haml', '~> 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 55a3c463b63..46a55043316 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,6 +53,11 @@ GEM rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) mercenary (0.3.3) + octopress-code-highlighter (4.0.0) + colorator (~> 0.1.0) + octopress-codefence (1.4.2) + jekyll-page-hooks (>= 1.0.2) + octopress-code-highlighter (~> 4.0.0) parslet (1.5.0) blankslate (~> 2.0) posix-spawn (0.3.8) @@ -95,6 +100,7 @@ DEPENDENCIES jekyll-date-format (~> 1.0) jekyll-page-hooks (~> 1.2) jekyll-sitemap + octopress-codefence rake (~> 10.0) rb-fsevent (~> 0.9) rdiscount (~> 2.0) diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb deleted file mode 100644 index 8e2c11414a1..00000000000 --- a/plugins/backtick_code_block.rb +++ /dev/null @@ -1,43 +0,0 @@ -require './plugins/pygments_code' - -module BacktickCodeBlock - include HighlightCode - AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i - LangCaption = /([^\s]+)\s*(.+)?/i - def render_code_block(input) - @options = nil - @caption = nil - @lang = nil - @url = nil - @title = nil - input.gsub(/^`{3} *([^\n]+)?\n(.+?)\n`{3}/m) do - @options = $1 || '' - str = $2 - - if @options =~ AllOptions - @lang = $1 - @caption = "
#{$2}#{$4 || 'link'}
" - elsif @options =~ LangCaption - @lang = $1 - @caption = "
#{$2}
" - end - - if str.match(/\A( {4}|\t)/) - str = str.gsub(/^( {4}|\t)/, '') - end - if @lang.nil? || @lang == 'plain' - code = tableize_code(str.gsub('<','<').gsub('>','>')) - "
#{@caption}#{code}
" - else - if @lang.include? "-raw" - raw = "``` #{@options.sub('-raw', '')}\n" - raw += str - raw += "\n```\n" - else - code = highlight(str, @lang) - "
#{@caption}#{code}
" - end - end - end - end -end diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index aad5bf9f960..cf5d51740ac 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -1,43 +1,11 @@ #custom filters for Octopress -require './plugins/backtick_code_block' -require 'jekyll-page-hooks' +#require './plugins/backtick_code_block' +require 'octopress-codefence' require 'jekyll-sitemap' require 'jekyll-date-format' require './plugins/raw' require 'rubypants' -module OctopressFilters - include BacktickCodeBlock - include TemplateWrapper - def pre_filter(input) - input = render_code_block(input) - input.gsub /(.+?<\/figure>)/m do - safe_wrap($1) - end - end - def post_filter(input) - input = unwrap(input) - RubyPants.new(input).to_html - end -end - -module Jekyll - class ContentFilters < PageHooks - include OctopressFilters - def pre_render(post) - if post.ext.match('html|textile|markdown|md|haml|slim|xml') - post.content = pre_filter(post.content) - end - end - def post_render(post) - if post.ext.match('html|textile|markdown|md|haml|slim|xml') - post.content = post_filter(post.content) - end - end - end -end - - module OctopressLiquidFilters # Used on the blog index to split posts on the marker @@ -131,5 +99,6 @@ def titlecase(input) end end + Liquid::Template.register_filter OctopressLiquidFilters diff --git a/plugins/raw.rb b/plugins/raw.rb index 4b002625d5c..a18fea0a48b 100644 --- a/plugins/raw.rb +++ b/plugins/raw.rb @@ -14,27 +14,3 @@ def unwrap(input) end end -# Author: phaer, https://github.com/phaer -# Source: https://gist.github.com/1020852 -# Description: Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %} - -module Jekyll - class RawTag < Liquid::Block - def parse(tokens) - @nodelist ||= [] - @nodelist.clear - - while token = tokens.shift - if token =~ FullToken - if block_delimiter == $1 - end_tag - return - end - end - @nodelist << token if not token.empty? - end - end - end -end - -Liquid::Template.register_tag('raw', Jekyll::RawTag) diff --git a/plugins/render_partial.rb b/plugins/render_partial.rb index b6ebfe8b549..39bf499be76 100644 --- a/plugins/render_partial.rb +++ b/plugins/render_partial.rb @@ -21,13 +21,11 @@ # # -require 'pathname' -require './plugins/octopress_filters' +require 'jekyll-page-hooks' module Jekyll class RenderPartialTag < Liquid::Tag - include OctopressFilters def initialize(tag_name, markup, tokens) @file = nil @raw = false @@ -40,7 +38,7 @@ def initialize(tag_name, markup, tokens) def render(context) file_dir = (context.registers[:site].source || 'source') - file_path = Pathname.new(file_dir).expand_path + file_path = File.expand_path(file_dir) file = file_path + @file unless file.file? @@ -52,7 +50,9 @@ def render(context) if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m contents = $1.lstrip end - contents = pre_filter(contents) + + content = parse_convertible(content, context) + if @raw contents else @@ -63,6 +63,14 @@ def render(context) end end end + + # Ensure jekyll page hooks are processed + def parse_convertible(content, context) + page = Jekyll::ConvertiblePartial.new(context.registers[:site], @path, content) + page.render({}) + page.output.strip + end + end end From e0dc448766893aed202d1695843e0b9ceea8975b Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sat, 21 Jun 2014 23:05:24 -0500 Subject: [PATCH 02/18] Replaced gist plugin --- Gemfile | 1 + Gemfile.lock | 3 + plugins/gist_tag.rb | 246 +++++++++++++++++------------------ plugins/octopress_filters.rb | 1 + 4 files changed, 128 insertions(+), 123 deletions(-) diff --git a/Gemfile b/Gemfile index aa825897408..29ed720c1c7 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ group :development do gem 'jekyll-date-format', '~> 1.0' gem 'jekyll-sitemap' gem 'octopress-codefence' + gem 'octopress-gist' gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2.9' gem 'haml', '~> 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 46a55043316..c86778ee98f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,6 +58,8 @@ GEM octopress-codefence (1.4.2) jekyll-page-hooks (>= 1.0.2) octopress-code-highlighter (~> 4.0.0) + octopress-gist (1.2.0) + octopress-code-highlighter (~> 4.0.0) parslet (1.5.0) blankslate (~> 2.0) posix-spawn (0.3.8) @@ -101,6 +103,7 @@ DEPENDENCIES jekyll-page-hooks (~> 1.2) jekyll-sitemap octopress-codefence + octopress-gist rake (~> 10.0) rb-fsevent (~> 0.9) rdiscount (~> 2.0) diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index 5120115621a..7874e488fdb 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -5,126 +5,126 @@ # # Example usage: {% gist 1027674 gist_tag.rb %} //embeds a gist for this plugin -require 'cgi' -require 'digest/md5' -require 'net/https' -require 'uri' - -module Jekyll - class GistTag < Liquid::Tag - def initialize(tag_name, text, token) - super - @text = text - @cache_disabled = false - @cache_folder = File.expand_path "../.gist-cache", File.dirname(__FILE__) - FileUtils.mkdir_p @cache_folder - end - - def render(context) - if parts = @text.match(/([a-zA-Z\d]*) (.*)/) - gist, file = parts[1].strip, parts[2].strip - else - gist, file = @text.strip, "" - end - if gist.empty? - "" - else - script_url = script_url_for gist, file - code = get_cached_gist(gist, file) || get_gist_from_web(gist, file) - html_output_for script_url, code - end - end - - def html_output_for(script_url, code) - code = CGI.escapeHTML code - <<-HTML -
-
- HTML - end - - def script_url_for(gist_id, filename) - url = "https://gist.github.com/#{gist_id}.js" - url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty? - url - end - - def get_gist_url_for(gist, file) - "https://gist.githubusercontent.com/raw/#{gist}/#{file}" - end - - def cache(gist, file, data) - cache_file = get_cache_file_for gist, file - File.open(cache_file, "w") do |io| - io.write data - end - end - - def get_cached_gist(gist, file) - return nil if @cache_disabled - cache_file = get_cache_file_for gist, file - File.read cache_file if File.exist? cache_file - end - - def get_cache_file_for(gist, file) - bad_chars = /[^a-zA-Z0-9\-_.]/ - gist = gist.gsub bad_chars, '' - file = file.gsub bad_chars, '' - md5 = Digest::MD5.hexdigest "#{gist}-#{file}" - File.join @cache_folder, "#{gist}-#{file}-#{md5}.cache" - end - - def get_gist_from_web(gist, file) - gist_url = get_gist_url_for(gist, file) - data = get_web_content(gist_url) - - locations = Array.new - while (data.code.to_i == 301 || data.code.to_i == 302) - data = handle_gist_redirecting(data) - break if locations.include? data.header['Location'] - locations << data.header['Location'] - end - - if data.code.to_i != 200 - raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}" - end - - cache(gist, file, data.body) unless @cache_disabled - data.body - end - - def handle_gist_redirecting(data) - redirected_url = data.header['Location'] - if redirected_url.nil? || redirected_url.empty? - raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers." - end - - get_web_content(redirected_url) - end - - def get_web_content(url) - raw_uri = URI.parse url - 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 - data = https.request request - end - end - - class GistTagNoCache < GistTag - def initialize(tag_name, text, token) - super - @cache_disabled = true - end - end -end - -Liquid::Template.register_tag('gist', Jekyll::GistTag) -Liquid::Template.register_tag('gistnocache', Jekyll::GistTagNoCache) +#require 'cgi' +#require 'digest/md5' +#require 'net/https' +#require 'uri' + +#module Jekyll + #class GistTag < Liquid::Tag + #def initialize(tag_name, text, token) + #super + #@text = text + #@cache_disabled = false + #@cache_folder = File.expand_path "../.gist-cache", File.dirname(__FILE__) + #FileUtils.mkdir_p @cache_folder + #end + + #def render(context) + #if parts = @text.match(/([a-zA-Z\d]*) (.*)/) + #gist, file = parts[1].strip, parts[2].strip + #else + #gist, file = @text.strip, "" + #end + #if gist.empty? + #"" + #else + #script_url = script_url_for gist, file + #code = get_cached_gist(gist, file) || get_gist_from_web(gist, file) + #html_output_for script_url, code + #end + #end + + #def html_output_for(script_url, code) + #code = CGI.escapeHTML code + #<<-HTML +#
+#
+ #HTML + #end + + #def script_url_for(gist_id, filename) + #url = "https://gist.github.com/#{gist_id}.js" + #url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty? + #url + #end + + #def get_gist_url_for(gist, file) + #"https://gist.githubusercontent.com/raw/#{gist}/#{file}" + #end + + #def cache(gist, file, data) + #cache_file = get_cache_file_for gist, file + #File.open(cache_file, "w") do |io| + #io.write data + #end + #end + + #def get_cached_gist(gist, file) + #return nil if @cache_disabled + #cache_file = get_cache_file_for gist, file + #File.read cache_file if File.exist? cache_file + #end + + #def get_cache_file_for(gist, file) + #bad_chars = /[^a-zA-Z0-9\-_.]/ + #gist = gist.gsub bad_chars, '' + #file = file.gsub bad_chars, '' + #md5 = Digest::MD5.hexdigest "#{gist}-#{file}" + #File.join @cache_folder, "#{gist}-#{file}-#{md5}.cache" + #end + + #def get_gist_from_web(gist, file) + #gist_url = get_gist_url_for(gist, file) + #data = get_web_content(gist_url) + + #locations = Array.new + #while (data.code.to_i == 301 || data.code.to_i == 302) + #data = handle_gist_redirecting(data) + #break if locations.include? data.header['Location'] + #locations << data.header['Location'] + #end + + #if data.code.to_i != 200 + #raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}" + #end + + #cache(gist, file, data.body) unless @cache_disabled + #data.body + #end + + #def handle_gist_redirecting(data) + #redirected_url = data.header['Location'] + #if redirected_url.nil? || redirected_url.empty? + #raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers." + #end + + #get_web_content(redirected_url) + #end + + #def get_web_content(url) + #raw_uri = URI.parse url + #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 + #data = https.request request + #end + #end + + #class GistTagNoCache < GistTag + #def initialize(tag_name, text, token) + #super + #@cache_disabled = true + #end + #end +#end + +#Liquid::Template.register_tag('gist', Jekyll::GistTag) +#Liquid::Template.register_tag('gistnocache', Jekyll::GistTagNoCache) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index cf5d51740ac..8075a0f7c45 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -1,6 +1,7 @@ #custom filters for Octopress #require './plugins/backtick_code_block' require 'octopress-codefence' +require 'octopress-gist' require 'jekyll-sitemap' require 'jekyll-date-format' require './plugins/raw' From 39d042f0ef397eb366a984d09f4cdd010cf2c5f0 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 22 Jun 2014 00:28:37 -0500 Subject: [PATCH 03/18] Updated styles for codeblocks --- .themes/classic/sass/_base.scss | 2 +- .themes/classic/sass/_partials.scss | 1 - .../sass/base/solarized/_code-highlight.scss | 145 ++++++++++ .../sass/base/solarized/_code-style.scss | 113 ++++++++ .../classic/sass/base/solarized/_index.scss | 5 + .../sass/base/solarized/_solarized.scss | 57 ++++ .../sass/base/solarized/_standard-code.scss | 14 + .themes/classic/sass/partials/_syntax.scss | 261 ------------------ 8 files changed, 335 insertions(+), 263 deletions(-) create mode 100644 .themes/classic/sass/base/solarized/_code-highlight.scss create mode 100644 .themes/classic/sass/base/solarized/_code-style.scss create mode 100644 .themes/classic/sass/base/solarized/_index.scss create mode 100644 .themes/classic/sass/base/solarized/_solarized.scss create mode 100644 .themes/classic/sass/base/solarized/_standard-code.scss delete mode 100644 .themes/classic/sass/partials/_syntax.scss diff --git a/.themes/classic/sass/_base.scss b/.themes/classic/sass/_base.scss index 05fdd005cbe..acac463832a 100644 --- a/.themes/classic/sass/_base.scss +++ b/.themes/classic/sass/_base.scss @@ -1,5 +1,5 @@ @import "base/utilities"; -@import "base/solarized"; +@import "base/solarized/index"; @import "base/theme"; @import "base/typography"; @import "base/layout"; diff --git a/.themes/classic/sass/_partials.scss b/.themes/classic/sass/_partials.scss index 99c28b6378c..f90a9c69fa1 100644 --- a/.themes/classic/sass/_partials.scss +++ b/.themes/classic/sass/_partials.scss @@ -2,7 +2,6 @@ @import "partials/navigation"; @import "partials/blog"; @import "partials/sharing"; -@import "partials/syntax"; @import "partials/archive"; @import "partials/sidebar"; @import "partials/footer"; diff --git a/.themes/classic/sass/base/solarized/_code-highlight.scss b/.themes/classic/sass/base/solarized/_code-highlight.scss new file mode 100644 index 00000000000..85bd37a126d --- /dev/null +++ b/.themes/classic/sass/base/solarized/_code-highlight.scss @@ -0,0 +1,145 @@ +.code-highlight { + @include octopress-highlight-style; + @include octopress-solarized-code; +} + +.code-highlight-figure { + margin: 1.8em 0; + font-size: 14px; + * { box-sizing: border-box; } +} + +.code-highlight-pre { + background: darken($base03, 1); + width: 100%; + margin-bottom: 0; + display: table; +} + +.code-highlight-row { + display: table-row; + width: 100%; +} + +.code-highlight-row { + &:before, .code-highlight-line { + padding: {left: $pre-line-padding + .8; right: $pre-line-padding + .8 } + } + &:first-child { + &:before, .code-highlight-line { padding-top: $pre-line-padding; } + } + &:last-child { + &:before, .code-highlight-line { padding-bottom: $pre-line-padding; } + } + &.numbered { + &:before, .code-highlight-line { + padding: {left: $pre-line-padding; right: $pre-line-padding } + } + &:before { + display: table-cell; + content: attr(data-line); + min-width: 1.2em; + color: $base01; + text-align: right; + line-height: 1.45em; + @if $solarized == light { + background: lighten($base03, 1); + border-right: 1px solid darken($base02, 2); + text-shadow: lighten($base02, 2) 0 -1px; + } @else { + background: $base02; + border-right: 1px solid darken($base03, 2); + box-shadow: lighten($base02, 2) -1px 0 inset; + text-shadow: darken($base02, 10) 0 -1px; + } + } + } +} + +.code-highlight-line { + display: table-cell; + width: 100%; + position: relative; + z-index: 1; +} + +.marked-line { + position: relative; + &.unnumbered { + } + .code-highlight-line { + &:before { + content: ""; + position: absolute; + background: $marker-bg; + left: 0; top: 0; bottom: 0; right: 0; + border-right: 1px solid $marker-border; + } + } + &.unnumbered .code-highlight-line:before { + border-left: 3px solid $marker-border-left; + } + &.numbered:before { + background: $marker-bg; + border-left: 3px solid $marker-border-left; + border-right-color: darken($marker-bg, 20); + } +} + +.start-marked-line { + &:before, .code-highlight-line:before { + border-top: 1px solid $marker-border; + } +} +.end-marked-line { + &:before, .code-highlight-line:before { + border-bottom: 1px solid $marker-border; + } +} + +.code-highlight-table { + margin-bottom: 0; + background: $base03; + pre { + padding: .8em; + background: none; + border-radius: 0; + border: none; + margin-bottom: 0; + } +} + +.code-highlight-figure { + margin: {left: 0; right: 0;} + background: none; + padding: 0; + border: 0; + pre { margin: { top: 0; bottom: 0; } } +} + +.code-highlight-caption { + position: relative; + text-align: center; + line-height: 2em; + text-shadow: #fff 0 1px 0; + color: #474747; + font-weight: normal; + margin-bottom: 0; + background-color: #ccc; + background-image: linear-gradient(#ffffff, #f0f0f0 6%, #e5e5e5 90%, #e5e5e5); + border-top-left-radius: 5px; + border-top-right-radius: 5px; + font-family: "Helvetica Neue", Arial, "Lucida Grande", "Lucida Sans Unicode", Lucida, sans-serif; + border: 1px solid #cbcbcb; + + .code-highlight { border-top: 0; } +} + +.code-highlight-caption-link { + position: absolute; right: .8em; + color: #666; + z-index: 1; + text-shadow: #cbcccc 0 1px 0; + padding-left: 3em; +} + + diff --git a/.themes/classic/sass/base/solarized/_code-style.scss b/.themes/classic/sass/base/solarized/_code-style.scss new file mode 100644 index 00000000000..44118deab0c --- /dev/null +++ b/.themes/classic/sass/base/solarized/_code-style.scss @@ -0,0 +1,113 @@ +$pre-line-padding: .8em !default; + +%octopress-diff-bg { + content: ""; + position: absolute; + z-index: -1; + left: 0; right: 0; top: 0; bottom: 0; +} + +@mixin octopress-diff-bg($bg) { + &:after { + background: $bg; + @extend %octopress-diff-bg; + } +} + +@mixin octopress-highlight-style { + border: 1px solid $code-highlight-border; + background: $pre-bg; + color: $base1; + + span { color: $base1; } + span { font-style: normal; font-weight: normal; } + + overflow: scroll; + overflow-y: hidden; + overflow-x: auto; + line-height: 1.45em; +} + +@mixin octopress-solarized-code { + .c { color: $base01; font-style: italic; } /* Comment */ + .cm { color: $base01; font-style: italic; } /* Comment.Multiline */ + .cp { color: $base01; font-style: italic; } /* Comment.Preproc */ + .c1 { color: $base01; font-style: italic; } /* Comment.Single */ + .cs { /* Comment.Special */ + color: $base01; + font-weight: bold; + font-style: italic; } + .err { color: $solar-red; background: none; } /* Error */ + .k { color: $solar-orange; } /* Keyword */ + .o { color: $base1; font-weight: bold; } /* Operator */ + .p { color: $base1; } /* Operator */ + .ow { color: $solar-cyan; font-weight: bold; } /* Operator.Word */ + .gd { + color: $base1; /* Generic.Deleted */ + @include octopress-diff-bg(mix($solar-red, $base03, 25%)); + } + .gd .x { /* Generic.Deleted.Specific */ + color: $base1; + @include octopress-diff-bg(mix($solar-red, $base03, 35%)); + } + .ge { /* Generic.Emph */ + color: $base1; + font-style: italic; } + //.gr { color: #aa0000 } /* Generic.Error */ + .gh { color: $base01; } /* Generic.Heading */ + .gi { /* Generic.Inserted */ + color: $base1; + @include octopress-diff-bg(mix($solar-green, $base03, 20%)); + } + .gi .x { /* Generic.Inserted.Specific */ + color: $base1; + @include octopress-diff-bg(mix($solar-green, $base03, 40%)); + } + //.go { color: #888888 } /* Generic.Output */ + //.gp { color: #555555 } /* Generic.Prompt */ + .gs { color: $base1; font-weight: bold; } /* Generic.Strong */ + .gu { color: $solar-violet; } /* Generic.Subheading */ + //.gt { color: #aa0000 } /* Generic.Traceback */ + .kc { color: $solar-green; font-weight: bold; } /* Keyword.Constant */ + .kd { color: $solar-blue; } /* Keyword.Declaration */ + .kp { color: $solar-orange; font-weight: bold; } /* Keyword.Pseudo */ + .kr { color: $solar-magenta; font-weight: bold; } /* Keyword.Reserved */ + .kt { color: $solar-cyan; } /* Keyword.Type */ + .n { color: $solar-blue; } + .na { color: $solar-blue; } /* Name.Attribute */ + .nb { color: $solar-green; } /* Name.Builtin */ + .nc { color: $solar-magenta;} /* Name.Class */ + .no { color: $solar-yellow; } /* Name.Constant */ + //.ni { color: #800080 } /* Name.Entity */ + .nl { color: $solar-green; } + .ne { color: $solar-blue; font-weight: bold; } /* Name.Exception */ + .nf { color: $solar-blue; font-weight: bold; } /* Name.Function */ + .nn { color: $solar-yellow; } /* Name.Namespace */ + .nt { color: $solar-blue; font-weight: bold; } /* Name.Tag */ + .nx { color: $solar-yellow; } + //.bp { color: #999999 } /* Name.Builtin.Pseudo */ + //.vc { color: #008080 } /* Name.Variable.Class */ + .vg { color: $solar-blue; } /* Name.Variable.Global */ + .vi { color: $solar-blue; } /* Name.Variable.Instance */ + .nv { color: $solar-blue; } /* Name.Variable */ + //.w { color: #bbbbbb } /* Text.Whitespace */ + .mf { color: $solar-cyan; } /* Literal.Number.Float */ + .m { color: $solar-cyan; } /* Literal.Number */ + .mh { color: $solar-cyan; } /* Literal.Number.Hex */ + .mi { color: $solar-cyan; } /* Literal.Number.Integer */ + //.mo { color: #009999 } /* Literal.Number.Oct */ + .s { color: $solar-cyan; } /* Literal.String */ + //.sb { color: #d14 } /* Literal.String.Backtick */ + //.sc { color: #d14 } /* Literal.String.Char */ + .sd { color: $solar-cyan; } /* Literal.String.Doc */ + .s2 { color: $solar-cyan; } /* Literal.String.Double */ + .se { color: $solar-red; } /* Literal.String.Escape */ + //.sh { color: #d14 } /* Literal.String.Heredoc */ + .si { color: $solar-blue; } /* Literal.String.Interpol */ + //.sx { color: #d14 } /* Literal.String.Other */ + .sr { color: $solar-cyan; } /* Literal.String.Regex */ + .s1 { color: $solar-cyan; } /* Literal.String.Single */ + //.ss { color: #990073 } /* Literal.String.Symbol */ + //.il { color: #009999 } /* Literal.Number.Integer.Long */ +} + diff --git a/.themes/classic/sass/base/solarized/_index.scss b/.themes/classic/sass/base/solarized/_index.scss new file mode 100644 index 00000000000..ae2d42c264a --- /dev/null +++ b/.themes/classic/sass/base/solarized/_index.scss @@ -0,0 +1,5 @@ +$solarized: light !default; +@import 'solarized'; +@import 'code-style'; +@import 'code-highlight'; +@import 'standard-code'; diff --git a/.themes/classic/sass/base/solarized/_solarized.scss b/.themes/classic/sass/base/solarized/_solarized.scss new file mode 100644 index 00000000000..4e11f3fe0d7 --- /dev/null +++ b/.themes/classic/sass/base/solarized/_solarized.scss @@ -0,0 +1,57 @@ +$base03: #002b36 !default; //darkest blue +$base02: #073642 !default; //dark blue +$base01: #586e75 !default; //darkest gray +$base00: #657b83 !default; //dark gray +$base0: #839496 !default; //medium gray +$base1: #93a1a1 !default; //medium light gray +$base2: #f2f2f2 !default; //very light gray +$base3: #ffffff !default; //white +$solar-yellow: #b58900 !default; +$solar-orange: #cb4b16 !default; +$solar-red: #dc322f !default; +$solar-magenta: #d33682 !default; +$solar-violet: #6c71c4 !default; +$solar-blue: #268bd2 !default; +$solar-cyan: #2aa198 !default; +$solar-green: #859900 !default; + +$marker: rgba(#00baff, .5) !default; +$marker-bg: rgba($marker, .13) !default; +$marker-border: rgba($marker, .13) !default; +$marker-border-left: $marker !default; + +$solarized: light !default; + +$solar-scroll-bg: rgba(#fff, .15); +$solar-scroll-thumb: rgba(#fff, .2); + +@if $solarized == light { + + $_base03: $base03; + $_base02: $base02; + $_base01: $base01; + $_base00: $base00; + $_base0: $base0; + $_base1: $base1; + $_base2: $base2; + $_base3: $base3; + + $base03: $_base3; + $base02: $_base2; + $base01: $_base1; + $base00: $_base0; + $base0: $_base00; + $base1: $_base01; + $base2: $_base02; + $base3: $_base03; + + $solar-scroll-bg: rgba(#000, .15); + $solar-scroll-thumb: rgba(#000, .15); + + $marker-bg: rgba($marker, .05); +} + +$pre-bg: $base03 !default; +$pre-border: darken($base02, 5) !default; +$pre-color: $base1 !default; +$code-highlight-border: $pre-border; diff --git a/.themes/classic/sass/base/solarized/_standard-code.scss b/.themes/classic/sass/base/solarized/_standard-code.scss new file mode 100644 index 00000000000..51658a334a2 --- /dev/null +++ b/.themes/classic/sass/base/solarized/_standard-code.scss @@ -0,0 +1,14 @@ +.highlight pre, +pre:not(.code-highlight-pre) { + @include octopress-highlight-style; + padding: 1em .8rem; + border-radius: .4em; + margin: 1.8em 0; + @include octopress-solarized-code; +} + +pre, pre code { + * { box-sizing: border-box; } + font-size: 13px; + font-family: "PT Mono", "Source Code Pro", Inconsolata-dz, Inconsolata, Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; +} diff --git a/.themes/classic/sass/partials/_syntax.scss b/.themes/classic/sass/partials/_syntax.scss deleted file mode 100644 index 5465286fdee..00000000000 --- a/.themes/classic/sass/partials/_syntax.scss +++ /dev/null @@ -1,261 +0,0 @@ -.highlight, html .gist .gist-file .gist-syntax .gist-highlight { - table td.code { width: 100%; } - border: 1px solid $pre-border !important; -} -.highlight .line-numbers, html .gist .gist-file .gist-syntax .highlight .line_numbers { - text-align: right; - font-size: 13px; - line-height: 1.45em; - @if $solarized == light { - background: lighten($base03, 1) $noise-bg !important; - border-right: 1px solid darken($base02, 2) !important; - @include box-shadow(lighten($base03, 2) -1px 0 inset); - text-shadow: lighten($base02, 2) 0 -1px; - } @else { - background: $base02 $noise-bg !important; - border-right: 1px solid darken($base03, 2) !important; - @include box-shadow(lighten($base02, 2) -1px 0 inset); - text-shadow: darken($base02, 10) 0 -1px; - } - span { color: $base01 !important; } - padding: .8em !important; - @include border-radius(0); -} - -figure.code, .gist-file, pre { - @include box-shadow(rgba(#000, .06) 0 0 10px); - .highlight pre { @include box-shadow(none); } -} - -.gist .highlight, figure.code .highlight { - @include selection(adjust-color($base03, $lightness: 23%, $saturation: -65%), $text-shadow: $base03 0 1px); -} -html .gist .gist-file { - margin-bottom: 1.8em; - position: relative; - border: none; - padding-top: image-height("code_bg.png") !important; - .highlight { - margin-bottom: 0; - } - .gist-syntax { - border-bottom: 0 !important; - background: none !important; - .gist-highlight { - background: $base03 !important; - } - .highlight pre { - @extend .pre-code; - padding: 0; - } - } - .gist-meta { - padding: .6em 0.8em; - border: 1px solid lighten($base02, 2) !important; - color: $base01; - font-size: .7em !important; - @if $solarized == light { - background: lighten($base03, 2) $noise-bg; - border: 1px solid $pre-border !important; - border-top: 1px solid lighten($base03, 2) !important; - } @else { - background: $base02 $noise-bg; - } - @extend .sans; - line-height: 1.5em; - a { - color: mix($base1, $base01) !important; - @include hover-link; - &:hover { color: $base1 !important; } - } - a[href*='#file'] { - position: absolute; top: 0; left:0; right:-10px; - color: #474747 !important; - @extend .code-title; - &:hover { color: $link-color !important; } - } - a[href*=raw]{ - @extend .download-source; - top: .4em; - } - } -} -pre { - background: $pre-bg $noise-bg; - @include border-radius(.4em); - @extend .mono; - border: 1px solid $pre-border; - line-height: 1.45em; - font-size: 13px; - margin-bottom: 2.1em; - padding: .8em 1em; - color: $pre-color; - overflow: auto; -} -h3.filename { - @extend .code-title; - + pre { @include border-top-radius(0px); } -} - -p, li { - code { - @extend .mono; - display: inline-block; - white-space: no-wrap; - background: #fff; - font-size: .8em; - line-height: 1.5em; - color: #555; - border: 1px solid #ddd; - @include border-radius(.4em); - padding: 0 .3em; - margin: -1px 0; - } - pre code { font-size: 1em !important; background: none; border: none; } -} - -.pre-code { - font-family: $mono !important; - overflow: scroll; - overflow-y: hidden; - display: block; - padding: .8em; - overflow-x: auto; - line-height: 1.45em; - background: $base03 $noise-bg !important; - color: $base1 !important; - span { color: $base1 !important; } - span { font-style: normal !important; font-weight: normal !important; } - - .c { color: $base01 !important; font-style: italic !important; } /* Comment */ - .cm { color: $base01 !important; font-style: italic !important; } /* Comment.Multiline */ - .cp { color: $base01 !important; font-style: italic !important; } /* Comment.Preproc */ - .c1 { color: $base01 !important; font-style: italic !important; } /* Comment.Single */ - .cs { color: $base01 !important; font-weight: bold !important; font-style: italic !important; } /* Comment.Special */ - .err { color: $solar-red !important; background: none !important; } /* Error */ - .k { color: $solar-orange !important; } /* Keyword */ - .o { color: $base1 !important; font-weight: bold !important; } /* Operator */ - .p { color: $base1 !important; } /* Operator */ - .ow { color: $solar-cyan !important; font-weight: bold !important; } /* Operator.Word */ - .gd { color: $base1 !important; background-color: mix($solar-red, $base03, 25%) !important; display: inline-block; } /* Generic.Deleted */ - .gd .x { color: $base1 !important; background-color: mix($solar-red, $base03, 35%) !important; display: inline-block; } /* Generic.Deleted.Specific */ - .ge { color: $base1 !important; font-style: italic !important; } /* Generic.Emph */ - //.gr { color: #aa0000 } /* Generic.Error */ - .gh { color: $base01 !important; } /* Generic.Heading */ - .gi { color: $base1 !important; background-color: mix($solar-green, $base03, 20%) !important; display: inline-block; } /* Generic.Inserted */ - .gi .x { color: $base1 !important; background-color: mix($solar-green, $base03, 40%) !important; display: inline-block; } /* Generic.Inserted.Specific */ - //.go { color: #888888 } /* Generic.Output */ - //.gp { color: #555555 } /* Generic.Prompt */ - .gs { color: $base1 !important; font-weight: bold !important; } /* Generic.Strong */ - .gu { color: $solar-violet !important; } /* Generic.Subheading */ - //.gt { color: #aa0000 } /* Generic.Traceback */ - .kc { color: $solar-green !important; font-weight: bold !important; } /* Keyword.Constant */ - .kd { color: $solar-blue !important; } /* Keyword.Declaration */ - .kp { color: $solar-orange !important; font-weight: bold !important; } /* Keyword.Pseudo */ - .kr { color: $solar-magenta !important; font-weight: bold !important; } /* Keyword.Reserved */ - .kt { color: $solar-cyan !important; } /* Keyword.Type */ - .n { color: $solar-blue !important; } - .na { color: $solar-blue !important; } /* Name.Attribute */ - .nb { color: $solar-green !important; } /* Name.Builtin */ - .nc { color: $solar-magenta !important;} /* Name.Class */ - .no { color: $solar-yellow !important; } /* Name.Constant */ - //.ni { color: #800080 } /* Name.Entity */ - .nl { color: $solar-green !important; } - .ne { color: $solar-blue !important; font-weight: bold !important; } /* Name.Exception */ - .nf { color: $solar-blue !important; font-weight: bold !important; } /* Name.Function */ - .nn { color: $solar-yellow !important; } /* Name.Namespace */ - .nt { color: $solar-blue !important; font-weight: bold !important; } /* Name.Tag */ - .nx { color: $solar-yellow !Important; } - //.bp { color: #999999 } /* Name.Builtin.Pseudo */ - //.vc { color: #008080 } /* Name.Variable.Class */ - .vg { color: $solar-blue !important; } /* Name.Variable.Global */ - .vi { color: $solar-blue !important; } /* Name.Variable.Instance */ - .nv { color: $solar-blue !important; } /* Name.Variable */ - //.w { color: #bbbbbb } /* Text.Whitespace */ - .mf { color: $solar-cyan !important; } /* Literal.Number.Float */ - .m { color: $solar-cyan !important; } /* Literal.Number */ - .mh { color: $solar-cyan !important; } /* Literal.Number.Hex */ - .mi { color: $solar-cyan !important; } /* Literal.Number.Integer */ - //.mo { color: #009999 } /* Literal.Number.Oct */ - .s { color: $solar-cyan !important; } /* Literal.String */ - //.sb { color: #d14 } /* Literal.String.Backtick */ - //.sc { color: #d14 } /* Literal.String.Char */ - .sd { color: $solar-cyan !important; } /* Literal.String.Doc */ - .s2 { color: $solar-cyan !important; } /* Literal.String.Double */ - .se { color: $solar-red !important; } /* Literal.String.Escape */ - //.sh { color: #d14 } /* Literal.String.Heredoc */ - .si { color: $solar-blue !important; } /* Literal.String.Interpol */ - //.sx { color: #d14 } /* Literal.String.Other */ - .sr { color: $solar-cyan !important; } /* Literal.String.Regex */ - .s1 { color: $solar-cyan !important; } /* Literal.String.Single */ - //.ss { color: #990073 } /* Literal.String.Symbol */ - //.il { color: #009999 } /* Literal.Number.Integer.Long */ - div { .gd, .gd .x, .gi, .gi .x { display: inline-block; width: 100%; }} -} - -.highlight, .gist-highlight { - pre { background: none; @include border-radius(0px); border: none; padding: 0; margin-bottom: 0; } - margin-bottom: 1.8em; - background: $base03; - overflow-y: hidden; - overflow-x: auto; -} - -$solar-scroll-bg: rgba(#fff, .15); -$solar-scroll-thumb: rgba(#fff, .2); -@if $solarized == light { - $solar-scroll-bg: rgba(#000, .15); - $solar-scroll-thumb: rgba(#000, .15); -} - -pre, .highlight, .gist-highlight { - &::-webkit-scrollbar { height: .5em; background: $solar-scroll-bg; } - &::-webkit-scrollbar-thumb:horizontal { background: $solar-scroll-thumb; -webkit-border-radius: 4px; border-radius: 4px } -} - -.highlight code { - @extend .pre-code; background: #000; -} -figure.code { - background: none; - padding: 0; - border: 0; - margin-bottom: 1.5em; - pre { margin-bottom: 0; } - figcaption { - position: relative; - @extend .code-title; - a { @extend .download-source; } - } - .highlight { - margin-bottom: 0; - } -} - -.code-title { - text-align: center; - font-size: 13px; - line-height: 2em; - text-shadow: #cbcccc 0 1px 0; - color: #474747; - font-weight: normal; - margin-bottom: 0; - @include border-top-radius(5px); - font-family: "Helvetica Neue", Arial, "Lucida Grande", "Lucida Sans Unicode", Lucida, sans-serif; - background: #aaaaaa image-url("code_bg.png") top repeat-x; - border: 1px solid #565656; - border-top-color: #cbcbcb; - border-left-color: #a5a5a5; - border-right-color: #a5a5a5; - border-bottom: 0; -} - -.download-source { - position: absolute; right: .8em; - @include hover-link; - color: #666 !important; - z-index: 1; - font-size: 13px; - text-shadow: #cbcccc 0 1px 0; - padding-left: 3em; -} From 525fd371c4c09dca7ba7a78e05a5f0448349525d Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 22 Jun 2014 00:28:57 -0500 Subject: [PATCH 04/18] replaced codeblock tag --- Gemfile | 5 +- Gemfile.lock | 7 ++- plugins/code_block.rb | 94 ------------------------------------ plugins/octopress_filters.rb | 2 +- 4 files changed, 9 insertions(+), 99 deletions(-) delete mode 100644 plugins/code_block.rb diff --git a/Gemfile b/Gemfile index 29ed720c1c7..77f406efeac 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,9 @@ group :development do gem 'jekyll-page-hooks', '~> 1.2' gem 'jekyll-date-format', '~> 1.0' gem 'jekyll-sitemap' - gem 'octopress-codefence' - gem 'octopress-gist' + gem 'octopress-codefence', '~> 1.4.2' + gem 'octopress-codeblock', '~> 1.0.0' + gem 'octopress-gist', '~> 1.2.0' gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2.9' gem 'haml', '~> 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index c86778ee98f..aad6e231679 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,8 @@ GEM mercenary (0.3.3) octopress-code-highlighter (4.0.0) colorator (~> 0.1.0) + octopress-codeblock (1.0.0) + octopress-code-highlighter (~> 4.0.0) octopress-codefence (1.4.2) jekyll-page-hooks (>= 1.0.2) octopress-code-highlighter (~> 4.0.0) @@ -102,8 +104,9 @@ DEPENDENCIES jekyll-date-format (~> 1.0) jekyll-page-hooks (~> 1.2) jekyll-sitemap - octopress-codefence - octopress-gist + octopress-codeblock (~> 1.0.0) + octopress-codefence (~> 1.4.2) + octopress-gist (~> 1.2.0) rake (~> 10.0) rb-fsevent (~> 0.9) rdiscount (~> 2.0) diff --git a/plugins/code_block.rb b/plugins/code_block.rb deleted file mode 100644 index 46620d86c0d..00000000000 --- a/plugins/code_block.rb +++ /dev/null @@ -1,94 +0,0 @@ -# Title: Simple Code Blocks for Jekyll -# Author: Brandon Mathis http://brandonmathis.com -# Description: Write codeblocks with semantic HTML5
and
elements and optional syntax highlighting — all with a simple, intuitive interface. -# -# Syntax: -# {% codeblock [title] [url] [link text] %} -# code snippet -# {% endcodeblock %} -# -# For syntax highlighting, put a file extension somewhere in the title. examples: -# {% codeblock file.sh %} -# code snippet -# {% endcodeblock %} -# -# {% codeblock Time to be Awesome! (awesome.rb) %} -# code snippet -# {% endcodeblock %} -# -# Example: -# -# {% codeblock Got pain? painreleif.sh http://site.com/painreleief.sh Download it! %} -# $ rm -rf ~/PAIN -# {% endcodeblock %} -# -# Output: -# -#
-#
Got pain? painrelief.sh Download it! -#

-# -- nicely escaped highlighted code --
-# 
-#
-# -# Example 2 (no syntax highlighting): -# -# {% codeblock %} -# Ooooh, sarcasm... How original! -# {% endcodeblock %} -# -#
-#
<sarcasm> Ooooh, sarcasm... How original!</sarcasm>
-#
-# -require './plugins/pygments_code' -require './plugins/raw' - -module Jekyll - - class CodeBlock < Liquid::Block - include HighlightCode - include TemplateWrapper - CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i - Caption = /(\S[\S\s]*)/ - def initialize(tag_name, markup, tokens) - @title = nil - @caption = nil - @filetype = nil - @highlight = true - if markup =~ /\s*lang:(\S+)/i - @filetype = $1 - markup = markup.sub(/\s*lang:(\S+)/i,'') - end - if markup =~ CaptionUrlTitle - @file = $1 - @caption = "
#{$1}#{$3 || 'link'}
" - elsif markup =~ Caption - @file = $1 - @caption = "
#{$1}
\n" - end - if @file =~ /\S[\S\s]*\w+\.(\w+)/ && @filetype.nil? - @filetype = $1 - end - super - end - - def render(context) - output = super - code = super - source = "
" - source += @caption if @caption - if @filetype - source += "#{highlight(code, @filetype)}
" - else - source += "#{tableize_code(code.lstrip.rstrip.gsub(/" - end - source = safe_wrap(source) - source = context['pygments_prefix'] + source if context['pygments_prefix'] - source = source + context['pygments_suffix'] if context['pygments_suffix'] - source - end - end -end - -Liquid::Template.register_tag('codeblock', Jekyll::CodeBlock) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index 8075a0f7c45..a01874d6c14 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -1,6 +1,6 @@ #custom filters for Octopress -#require './plugins/backtick_code_block' require 'octopress-codefence' +require 'octopress-codeblock' require 'octopress-gist' require 'jekyll-sitemap' require 'jekyll-date-format' From 9854ee16c1af5d4027346dae31ac016776b824d3 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 22 Jun 2014 00:29:56 -0500 Subject: [PATCH 05/18] Removed gist_tag plugin --- plugins/gist_tag.rb | 130 -------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 plugins/gist_tag.rb diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb deleted file mode 100644 index 7874e488fdb..00000000000 --- a/plugins/gist_tag.rb +++ /dev/null @@ -1,130 +0,0 @@ -# A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers. -# by: Brandon Tilly -# Source URL: https://gist.github.com/1027674 -# Post http://brandontilley.com/2011/01/31/gist-tag-for-jekyll.html -# -# Example usage: {% gist 1027674 gist_tag.rb %} //embeds a gist for this plugin - -#require 'cgi' -#require 'digest/md5' -#require 'net/https' -#require 'uri' - -#module Jekyll - #class GistTag < Liquid::Tag - #def initialize(tag_name, text, token) - #super - #@text = text - #@cache_disabled = false - #@cache_folder = File.expand_path "../.gist-cache", File.dirname(__FILE__) - #FileUtils.mkdir_p @cache_folder - #end - - #def render(context) - #if parts = @text.match(/([a-zA-Z\d]*) (.*)/) - #gist, file = parts[1].strip, parts[2].strip - #else - #gist, file = @text.strip, "" - #end - #if gist.empty? - #"" - #else - #script_url = script_url_for gist, file - #code = get_cached_gist(gist, file) || get_gist_from_web(gist, file) - #html_output_for script_url, code - #end - #end - - #def html_output_for(script_url, code) - #code = CGI.escapeHTML code - #<<-HTML -#
-#
- #HTML - #end - - #def script_url_for(gist_id, filename) - #url = "https://gist.github.com/#{gist_id}.js" - #url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty? - #url - #end - - #def get_gist_url_for(gist, file) - #"https://gist.githubusercontent.com/raw/#{gist}/#{file}" - #end - - #def cache(gist, file, data) - #cache_file = get_cache_file_for gist, file - #File.open(cache_file, "w") do |io| - #io.write data - #end - #end - - #def get_cached_gist(gist, file) - #return nil if @cache_disabled - #cache_file = get_cache_file_for gist, file - #File.read cache_file if File.exist? cache_file - #end - - #def get_cache_file_for(gist, file) - #bad_chars = /[^a-zA-Z0-9\-_.]/ - #gist = gist.gsub bad_chars, '' - #file = file.gsub bad_chars, '' - #md5 = Digest::MD5.hexdigest "#{gist}-#{file}" - #File.join @cache_folder, "#{gist}-#{file}-#{md5}.cache" - #end - - #def get_gist_from_web(gist, file) - #gist_url = get_gist_url_for(gist, file) - #data = get_web_content(gist_url) - - #locations = Array.new - #while (data.code.to_i == 301 || data.code.to_i == 302) - #data = handle_gist_redirecting(data) - #break if locations.include? data.header['Location'] - #locations << data.header['Location'] - #end - - #if data.code.to_i != 200 - #raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}" - #end - - #cache(gist, file, data.body) unless @cache_disabled - #data.body - #end - - #def handle_gist_redirecting(data) - #redirected_url = data.header['Location'] - #if redirected_url.nil? || redirected_url.empty? - #raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers." - #end - - #get_web_content(redirected_url) - #end - - #def get_web_content(url) - #raw_uri = URI.parse url - #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 - #data = https.request request - #end - #end - - #class GistTagNoCache < GistTag - #def initialize(tag_name, text, token) - #super - #@cache_disabled = true - #end - #end -#end - -#Liquid::Template.register_tag('gist', Jekyll::GistTag) -#Liquid::Template.register_tag('gistnocache', Jekyll::GistTagNoCache) From ddf78cc846e157fea5baf8be31ba15c2cff2b053 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 23 Jun 2014 12:08:36 -0500 Subject: [PATCH 06/18] Replaced include code with octopress-render-code --- Gemfile | 5 ++- Gemfile.lock | 24 +++++++----- plugins/include_code.rb | 73 ------------------------------------ plugins/octopress_filters.rb | 1 + plugins/pygments_code.rb | 45 ---------------------- 5 files changed, 19 insertions(+), 129 deletions(-) delete mode 100644 plugins/include_code.rb delete mode 100644 plugins/pygments_code.rb diff --git a/Gemfile b/Gemfile index 77f406efeac..fe2a139c5ea 100644 --- a/Gemfile +++ b/Gemfile @@ -7,8 +7,9 @@ group :development do gem 'jekyll-date-format', '~> 1.0' gem 'jekyll-sitemap' gem 'octopress-codefence', '~> 1.4.2' - gem 'octopress-codeblock', '~> 1.0.0' - gem 'octopress-gist', '~> 1.2.0' + gem 'octopress-codeblock', '~> 1.0.1' + gem 'octopress-gist', '~> 1.3.0' + gem 'octopress-render-code', '~> 1.0.0' gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2.9' gem 'haml', '~> 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index aad6e231679..f598af304e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,7 @@ GEM coffee-script (~> 2.2) jekyll-date-format (1.0.0) jekyll (>= 1.0.0) - jekyll-page-hooks (1.2.0) + jekyll-page-hooks (1.3.0) jekyll (>= 2.0.0) jekyll-sass-converter (1.0.0) sass (~> 3.2) @@ -53,15 +53,20 @@ GEM rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) mercenary (0.3.3) - octopress-code-highlighter (4.0.0) + octopress-code-highlighter (4.0.2) colorator (~> 0.1.0) - octopress-codeblock (1.0.0) - octopress-code-highlighter (~> 4.0.0) + octopress-codeblock (1.0.1) + jekyll (~> 2.0.3) + octopress-code-highlighter (~> 4.0.1) octopress-codefence (1.4.2) jekyll-page-hooks (>= 1.0.2) octopress-code-highlighter (~> 4.0.0) - octopress-gist (1.2.0) - octopress-code-highlighter (~> 4.0.0) + octopress-gist (1.3.0) + jekyll (~> 2.0.3) + octopress-code-highlighter (~> 4.0.2) + octopress-render-code (1.0.0) + jekyll (~> 2.0.3) + octopress-code-highlighter (~> 4.0.1) parslet (1.5.0) blankslate (~> 2.0) posix-spawn (0.3.8) @@ -75,7 +80,7 @@ GEM rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - rdiscount (2.0.7.3) + rdiscount (2.1.7.1) redcarpet (3.1.2) rubypants (0.2.0) safe_yaml (1.0.3) @@ -104,9 +109,10 @@ DEPENDENCIES jekyll-date-format (~> 1.0) jekyll-page-hooks (~> 1.2) jekyll-sitemap - octopress-codeblock (~> 1.0.0) + octopress-codeblock (~> 1.0.1) octopress-codefence (~> 1.4.2) - octopress-gist (~> 1.2.0) + octopress-gist (~> 1.3.0) + octopress-render-code (~> 1.0.0) rake (~> 10.0) rb-fsevent (~> 0.9) rdiscount (~> 2.0) diff --git a/plugins/include_code.rb b/plugins/include_code.rb deleted file mode 100644 index 41f30337bd6..00000000000 --- a/plugins/include_code.rb +++ /dev/null @@ -1,73 +0,0 @@ -# Title: Include Code Tag for Jekyll -# Author: Brandon Mathis http://brandonmathis.com -# Description: Import files on your filesystem into any blog post as embedded code snippets with syntax highlighting and a download link. -# Configuration: You can set default import path in _config.yml (defaults to code_dir: downloads/code) -# -# Syntax {% include_code path/to/file %} -# -# Example 1: -# {% include_code javascripts/test.js %} -# -# This will import test.js from source/downloads/code/javascripts/test.js -# and output the contents in a syntax highlighted code block inside a figure, -# with a figcaption listing the file name and download link -# -# Example 2: -# You can also include an optional title for the
-# -# {% include_code Example 2 javascripts/test.js %} -# -# will output a figcaption with the title: Example 2 (test.js) -# - -require './plugins/pygments_code' -require './plugins/raw' -require 'pathname' - -module Jekyll - - class IncludeCodeTag < Liquid::Tag - include HighlightCode - include TemplateWrapper - def initialize(tag_name, markup, tokens) - @title = nil - @file = nil - if markup.strip =~ /\s*lang:(\S+)/i - @filetype = $1 - markup = markup.strip.sub(/lang:\S+/i,'') - end - if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i - @title = $1 || nil - @file = $3 - end - super - end - - def render(context) - code_dir = (context.registers[:site].config['code_dir'].sub(/^\//,'') || 'downloads/code') - code_path = (Pathname.new(context.registers[:site].source) + code_dir).expand_path - file = code_path + @file - - if File.symlink?(code_path) - return "Code directory '#{code_path}' cannot be a symlink" - end - - unless file.file? - return "File #{file} could not be found" - end - - Dir.chdir(code_path) do - code = file.read - @filetype = file.extname.sub('.','') if @filetype.nil? - title = @title ? "#{@title} (#{file.basename})" : file.basename - url = "/#{code_dir}/#{@file}" - source = "
#{title} download
\n" - source += "#{highlight(code, @filetype)}
" - safe_wrap(source) - end - end - end - -end - -Liquid::Template.register_tag('include_code', Jekyll::IncludeCodeTag) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index a01874d6c14..de322210d7a 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -2,6 +2,7 @@ require 'octopress-codefence' require 'octopress-codeblock' require 'octopress-gist' +require 'octopress-render-code' require 'jekyll-sitemap' require 'jekyll-date-format' require './plugins/raw' diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb deleted file mode 100644 index 8b851a3bdd8..00000000000 --- a/plugins/pygments_code.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'pygments' -require 'fileutils' -require 'digest/md5' - -PYGMENTS_CACHE_DIR = File.expand_path('../../.pygments-cache', __FILE__) -FileUtils.mkdir_p(PYGMENTS_CACHE_DIR) - -module HighlightCode - def highlight(str, lang) - lang = 'ruby' if lang == 'ru' - lang = 'objc' if lang == 'm' - lang = 'perl' if lang == 'pl' - lang = 'yaml' if lang == 'yml' - str = pygments(str, lang).match(/
(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs 
- tableize_code(str, lang) - end - - def pygments(code, lang) - if defined?(PYGMENTS_CACHE_DIR) - path = File.join(PYGMENTS_CACHE_DIR, "#{lang}-#{Digest::MD5.hexdigest(code)}.html") - if File.exist?(path) - highlighted_code = File.read(path) - else - begin - highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true}) - rescue MentosError - raise "Pygments can't parse unknown language: #{lang}." - end - File.open(path, 'w') {|f| f.print(highlighted_code) } - end - else - highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true}) - end - highlighted_code - end - def tableize_code (str, lang = '') - table = '
'
-    code = ''
-    str.lines.each_with_index do |line,index|
-      table += "#{index+1}\n"
-      code  += "#{line}"
-    end
-    table += "
#{code}
" - end -end From 50b0a5d40164f6f6bc8f083d7a880079a9a7b020 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 23 Jun 2014 14:18:20 -0500 Subject: [PATCH 07/18] activated more code colors --- .../sass/base/solarized/_code-style.scss | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.themes/classic/sass/base/solarized/_code-style.scss b/.themes/classic/sass/base/solarized/_code-style.scss index 44118deab0c..6d710c42818 100644 --- a/.themes/classic/sass/base/solarized/_code-style.scss +++ b/.themes/classic/sass/base/solarized/_code-style.scss @@ -63,11 +63,11 @@ $pre-line-padding: .8em !default; color: $base1; @include octopress-diff-bg(mix($solar-green, $base03, 40%)); } - //.go { color: #888888 } /* Generic.Output */ - //.gp { color: #555555 } /* Generic.Prompt */ + .go { color: $base0; } /* Generic.Output */ + .gp { color: $solar-cyan; } /* Generic.Prompt */ .gs { color: $base1; font-weight: bold; } /* Generic.Strong */ .gu { color: $solar-violet; } /* Generic.Subheading */ - //.gt { color: #aa0000 } /* Generic.Traceback */ + .gt { color: $solar-red; } /* Generic.Traceback */ .kc { color: $solar-green; font-weight: bold; } /* Keyword.Constant */ .kd { color: $solar-blue; } /* Keyword.Declaration */ .kp { color: $solar-orange; font-weight: bold; } /* Keyword.Pseudo */ @@ -78,36 +78,36 @@ $pre-line-padding: .8em !default; .nb { color: $solar-green; } /* Name.Builtin */ .nc { color: $solar-magenta;} /* Name.Class */ .no { color: $solar-yellow; } /* Name.Constant */ - //.ni { color: #800080 } /* Name.Entity */ + .ni { color: $solar-magenta; } /* Name.Entity */ .nl { color: $solar-green; } .ne { color: $solar-blue; font-weight: bold; } /* Name.Exception */ .nf { color: $solar-blue; font-weight: bold; } /* Name.Function */ .nn { color: $solar-yellow; } /* Name.Namespace */ .nt { color: $solar-blue; font-weight: bold; } /* Name.Tag */ .nx { color: $solar-yellow; } - //.bp { color: #999999 } /* Name.Builtin.Pseudo */ - //.vc { color: #008080 } /* Name.Variable.Class */ + .bp { color: $base1; } /* Name.Builtin.Pseudo */ + .vc { color: $solar-green; } /* Name.Variable.Class */ .vg { color: $solar-blue; } /* Name.Variable.Global */ .vi { color: $solar-blue; } /* Name.Variable.Instance */ .nv { color: $solar-blue; } /* Name.Variable */ - //.w { color: #bbbbbb } /* Text.Whitespace */ + .w { color: $base00; } /* Text.Whitespace */ .mf { color: $solar-cyan; } /* Literal.Number.Float */ .m { color: $solar-cyan; } /* Literal.Number */ .mh { color: $solar-cyan; } /* Literal.Number.Hex */ .mi { color: $solar-cyan; } /* Literal.Number.Integer */ - //.mo { color: #009999 } /* Literal.Number.Oct */ + .mo { color: $colar-cyan; } /* Literal.Number.Oct */ .s { color: $solar-cyan; } /* Literal.String */ - //.sb { color: #d14 } /* Literal.String.Backtick */ - //.sc { color: #d14 } /* Literal.String.Char */ + .sb { color: $solar-green; } /* Literal.String.Backtick */ + .sc { color: $solar-green; } /* Literal.String.Char */ .sd { color: $solar-cyan; } /* Literal.String.Doc */ .s2 { color: $solar-cyan; } /* Literal.String.Double */ .se { color: $solar-red; } /* Literal.String.Escape */ - //.sh { color: #d14 } /* Literal.String.Heredoc */ + .sh { color: $solar-green; } /* Literal.String.Heredoc */ .si { color: $solar-blue; } /* Literal.String.Interpol */ - //.sx { color: #d14 } /* Literal.String.Other */ + .sx { color: $solar-green; } /* Literal.String.Other */ .sr { color: $solar-cyan; } /* Literal.String.Regex */ .s1 { color: $solar-cyan; } /* Literal.String.Single */ - //.ss { color: #990073 } /* Literal.String.Symbol */ - //.il { color: #009999 } /* Literal.Number.Integer.Long */ + .ss { color: $solar-orange; } /* Literal.String.Symbol */ + .il { color: $solar-yellow; } /* Literal.Number.Integer.Long */ } From fb1c06a60bfb3a7fd936839e79bb37baa64efdd5 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 23 Jun 2014 14:18:43 -0500 Subject: [PATCH 08/18] Loosened version number requirements on Gems --- Gemfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index fe2a139c5ea..2c9e4448c2a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,18 +6,18 @@ group :development do gem 'jekyll-page-hooks', '~> 1.2' gem 'jekyll-date-format', '~> 1.0' gem 'jekyll-sitemap' - gem 'octopress-codefence', '~> 1.4.2' - gem 'octopress-codeblock', '~> 1.0.1' - gem 'octopress-gist', '~> 1.3.0' - gem 'octopress-render-code', '~> 1.0.0' + gem 'octopress-codefence', '~> 1.4' + gem 'octopress-codeblock', '~> 1.0' + gem 'octopress-gist', '~> 1.3' + gem 'octopress-render-code', '~> 1.0' gem 'rdiscount', '~> 2.0' - gem 'RedCloth', '~> 4.2.9' + gem 'RedCloth', '~> 4.2' gem 'haml', '~> 4.0' gem 'compass', '~> 0.12.2' - gem 'sass-globbing', '~> 1.0.0' + gem 'sass-globbing', '~> 1.0' gem 'rubypants', '~> 0.2.0' gem 'rb-fsevent', '~> 0.9' - gem 'stringex', '~> 1.4.0' + gem 'stringex', '~> 1.4' end gem 'sinatra', '~> 1.4.2' From feb2e28b3508f39e4d53efbe670232bff527d574 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 23 Jun 2014 15:05:12 -0500 Subject: [PATCH 09/18] I'm tired of shipping a Gemfile.lock --- .gitignore | 1 + Gemfile.lock | 122 --------------------------------------------------- 2 files changed, 1 insertion(+), 122 deletions(-) delete mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index fddcefb0d9e..3d7868e302c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .gist-cache .pygments-cache .code-highlighter-cache +Gemfile.lock _deploy public sass.old diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index f598af304e7..00000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,122 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - RedCloth (4.2.9) - blankslate (2.1.2.4) - celluloid (0.15.2) - timers (~> 1.1.0) - chunky_png (1.3.1) - classifier (1.3.4) - fast-stemmer (>= 1.0.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.7.0) - colorator (0.1) - compass (0.12.6) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.2.19) - execjs (2.2.0) - fast-stemmer (1.0.2) - ffi (1.9.3) - fssm (0.2.10) - haml (4.0.5) - tilt - jekyll (2.0.3) - classifier (~> 1.3) - colorator (~> 0.1) - jekyll-coffeescript (~> 1.0) - jekyll-sass-converter (~> 1.0) - kramdown (~> 1.3) - liquid (~> 2.5.5) - listen (~> 2.5) - mercenary (~> 0.3.3) - pygments.rb (~> 0.5.0) - redcarpet (~> 3.1) - safe_yaml (~> 1.0) - toml (~> 0.1.0) - jekyll-coffeescript (1.0.0) - coffee-script (~> 2.2) - jekyll-date-format (1.0.0) - jekyll (>= 1.0.0) - jekyll-page-hooks (1.3.0) - jekyll (>= 2.0.0) - jekyll-sass-converter (1.0.0) - sass (~> 3.2) - jekyll-sitemap (0.4.1) - jekyll (~> 2.0) - kramdown (1.4.0) - liquid (2.5.5) - listen (2.7.9) - celluloid (>= 0.15.2) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - mercenary (0.3.3) - octopress-code-highlighter (4.0.2) - colorator (~> 0.1.0) - octopress-codeblock (1.0.1) - jekyll (~> 2.0.3) - octopress-code-highlighter (~> 4.0.1) - octopress-codefence (1.4.2) - jekyll-page-hooks (>= 1.0.2) - octopress-code-highlighter (~> 4.0.0) - octopress-gist (1.3.0) - jekyll (~> 2.0.3) - octopress-code-highlighter (~> 4.0.2) - octopress-render-code (1.0.0) - jekyll (~> 2.0.3) - octopress-code-highlighter (~> 4.0.1) - parslet (1.5.0) - blankslate (~> 2.0) - posix-spawn (0.3.8) - pygments.rb (0.5.4) - posix-spawn (~> 0.3.6) - yajl-ruby (~> 1.1.0) - rack (1.5.2) - rack-protection (1.5.3) - rack - rake (10.3.2) - rb-fsevent (0.9.4) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rdiscount (2.1.7.1) - redcarpet (3.1.2) - rubypants (0.2.0) - safe_yaml (1.0.3) - sass (3.2.19) - sass-globbing (1.0.0) - sass (>= 3.1) - sinatra (1.4.5) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - stringex (1.4.0) - tilt (1.4.1) - timers (1.1.0) - toml (0.1.1) - parslet (~> 1.5.0) - yajl-ruby (1.1.0) - -PLATFORMS - ruby - -DEPENDENCIES - RedCloth (~> 4.2.9) - compass (~> 0.12.2) - haml (~> 4.0) - jekyll (~> 2.0) - jekyll-date-format (~> 1.0) - jekyll-page-hooks (~> 1.2) - jekyll-sitemap - octopress-codeblock (~> 1.0.1) - octopress-codefence (~> 1.4.2) - octopress-gist (~> 1.3.0) - octopress-render-code (~> 1.0.0) - rake (~> 10.0) - rb-fsevent (~> 0.9) - rdiscount (~> 2.0) - rubypants (~> 0.2.0) - sass-globbing (~> 1.0.0) - sinatra (~> 1.4.2) - stringex (~> 1.4.0) From f6417da3f380a63c98e31654f05743306c0b1cf6 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 23 Jun 2014 15:13:24 -0500 Subject: [PATCH 10/18] Fixed sass typo --- .themes/classic/sass/base/solarized/_code-style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.themes/classic/sass/base/solarized/_code-style.scss b/.themes/classic/sass/base/solarized/_code-style.scss index 6d710c42818..ebcf55a69f6 100644 --- a/.themes/classic/sass/base/solarized/_code-style.scss +++ b/.themes/classic/sass/base/solarized/_code-style.scss @@ -95,7 +95,7 @@ $pre-line-padding: .8em !default; .m { color: $solar-cyan; } /* Literal.Number */ .mh { color: $solar-cyan; } /* Literal.Number.Hex */ .mi { color: $solar-cyan; } /* Literal.Number.Integer */ - .mo { color: $colar-cyan; } /* Literal.Number.Oct */ + .mo { color: $solar-cyan; } /* Literal.Number.Oct */ .s { color: $solar-cyan; } /* Literal.String */ .sb { color: $solar-green; } /* Literal.String.Backtick */ .sc { color: $solar-green; } /* Literal.String.Char */ From 83e77f2b80e3d26b66829dc6164eb7d285f4667a Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 26 Jun 2014 00:08:04 -0500 Subject: [PATCH 11/18] Updated render partial to better handle raw tags --- plugins/octopress_filters.rb | 1 - plugins/raw.rb | 16 -------- plugins/render_partial.rb | 80 ++++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 38 deletions(-) delete mode 100644 plugins/raw.rb diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index de322210d7a..cb5eba3fc51 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -5,7 +5,6 @@ require 'octopress-render-code' require 'jekyll-sitemap' require 'jekyll-date-format' -require './plugins/raw' require 'rubypants' module OctopressLiquidFilters diff --git a/plugins/raw.rb b/plugins/raw.rb deleted file mode 100644 index a18fea0a48b..00000000000 --- a/plugins/raw.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Author: Brandon Mathis -# Description: Provides plugins with a method for wrapping and unwrapping input to prevent Markdown and Textile from parsing it. -# Purpose: This is useful for preventing Markdown and Textile from being too aggressive and incorrectly parsing in-line HTML. -module TemplateWrapper - # Wrap input with a
- def safe_wrap(input) - "
#{input}
" - end - # This must be applied after the - def unwrap(input) - input.gsub /
(.+?)<\/notextile><\/div>/m do - $1 - end - end -end - diff --git a/plugins/render_partial.rb b/plugins/render_partial.rb index 39bf499be76..1c4e235e082 100644 --- a/plugins/render_partial.rb +++ b/plugins/render_partial.rb @@ -36,37 +36,75 @@ def initialize(tag_name, markup, tokens) super end + def expand_path(context) + root = context.registers[:site].source + + # If relative path, e.g. ./somefile, ../somefile + if @file =~ /^\.+\// + page = context['page'] + if local_dir = page['dir'] + File.join(root, local_dir, @file) + else + local_dir = File.dirname(page['path']) + File.join(root, local_dir, @file) + end + + # If absolute or relative to a user directory, e.g. /Users/Bob/somefile or ~/somefile + elsif @file =~ /^[\/~]/ + File.expand_path(@file) + + # Otherwise, assume relative to site root + else + File.join(root, @file) + end + + end + def render(context) - file_dir = (context.registers[:site].source || 'source') - file_path = File.expand_path(file_dir) - file = file_path + @file + file = expand_path(context) - unless file.file? + unless File.exists?(file) return "File #{file} could not be found" end - Dir.chdir(file_path) do - contents = file.read - if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m - contents = $1.lstrip - end + content = File.open(file).read - content = parse_convertible(content, context) - - if @raw - contents - else - partial = Liquid::Template.parse(contents) - context.stack do - partial.render(context) - end - end + raw_content = {} + + content = content.gsub /{%\s*raw\s*%}(.+?){% endraw %}/m do + data = $1 + key = Digest::MD5.hexdigest(data) + raw_content[key] = data + key + end + + content = parse_convertible(content, context, file) + + if content =~ /\A-{3}(.+[^\A])-{3}\n(.+)/m + local_vars = SafeYAML.load($1.strip) + content = $2.strip end + + return content if @raw + + partial = Liquid::Template.parse(content) + + content = context.stack { + if local_vars + context['page'] = Jekyll::Utils.deep_merge_hashes(context['page'], local_vars) + end + partial.render!(context) + }.strip + + raw_content.each { |k, v| content.sub!(k, v) } + + content + end # Ensure jekyll page hooks are processed - def parse_convertible(content, context) - page = Jekyll::ConvertiblePartial.new(context.registers[:site], @path, content) + def parse_convertible(content, context, path) + page = Jekyll::ConvertiblePartial.new(context.registers[:site], path, content) page.render({}) page.output.strip end From bca82cc552420c5a66481be5441ada7de3d5afe1 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 26 Jun 2014 20:21:57 -0500 Subject: [PATCH 12/18] Fix for render_partial {% raw %} handling --- plugins/render_partial.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/render_partial.rb b/plugins/render_partial.rb index 1c4e235e082..7374c27d3a5 100644 --- a/plugins/render_partial.rb +++ b/plugins/render_partial.rb @@ -74,12 +74,10 @@ def render(context) content = content.gsub /{%\s*raw\s*%}(.+?){% endraw %}/m do data = $1 key = Digest::MD5.hexdigest(data) - raw_content[key] = data + raw_content[key] = "{% raw %}#{data}{% endraw %}" key end - content = parse_convertible(content, context, file) - if content =~ /\A-{3}(.+[^\A])-{3}\n(.+)/m local_vars = SafeYAML.load($1.strip) content = $2.strip @@ -97,9 +95,8 @@ def render(context) }.strip raw_content.each { |k, v| content.sub!(k, v) } - - content + parse_convertible(content, context, file) end # Ensure jekyll page hooks are processed From cbe43d1077c8963651cf2b4c32a68e66a32d5a55 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 26 Jun 2014 20:22:15 -0500 Subject: [PATCH 13/18] Updated changelog, added styles for type elements --- .../sass/base/solarized/_standard-code.scss | 28 ++++++++++++++++++- CHANGELOG.markdown | 5 ++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.themes/classic/sass/base/solarized/_standard-code.scss b/.themes/classic/sass/base/solarized/_standard-code.scss index 51658a334a2..0c8f3a5553f 100644 --- a/.themes/classic/sass/base/solarized/_standard-code.scss +++ b/.themes/classic/sass/base/solarized/_standard-code.scss @@ -1,3 +1,29 @@ +code, +kbd, +samp, +tt { + color: inherit; + background-color: rgba(#fff, .3); + border: 1px solid rgba(#000, .1); + font-family: "Source Code Pro", Inconsolata-dz, Inconsolata, Menlo, Monaco, Consolas, "Liberation Mono", Courier, monospace; + border-radius: 3px; + font-size: .85em; + &:before, &:after { + content: "\00a0"; + letter-spacing: -0.2em; + } +} + +pre code { + &:before, &:after { + content: none; + } + border: none; + background-color: none; + border-raidus: 0; + font-size: inherit; +} + .highlight pre, pre:not(.code-highlight-pre) { @include octopress-highlight-style; @@ -10,5 +36,5 @@ pre:not(.code-highlight-pre) { pre, pre code { * { box-sizing: border-box; } font-size: 13px; - font-family: "PT Mono", "Source Code Pro", Inconsolata-dz, Inconsolata, Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; + font-family: "Source Code Pro", Inconsolata-dz, Inconsolata, Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; } diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 0da6ecb6593..c25446e89c2 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,5 +1,10 @@ # Octopress Changelog +## 2.1 + +- Now using on Jekyll 2.0 +- Upgraded all syntax highlighting plugins (now using external gem plugins) + ## 2.0 - Now based on [mojombo/jekyll](http://github.com/mojombo/jekyll) From c28541d9502010e7cabdbe48be698cd1359d0c9b Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sat, 28 Jun 2014 15:24:47 -0500 Subject: [PATCH 14/18] Removed rubypants.rb, loosened gemfile versions --- Gemfile | 4 +- plugins/rubypants.rb | 489 ------------------------------------------- 2 files changed, 2 insertions(+), 491 deletions(-) delete mode 100644 plugins/rubypants.rb diff --git a/Gemfile b/Gemfile index 2c9e4448c2a..827ae34a586 100644 --- a/Gemfile +++ b/Gemfile @@ -13,9 +13,9 @@ group :development do gem 'rdiscount', '~> 2.0' gem 'RedCloth', '~> 4.2' gem 'haml', '~> 4.0' - gem 'compass', '~> 0.12.2' + gem 'compass', '~> 0.12' gem 'sass-globbing', '~> 1.0' - gem 'rubypants', '~> 0.2.0' + gem 'rubypants', '~> 0.2' gem 'rb-fsevent', '~> 0.9' gem 'stringex', '~> 1.4' end diff --git a/plugins/rubypants.rb b/plugins/rubypants.rb deleted file mode 100644 index e4f4502f57c..00000000000 --- a/plugins/rubypants.rb +++ /dev/null @@ -1,489 +0,0 @@ -# -# = RubyPants -- SmartyPants ported to Ruby -# -# Ported by Christian Neukirchen -# Copyright (C) 2004 Christian Neukirchen -# -# Incooporates ideas, comments and documentation by Chad Miller -# Copyright (C) 2004 Chad Miller -# -# Original SmartyPants by John Gruber -# Copyright (C) 2003 John Gruber -# - -# -# = RubyPants -- SmartyPants ported to Ruby -# -# == Synopsis -# -# RubyPants is a Ruby port of the smart-quotes library SmartyPants. -# -# The original "SmartyPants" is a free web publishing plug-in for -# Movable Type, Blosxom, and BBEdit that easily translates plain ASCII -# punctuation characters into "smart" typographic punctuation HTML -# entities. -# -# -# == Description -# -# RubyPants can perform the following transformations: -# -# * Straight quotes (" and ') into "curly" quote -# HTML entities -# * Backticks-style quotes (``like this'') into "curly" quote -# HTML entities -# * Dashes (-- and ---) into en- and em-dash -# entities -# * Three consecutive dots (... or . . .) into an -# ellipsis entity -# -# This means you can write, edit, and save your posts using plain old -# ASCII straight quotes, plain dashes, and plain dots, but your -# published posts (and final HTML output) will appear with smart -# quotes, em-dashes, and proper ellipses. -# -# RubyPants does not modify characters within
,
-# , ,  or
-#