octopress 3.0.0.rc.15 → 3.0.0.rc.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.clash.yml +159 -0
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +11 -144
  6. data/assets/docs/index.md +187 -0
  7. data/bin/octopress +0 -2
  8. data/lib/octopress.rb +10 -6
  9. data/lib/octopress/commands/isolate.rb +31 -0
  10. data/lib/octopress/commands/new.rb +2 -1
  11. data/lib/octopress/isolate.rb +108 -0
  12. data/lib/octopress/scaffold.rb +2 -1
  13. data/lib/octopress/version.rb +1 -1
  14. data/octopress.gemspec +2 -1
  15. data/test/Gemfile +1 -2
  16. data/test/_config.yml +3 -0
  17. data/test/{expected → _expected/blank}/_config.yml +0 -0
  18. data/test/{expected → _expected/blank}/_octopress.yml +0 -0
  19. data/test/{expected → _expected/blank}/_templates/draft +0 -0
  20. data/test/{expected → _expected/blank}/_templates/page +0 -0
  21. data/test/{expected → _expected/blank}/_templates/post +0 -0
  22. data/test/{expected/_site → _expected/blank}/index.html +0 -0
  23. data/test/_expected/integrate/_posts/2011-11-11-a-random-post.markdown +6 -0
  24. data/test/_expected/integrate/_posts/2012-11-11-another-random-post.markdown +6 -0
  25. data/test/_expected/integrate/_posts/2013-11-11-this-post-is-happy.markdown +6 -0
  26. data/test/_expected/isolate-path/_posts/2011-11-11-a-random-post.markdown +6 -0
  27. data/test/_expected/isolate-path/_posts/_exile/2012-11-11-another-random-post.markdown +6 -0
  28. data/test/_expected/isolate-path/_posts/_exile/2013-11-11-this-post-is-happy.markdown +6 -0
  29. data/test/_expected/isolate-search/_posts/2011-11-11-a-random-post.markdown +6 -0
  30. data/test/_expected/isolate-search/_posts/2012-11-11-another-random-post.markdown +6 -0
  31. data/test/_expected/isolate-search/_posts/_exile/2013-11-11-this-post-is-happy.markdown +6 -0
  32. data/test/_expected/isolate/_posts/2013-11-11-this-post-is-happy.markdown +6 -0
  33. data/test/_expected/isolate/_posts/_exile/2011-11-11-a-random-post.markdown +6 -0
  34. data/test/_expected/isolate/_posts/_exile/2012-11-11-another-random-post.markdown +6 -0
  35. data/test/{expected/_posts/2014-03-11-idea.markdown → _expected/new-draft-slug/_drafts/idea.markdown} +0 -1
  36. data/test/{expected/_drafts/stupid-idea.markdown → _expected/new-draft/_drafts/some-cool-idea.markdown} +1 -1
  37. data/test/{expected/date-page.html → _expected/new-page-date/pages/awesome-page.html} +1 -1
  38. data/test/{expected/awesome-page.html → _expected/new-page-extension/pages/awesome-page.md} +0 -0
  39. data/test/_expected/new-page-index/pages/index.html +5 -0
  40. data/test/{expected/custom-template-page.html → _expected/new-page-template/pages/awesome-page.html} +1 -1
  41. data/test/_expected/new-page/pages/awesome-page.html +5 -0
  42. data/test/{expected → _expected/new-post-dir}/_posts/stuff/2014-02-11-some-stuff.markdown +0 -0
  43. data/test/{expected → _expected/new-post-slug}/_posts/2014-03-13-awesome.markdown +0 -0
  44. data/test/{expected → _expected/new-post}/_posts/2014-03-12-awesome-stuff.markdown +0 -0
  45. data/test/_expected/publish-draft-date/_posts/2014-03-11-some-cool-idea.markdown +6 -0
  46. data/test/_expected/publish-draft-dir/_posts/ideas/2014-03-10-some-cool-idea.markdown +6 -0
  47. data/test/_expected/publish-draft/_posts/2014-03-10-some-cool-idea.markdown +6 -0
  48. data/test/_layouts/page.html +1 -0
  49. data/test/_layouts/post.html +1 -0
  50. data/test/_octopress.yml +11 -0
  51. data/test/{expected/_templates/other_page → _templates/draft} +0 -1
  52. data/test/_templates/page +4 -0
  53. data/test/{expected/_templates/date_page → _templates/post} +0 -0
  54. metadata +100 -81
  55. data/lib/octopress/commands/build.rb +0 -19
  56. data/lib/octopress/commands/doctor.rb +0 -20
  57. data/lib/octopress/commands/serve.rb +0 -30
  58. data/test/expected/_layouts/page.html +0 -1
  59. data/test/expected/_layouts/post.html +0 -1
  60. data/test/expected/_posts/2014-02-10-another-idea.markdown +0 -6
  61. data/test/expected/_posts/ideas/2014-02-13-yet-another-idea.markdown +0 -6
  62. data/test/expected/_site/2014/02/10/another-idea.html +0 -2
  63. data/test/expected/_site/2014/02/11/some-stuff.html +0 -2
  64. data/test/expected/_site/2014/02/13/yet-another-idea.html +0 -2
  65. data/test/expected/_site/2014/03/11/idea.html +0 -2
  66. data/test/expected/_site/2014/03/12/awesome-stuff.html +0 -2
  67. data/test/expected/_site/2014/03/13/awesome.html +0 -2
  68. data/test/expected/_site/awesome-page.html +0 -1
  69. data/test/expected/_site/cool-page.html +0 -1
  70. data/test/expected/_site/custom-template-page.html +0 -1
  71. data/test/expected/_site/date-page.html +0 -1
  72. data/test/expected/_site/okay-page/index.html +0 -1
  73. data/test/expected/cool-page.html +0 -5
  74. data/test/expected/index.html +0 -0
  75. data/test/expected/okay-page/index.html +0 -5
  76. data/test/test.rb +0 -162
  77. data/test/test_suite.rb +0 -161
