jsjohnst-jekyll 0.4.1.999.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/History.txt +106 -0
  2. data/README.textile +555 -0
  3. data/VERSION.yml +4 -0
  4. data/bin/jekyll +146 -0
  5. data/lib/jekyll.rb +81 -0
  6. data/lib/jekyll/albino.rb +121 -0
  7. data/lib/jekyll/converters/csv.rb +26 -0
  8. data/lib/jekyll/converters/mephisto.rb +79 -0
  9. data/lib/jekyll/converters/mt.rb +59 -0
  10. data/lib/jekyll/converters/rss.rb +44 -0
  11. data/lib/jekyll/converters/textpattern.rb +50 -0
  12. data/lib/jekyll/converters/typo.rb +49 -0
  13. data/lib/jekyll/converters/wordpress.rb +55 -0
  14. data/lib/jekyll/convertible.rb +71 -0
  15. data/lib/jekyll/core_ext.rb +22 -0
  16. data/lib/jekyll/filters.rb +87 -0
  17. data/lib/jekyll/layout.rb +47 -0
  18. data/lib/jekyll/page.rb +64 -0
  19. data/lib/jekyll/post.rb +232 -0
  20. data/lib/jekyll/site.rb +221 -0
  21. data/lib/jekyll/tags/highlight.rb +53 -0
  22. data/lib/jekyll/tags/include.rb +49 -0
  23. data/lib/jekyll/tasks.rb +68 -0
  24. data/test/helper.rb +14 -0
  25. data/test/source/_includes/sig.markdown +3 -0
  26. data/test/source/_layouts/default.html +27 -0
  27. data/test/source/_layouts/simple.html +1 -0
  28. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  29. data/test/source/_posts/2008-02-02-published.textile +8 -0
  30. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  31. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  32. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  33. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  34. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  35. data/test/source/_posts/2009-01-27-category.textile +7 -0
  36. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  37. data/test/source/category_test.html +13 -0
  38. data/test/source/css/screen.css +76 -0
  39. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  40. data/test/source/index.html +22 -0
  41. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  42. data/test/suite.rb +9 -0
  43. data/test/test_filters.rb +49 -0
  44. data/test/test_generated_site.rb +37 -0
  45. data/test/test_jekyll.rb +0 -0
  46. data/test/test_post.rb +174 -0
  47. data/test/test_site.rb +51 -0
  48. data/test/test_tags.rb +52 -0
  49. metadata +186 -0
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 4
4
+ :patch: 4
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ help = <<HELP
6
+ Jekyll is a blog-aware, static site generator.
7
+
8
+ Basic Command Line Usage:
9
+ jekyll # . -> ./_site
10
+ jekyll <path to write generated site> # . -> <path>
11
+ jekyll <path to source> <path to write generated site> # <path> -> <path>
12
+
13
+ Options:
14
+ HELP
15
+
16
+ require 'optparse'
17
+ require 'jekyll'
18
+
19
+ options = {}
20
+
21
+ opts = OptionParser.new do |opts|
22
+ opts.banner = help
23
+
24
+ opts.on("--auto", "Auto-regenerate") do
25
+ options[:auto] = true
26
+ end
27
+
28
+ opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
29
+ options[:server] = true
30
+ options[:server_port] = port || 4000
31
+ end
32
+
33
+ opts.on("--lsi", "Use LSI for better related posts") do
34
+ Jekyll.lsi = true
35
+ end
36
+
37
+ opts.on("--pygments", "Use pygments to highlight code") do
38
+ Jekyll.pygments = true
39
+ end
40
+
41
+ opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
42
+ begin
43
+ require 'rdiscount'
44
+ Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html }
45
+ puts 'Using rdiscount for Markdown'
46
+ rescue LoadError
47
+ puts 'You must have the rdiscount gem installed first'
48
+ end
49
+ end
50
+
51
+ opts.on("--bluecloth", "Use bluecloth gem for Markdown") do
52
+ begin
53
+ require 'bluecloth'
54
+ Jekyll.markdown_proc = Proc.new { |x| BlueCloth.new(x).to_html }
55
+ puts 'Using BlueCloth for Markdown'
56
+ rescue LoadError
57
+ puts 'You must have the BlueCloth gem installed first'
58
+ end
59
+ end
60
+
61
+ opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
62
+ Jekyll.permalink_style = (style || 'date').to_sym
63
+ end
64
+
65
+ opts.on("--version", "Display current version") do
66
+ puts "Jekyll " + Jekyll.version
67
+ exit 0
68
+ end
69
+ end
70
+
71
+ opts.parse!
72
+
73
+ def clean(dest)
74
+ FileUtils.rm_rf(dest)
75
+ FileUtils.mkdir_p(dest)
76
+ end
77
+
78
+ def globs(source)
79
+ Dir.chdir(source) do
80
+ dirs = Dir['*'].select { |x| File.directory?(x) }
81
+ dirs -= ['_site']
82
+ dirs = dirs.map { |x| "#{x}/**/*" }
83
+ dirs += ['*']
84
+ end
85
+ end
86
+
87
+ source = nil
88
+ destination = nil
89
+
90
+ case ARGV.size
91
+ when 0
92
+ source = Dir.pwd
93
+ destination = File.join(source, '_site')
94
+ when 1
95
+ source = Dir.pwd
96
+ destination = ARGV[0]
97
+ when 2
98
+ source = ARGV[0]
99
+ destination = ARGV[1]
100
+ else
101
+ puts "Invalid options. Run `jekyll --help` for assistance."
102
+ exit(1)
103
+ end
104
+
105
+ if options[:auto]
106
+ require 'directory_watcher'
107
+
108
+ puts "Auto-regenerating enabled: #{source} -> #{destination}"
109
+
110
+ dw = DirectoryWatcher.new(source)
111
+ dw.interval = 1
112
+ dw.glob = globs(source)
113
+
114
+ dw.add_observer do |*args|
115
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
116
+ puts "[#{t}] regeneration: #{args.size} files changed"
117
+ Jekyll.process(source, destination)
118
+ end
119
+
120
+ dw.start
121
+
122
+ unless options[:server]
123
+ loop { sleep 1000 }
124
+ end
125
+ else
126
+ Jekyll.process(source, destination)
127
+ puts "Successfully generated site in #{destination}"
128
+ end
129
+
130
+ if options[:server]
131
+ require 'webrick'
132
+ include WEBrick
133
+
134
+ FileUtils.mkdir_p(destination)
135
+
136
+ s = HTTPServer.new(
137
+ :Port => options[:server_port],
138
+ :DocumentRoot => destination
139
+ )
140
+ t = Thread.new {
141
+ s.start
142
+ }
143
+
144
+ trap("INT") { s.shutdown }
145
+ t.join()
146
+ end
@@ -0,0 +1,81 @@
1
+ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
+
3
+ # rubygems
4
+ require 'rubygems'
5
+
6
+ # core
7
+ require 'fileutils'
8
+ require 'time'
9
+ require 'yaml'
10
+
11
+ # stdlib
12
+ require 'open-uri'
13
+
14
+ # 3rd party
15
+ require 'liquid'
16
+ require 'redcloth'
17
+ require 'hpricot'
18
+ begin
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
+ rescue LoadError
32
+ puts "The maruku gem is required for markdown support!"
33
+ end
34
+
35
+ # internal requires
36
+ require 'jekyll/core_ext'
37
+ require 'jekyll/site'
38
+ require 'jekyll/convertible'
39
+ require 'jekyll/layout'
40
+ require 'jekyll/page'
41
+ require 'jekyll/post'
42
+ require 'jekyll/filters'
43
+ require 'jekyll/tags/highlight'
44
+ require 'jekyll/tags/include'
45
+ require 'jekyll/tags/markdown'
46
+ require 'jekyll/tags/smartypants'
47
+ require 'jekyll/albino'
48
+
49
+ if File.exists?('_jekyll/extensions.rb')
50
+ require '_jekyll/extensions.rb'
51
+ end
52
+
53
+ module Jekyll
54
+ class << self
55
+ attr_accessor :source, :dest, :site, :lsi, :pygments, :markdown_proc, :content_type, :permalink_style
56
+ end
57
+
58
+ Jekyll.lsi = false
59
+ Jekyll.pygments = false
60
+ Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
61
+ Jekyll.permalink_style = :pretty
62
+
63
+ def self.process(source, dest)
64
+ require 'classifier' if Jekyll.lsi
65
+
66
+ Jekyll.source = source
67
+ Jekyll.dest = dest
68
+ # Read regular expressions identifying files to ignore from
69
+ # .jekyllignore.
70
+ ignore_pattern = FileTest.exist?(File.join(source, '.jekyllignore')) ? File.open(File.join(source, '.jekyllignore')) { |f| f.read.split.join('|') } : '^$'
71
+ Jekyll.site = Jekyll::Site.new(source, dest, ignore_pattern)
72
+ Jekyll.site.process
73
+ end
74
+
75
+ def self.version
76
+ yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
77
+ "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
78
+ end
79
+
80
+ BINARY = File.expand_path(File.dirname(__FILE__) + '/../bin/jekyll')
81
+ end
@@ -0,0 +1,121 @@
1
+ ##
2
+ # Wrapper for the Pygments command line tool, pygmentize.
3
+ #
4
+ # Pygments: http://pygments.org/
5
+ #
6
+ # Assumes pygmentize is in the path. If not, set its location
7
+ # with Albino.bin = '/path/to/pygmentize'
8
+ #
9
+ # Use like so:
10
+ #
11
+ # @syntaxer = Albino.new('/some/file.rb', :ruby)
12
+ # puts @syntaxer.colorize
13
+ #
14
+ # This'll print out an HTMLized, Ruby-highlighted version
15
+ # of '/some/file.rb'.
16
+ #
17
+ # To use another formatter, pass it as the third argument:
18
+ #
19
+ # @syntaxer = Albino.new('/some/file.rb', :ruby, :bbcode)
20
+ # puts @syntaxer.colorize
21
+ #
22
+ # You can also use the #colorize class method:
23
+ #
24
+ # puts Albino.colorize('/some/file.rb', :ruby)
25
+ #
26
+ # Another also: you get a #to_s, for somewhat nicer use in Rails views.
27
+ #
28
+ # ... helper file ...
29
+ # def highlight(text)
30
+ # Albino.new(text, :ruby)
31
+ # end
32
+ #
33
+ # ... view file ...
34
+ # <%= highlight text %>
35
+ #
36
+ # The default lexer is 'text'. You need to specify a lexer yourself;
37
+ # because we are using STDIN there is no auto-detect.
38
+ #
39
+ # To see all lexers and formatters available, run `pygmentize -L`.
40
+ #
41
+ # Chris Wanstrath // chris@ozmm.org
42
+ # GitHub // http://github.com
43
+ #
44
+ require 'open4'
45
+
46
+ class Albino
47
+ @@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
48
+
49
+ def self.bin=(path)
50
+ @@bin = path
51
+ end
52
+
53
+ def self.colorize(*args)
54
+ new(*args).colorize
55
+ end
56
+
57
+ def initialize(target, lexer = :text, format = :html)
58
+ @target = File.exists?(target) ? File.read(target) : target rescue target
59
+ @options = { :l => lexer, :f => format }
60
+ end
61
+
62
+ def execute(command)
63
+ output = ''
64
+ Open4.popen4(command) do |pid, stdin, stdout, stderr|
65
+ stdin.puts @target
66
+ stdin.close
67
+ output = stdout.read.strip
68
+ end
69
+
70
+ # rdiscount wants the closing pre on a line by itself
71
+ output.gsub( %r(</pre></div>), "</pre>\n</div>" )
72
+ end
73
+
74
+ def colorize(options = {})
75
+ execute @@bin + convert_options(options)
76
+ end
77
+ alias_method :to_s, :colorize
78
+
79
+ def convert_options(options = {})
80
+ @options.merge(options).inject('') do |string, (flag, value)|
81
+ string + " -#{flag} #{value}"
82
+ end
83
+ end
84
+ end
85
+
86
+ if $0 == __FILE__
87
+ require 'rubygems'
88
+ require 'test/spec'
89
+ require 'mocha'
90
+ begin require 'redgreen'; rescue LoadError; end
91
+
92
+ context "Albino" do
93
+ setup do
94
+ @syntaxer = Albino.new(__FILE__, :ruby)
95
+ end
96
+
97
+ specify "defaults to text" do
98
+ syntaxer = Albino.new(__FILE__)
99
+ syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
100
+ syntaxer.colorize
101
+ end
102
+
103
+ specify "accepts options" do
104
+ @syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
105
+ @syntaxer.colorize
106
+ end
107
+
108
+ specify "works with strings" do
109
+ syntaxer = Albino.new('class New; end', :ruby)
110
+ assert_match %r(highlight), syntaxer.colorize
111
+ end
112
+
113
+ specify "aliases to_s" do
114
+ assert_equal @syntaxer.colorize, @syntaxer.to_s
115
+ end
116
+
117
+ specify "class method colorize" do
118
+ assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,26 @@
1
+ module Jekyll
2
+ module CSV
3
+ #Reads a csv with title, permalink, body, published_at, and filter.
4
+ #It creates a post file for each row in the csv
5
+ def self.process(file = "posts.csv")
6
+ FileUtils.mkdir_p "_posts"
7
+ posts = 0
8
+ FasterCSV.foreach(file) do |row|
9
+ next if row[0] == "title"
10
+ posts += 1
11
+ name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
12
+ File.open("_posts/#{name}", "w") do |f|
13
+ f.puts <<-HEADER
14
+ ---
15
+ layout: post
16
+ title: #{row[0]}
17
+ ---
18
+
19
+ HEADER
20
+ f.puts row[2]
21
+ end
22
+ end
23
+ "Created #{posts} posts!"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,79 @@
1
+ # Quickly hacked together my Michael Ivey
2
+ # Based on mt.rb by Nick Gerakines, open source and publically
3
+ # available under the MIT license. Use this module at your own risk.
4
+
5
+ require 'rubygems'
6
+ require 'sequel'
7
+ require 'fastercsv'
8
+ require 'fileutils'
9
+ require File.join(File.dirname(__FILE__),"csv.rb")
10
+
11
+ # NOTE: This converter requires Sequel and the MySQL gems.
12
+ # The MySQL gem can be difficult to install on OS X. Once you have MySQL
13
+ # installed, running the following commands should work:
14
+ # $ sudo gem install sequel
15
+ # $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
16
+
17
+ module Jekyll
18
+ module Mephisto
19
+ #Accepts a hash with database config variables, exports mephisto posts into a csv
20
+ #export PGPASSWORD if you must
21
+ def self.postgres(c)
22
+ sql = <<-SQL
23
+ BEGIN;
24
+ CREATE TEMP TABLE jekyll AS
25
+ SELECT title, permalink, body, published_at, filter FROM contents
26
+ WHERE user_id = 1 AND type = 'Article' ORDER BY published_at;
27
+ COPY jekyll TO STDOUT WITH CSV HEADER;
28
+ ROLLBACK;
29
+ SQL
30
+ command = %Q(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
31
+ puts command
32
+ `#{command}`
33
+ CSV.process
34
+ end
35
+
36
+ # This query will pull blog posts from all entries across all blogs. If
37
+ # you've got unpublished, deleted or otherwise hidden posts please sift
38
+ # through the created posts to make sure nothing is accidently published.
39
+
40
+ QUERY = "SELECT id, permalink, body, published_at, title FROM contents WHERE user_id = 1 AND type = 'Article' AND published_at IS NOT NULL ORDER BY published_at"
41
+
42
+ def self.process(dbname, user, pass, host = 'localhost')
43
+ db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
44
+
45
+ FileUtils.mkdir_p "_posts"
46
+
47
+ db[QUERY].each do |post|
48
+ title = post[:title]
49
+ slug = post[:permalink]
50
+ date = post[:published_at]
51
+ content = post[:body]
52
+ # more_content = ''
53
+
54
+ # Be sure to include the body and extended body.
55
+ # if more_content != nil
56
+ # content = content + " \n" + more_content
57
+ # end
58
+
59
+ # Ideally, this script would determine the post format (markdown, html
60
+ # , etc) and create files with proper extensions. At this point it
61
+ # just assumes that markdown will be acceptable.
62
+ name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
63
+
64
+ data = {
65
+ 'layout' => 'post',
66
+ 'title' => title.to_s,
67
+ 'mt_id' => post[:entry_id],
68
+ }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
69
+
70
+ File.open("_posts/#{name}", "w") do |f|
71
+ f.puts data
72
+ f.puts "---"
73
+ f.puts content
74
+ end
75
+ end
76
+
77
+ end
78
+ end
79
+ end