octopress 3.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +15 -0
  2. data/.editorconfig +22 -0
  3. data/.gitattributes +1 -0
  4. data/.gitignore +20 -0
  5. data/.powrc +4 -0
  6. data/.rspec +5 -0
  7. data/.rubocop.yml +119 -0
  8. data/.slugignore +3 -0
  9. data/.themes/classic/.editorconfig +44 -0
  10. data/.themes/classic/_config/adn-timeline.yml +10 -0
  11. data/.themes/classic/_config/delicious-feed.yml +4 -0
  12. data/.themes/classic/_config/deploy/gh_pages.yml +9 -0
  13. data/.themes/classic/_config/deploy/rsync.yml +14 -0
  14. data/.themes/classic/_config/disqus.yml +11 -0
  15. data/.themes/classic/_config/facebook-like.yml +2 -0
  16. data/.themes/classic/_config/gauges-analytics.yml +6 -0
  17. data/.themes/classic/_config/github-repos.yml +24 -0
  18. data/.themes/classic/_config/google-analytics.yml +6 -0
  19. data/.themes/classic/_config/google-plus.yml +13 -0
  20. data/.themes/classic/_config/jekyll.yml +37 -0
  21. data/.themes/classic/_config/pinboard-feed.yml +4 -0
  22. data/.themes/classic/_config/require-js.yml +19 -0
  23. data/.themes/classic/_config/theme.yml +54 -0
  24. data/.themes/classic/_config/twitter-timeline.yml +9 -0
  25. data/.themes/classic/assets/javascripts/lib/ios-rotate-scaling-fix.js +18 -0
  26. data/.themes/classic/assets/javascripts/lib/jquery.cookie.js +92 -0
  27. data/.themes/classic/assets/javascripts/lib/modernizr.js +447 -0
  28. data/.themes/classic/assets/javascripts/lib/octopress.js +83 -0
  29. data/.themes/classic/assets/javascripts/modules/adn-timeline.coffee +68 -0
  30. data/.themes/classic/assets/javascripts/modules/delicious-feed.coffee +38 -0
  31. data/.themes/classic/assets/javascripts/modules/github-repos.coffee +60 -0
  32. data/.themes/classic/assets/javascripts/modules/github.coffee +60 -0
  33. data/.themes/classic/assets/javascripts/modules/helpers.coffee +96 -0
  34. data/.themes/classic/assets/javascripts/modules/pinboard-feed.coffee +42 -0
  35. data/.themes/classic/assets/javascripts/modules/site.coffee +11 -0
  36. data/.themes/classic/assets/stylesheets/_base.scss +5 -0
  37. data/.themes/classic/assets/stylesheets/_partials.scss +8 -0
  38. data/.themes/classic/assets/stylesheets/base/_layout.scss +191 -0
  39. data/.themes/classic/assets/stylesheets/base/_solarized.scss +75 -0
  40. data/.themes/classic/assets/stylesheets/base/_theme.scss +92 -0
  41. data/.themes/classic/assets/stylesheets/base/_typography.scss +168 -0
  42. data/.themes/classic/assets/stylesheets/base/_utilities.scss +27 -0
  43. data/.themes/classic/assets/stylesheets/custom/_colors.scss +49 -0
  44. data/.themes/classic/assets/stylesheets/custom/_fonts.scss +10 -0
  45. data/.themes/classic/assets/stylesheets/custom/_layout.scss +17 -0
  46. data/.themes/classic/assets/stylesheets/custom/_styles.scss +2 -0
  47. data/.themes/classic/assets/stylesheets/partials/_archive.scss +77 -0
  48. data/.themes/classic/assets/stylesheets/partials/_blog.scss +165 -0
  49. data/.themes/classic/assets/stylesheets/partials/_footer.scss +19 -0
  50. data/.themes/classic/assets/stylesheets/partials/_header.scss +18 -0
  51. data/.themes/classic/assets/stylesheets/partials/_navigation.scss +136 -0
  52. data/.themes/classic/assets/stylesheets/partials/_sharing.scss +73 -0
  53. data/.themes/classic/assets/stylesheets/partials/_sidebar.scss +4 -0
  54. data/.themes/classic/assets/stylesheets/partials/_syntax.scss +234 -0
  55. data/.themes/classic/assets/stylesheets/partials/sidebar/_base.scss +106 -0
  56. data/.themes/classic/assets/stylesheets/partials/sidebar/_delicious.scss +4 -0
  57. data/.themes/classic/assets/stylesheets/partials/sidebar/_googleplus.scss +26 -0
  58. data/.themes/classic/assets/stylesheets/partials/sidebar/_pinboard.scss +12 -0
  59. data/.themes/classic/assets/stylesheets/plugins/_plugins.scss +5 -0
  60. data/.themes/classic/assets/stylesheets/screen.scss +11 -0
  61. data/.themes/classic/source/404.markdown +9 -0
  62. data/.themes/classic/source/_includes/after_footer.html +7 -0
  63. data/.themes/classic/source/_includes/archive_post.html +12 -0
  64. data/.themes/classic/source/_includes/article.html +23 -0
  65. data/.themes/classic/source/_includes/comments.html +9 -0
  66. data/.themes/classic/source/_includes/custom/after_footer.html +3 -0
  67. data/.themes/classic/source/_includes/custom/after_page.html +1 -0
  68. data/.themes/classic/source/_includes/custom/after_post.html +0 -0
  69. data/.themes/classic/source/_includes/custom/comments.html +5 -0
  70. data/.themes/classic/source/_includes/custom/footer.html +4 -0
  71. data/.themes/classic/source/_includes/custom/head.html +7 -0
  72. data/.themes/classic/source/_includes/custom/header.html +6 -0
  73. data/.themes/classic/source/_includes/custom/navigation.html +4 -0
  74. data/.themes/classic/source/_includes/custom/page_meta.html +1 -0
  75. data/.themes/classic/source/_includes/custom/post_meta.html +1 -0
  76. data/.themes/classic/source/_includes/custom/sharing.html +3 -0
  77. data/.themes/classic/source/_includes/disqus.html +22 -0
  78. data/.themes/classic/source/_includes/facebook_like.html +10 -0
  79. data/.themes/classic/source/_includes/feed_entry.xml +10 -0
  80. data/.themes/classic/source/_includes/footer.html +1 -0
  81. data/.themes/classic/source/_includes/gauges_analytics.html +15 -0
  82. data/.themes/classic/source/_includes/google_analytics.html +13 -0
  83. data/.themes/classic/source/_includes/google_plus_one.html +9 -0
  84. data/.themes/classic/source/_includes/head.html +33 -0
  85. data/.themes/classic/source/_includes/header.html +1 -0
  86. data/.themes/classic/source/_includes/navigation.html +15 -0
  87. data/.themes/classic/source/_includes/post/author.html +8 -0
  88. data/.themes/classic/source/_includes/post/categories.html +10 -0
  89. data/.themes/classic/source/_includes/post/date.html +15 -0
  90. data/.themes/classic/source/_includes/post/disqus_thread.html +1 -0
  91. data/.themes/classic/source/_includes/post/meta.html +3 -0
  92. data/.themes/classic/source/_includes/post/sharing.html +36 -0
  93. data/.themes/classic/source/_includes/post/title.html +5 -0
  94. data/.themes/classic/source/_includes/post/variables.html +14 -0
  95. data/.themes/classic/source/_includes/sidebars/blog_index_default.html +3 -0
  96. data/.themes/classic/source/_includes/sidebars/page_default.html +4 -0
  97. data/.themes/classic/source/_includes/sidebars/post_default.html +4 -0
  98. data/.themes/classic/source/_includes/sidebars/sections/delicious.html +8 -0
  99. data/.themes/classic/source/_includes/sidebars/sections/github.html +9 -0
  100. data/.themes/classic/source/_includes/sidebars/sections/google_plus.html +5 -0
  101. data/.themes/classic/source/_includes/sidebars/sections/pinboard.html +17 -0
  102. data/.themes/classic/source/_includes/sidebars/sections/recent_posts.html +10 -0
  103. data/.themes/classic/source/_includes/twitter_sharing.html +11 -0
  104. data/.themes/classic/source/_layouts/category_feed.xml +24 -0
  105. data/.themes/classic/source/_layouts/category_index.html +19 -0
  106. data/.themes/classic/source/_layouts/default.html +14 -0
  107. data/.themes/classic/source/_layouts/page.html +34 -0
  108. data/.themes/classic/source/_layouts/post.html +39 -0
  109. data/.themes/classic/source/archives/index.html +20 -0
  110. data/.themes/classic/source/assets/jwplayer/glow/controlbar/background.png +0 -0
  111. data/.themes/classic/source/assets/jwplayer/glow/controlbar/blankButton.png +0 -0
  112. data/.themes/classic/source/assets/jwplayer/glow/controlbar/divider.png +0 -0
  113. data/.themes/classic/source/assets/jwplayer/glow/controlbar/fullscreenButton.png +0 -0
  114. data/.themes/classic/source/assets/jwplayer/glow/controlbar/fullscreenButtonOver.png +0 -0
  115. data/.themes/classic/source/assets/jwplayer/glow/controlbar/muteButton.png +0 -0
  116. data/.themes/classic/source/assets/jwplayer/glow/controlbar/muteButtonOver.png +0 -0
  117. data/.themes/classic/source/assets/jwplayer/glow/controlbar/normalscreenButton.png +0 -0
  118. data/.themes/classic/source/assets/jwplayer/glow/controlbar/normalscreenButtonOver.png +0 -0
  119. data/.themes/classic/source/assets/jwplayer/glow/controlbar/pauseButton.png +0 -0
  120. data/.themes/classic/source/assets/jwplayer/glow/controlbar/pauseButtonOver.png +0 -0
  121. data/.themes/classic/source/assets/jwplayer/glow/controlbar/playButton.png +0 -0
  122. data/.themes/classic/source/assets/jwplayer/glow/controlbar/playButtonOver.png +0 -0
  123. data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderBuffer.png +0 -0
  124. data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderCapLeft.png +0 -0
  125. data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderCapRight.png +0 -0
  126. data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderProgress.png +0 -0
  127. data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderRail.png +0 -0
  128. data/.themes/classic/source/assets/jwplayer/glow/controlbar/unmuteButton.png +0 -0
  129. data/.themes/classic/source/assets/jwplayer/glow/controlbar/unmuteButtonOver.png +0 -0
  130. data/.themes/classic/source/assets/jwplayer/glow/display/background.png +0 -0
  131. data/.themes/classic/source/assets/jwplayer/glow/display/bufferIcon.png +0 -0
  132. data/.themes/classic/source/assets/jwplayer/glow/display/muteIcon.png +0 -0
  133. data/.themes/classic/source/assets/jwplayer/glow/display/playIcon.png +0 -0
  134. data/.themes/classic/source/assets/jwplayer/glow/dock/button.png +0 -0
  135. data/.themes/classic/source/assets/jwplayer/glow/glow.xml +115 -0
  136. data/.themes/classic/source/assets/jwplayer/glow/playlist/item.png +0 -0
  137. data/.themes/classic/source/assets/jwplayer/glow/playlist/itemOver.png +0 -0
  138. data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderCapBottom.png +0 -0
  139. data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderCapTop.png +0 -0
  140. data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderRail.png +0 -0
  141. data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderThumb.png +0 -0
  142. data/.themes/classic/source/assets/jwplayer/glow/sharing/embedIcon.png +0 -0
  143. data/.themes/classic/source/assets/jwplayer/glow/sharing/embedScreen.png +0 -0
  144. data/.themes/classic/source/assets/jwplayer/glow/sharing/shareIcon.png +0 -0
  145. data/.themes/classic/source/assets/jwplayer/glow/sharing/shareScreen.png +0 -0
  146. data/.themes/classic/source/assets/jwplayer/player.swf +0 -0
  147. data/.themes/classic/source/atom.xml +23 -0
  148. data/.themes/classic/source/images/bird_32_gray.png +0 -0
  149. data/.themes/classic/source/images/bird_32_gray_fail.png +0 -0
  150. data/.themes/classic/source/images/code_bg.png +0 -0
  151. data/.themes/classic/source/images/dotted-border.png +0 -0
  152. data/.themes/classic/source/images/email.png +0 -0
  153. data/.themes/classic/source/images/icon/facebook.png +0 -0
  154. data/.themes/classic/source/images/icon/github.png +0 -0
  155. data/.themes/classic/source/images/icon/googleplus.png +0 -0
  156. data/.themes/classic/source/images/icon/twitter-bird.png +0 -0
  157. data/.themes/classic/source/images/icon/twitter.png +0 -0
  158. data/.themes/classic/source/images/line-tile.png +0 -0
  159. data/.themes/classic/source/images/noise.png +0 -0
  160. data/.themes/classic/source/images/rss.png +0 -0
  161. data/.themes/classic/source/images/search.png +0 -0
  162. data/.themes/classic/source/index.html +30 -0
  163. data/.themes/classic/source/javascripts/jquery.min.js +5 -0
  164. data/.themes/classic/source/octopress-favicon.png +0 -0
  165. data/.themes/classic/source/robots.txt +7 -0
  166. data/.travis.yml +6 -0
  167. data/CHANGELOG.markdown +46 -0
  168. data/CONTRIBUTING.markdown +17 -0
  169. data/Gemfile +2 -0
  170. data/README.markdown +37 -0
  171. data/Rakefile +76 -0
  172. data/bin/octopress +66 -0
  173. data/lib/console +17 -0
  174. data/lib/guard/jekyll.rb +33 -0
  175. data/lib/octopress.rb +89 -0
  176. data/lib/octopress/command.rb +9 -0
  177. data/lib/octopress/commands.rb +14 -0
  178. data/lib/octopress/commands/build.rb +17 -0
  179. data/lib/octopress/commands/build_javascripts.rb +11 -0
  180. data/lib/octopress/commands/build_jekyll.rb +25 -0
  181. data/lib/octopress/commands/build_stylesheets.rb +13 -0
  182. data/lib/octopress/commands/install.rb +45 -0
  183. data/lib/octopress/commands/new.rb +21 -0
  184. data/lib/octopress/commands/scaffold.rb +101 -0
  185. data/lib/octopress/commands/serve.rb +25 -0
  186. data/lib/octopress/configuration.rb +231 -0
  187. data/lib/octopress/core_ext.rb +44 -0
  188. data/lib/octopress/dependency_installer.rb +287 -0
  189. data/lib/octopress/errors.rb +3 -0
  190. data/lib/octopress/filters/content.rb +66 -0
  191. data/lib/octopress/filters/date.rb +46 -0
  192. data/lib/octopress/filters/post.rb +175 -0
  193. data/lib/octopress/filters/url.rb +34 -0
  194. data/lib/octopress/formatters.rb +9 -0
  195. data/lib/octopress/formatters/base_formatter.rb +17 -0
  196. data/lib/octopress/formatters/simple_formatter.rb +9 -0
  197. data/lib/octopress/formatters/verbose_formatter.rb +9 -0
  198. data/lib/octopress/generators/category_generator.rb +196 -0
  199. data/lib/octopress/generators/sitemap_generator.rb +308 -0
  200. data/lib/octopress/guardfile +43 -0
  201. data/lib/octopress/helpers/titlecase.rb +37 -0
  202. data/lib/octopress/ink.rb +12 -0
  203. data/lib/octopress/inquirable_string.rb +12 -0
  204. data/lib/octopress/installer.rb +92 -0
  205. data/lib/octopress/js_asset_manager.rb +98 -0
  206. data/lib/octopress/liquid_helpers/conditional.rb +36 -0
  207. data/lib/octopress/liquid_helpers/config.rb +58 -0
  208. data/lib/octopress/liquid_helpers/include.rb +33 -0
  209. data/lib/octopress/liquid_helpers/url.rb +29 -0
  210. data/lib/octopress/liquid_helpers/vars.rb +30 -0
  211. data/lib/octopress/plugin.rb +33 -0
  212. data/lib/octopress/rake.rb +16 -0
  213. data/lib/octopress/scaffold/.gitignore +18 -0
  214. data/lib/octopress/scaffold/site/Gemfile +3 -0
  215. data/lib/octopress/scaffold/site/config/compass.rb +27 -0
  216. data/lib/octopress/scaffold/site/config/rack.rb +25 -0
  217. data/lib/octopress/scaffold/site/config/site.yml +0 -0
  218. data/lib/octopress/scaffold/site/javascripts/lib/ios-rotate-scaling-fix.js +19 -0
  219. data/lib/octopress/scaffold/site/javascripts/lib/jquery-1.9.1.js +9598 -0
  220. data/lib/octopress/scaffold/site/javascripts/lib/jquery.cookie.js +93 -0
  221. data/lib/octopress/scaffold/site/stylesheets/_config.scss +1 -0
  222. data/lib/octopress/scaffold/site/stylesheets/_style.scss +1 -0
  223. data/lib/octopress/scaffold/site/stylesheets/site.scss +16 -0
  224. data/lib/octopress/tags/assign.rb +34 -0
  225. data/lib/octopress/tags/capture.rb +31 -0
  226. data/lib/octopress/tags/config-tag.rb +23 -0
  227. data/lib/octopress/tags/include.rb +63 -0
  228. data/lib/octopress/tags/js-assets.rb +23 -0
  229. data/lib/octopress/tags/puts.rb +39 -0
  230. data/lib/octopress/tags/render-partial.rb +89 -0
  231. data/lib/octopress/tags/return.rb +21 -0
  232. data/lib/octopress/version.rb +3 -0
  233. data/lib/rake/clean.rake +8 -0
  234. data/lib/rake/clobber.rake +5 -0
  235. data/lib/rake/console.rake +5 -0
  236. data/lib/rake/deploy.rake +4 -0
  237. data/lib/rake/gen_deploy.rake +2 -0
  238. data/lib/rake/generate.rake +4 -0
  239. data/lib/rake/generate_only.rake +14 -0
  240. data/lib/rake/hygiene.rake +29 -0
  241. data/lib/rake/install.rake +8 -0
  242. data/lib/rake/integrate.rake +4 -0
  243. data/lib/rake/isolate.rake +13 -0
  244. data/lib/rake/list_drafts.rake +7 -0
  245. data/lib/rake/new.rake +7 -0
  246. data/lib/rake/new_page.rake +49 -0
  247. data/lib/rake/new_post.rake +32 -0
  248. data/lib/rake/nuke.rake +4 -0
  249. data/lib/rake/preview.rake +4 -0
  250. data/lib/rake/push.rake +37 -0
  251. data/lib/rake/rsync.rake +20 -0
  252. data/lib/rake/set_root_dir.rake +35 -0
  253. data/lib/rake/setup_github_pages.rake +115 -0
  254. data/lib/rake/watch.rake +11 -0
  255. data/lib/scaffold/Rakefile +142 -0
  256. data/lib/scaffold/plugin-name.gemspec +43 -0
  257. data/lib/spec/fixtures/env/defaults/classic.yml +2 -0
  258. data/lib/spec/fixtures/no_override/defaults/classic.yml +11 -0
  259. data/lib/spec/fixtures/override/defaults/classic.yml +11 -0
  260. data/lib/spec/fixtures/override/site.yml +11 -0
  261. data/lib/spec/octopress/configuration_spec.rb +67 -0
  262. data/lib/spec/octopress/dependency_installer_spec.rb +66 -0
  263. data/lib/spec/octopress/ink_spec.rb +10 -0
  264. data/lib/spec/octopress/octopress_spec.rb +97 -0
  265. data/lib/spec/spec_helper.rb +22 -0
  266. data/lib/spec/support/env.rb +36 -0
  267. data/lib/spec/support/simplecov.rb +52 -0
  268. data/octopress.gemspec +52 -0
  269. metadata +697 -0
@@ -0,0 +1,9 @@
1
+ module Octopress
2
+ class Command
3
+ class << self
4
+ def process(args = nil, options = nil)
5
+ raise NotImplementedError
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ module Octopress
4
+ module Commands
5
+ autoload :Build, 'commands/build'
6
+ autoload :BuildJekyll, 'commands/build_jekyll'
7
+ autoload :BuildJavascripts, 'commands/build_javascripts'
8
+ autoload :BuildStylesheets, 'commands/build_stylesheets'
9
+ autoload :Install, 'commands/install'
10
+ autoload :New, 'commands/new'
11
+ autoload :Scaffold, 'commands/scaffold'
12
+ autoload :Serve, 'commands/serve'
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Octopress
2
+ module Commands
3
+ class Build < Command
4
+ class << self
5
+ def process(args, options)
6
+ if Octopress.configuration[:source].nil? || !File.directory?(Octopress.configuration[:source])
7
+ Octopress.logger.error "### You haven't set anything up yet. First run `octopress install <theme-name>` to set up an Octopress theme."
8
+ raise SiteNotFoundError
9
+ end
10
+ BuildJavascripts.process(args, options)
11
+ BuildStylesheets.process(args, options)
12
+ BuildJekyll.process(args, options)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Octopress
2
+ module Commands
3
+ class BuildJavascripts < Command
4
+ class << self
5
+ def process(args, options)
6
+ puts Octopress::JSAssetsManager.new.compile if Dir.exists?("javascripts")
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module Octopress
2
+ module Commands
3
+ class BuildJekyll < Command
4
+ class << self
5
+ def process(args, options)
6
+ Octopress.configurator.write_configs_for_generation
7
+ puts "## Generating Site with Jekyll - ENV: #{Octopress.env}"
8
+ system "jekyll build #{jekyll_flags}"
9
+ puts unpublished unless unpublished.empty?
10
+ Octopress.configurator.remove_configs_for_generation
11
+ end
12
+
13
+ def unpublished
14
+ posts = Dir.glob("#{Octopress.configuration[:source]}/#{Octopress.configuration[:posts_dir]}/*.*")
15
+ options = {env: Octopress.env, message: "\nThese posts were not generated:"}
16
+ @unpublished ||= get_unpublished(posts, options)
17
+ end
18
+
19
+ def jekyll_flags
20
+ Octopress.env.production? ? "" : "--drafts --trace"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module Octopress
2
+ module Commands
3
+ class Build < Command
4
+ class << self
5
+ def process(args, options)
6
+ if Dir.exists?("stylesheets")
7
+ system "compass compile --css-dir #{Octopress.configuration[:source]}/stylesheets"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ module Octopress
2
+ module Commands
3
+ class Install < Command
4
+ class << self
5
+ def process(args = nil, options = nil)
6
+ raise "Please specify at least one plugin to install." if args.nil? || args.empty?
7
+
8
+ plugin_name = args[0]
9
+ require_plugin(plugin_name)
10
+
11
+ # Essentially doing: 'Adn::Installer.new.install':
12
+ Object.const_get(classify(plugin_name))::Installer.new.install
13
+ end
14
+
15
+ def require_plugin(plugin_name)
16
+ require "#{plugin_name}"
17
+ rescue LoadError
18
+ begin
19
+ if File.read("#{Octopress.root}/Gemfile").match(/gem ["']#{plugin_name}["']/)
20
+ Octopress.logger.warn("Oops! Looks like you haven't installed the gem but you have it in your Gemfile. Running 'bundle install'...")
21
+ `bundle install`
22
+ require "#{plugin_name}"
23
+ else
24
+ raise LoadError, "Cannot load #{plugin_name}"
25
+ end
26
+ rescue LoadError
27
+ Octopress.logger.error("We could couldn't find the plugin '#{plugin_name}'.")
28
+ Octopress.logger.error("Make sure you add this to your Gemfile:\n")
29
+ Octopress.logger.error("gem '#{plugin_name}'\n")
30
+ Octopress.logger.error("Then run 'bundle install' and retry the installation.")
31
+ raise LoadError, "Cannot load #{plugin_name}"
32
+ end
33
+ end
34
+
35
+ def classify(plugin_name)
36
+ rubyify(plugin_name).split("_").map(&:capitalize).join("")
37
+ end
38
+
39
+ def rubyify(plugin_name)
40
+ plugin_name.to_s.gsub(/-/, '_')
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ module Octopress
2
+ module Commands
3
+ class New < Command
4
+ class << self
5
+ def process(args = nil, options = nil)
6
+ source = File.join(Octopress.root, 'lib/octopress/scaffold/site')
7
+ destination = process_args(args)
8
+ FileUtils.cp_r "#{source}/.", "#{destination}/"
9
+ end
10
+
11
+ def process_args(args)
12
+ if args.nil? || args.empty?
13
+ Octopress.logger.error "You must specify a destination for your new site."
14
+ raise ArgumentError
15
+ end
16
+ args.first
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,101 @@
1
+ module Octopress
2
+ module Commands
3
+ class Scaffold < Command
4
+ SCAFFOLD_DIR = File.join(Octopress.lib_root, "scaffold")
5
+
6
+ SCAFFOLD_DIRS = %w[
7
+ configs
8
+ includes
9
+ layouts
10
+ lib
11
+ lib/rake
12
+ javascripts
13
+ javascripts/lib
14
+ javascripts/modules
15
+ source
16
+ stylesheets
17
+ plugins
18
+ ]
19
+
20
+ class << self
21
+ def process(args, options)
22
+ type, plugin_name = process_args(args)
23
+
24
+ create_scaffold(type, plugin_name)
25
+ end
26
+
27
+ ####################
28
+ # Scaffolding
29
+ ####################
30
+
31
+ def create_scaffold(type, plugin_name)
32
+ Octopress.logger.info "Scaffolding a new Octopress #{type} in ./#{plugin_name}..."
33
+ FileUtils.mkdir(plugin_name)
34
+ Dir.chdir(plugin_name) do
35
+ FileUtils.mkdir(SCAFFOLD_DIRS)
36
+ FileUtils.mkdir("lib/#{ruby_name(plugin_name)}")
37
+ FileUtils.cp(scaffold_file("Rakefile"), "Rakefile")
38
+ FileUtils.cp(scaffold_file("plugin-name.gemspec"), "#{plugin_name}.gemspec")
39
+ File.open("MANIFEST.yml", "w") { |f| f.write(plugin_yaml(plugin_name)) }
40
+ File.open("lib/#{ruby_name(plugin_name)}.rb", "w") do |f|
41
+ f.puts "require 'octopress'"
42
+ f.puts
43
+ f.puts "class #{plugin_class(plugin_name)} < Octopress::Plugin"
44
+ f.puts " ROOT = File.expand_path('../../', __FILE__)"
45
+ f.puts "end"
46
+ end
47
+ File.open("Gemfile", "w") do |f|
48
+ f.puts "source 'https://rubygems.org'"
49
+ f.puts
50
+ f.puts "gemspec"
51
+ end
52
+ end
53
+ end
54
+
55
+ def ruby_name(plugin_name)
56
+ plugin_name.gsub(/-/, '_')
57
+ end
58
+
59
+ def plugin_yaml(plugin_name)
60
+ plugin_data = {
61
+ "name" => plugin_name,
62
+ "slug" => plugin_name,
63
+ "version" => "0.0.1",
64
+ "description" => "TODO- Add your description",
65
+ "summary" => "TODO- Add your summary",
66
+ "homepage" => "TODO- Add your plugin's homepage",
67
+ "authors" => ["YOUR NAME"],
68
+ "emails" => ["YOUREMAIL@EXAMPLE.COM"]
69
+ }.to_yaml
70
+ end
71
+
72
+ def plugin_class(plugin_name)
73
+ plugin_name.split("-").map{ |n| n.capitalize }.join("")
74
+ end
75
+
76
+ def scaffold_file(*args)
77
+ File.join(SCAFFOLD_DIR, *args)
78
+ end
79
+
80
+ ####################
81
+ # Arguments
82
+ ####################
83
+
84
+ def process_args(args)
85
+ validate_args(args)
86
+ type = args.shift.downcase
87
+ plugin_name = args.join(" ").downcase.gsub(/[\ \-_]+/, '-')
88
+ [type, plugin_name]
89
+ end
90
+
91
+ def validate_args(args)
92
+ if args.size < 2 || !%w[plugin theme].include?(args.first)
93
+ Octopress.logger.error "Invalid arguments: type must be one of 'plugin'," +
94
+ "'theme', and a plugin name must follow."
95
+ raise ArgumentError
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,25 @@
1
+ module Octopress
2
+ module Commands
3
+ class Serve < Command
4
+ class << self
5
+ def process(args, options)
6
+ Octopress::Commands::Build.process(args, options)
7
+ serve(args, options)
8
+ end
9
+
10
+ def serve(args, options)
11
+ guardPid = Process.spawn("guard --guardfile #{Octopress.root}/lib/octopress/guardfile")
12
+ puts "Starting Rack, serving to http://#{Octopress.configuration[:server_host]}:#{Octopress.configuration[:port]}"
13
+ rackupPid = Process.spawn("rackup --host #{Octopress.configuration[:server_host]} --port #{Octopress.configuration[:port]}")
14
+
15
+ trap("INT") {
16
+ [guardPid, rackupPid].each { |pid| Process.kill(3, pid) rescue Errno::ESRCH }
17
+ exit 0
18
+ }
19
+
20
+ [guardPid, rackupPid].each { |pid| Process.wait(pid) }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,231 @@
1
+ require 'yaml'
2
+
3
+ module Octopress
4
+ class Configuration
5
+ DEFAULT_CONFIG_DIR = File.join(Octopress.root, 'config')
6
+ attr_accessor :config_directory
7
+
8
+ def initialize(config_dir = DEFAULT_CONFIG_DIR)
9
+ self.config_directory = config_dir
10
+ end
11
+
12
+ def config_dir(*subdirs)
13
+ File.expand_path(File.join(*subdirs), self.config_directory)
14
+ end
15
+
16
+ # Static: Reads the configuration of the specified file
17
+ #
18
+ # path - the String path to the configuration file, relative to ./_config
19
+ #
20
+ # Returns a Hash of the items in the configuration file (symbol keys)
21
+ def read_config(path)
22
+ full_path = self.config_dir(path)
23
+ if File.exists? full_path
24
+ begin
25
+ configs = YAML.load(File.open(full_path))
26
+ if configs.nil?
27
+ Hash.new
28
+ else
29
+ configs.to_symbol_keys
30
+ end
31
+ rescue => e
32
+ puts "Error reading configuration file '#{full_path}':"
33
+ puts e.message, e.backtrace
34
+ exit(-1)
35
+ end
36
+ else
37
+ raise ArgumentError, "File at '#{full_path}' does not exist."
38
+ end
39
+ end
40
+
41
+ # Static: Concatenates javacript lib instead of merging (the default behavior for other configs)
42
+ #
43
+ # current - current configuration hash
44
+ # new - hash which hasn't yet been merged
45
+ #
46
+ # Returns a concatenated array of javascript lib configurations
47
+
48
+ def add_js_lib(current, new)
49
+ begin
50
+ new_lib = new[:require_js][:lib]
51
+ new_lib = [new_lib] unless new_lib.kind_of?(Array)
52
+ new[:require_js][:lib] = current[:require_js][:lib].concat new_lib
53
+ rescue
54
+ end
55
+ new
56
+ end
57
+
58
+ # Static: Writes the contents of a set of configurations to a path in the config directory
59
+ #
60
+ # path - the String path to the configuration file, relative to ./_config
61
+ # obj - the object to be dumped into the specified file in YAML form
62
+ #
63
+ # Returns the Hash for the configuration file.
64
+ def write_config(path, obj)
65
+ YAML.dump(obj.to_string_keys, File.open(self.config_dir(path), 'w'))
66
+ end
67
+
68
+ # Static: Reads all the configuration files into one hash
69
+ #
70
+ # Returns a Hash of all the configuration files, with each key being a symbol
71
+ def read_configuration
72
+ configs = DEFAULTS.dup
73
+ Dir.glob(self.config_dir('defaults', '**', '*.yml')) do |filename|
74
+ file_yaml = read_config(filename)
75
+ unless file_yaml.nil?
76
+ file_yaml = add_js_lib(configs, file_yaml)
77
+ configs = configs.deep_merge(file_yaml)
78
+ end
79
+ end
80
+ Dir.glob(self.config_dir('*.yml')) do |filename|
81
+ file_yaml = read_config(filename)
82
+ unless file_yaml.nil?
83
+ file_yaml = add_js_lib(configs, file_yaml)
84
+ configs = configs.deep_merge(file_yaml)
85
+ end
86
+ end
87
+
88
+ configs.to_symbol_keys
89
+ end
90
+
91
+ # Static: Writes configuration files necessary for generation of the Jekyll site
92
+ #
93
+ # Returns a Hash of the items which were written to the Jekyll configuration file
94
+ def write_configs_for_generation
95
+ jekyll_configs = {}
96
+
97
+ Dir.chdir(Octopress.root) do
98
+ File.open("_config.yml", "w") do |f|
99
+ jekyll_configs = Octopress.configuration.to_string_keys.to_yaml :canonical => false
100
+ f.write(jekyll_configs)
101
+ end
102
+ end
103
+
104
+ jekyll_configs
105
+ end
106
+
107
+ # Static: Removes configuration files required for site generation
108
+ #
109
+ # Returns the number of files deleted
110
+ def remove_configs_for_generation
111
+ Dir.chdir(Octopress.root) do
112
+ File.unlink("_config.yml")
113
+ end
114
+ end
115
+
116
+ PostTemplate = YAML.load <<-YAML
117
+ extension: markdown
118
+ layout: post
119
+ title: true
120
+ date: true
121
+ categories:
122
+ YAML
123
+
124
+ LinkPostTemplate = YAML.load <<-YAML
125
+ extension: markdown
126
+ layout: post
127
+ title: true
128
+ date: true
129
+ external-url:
130
+ categories:
131
+ YAML
132
+
133
+ PageTemplate = YAML.load <<-YAML
134
+ extension: html
135
+ layout: page
136
+ title: true
137
+ date: false
138
+ YAML
139
+
140
+ DEFAULTS = {
141
+ url: 'http://yoursite.com',
142
+ title: 'My Octopress Blog',
143
+ subtitle: 'A blogging framework for hackers.',
144
+ author: 'Your Name',
145
+ description: '',
146
+
147
+ # If publishing to a subdirectory as in http://site.com/project set 'root: /project'
148
+ root: '/',
149
+ permalink: '/:year/:month/:day/:title/',
150
+ source: 'source', # source file directory
151
+ destination: 'public', # compiled site directory
152
+ plugins: ['lib/octopress/liquid_helpers', 'lib/octopress/filters', 'lib/octopress/tags', 'lib/octopress/generators', 'plugins'],
153
+ code_dir: 'downloads/code',
154
+ category_dir: 'categories',
155
+ include: ['.htaccess'],
156
+
157
+ markdown: 'redcarpet',
158
+ redcarpet: {
159
+ extensions: [
160
+ 'no_intra_emphasis',
161
+ 'strikethrough',
162
+ 'autolink',
163
+ 'superscript',
164
+ 'smart',
165
+ 'footnotes',
166
+ ]
167
+ },
168
+
169
+ # Default date format is "ordinal" (resulting in "July 22nd 2007")
170
+ # You can customize the format as defined in
171
+ # http://www.ruby-doc.org/core-1.9.2/Time.html#method-i-strftime
172
+ # Additionally, %o will give you the ordinal representation of the day
173
+
174
+ date_format: 'ordinal',
175
+ env: 'production', # affects asset compilation
176
+ post_index_dir: 'source', # directory for your posts index page (if you put your index in source/blog/index.html, set this to 'source/blog')
177
+ stash_dir: '_stash', # directory to stash posts for speedy generation
178
+ posts_dir: '_posts', # directory for blog files
179
+ deploy_dir: '_deploy', # directory whose contents are to be deployed
180
+ new_post_ext: 'markdown', # default new post file extension when using the new_post task
181
+ new_page_ext: 'markdown', # default new page file extension when using the new_page task
182
+ titlecase: true, # Converts page and post titles to titlecase
183
+ server_host: '0.0.0.0', # host ip address for preview server
184
+ port: 4000, # port for preview server eg. localhost:4000
185
+ timezone: 'local', # default time and date used to local timezone. Vew supported timezones (under TZ column): http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
186
+ #paginate_path: page/:num, # default path for pagination, eg. page/2/
187
+ paginate: 10, # Posts per page on the blog index
188
+
189
+ # Templates - these can be overridden in site.yml and themes can ship with their own default templates.
190
+
191
+ templates: {
192
+ post: PostTemplate,
193
+ linkpost: LinkPostTemplate,
194
+ page: PageTemplate,
195
+ },
196
+
197
+
198
+ # Feed settings
199
+
200
+ feed: {
201
+ limit: 20, # Maximum number of posts to include in the feed
202
+ url: '/feed/', # Link to templates feed
203
+ email_url: false, # Link to email subscription page (if you offer it)
204
+ categories: false, # Generate individual feeds for each post category (potential performance hit)
205
+ author_email: false, # Author email address to the feed
206
+ },
207
+
208
+ # Asset configuration
209
+
210
+ # Asset configuration
211
+
212
+ # Javascript assets stored in javascripts/lib and javascripts/modules
213
+ # Are wrapped with CommonJS functions, combined, uglified and fingerprinted
214
+ # Supported files: .js, .coffee, .mustache, .eco, .tmpl
215
+
216
+ # Dependiences from lib are added first as globals
217
+ require_js: {
218
+
219
+ # Dependiences are added first as globals
220
+ lib: ['jquery-1.9.1.js', 'jquery.cookie.js'],
221
+
222
+ # Modules are wrapped with CommonJS functions and must be
223
+ # Example:
224
+ # for file: assets/javascripts/modules/some-plugin/awesome.js
225
+ # require like: var awesome = require('some-plugin/awesome')
226
+ modules: ['modules']
227
+ }
228
+ }
229
+ end
230
+ end
231
+