data/bin/octopress CHANGED
@@ -5,8 +5,6 @@ $LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
5
5
  require 'mercenary'
6
6
  require 'octopress'
7
7
 
8
- Octopress.require_blessed_gems
9
-
10
8
  if ENV['BUNDLE_BIN_PATH'] || ENV['BUNDLE_GEMFILE']
11
9
  begin
12
10
  require 'bundler'
data/lib/octopress.rb CHANGED
@@ -8,19 +8,18 @@ module Octopress
8
8
  require 'octopress/commands/new'
9
9
  require 'octopress/commands/init'
10
10
  require 'octopress/commands/publish'
11
- require 'octopress/commands/build'
12
- require 'octopress/commands/serve'
13
- require 'octopress/commands/doctor'
11
+ require 'octopress/commands/isolate'
12
+ require 'octopress/isolate'
14
13
 
15
14
  autoload :Page, 'octopress/page'
16
15
  autoload :Post, 'octopress/post'
17
16
  autoload :Draft, 'octopress/draft'
18
17
  autoload :Scaffold, 'octopress/scaffold'
19
18
 
19
+ # Automatically require these gems if installed
20
20
  BLESSED_GEMS = %w[
21
- octopress-deploy
22
21
  octopress-ink
23
- octopress-docs
22
+ octopress-deploy
24
23
  ]
25
24
 
26
25
  def self.logger
@@ -50,6 +49,11 @@ end
50
49
  require 'octopress-docs'
51
50
 
52
51
  Octopress::Docs.add({
53
- name: "Octopress",
52
+ name: "Octopress CLI",
53
+ slug: "octopress",
54
+ base_url: "/octopress",
54
55
  dir: File.expand_path(File.join(File.dirname(__FILE__), "../")),
55
56
  })
