jsjohnst-jekyll 0.4.1.999.4 → 0.4.1.999.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,17 +17,6 @@ require 'redcloth'
17
17
  require 'hpricot'
18
18
  begin
19
19
  require 'maruku'
20
- require 'maruku/ext/math'
21
- # Switch off MathML output
22
- MaRuKu::Globals[:html_math_output_mathml] = false
23
- MaRuKu::Globals[:html_math_engine] = 'none'
24
-
25
- # Turn on math to PNG support with blahtex
26
- # Resulting PNGs stored in `images/latex`
27
- MaRuKu::Globals[:html_math_output_png] = true
28
- MaRuKu::Globals[:html_png_engine] = 'blahtex'
29
- MaRuKu::Globals[:html_png_dir] = 'images/latex'
30
- MaRuKu::Globals[:html_png_url] = '/images/latex/'
31
20
  rescue LoadError
32
21
  puts "The maruku gem is required for markdown support!"
33
22
  end
@@ -44,7 +44,7 @@
44
44
  require 'open4'
45
45
 
46
46
  class Albino
47
- @@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
47
+ @@bin = '/usr/local/bin/pygmentize'
48
48
 
49
49
  def self.bin=(path)
50
50
  @@bin = path
@@ -54,7 +54,7 @@ class Albino
54
54
  new(*args).colorize
55
55
  end
56
56
 
57
- def initialize(target, lexer = :text, format = :html)
57
+ def initialize(target, lexer = :text, format = :html )
58
58
  @target = File.exists?(target) ? File.read(target) : target rescue target
59
59
  @options = { :l => lexer, :f => format }
60
60
  end
@@ -64,7 +64,13 @@ class Albino
64
64
  Open4.popen4(command) do |pid, stdin, stdout, stderr|
65
65
  stdin.puts @target
66
66
  stdin.close
67
+
67
68
  output = stdout.read.strip
69
+
70
+ # puts "pid : #{ pid }"
71
+ # puts "stdout : #{ stdout.read.strip }"
72
+ # puts "stderr : #{ stderr.read.strip }"
73
+
68
74
  end
69
75
 
70
76
  # rdiscount wants the closing pre on a line by itself
@@ -13,6 +13,10 @@ module Jekyll
13
13
  date.strftime("%d %b %Y")
14
14
  end
15
15
 
16
+ def archivedate_to_string(date)
17
+ Time.parse("01-" + date).strftime("%B %Y")
18
+ end
19
+
16
20
  def date_to_long_string(date)
17
21
  date.strftime("%d %B %Y")
18
22
  end
@@ -38,6 +38,8 @@ module Jekyll
38
38
  #
39
39
  # Returns nothing
40
40
  def add_layout(layouts, site_payload)
41
+ self.data['url'] = @dir
42
+ self.data['topleveldir'] = @dir.split("/")[1]
41
43
  payload = {"page" => self.data}.deep_merge(site_payload)
42
44
  do_layout(payload, layouts)
43
45
  end
@@ -20,7 +20,7 @@ module Jekyll
20
20
 
21
21
  attr_accessor :date, :slug, :ext, :categories, :topics, :published
22
22
  attr_accessor :data, :content, :output
23
- attr_accessor :previous, :next
23
+ attr_accessor :previous, :next, :numericid, :archivedate
24
24
 
25
25
  # Initialize this Post instance.
26
26
  # +base+ is the String path to the dir containing the post file
@@ -31,7 +31,9 @@ module Jekyll
31
31
  def initialize(source, dir, name)
32
32
  @base = File.join(source, dir, '_posts')
33
33
  @name = name
34
-
34
+
35
+ self.numericid = 0
36
+
35
37
  self.categories = dir.split('/').reject { |x| x.empty? }
36
38
 
37
39
  parts = name.split('/')
@@ -46,36 +48,32 @@ module Jekyll
46
48
  self.published = true
47
49
  end
48
50
 
49
- self.data['topics'] = if self.topics.empty?
50
- if self.data.has_key?('topic')
51
- self.topics << self.data['topic']
52
- elsif self.data.has_key?('topics')
53
- if self.data['topics'].kind_of? Array
54
- self.topics = self.topics['topics']
55
- elsif self.data['topics'].kind_of? String
56
- self.topics = self.data['topics'].split
57
- else
58
- self.topics = []
59
- end
51
+ if self.data.has_key?('topic')
52
+ self.topics << self.data['topic']
53
+ elsif self.data.has_key?('topics')
54
+ if self.data['topics'].kind_of? Array
55
+ self.topics = self.data['topics']
56
+ elsif self.data['topics'].kind_of? String
57
+ self.topics = self.data['topics'].split
58
+ else
59
+ self.topics = []
60
60
  end
