blackwinter-jekyll 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +7 -0
  2. data/History.txt +188 -0
  3. data/README.textile +55 -0
  4. data/Rakefile +90 -0
  5. data/VERSION.yml +5 -0
  6. data/bin/jekyll +158 -0
  7. data/features/create_sites.feature +94 -0
  8. data/features/embed_filters.feature +60 -0
  9. data/features/markdown.feature +30 -0
  10. data/features/pagination.feature +27 -0
  11. data/features/permalinks.feature +65 -0
  12. data/features/post_data.feature +153 -0
  13. data/features/site_configuration.feature +63 -0
  14. data/features/site_data.feature +82 -0
  15. data/features/step_definitions/jekyll_steps.rb +136 -0
  16. data/features/support/env.rb +16 -0
  17. data/lib/jekyll.rb +88 -0
  18. data/lib/jekyll/albino.rb +122 -0
  19. data/lib/jekyll/converters/csv.rb +26 -0
  20. data/lib/jekyll/converters/mephisto.rb +79 -0
  21. data/lib/jekyll/converters/mt.rb +59 -0
  22. data/lib/jekyll/converters/textpattern.rb +50 -0
  23. data/lib/jekyll/converters/typo.rb +49 -0
  24. data/lib/jekyll/converters/wordpress.rb +54 -0
  25. data/lib/jekyll/convertible.rb +91 -0
  26. data/lib/jekyll/core_ext.rb +52 -0
  27. data/lib/jekyll/engine.rb +73 -0
  28. data/lib/jekyll/filters.rb +47 -0
  29. data/lib/jekyll/layout.rb +36 -0
  30. data/lib/jekyll/page.rb +116 -0
  31. data/lib/jekyll/pager.rb +45 -0
  32. data/lib/jekyll/post.rb +243 -0
  33. data/lib/jekyll/site.rb +280 -0
  34. data/lib/jekyll/static_file.rb +28 -0
  35. data/test/helper.rb +27 -0
  36. data/test/source/_includes/sig.markdown +3 -0
  37. data/test/source/_layouts/default.html +27 -0
  38. data/test/source/_layouts/simple.html +1 -0
  39. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  40. data/test/source/_posts/2008-02-02-published.textile +8 -0
  41. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  42. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  43. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  44. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  45. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  46. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  47. data/test/source/_posts/2009-01-27-category.textile +7 -0
  48. data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
  49. data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
  50. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  51. data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
  52. data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
  53. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  54. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  55. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  56. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  57. data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
  58. data/test/source/_posts/2010-01-09-date-override.textile +5 -0
  59. data/test/source/_posts/2010-01-09-time-override.textile +5 -0
  60. data/test/source/about.html +6 -0
  61. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  62. data/test/source/contacts.html +5 -0
  63. data/test/source/css/screen.css +76 -0
  64. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  65. data/test/source/index.html +22 -0
  66. data/test/source/sitemap.xml +21 -0
  67. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  68. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  69. data/test/suite.rb +9 -0
  70. data/test/test_configuration.rb +29 -0
  71. data/test/test_core_ext.rb +66 -0
  72. data/test/test_filters.rb +49 -0
  73. data/test/test_generated_site.rb +44 -0
  74. data/test/test_page.rb +98 -0
  75. data/test/test_pager.rb +113 -0
  76. data/test/test_post.rb +345 -0
  77. data/test/test_site.rb +91 -0
  78. metadata +234 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ test/dest
2
+ *.gem
3
+ *.gemspec
4
+ pkg/
5
+ *.swp
6
+ *~
7
+ _site/
data/History.txt ADDED
@@ -0,0 +1,188 @@
1
+ == Edge
2
+ * Bug Fixes
3
+ * Render highlighted code for non markdown/textile pages (#116)
4
+ * Expand source to full path so includes work anywhere (#101)
5
+ * Fix highlighting on Ruby 1.9 (#65)
6
+ * Fix extension munging when pretty permalinks are enabled (#64)
7
+ * Stop sorting categories (#33)
8
+
9
+ == 0.5.7 / 2010-01-12
10
+ * Minor Enhancements
11
+ * Allow overriding of post date in the front matter (#62, #38)
12
+ * Bug Fixes
13
+ * Categories isn't always an array (#73)
14
+ * Empty tags causes error in read_posts (#84)
15
+ * Fix pagination to adhere to read/render/write paradigm
16
+ * Test Enhancement
17
+ * cucumber features no longer use site.ports.first where a better alternative is available
18
+
19
+ == 0.5.6 / 2010-01-08
20
+ * Bug Fixes
21
+ * Require redcloth >= 4.2.1 in tests (#92)
22
+ * Don't break on triple dashes in yaml frontmatter (#93)
23
+ * Minor Enhancements
24
+ * Allow .mkd as markdown extension
25
+ * Use $stdout/err instead of constants (#99)
26
+ * Properly wrap code blocks (#91)
27
+ * Add javascript mime type for webrick (#98)
28
+
29
+ == 0.5.5 / 2010-01-08
30
+ * Bug Fixes
31
+ * Fix pagination % 0 bug (#78)
32
+ * Ensure all posts are processed first (#71)
33
+
34
+ == NOTE
35
+ * After this point I will no longer be giving credit in the history;
36
+ that is what the commit log is for.
37
+
38
+ == 0.5.4 / 2009-08-23
39
+ * Bug Fixes
40
+ * Do not allow symlinks (security vulnerability)
41
+
42
+ == 0.5.3 / 2009-07-14
43
+ * Bug Fixes
44
+ * Solving the permalink bug where non-html files wouldn't work [github.com/jeffrydegrande]
45
+
46
+ == 0.5.2 / 2009-06-24
47
+ * Enhancements
48
+ * Added --paginate option to the executable along with a paginator object for the payload [github.com/calavera]
49
+ * Upgraded RedCloth to 4.2.1, which makes <notextile> tags work once again.
50
+ * Configuration options set in config.yml are now available through the site payload [github.com/vilcans]
51
+ * Posts can now have an empty YAML front matter or none at all [github.com/bahuvrihi]
52
+ * Bug Fixes
53
+ * Fixing Ruby 1.9 issue that requires to_s on the err object [github.com/Chrononaut]
54
+ * Fixes for pagination and ordering posts on the same day [github.com/ujh]
55
+ * Made pages respect permalinks style and permalinks in yml front matter [github.com/eugenebolshakov]
56
+ * Index.html file should always have index.html permalink [github.com/eugenebolshakov]
57
+ * Added trailing slash to pretty permalink style so Apache is happy [github.com/eugenebolshakov]
58
+ * Bad markdown processor in config fails sooner and with better message [github.com/gcnovus]
59
+ * Allow CRLFs in yaml frontmatter [github.com/juretta]
60
+ * Added Date#xmlschema for Ruby versions < 1.9
61
+
62
+ == 0.5.1 / 2009-05-06
63
+ * Major Enhancements
64
+ * Next/previous posts in site payload [github.com/pantulis, github.com/tomo]
65
+ * Permalink templating system
66
+ * Moved most of the README out to the GitHub wiki
67
+ * Exclude option in configuration so specified files won't be brought over with generated site [github.com/duritong]
68
+ * Bug Fixes
69
+ * Making sure config.yaml references are all gone, using only config.yml
70
+ * Fixed syntax highlighting breaking for UTF-8 code [github.com/henrik]
71
+ * Worked around RDiscount bug that prevents Markdown from getting parsed after highlight [github.com/henrik]
72
+ * CGI escaped post titles [github.com/Chrononaut]
73
+
74
+ == 0.5.0 / 2009-04-07
75
+ * Minor Enhancements
76
+ * Ability to set post categories via YAML [github.com/qrush]
77
+ * Ability to set prevent a post from publishing via YAML [github.com/qrush]
78
+ * Add textilize filter [github.com/willcodeforfoo]
79
+ * Add 'pretty' permalink style for wordpress-like urls [github.com/dysinger]
80
+ * Made it possible to enter categories from YAML as an array [github.com/Chrononaut]
81
+ * Ignore Emacs autosave files [github.com/Chrononaut]
82
+ * Bug Fixes
83
+ * Use block syntax of popen4 to ensure that subprocesses are properly disposed [github.com/jqr]
84
+ * Close open4 streams to prevent zombies [github.com/rtomayko]
85
+ * Only query required fields from the WP Database [github.com/ariejan]
86
+ * Prevent _posts from being copied to the destination directory [github.com/bdimcheff]
87
+ * Refactors
88
+ * Factored the filtering code into a method [github.com/Chrononaut]
89
+ * Fix tests and convert to Shoulda [github.com/qrush, github.com/technicalpickles]
90
+ * Add Cucumber acceptance test suite [github.com/qrush, github.com/technicalpickles]
91
+
92
+ == 0.4.1
93
+ * Minor Enhancements
94
+ * Changed date format on wordpress converter (zeropadding) [github.com/dysinger]
95
+ * Bug Fixes
96
+ * Add jekyll binary as executable to gemspec [github.com/dysinger]
97
+
98
+ == 0.4.0 / 2009-02-03
99
+ * Major Enhancements
100
+ * Switch to Jeweler for packaging tasks
101
+ * Minor Enhancements
102
+ * Type importer [github.com/codeslinger]
103
+ * site.topics accessor [github.com/baz]
104
+ * Add array_to_sentence_string filter [github.com/mchung]
105
+ * Add a converter for textpattern [github.com/PerfectlyNormal]
106
+ * Add a working Mephisto / MySQL converter [github.com/ivey]
107
+ * Allowing .htaccess files to be copied over into the generated site [github.com/briandoll]
108
+ * Add option to not put file date in permalink URL [github.com/mreid]
109
+ * Add line number capabilities to highlight blocks [github.com/jcon]
110
+ * Bug Fixes
111
+ * Fix permalink behavior [github.com/cavalle]
112
+ * Fixed an issue with pygments, markdown, and newlines [github.com/zpinter]
113
+ * Ampersands need to be escaped [github.com/pufuwozu, github.com/ap]
114
+ * Test and fix the site.categories hash [github.com/zzot]
115
+ * Fix site payload available to files [github.com/matrix9180]
116
+
117
+ == 0.3.0 / 2008-12-24
118
+ * Major Enhancements
119
+ * Added --server option to start a simple WEBrick server on destination directory [github.com/johnreilly and github.com/mchung]
120
+ * Minor Enhancements
121
+ * Added post categories based on directories containing _posts [github.com/mreid]
122
+ * Added post topics based on directories underneath _posts
123
+ * Added new date filter that shows the full month name [github.com/mreid]
124
+ * Merge Post's YAML front matter into its to_liquid payload [github.com/remi]
125
+ * Restrict includes to regular files underneath _includes
126
+ * Bug Fixes
127
+ * Change YAML delimiter matcher so as to not chew up 2nd level markdown headers [github.com/mreid]
128
+ * Fix bug that meant page data (such as the date) was not available in templates [github.com/mreid]
129
+ * Properly reject directories in _layouts
130
+
131
+ == 0.2.1 / 2008-12-15
132
+ * Major Changes
133
+ * Use Maruku (pure Ruby) for Markdown by default [github.com/mreid]
134
+ * Allow use of RDiscount with --rdiscount flag
135
+ * Minor Enhancements
136
+ * Don't load directory_watcher unless it's needed [github.com/pjhyett]
137
+
138
+ == 0.2.0 / 2008-12-14
139
+ * Major Changes
140
+ * related_posts is now found in site.related_posts
141
+
142
+ == 0.1.6 / 2008-12-13
143
+ * Major Features
144
+ * Include files in _includes with {% include x.textile %}
145
+
146
+ == 0.1.5 / 2008-12-12
147
+ * Major Features
148
+ * Code highlighting with Pygments if --pygments is specified
149
+ * Disable true LSI by default, enable with --lsi
150
+ * Minor Enhancements
151
+ * Output informative message if RDiscount is not available [github.com/JackDanger]
152
+ * Bug Fixes
153
+ * Prevent Jekyll from picking up the output directory as a source [github.com/JackDanger]
154
+ * Skip related_posts when there is only one post [github.com/JackDanger]
155
+
156
+ == 0.1.4 / 2008-12-08
157
+ * Bug Fixes
158
+ * DATA does not work properly with rubygems
159
+
160
+ == 0.1.3 / 2008-12-06
161
+ * Major Features
162
+ * Markdown support [github.com/vanpelt]
163
+ * Mephisto and CSV converters [github.com/vanpelt]
164
+ * Code hilighting [github.com/vanpelt]
165
+ * Autobuild
166
+ * Bug Fixes
167
+ * Accept both \r\n and \n in YAML header [github.com/vanpelt]
168
+
169
+ == 0.1.2 / 2008-11-22
170
+ * Major Features
171
+ * Add a real "related posts" implementation using Classifier
172
+ * Command Line Changes
173
+ * Allow cli to be called with 0, 1, or 2 args intuiting dir paths
174
+ if they are omitted
175
+
176
+ == 0.1.1 / 2008-11-22
177
+ * Minor Additions
178
+ * Posts now support introspectional data e.g. {{ page.url }}
179
+
180
+ == 0.1.0 / 2008-11-05
181
+ * First release
182
+ * Converts posts written in Textile
183
+ * Converts regular site pages
184
+ * Simple copy of binary files
185
+
186
+ == 0.0.0 / 2008-10-19
187
+ * Birthday!
188
+
data/README.textile ADDED
@@ -0,0 +1,55 @@
1
+ h1. Jekyll
2
+
3
+ By Tom Preston-Werner, Nick Quaranto, and many awesome contributors!
4
+
5
+ Jekyll is a simple, blog aware, static site generator. It takes a template directory (representing the raw form of a website), runs it through Textile or Markdown and -Liquid- ERB (in this fork) converters, and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind "GitHub Pages":http://pages.github.com, which you can use to host your project's page or blog right here from GitHub.
6
+
7
+ h2. Getting Started
8
+
9
+ * "Install":http://wiki.github.com/mojombo/jekyll/install the gem
10
+ * Read up about its "Usage":http://wiki.github.com/mojombo/jekyll/usage and "Configuration":http://wiki.github.com/mojombo/jekyll/configuration
11
+ * Take a gander at some existing "Sites":http://wiki.github.com/mojombo/jekyll/sites
12
+ * Fork and "Contribute":http://wiki.github.com/mojombo/jekyll/contribute your own modifications
13
+ * Have questions? Post them on the "Mailing List":http://groups.google.com/group/jekyll-rb
14
+
15
+ h2. Diving In
16
+
17
+ * "Migrate":http://wiki.github.com/mojombo/jekyll/blog-migrations from your previous system
18
+ * Learn how the "YAML Front Matter":http://wiki.github.com/mojombo/jekyll/yaml-front-matter works
19
+ * Put information on your site with "Template Data":http://wiki.github.com/mojombo/jekyll/template-data
20
+ * Customize the "Permalinks":http://wiki.github.com/mojombo/jekyll/permalinks your posts are generated with
21
+ * -Use the built-in "Liquid Extensions":http://wiki.github.com/mojombo/jekyll/liquid-extensions to make your life easier-
22
+
23
+ h2. Runtime Dependencies
24
+
25
+ * RedCloth: Textile support (Ruby)
26
+ * -Liquid: Templating system (Ruby)-
27
+ * Classifier: Generating related posts (Ruby)
28
+ * Maruku: Default markdown engine (Ruby)
29
+ * Directory Watcher: Auto-regeneration of sites (Ruby)
30
+ * Open4: Talking to pygments for syntax highlighting (Ruby)
31
+ * Pygments: Syntax highlighting (Python)
32
+
33
+ h2. Developer Dependencies
34
+
35
+ * Shoulda: Test framework (Ruby)
36
+ * RR: Mocking (Ruby)
37
+ * RedGreen: Nicer test output (Ruby)
38
+
39
+ h2. This fork...
40
+ * uses ERB instead of Liquid for templates.
41
+ * is extendable by creating an @_init.rb@ file in your site's root.
42
+ * enables pagination for other files than index.html. Set @paginate_file@ in your @_config.yml@ like @paginate_file: blog.html@ to do that.
43
+ * is some kind of a hack. Be careful.
44
+
45
+ h2. License
46
+
47
+ (The MIT License)
48
+
49
+ Copyright (c) 2008 Tom Preston-Werner
50
+
51
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,90 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ begin
6
+ gem 'jeweler', '>= 0.11.0'
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |s|
9
+ s.name = "blackwinter-jekyll"
10
+ s.summary = %Q{Jekyll is a simple, blog aware, static site generator.}
11
+ s.email = ["tom@mojombo.com", "jens.wille@uni-koeln.de"]
12
+ s.homepage = "http://github.com/blackwinter/jekyll"
13
+ s.description = "Jekyll is a simple, blog aware, static site generator."
14
+ s.authors = ["Tom Preston-Werner", "Jens Wille"]
15
+ s.rubyforge_project = "jekyll"
16
+ s.files.exclude 'test/dest'
17
+ s.test_files.exclude 'test/dest'
18
+ s.add_dependency('RedCloth', '>= 4.2.1')
19
+ s.add_dependency('classifier', '>= 1.3.1')
20
+ s.add_dependency('maruku', '>= 0.5.9')
21
+ s.add_dependency('directory_watcher', '>= 1.1.1')
22
+ s.add_dependency('open4', '>= 0.9.6')
23
+ end
24
+ rescue LoadError
25
+ puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
26
+ exit(1)
27
+ end
28
+
29
+ Rake::TestTask.new do |t|
30
+ t.libs << 'lib'
31
+ t.pattern = 'test/**/test_*.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+ Rake::RDocTask.new do |rdoc|
36
+ rdoc.rdoc_dir = 'rdoc'
37
+ rdoc.title = 'jekyll'
38
+ rdoc.options << '--line-numbers' << '--inline-source'
39
+ rdoc.rdoc_files.include('README*')
40
+ rdoc.rdoc_files.include('lib/**/*.rb')
41
+ end
42
+
43
+ begin
44
+ require 'rcov/rcovtask'
45
+ Rcov::RcovTask.new do |t|
46
+ t.libs << 'test'
47
+ t.test_files = FileList['test/**/test_*.rb']
48
+ t.verbose = true
49
+ end
50
+ rescue LoadError
51
+ end
52
+
53
+ task :default => [:test, :features]
54
+
55
+ # console
56
+
57
+ desc "Open an irb session preloaded with this library"
58
+ task :console do
59
+ sh "irb -rubygems -I lib -r jekyll.rb"
60
+ end
61
+
62
+ # converters
63
+
64
+ namespace :convert do
65
+ desc "Migrate from mephisto in the current directory"
66
+ task :mephisto do
67
+ sh %q(ruby -r './lib/jekyll/converters/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
68
+ end
69
+ desc "Migrate from Movable Type in the current directory"
70
+ task :mt do
71
+ sh %q(ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
72
+ end
73
+ desc "Migrate from Typo in the current directory"
74
+ task :typo do
75
+ sh %q(ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
76
+ end
77
+ end
78
+
79
+ begin
80
+ require 'cucumber/rake/task'
81
+
82
+ Cucumber::Rake::Task.new(:features) do |t|
83
+ t.cucumber_opts = "--format progress"
84
+ end
85
+ rescue LoadError
86
+ desc 'Cucumber rake task not available'
87
+ task :features do
88
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
89
+ end
90
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :minor: 5
3
+ :patch: 7
4
+ :build:
5
+ :major: 0
data/bin/jekyll ADDED
@@ -0,0 +1,158 @@
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
+ Configuration is read from '<source>/_config.yml' but can be overriden
14
+ using the following options:
15
+
16
+ HELP
17
+
18
+ require 'optparse'
19
+ require 'jekyll'
20
+
21
+ exec = {}
22
+ options = {}
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = help
25
+
26
+ opts.on("--auto", "Auto-regenerate") do
27
+ options['auto'] = true
28
+ end
29
+
30
+ opts.on("--no-auto", "No auto-regenerate") do
31
+ options['auto'] = false
32
+ end
33
+
34
+ opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
35
+ options['server'] = true
36
+ options['server_port'] = port unless port.nil?
37
+ end
38
+
39
+ opts.on("--lsi", "Use LSI for better related posts") do
40
+ options['lsi'] = true
41
+ end
42
+
43
+ opts.on("--pygments", "Use pygments to highlight code") do
44
+ options['pygments'] = true
45
+ end
46
+
47
+ opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
48
+ options['markdown'] = 'rdiscount'
49
+ end
50
+
51
+ opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
52
+ options['permalink'] = style unless style.nil?
53
+ end
54
+
55
+ opts.on("--paginate [POSTS_PER_PAGE]", "Paginate a blog's posts") do |per_page|
56
+ begin
57
+ options['paginate'] = per_page.to_i
58
+ raise ArgumentError if options['paginate'] == 0
59
+ rescue
60
+ puts 'you must specify a number of posts by page bigger than 0'
61
+ exit 0
62
+ end
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
+ # Read command line options into `options` hash
72
+ opts.parse!
73
+
74
+ # Get source and destintation from command line
75
+ case ARGV.size
76
+ when 0
77
+ when 1
78
+ options['destination'] = ARGV[0]
79
+ when 2
80
+ options['source'] = ARGV[0]
81
+ options['destination'] = ARGV[1]
82
+ else
83
+ puts "Invalid options. Run `jekyll --help` for assistance."
84
+ exit(1)
85
+ end
86
+
87
+ options = Jekyll.configuration(options)
88
+
89
+ # Get source and destination directories (possibly set by config file)
90
+ source = options['source']
91
+ destination = options['destination']
92
+
93
+ # Load custom init script
94
+ init = File.join(source, '_init.rb')
95
+ require init if File.readable?(init)
96
+
97
+ # Files to watch
98
+ def globs(source)
99
+ Dir.chdir(source) do
100
+ dirs = Dir['*'].select { |x| File.directory?(x) }
101
+ dirs -= ['_site']
102
+ dirs = dirs.map { |x| "#{x}/**/*" }
103
+ dirs += ['*']
104
+ end
105
+ end
106
+
107
+ # Create the Site
108
+ site = Jekyll::Site.new(options)
109
+
110
+ # Run the directory watcher for auto-generation, if required
111
+ if options['auto']
112
+ require 'directory_watcher'
113
+
114
+ puts "Auto-regenerating enabled: #{source} -> #{destination}"
115
+
116
+ dw = DirectoryWatcher.new(source)
117
+ dw.interval = 1
118
+ dw.glob = globs(source)
119
+
120
+ dw.add_observer do |*args|
121
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
122
+ puts "[#{t}] regeneration: #{args.size} files changed"
123
+ site.process
124
+ end
125
+
126
+ dw.start
127
+
128
+ unless options['server']
129
+ loop { sleep 1000 }
130
+ end
131
+ else
132
+ puts "Building site: #{source} -> #{destination}"
133
+ site.process
134
+ puts "Successfully generated site: #{source} -> #{destination}"
135
+ end
136
+
137
+ # Run the server on the specified port, if required
138
+ if options['server']
139
+ require 'webrick'
140
+ include WEBrick
141
+
142
+ FileUtils.mkdir_p(destination)
143
+
144
+ mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
145
+ mime_types.store 'js', 'application/javascript'
146
+
147
+ s = HTTPServer.new(
148
+ :Port => options['server_port'],
149
+ :DocumentRoot => destination,
150
+ :MimeTypes => mime_types
151
+ )
152
+ t = Thread.new {
153
+ s.start
154
+ }
155
+
156
+ trap("INT") { s.shutdown }
157
+ t.join()
158
+ end