57
+
58
+ Octopress.require_blessed_gems
59
+
@@ -0,0 +1,31 @@
1
+ module Octopress
2
+ module Commands
3
+ class Isolate < Command
4
+ def self.init_with_program(p)
5
+ p.command(:isolate) do |c|
6
+ c.syntax 'isolate [search] [options]'
7
+ c.description "Move posts to _posts/_exile if they do not match the search text or move the most recent post if search text is omitted."
8
+ c.option 'path', '--path [STRING]', 'Isolate a post at the specified path.'
9
+ c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
10
+
11
+ c.action do |args, options|
12
+ if !args.empty?
13
+ options['search'] = args.first
14
+ end
15
+ Octopress::Isolate.new(options).process
16
+ end
17
+ end
18
+
19
+ p.command(:integrate) do |c|
20
+ c.syntax 'integrate'
21
+ c.description "Reintegrate posts from _posts/_exile."
22
+ c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
23
+
24
+ c.action do |args, options|
25
+ Octopress::Isolate.new(options).revert
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,7 +3,7 @@ module Octopress
3
3
  def self.init_with_program(p)
4
4
  p.command(:new) do |c|
5
5
  c.syntax 'new <PATH>'
6
- c.description 'Creates a new Jekyll site scaffold in path.'
6
+ c.description 'Creates a new site with Jekyll and Octopress scaffolding at the specified path.'
7
7
  c.option 'force', '--force', 'Force creation even if path already exists.'
8
8
  c.option 'blank', '--blank', 'Creates scaffolding but with empty files.'
9
9
 
@@ -12,6 +12,7 @@ module Octopress
12
12
  c.logger.error "You must specify a path."
13
13
  else
14
14
  Jekyll::Commands::New.process(args, options)
15
+ Octopress::Scaffold.new(args, options).write
15
16
  end
16
17
  end
17
18
 