61
61
  end
62
-
63
-
64
- if self.categories.empty?
65
- if self.data.has_key?('category')
66
- self.categories << self.data['category']
67
- elsif self.data.has_key?('categories')
68
- # Look for categories in the YAML-header, either specified as
69
- # an array or a string.
70
- if self.data['categories'].kind_of? Array
71
- self.categories = self.data['categories']
72
- elsif self.data['categories'].kind_of? String
73
- self.categories = self.data['categories'].split
74
- else
75
- self.categories = []
76
- end
62
+
63
+ if self.data.has_key?('category')
64
+ self.categories << self.data['category']
65
+ elsif self.data.has_key?('categories')
66
+ # Look for categories in the YAML-header, either specified as
67
+ # an array or a string.
68
+ if self.data['categories'].kind_of? Array
69
+ self.categories = self.data['categories']
70
+ elsif self.data['categories'].kind_of? String
71
+ self.categories = self.data['categories'].split
72
+ else
73
+ self.categories = []
77
74
  end
78
75
  end
76
+
79
77
  end
80
78
 
81
79
  # Spaceship is based on Post#date
@@ -92,6 +90,7 @@ module Jekyll
92
90
  def process(name)
93
91
  m, cats, date, slug, ext = *name.match(MATCHER)
94
92
  self.date = Time.parse(date)
93
+ self.archivedate = self.date.month.to_s + "-" + self.date.year.to_s
95
94
  self.slug = slug
96
95
  self.ext = ext
97
96
  end
@@ -216,8 +215,11 @@ module Jekyll
216
215
  def to_liquid
217
216
  { "title" => self.data["title"] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '),
218
217
  "url" => self.url,
218
+ "topleveldir" => self.url.split("/")[1],
219
219
  "date" => self.date,
220
+ "archivedate" => self.archivedate,
220
221
  "id" => self.id,
222
+ "numericid" => self.numericid,
221
223
  "topics" => self.topics,
222
224
  "folded" => (self.content.match("<hr") ? true : false),
223
225
  "content" => self.content,
@@ -101,7 +101,8 @@ module Jekyll
101
101
 
102
102
  # second pass renders each post now that full site payload is available
103
103
  self.posts.each_with_index do |post, idx|
104
- post.previous = posts[idx - 1] unless idx - 1 < 0
104
+ post.numericid = idx+1
105
+ post.previous = posts[idx - 1] unless idx - 1 < 0
105
106
  post.next = posts[idx + 1] unless idx + 1 >= posts.size
106
107
  post.render(self.layouts, site_payload)
107
108
  end
@@ -188,18 +189,21 @@ module Jekyll
188
189
  # "topics" => [<Post>] }}
189
190
  def site_payload
190
191
  all_posts = self.posts.sort { |a,b| b <=> a }
191
- latest_posts = all_posts[0..2]
192
+ latest_post = all_posts[0]
193
+ recent_posts = all_posts[1..2]
192
194
  older_posts = all_posts[3..7]
193
195
  rss_posts = all_posts[0..25]
194
196
 
195
197
  {"site" => self.settings.merge({
196
198
  "time" => Time.now,
197
199
  "posts" => all_posts,
198
- "latest_posts" => latest_posts,
200
+ "latest_post" => latest_post,
201
+ "recent_posts" => recent_posts,
199
202
  "older_posts" => older_posts,
200
203
  "rss_posts" => rss_posts,
201
204
  "categories" => post_attr_hash('categories'),
202
- "topics" => post_attr_hash('topics')
205
+ "topics" => post_attr_hash('topics'),
206
+ "archives" => post_attr_hash('archivedate')
203
207
  })}
204
208
  end
205
209
 
@@ -11,9 +11,9 @@ module Jekyll
11
11
  @lang = $1
12
12
  if defined? $2
13
13
  # additional options to pass to Albino.
14
- @options = { 'O' => 'linenos=inline' }
14
+ @options = { 'O' => 'linenos=table,encoding=utf8,style=native' }
15
15
  else
16
- @options = {}
16
+ @options = { 'O' => 'encoding=utf8,style=native' }
17
17
  end
18
18
  else
19
19
  raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]")
@@ -32,7 +32,8 @@ module Jekyll
32
32
  if Jekyll.content_type == :markdown
33
33
  return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
34
34
  else
35
- "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
35
+ content = "\n<notextile>\n" + Albino.new(code, @lang).to_s(@options) + "\n</notextile>\n"
36
+ content
36
37
  end
37
38
  end
38
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsjohnst-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1.999.4
4
+ version: 0.4.1.999.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner