Navigation Menu

Skip to content

Commit

Permalink
Whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncodes committed Jan 15, 2012
1 parent 21bdb1e commit 8dd6aab
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 34 deletions.
20 changes: 11 additions & 9 deletions _plugins/asset_tags.rb
Expand Up @@ -2,7 +2,6 @@
require 'active_support/core_ext/module/aliasing'

module Jekyll

class Site
attr_accessor :current_page
end
Expand Down Expand Up @@ -95,32 +94,36 @@ class StylesheetTag < AssetTag
def path_prefix
"stylesheets/"
end

def extensions
%w(.css .sass .scss)
end

def calculate_timestamp(context)
super

# find the page this tag is being rendered in
site = context.registers[:site]
page = site.pages.detect do |p|
@local_path == p.instance_eval { File.join(@base, @dir, @name) }
end

# if we have a page object (i.e. we are dynamically renderered)
if page
# render the page if it isn't already rendered
if page.output.nil?
page = page.clone # we need a clone as rendering isn't idempotent
page.render site.layouts, site.site_payload
end

# extract timestamps out of rendered page
asset_timestamps = page.output.scan(%r[url\(["'][^"']+\?(\d+)["']\)]).map(&:first).map(&:to_i)

# pick the latest timestamp
@timestamp = ([@timestamp] + asset_timestamps).max
end
end

def render_tag
%Q{<link rel="stylesheet" type="text/css" href="#{@remote_path.gsub(/\.\S+$/,'')}.css#{suffix}"#{@extra || ' media="screen"'}/>}
end
Expand All @@ -130,11 +133,11 @@ class ImageTag < AssetTag
def path_prefix
"images/"
end

def extensions
%w(.png .jpg .jpeg)
end

def render_tag
%Q{<img src="#{@remote_path}#{suffix}"#{@extra}/>}
end
Expand All @@ -144,16 +147,15 @@ class JavascriptTag < AssetTag
def path_prefix
"javascripts/"
end

def extensions
%w(.js)
end

def render_tag
%Q{<script src="#{@remote_path}#{suffix}"#{@extra.rstrip}></script>}
end
end

end

Liquid::Template.register_tag('asset', Jekyll::AssetTag)
Expand Down
1 change: 0 additions & 1 deletion _plugins/header_anchors.rb
Expand Up @@ -2,7 +2,6 @@
require 'active_support/core_ext/module/aliasing'

# convert `## Foo Bar [example]` to `<h2 id="example">Foo Bar</h2>`

class Jekyll::MarkdownConverter
def convert_with_header_anchors(content)
html = convert_without_header_anchors(content)
Expand Down
24 changes: 9 additions & 15 deletions _plugins/semantic_code_blocks.rb
Expand Up @@ -2,50 +2,45 @@
require 'active_support/core_ext/module/aliasing'

class Albino

def colorize(options = {})

# disable the built in <div/> and <pre/> wrappers
options[:O] = "#{@options[:O]},nowrap=true"

# call the colorizer
html = execute([@@bin] + convert_options(options))

# move whole of <span class="hll"/> onto single line
html.gsub! %r[(<span class="hll">)([^\n]*)(\n)(</span>)], '\1\2\4\3'

# wrap each line in <code/> so we can style them easier
html.gsub!(/^.*$/, '<code>\0</code>')

# convert <span class="hll"/> into <strong/> and add styling hook to <code/>
html.gsub! %r[^<code><span class="hll">(.*)</span></code>$], '<code class="hll"><strong>\1</strong></code>'

# wrap the result in a <pre/> with our desired CSS classes
"<pre class=\"source source-#{@options[:l]}\">#{html}</pre>"

end
alias_method :to_s, :colorize

def convert_options(options = {})
@options.merge(options).inject [] do |args, (flag, value)|
args += ["-#{flag}", "#{value}"]
end
end

end

class Jekyll::HighlightBlock

def add_code_tags(code, lang)
code # noop
end

remove_const :SYNTAX
SYNTAX = /\A(\w+)(?:\s(.+))?\s\z/

def initialize_with_hl_lines(tag_name, markup, tokens)
initialize_without_hl_lines(tag_name, markup, tokens)

@options['O'].gsub!(/(hl_lines=)([0-9,-]+)/) do |match|
prefix = $1
lines = []
Expand All @@ -60,5 +55,4 @@ def initialize_with_hl_lines(tag_name, markup, tokens)
end unless @options['O'].nil?
end
alias_method_chain :initialize, :hl_lines

end
2 changes: 0 additions & 2 deletions _plugins/slugged_posts.rb
Expand Up @@ -2,10 +2,8 @@
require 'active_support/core_ext/module/aliasing'

class Jekyll::Post

def to_liquid_with_slug
to_liquid_without_slug.merge('slug' => self.slug)
end
alias_method_chain :to_liquid, :slug

end
8 changes: 3 additions & 5 deletions _plugins/timeless_posts.rb
@@ -1,23 +1,21 @@
raise 'Post not loaded' unless defined?(Jekyll::Post)
class Jekyll::Post

# dates in filenames are now optional
# if omitted, dates must be set in the metadata for published posts

remove_const :MATCHER
MATCHER = /^(.+\/)*(?:(\d+-\d+-\d+)-)?(.*)(\.[^.]+)$/

def process(name)
m, cats, date, slug, ext = *name.match(MATCHER)
self.date = date && Time.parse(date)
self.slug = slug
self.ext = ext
end

def initialize_with_timeless(site, source, dir, name)
initialize_without_timeless(site, source, dir, name)
self.published = false if self.date.nil?
end
alias_method_chain :initialize, :timeless

end
2 changes: 0 additions & 2 deletions _plugins/updated_posts.rb
Expand Up @@ -2,7 +2,6 @@
require 'active_support/core_ext/module/aliasing'

class Jekyll::Post

def initialize_with_updated(site, source, dir, name)
initialize_without_updated(site, source, dir, name)
self.data['updated'] = if self.data.has_key? 'updated'
Expand All @@ -11,5 +10,4 @@ def initialize_with_updated(site, source, dir, name)
self.data['last_modified'] = self.data['updated'] || self.date
end
alias_method_chain :initialize, :updated

end

0 comments on commit 8dd6aab

Please sign in to comment.