@@ -0,0 +1,108 @@
1
+ require 'find'
2
+
3
+ module Octopress
4
+ class Isolate
5
+ def initialize(options)
6
+ @options = options
7
+ Jekyll.logger.log_level = :error
8
+ @site = Jekyll::Site.new(Jekyll.configuration(@options))
9
+ Jekyll.logger.log_level = :info
10
+ end
11
+
12
+ def revert
13
+ dir = File.join(@site.source, '_posts')
14
+ exile_dir = File.join(dir, '_exile')
15
+ if Dir.exist?(exile_dir)
16
+ posts = find_exiled_posts
17
+ if posts.size > 0
18
+ FileUtils.mv(posts, dir)
19
+ FileUtils.rmdir(File.join(dir, '_exile'))
20
+
21
+ puts "Reintegrated #{posts.size} post#{'s' if posts.size != 1} from _posts/_exile"
22
+ else
23
+ puts "There aren't any posts in _posts/_exile."
24
+ end
25
+ else
26
+ puts "There aren't any posts in _posts/_exile."
27
+ end
28
+ end
29
+
30
+ def process
31
+
32
+ if @options['path']
33
+ path = File.join(@site.source, @options['path'])
34
+ if File.exist? path
35
+ isolate_except(path)
36
+ else
37
+ puts "File not found: #{@options['path']}"
38
+ end
39
+ elsif @options['search']
40
+ isolate_search(@options['search'])
41
+ else
42
+ isolate_latest
43
+ end
44
+ end
45
+
46
+ # remove all posts that do not match string
47
+ def isolate_search(string)
48
+ posts = find_posts.select { |p| p =~ /#{string.gsub(/\s/, '-')}/i }
49
+ isolate_except(posts)
50
+ end
51
+
52
+ # Isolate all but the most recent post
53
+ def isolate_latest
54
+ post = @site.read_posts('').sort_by(&:date).last
55
+ path = File.join(@site.source, post.path)
56
+ isolate_except(path)
57
+ end
58
+
59
+ def isolate_except(posts)
60
+ others = find_other_posts(posts)
61
+ posts = default_array(posts)
62
+ exile_dir = @site.source, '_posts/_exile'
63
+
64
+
65
+ if posts.size > 0
66
+ FileUtils.mkdir_p(exile_dir)
67
+ FileUtils.mv(others, exile_dir)
68
+
69
+ puts "Isolated #{posts.size} post#{'s' if posts.size != 1}:"
70
+ posts.each do |p|
71
+ puts " - #{p.sub(@site.source+'/_posts/', '')}"
72
+ end
73
+ puts "Moved #{others.size} post#{'s' if others.size != 1} into _posts/_exile"
74
+ else
75
+ puts "No matching posts were found."
76
+ end
77
+ end
78
+
79
+ def find_other_posts(paths)
80
+ paths = default_array(paths)
81
+
82
+ find_posts.reject do |p|
83
+ paths.include?(p)
84
+ end
85
+ end
86
+
87
+ def find_posts
88
+ dir = File.join(@site.source, '_posts')
89
+ Find.find(dir).to_a.reject do |f|
90
+ File.directory?(f) || f =~ /_exile\//
91
+ end
92
+ end
93
+
94
+ def find_exiled_posts
95
+ dir = File.join(@site.source, '_posts/_exile')
96
+ Find.find(dir).to_a.reject do |f|
97
+ File.directory?(f)
98
+ end
99
+ end
100
+
101
+ def default_array(input)
102
+ i = input || []
103
+ i = [i] unless i.is_a?(Array)
104
+ i
105
+ end
106
+
107
+ end
108
+ end
@@ -5,10 +5,11 @@ module Octopress
5
5
  def initialize(args, options)
6
6
  @path = File.expand_path(args.join(" "), Dir.pwd)
7
7
  @force = !!options['force']
8
+ @blank = !!options['blank']
8
9
  end
9
10
 
10
11
  def write
11
- if !force && (File.exist?(path + '/_templates') ||
12
+ if !@force && (File.exist?(path + '/_templates') ||
12
13
  File.exist?(path + '/_octopress.yml'))
13
14
  abort "Some files already exist. Use --force to overwrite."
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module Octopress
2
- VERSION = "3.0.0.rc.15"
2
+ VERSION = "3.0.0.rc.16"
3
3
  end
data/octopress.gemspec CHANGED
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "octopress-docs"
25
25
  spec.add_runtime_dependency "octopress-deploy"
26
26
 
27
- spec.add_development_dependency "octopress-ink"
27
+ spec.add_development_dependency "octopress-ink", "~> 1.0.0.rc"
28
28
  spec.add_development_dependency "bundler", "~> 1.3"
29
29
  spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "clash"
30
31
 
31
32
  if RUBY_VERSION >= "2"
32
33
  spec.add_development_dependency "pry-byebug"
data/test/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'octopress', path: '../'
4
- gem 'pry-debugger'
3
+ gemspec path: "../"
data/test/_config.yml ADDED
@@ -0,0 +1,3 @@
1
+ timezone: GMT
2
+ exclude:
3
+ - Gemfile*
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "A Random Post"
4
+ date: 2011-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Another Random Post"
4
+ date: 2012-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "This Post Is Happy."
4
+ date: 2013-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "A Random Post"
4
+ date: 2011-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Another Random Post"
4
+ date: 2012-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "This Post Is Happy."
4
+ date: 2013-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "A Random Post"
4
+ date: 2011-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Another Random Post"
4
+ date: 2012-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "This Post Is Happy."
4
+ date: 2013-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "This Post Is Happy."
4
+ date: 2013-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "A Random Post"
4
+ date: 2011-11-11T11:11:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Another Random Post"
4
+ date: 2012-11-11T11:11:00Z
5
+ ---
6
+
@@ -1,6 +1,5 @@
1
1
  ---
2
2
  layout: post
3
3
  title: "Some Great Idea for a Post"
4
- date: 2014-03-11T20:20:00Z
5
4
  ---
6
5
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  layout: post
3
- title: "Stupid Idea"
3
+ title: "Some Cool Idea"
4
4
  date: 2014-03-10T15:20:00Z
5
5
  ---
6
6
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  layout: page
3
- title: "Some Date Page"
3
+ title: ""
4
4
  date: 2011-11-11T11:11:00Z
5
5
  ---
6
6
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: page
3
+ title: "Awesome Page"
4
+ ---
5
+
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  layout: page
3
- title: "Some Date Page"
3
+ title: ""
4
4
  kittens: true
5
5
  ---
6
6
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: page
3
+ title: "Awesome Page"
4
+ ---
5
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Some Cool Idea"
4
+ date: 2014-03-11T20:20:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Some Cool Idea"
4
+ date: 2014-03-10T15:20:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Some Cool Idea"
4
+ date: 2014-03-10T15:20:00Z
5
+ ---
6
+