ruhoh 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  gem 'rack', "~> 1.4"
5
5
  gem 'directory_watcher', "~> 1.4"
6
- gem 'mustache', "~> 0.99"
6
+ gem 'kramdown', "~> 0.13"
7
7
  gem 'maruku', "~> 0.6"
8
8
  gem 'psych', "~> 1.3"
9
9
 
data/history.json ADDED
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "version" : "0.2.1",
4
+ "date" : "9.5.2012",
5
+ "changes" : [
6
+ "Treat all exclude values for posts/pages filenames as regular expressions. Strings are passed to Regex.new()"
7
+ ],
8
+ "features" : [
9
+ "Define 'pretty' paths for pages without using folder/index.md format.",
10
+ "Add ability to exclude files from posts folder."
11
+ ]
12
+ },
13
+ { "version" : "0.2.0",
14
+ "date" : "4.5.2012",
15
+ "changes" : [
16
+ "[change] Dates in post filenames are now optional but will be required in metadata.",
17
+ "[remove] _draft folder. Drafts are now simply a 'type' of post.",
18
+ "[remove] publish and un-publish in favor of specifying 'type' meta attribute.",
19
+ "[add] titleize method to client which renames draft filenames to their titles if set.",
20
+ "[change] /_draft panel is now /dash with updated UI.",
21
+ "[change] - rackup configuration is now through Ruhoh::Program.preview."
22
+ ],
23
+ "features" : [
24
+ "Maintain file extensions for files that don't respond to a converter.",
25
+ "Add 'development'/'production' environment configuration flag.",
26
+ "@ben-biddington Introduces local temporary directory as SampleSitePath.",
27
+ "@ben-biddington adds Travis integration."
28
+ ]
29
+ },
30
+ { "version" : "0.1.4",
31
+ "date" : "4.5.2012",
32
+ "bugs" : [
33
+ "Fix invalid byte sequence in US-ASCII by forcing UTF-8"
34
+ ]
35
+ },
36
+ { "version" : "0.1.3",
37
+ "date" : "19.4.2012",
38
+ "bugs" : [
39
+ "Fix drafts not maintaining file extension when publishing",
40
+ "Tags helper should use tags database.",
41
+ "Fix for properly handling filepaths on Windows machines."
42
+ ]
43
+ },
44
+ { "version" : "0.1.2",
45
+ "date" : "18.4.2012",
46
+ "bugs" : [
47
+ "Fix bug with YAML psych/syck errors"
48
+ ]
49
+ },
50
+ { "version" : "0.1.1",
51
+ "date" : "18.4.2012",
52
+ "bugs" : [
53
+ "@tkellen tidies up partials + fix 'paths.theme' error in theme scaffold."
54
+ ]
55
+ },
56
+ { "version" : "0.1.0",
57
+ "date" : "12.4.2012",
58
+ "features" : [
59
+ "Initial public release"
60
+ ]
61
+ }
62
+ ]
data/lib/ruhoh.rb CHANGED
@@ -43,7 +43,7 @@ class Ruhoh
43
43
  Folders = Struct.new(:database, :pages, :posts, :templates, :themes, :layouts, :partials, :media, :syntax, :compiled)
44
44
  Files = Struct.new(:site, :config, :dashboard)
45
45
  Filters = Struct.new(:posts, :pages, :static)
46
- Config = Struct.new(:permalink, :theme, :theme_path, :media_path, :syntax_path, :exclude, :env)
46
+ Config = Struct.new(:permalink, :pages_permalink, :theme, :theme_path, :media_path, :syntax_path, :exclude, :env)
47
47
  Paths = Struct.new(
48
48
  :site_source, :database, :pages, :posts, :theme, :layouts, :partials, :global_partials, :media, :syntax,
49
49
  :compiled, :dashboard)
@@ -87,7 +87,12 @@ class Ruhoh
87
87
  @config.media_path = File.join('/', @folders.media)
88
88
  @config.syntax_path = File.join('/', @folders.templates, @folders.syntax)
89
89
  @config.permalink = site_config['permalink']
90
- @config.exclude = Array(site_config['exclude'] || nil)
90
+ @config.pages_permalink = site_config['pages']['permalink'] rescue nil
91
+ excluded_pages = site_config['pages']['exclude'] rescue nil
92
+ @config.exclude = {
93
+ "posts" => Array(site_config['exclude'] || nil),
94
+ "pages" => Array(excluded_pages),
95
+ }
91
96
  @config.env = site_config['env'] || nil
92
97
  @config
93
98
  end
@@ -111,14 +116,8 @@ class Ruhoh
111
116
 
112
117
  # filename filters
113
118
  def self.setup_filters
114
- exclude = @config.exclude
115
- exclude.uniq!
116
-
117
- @filters.pages = { 'names' => [], 'regexes' => [] }
118
- exclude.each {|node|
119
- @filters.pages['names'] << node if node.is_a?(String)
120
- @filters.pages['regexes'] << node if node.is_a?(Regexp)
121
- }
119
+ @filters.pages = @config.exclude['pages'].map {|node| Regexp.new(node) }
120
+ @filters.posts = @config.exclude['posts'].map {|node| Regexp.new(node) }
122
121
  @filters
123
122
  end
124
123
 
@@ -1,4 +1,4 @@
1
- require 'maruku'
1
+ require 'kramdown'
2
2
 
3
3
  class Ruhoh
4
4
 
@@ -25,7 +25,7 @@ class Ruhoh
25
25
 
26
26
  # Markdown
27
27
  def self.markdown(page)
28
- Maruku.new(page.content).to_html
28
+ Kramdown::Document.new(page.content).to_html
29
29
  end
30
30
 
31
31
  # Textile
@@ -1,7 +1,5 @@
1
1
  class Ruhoh
2
-
3
2
  module Parsers
4
-
5
3
  module Pages
6
4
 
7
5
  # Public: Generate the Pages dictionary.
@@ -45,8 +43,7 @@ class Ruhoh
45
43
  def self.is_valid_page?(filepath)
46
44
  return false if FileTest.directory?(filepath)
47
45
  return false if ['.'].include? filepath[0]
48
- return false if Ruhoh.filters.pages['names'].include? filepath
49
- Ruhoh.filters.pages['regexes'].each {|regex| return false if filepath =~ regex }
46
+ Ruhoh.filters.pages.each {|regex| return false if filepath =~ regex }
50
47
  true
51
48
  end
52
49
 
@@ -66,24 +63,24 @@ class Ruhoh
66
63
  #
67
64
  # Returns [String] the permalink for this page.
68
65
  def self.permalink(page)
69
- ext = File.extname(page['id'])
70
66
  url = '/'
67
+ ext = File.extname(page['id'])
71
68
  url += if ['.md', '.markdown'].include?(ext)
72
69
  page['id'].gsub(Regexp.new("#{ext}$"), '.html')
73
70
  else
74
71
  page['id']
75
72
  end
76
73
 
77
- # sanitize url
78
- url = url.split('/').reject{ |part| part =~ /^\.+$/ }.join('/')
79
- url.gsub!(/\/index.html$/, '')
74
+ url = url.split('/').reject{ |part| part[0] == '.' }.join('/')
75
+ url = url.gsub(/\/index.html$/, '')
76
+ if page['permalink'] == 'pretty' || Ruhoh.config.pages_permalink == 'pretty'
77
+ url = url.gsub(/\.html$/, '')
78
+ end
80
79
  url = "/" if url.empty?
81
-
80
+
82
81
  url
83
82
  end
84
83
 
85
84
  end # Pages
86
-
87
85
  end #Parsers
88
-
89
86
  end #Ruhoh
@@ -79,13 +79,19 @@ class Ruhoh
79
79
  def self.files
80
80
  FileUtils.cd(Ruhoh.paths.site_source) {
81
81
  return Dir["#{Ruhoh.folders.posts}/**/*.*"].select { |filename|
82
- next if FileTest.directory?(filename)
83
- next if ['.'].include? filename[0]
82
+ next unless self.is_valid_page?(filename)
84
83
  true
85
84
  }
86
85
  }
87
86
  end
88
-
87
+
88
+ def self.is_valid_page?(filepath)
89
+ return false if FileTest.directory?(filepath)
90
+ return false if ['.'].include? filepath[0]
91
+ Ruhoh.filters.posts.each {|regex| return false if filepath =~ regex }
92
+ true
93
+ end
94
+
89
95
  def self.ordered_posts(dictionary)
90
96
  ordered_posts = []
91
97
  dictionary.each_value { |val| ordered_posts << val }
data/lib/ruhoh/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  class Ruhoh
2
- Version = VERSION = '0.2.0'
2
+ Version = VERSION = '0.2.1'
3
3
  RuhohSpec = '0.2'
4
4
  end
data/ruhoh.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  Rakefile
28
28
  bin/ruhoh
29
29
  dash.html
30
- history.txt
30
+ history.json
31
31
  lib/ruhoh.rb
32
32
  lib/ruhoh/client/client.rb
33
33
  lib/ruhoh/client/help.yml
@@ -72,24 +72,23 @@ title: #{page_name} (test)
72
72
 
73
73
  context "Exclude array is passed into config." do
74
74
 
75
- it "should return false for a filepath matching a string in exclude array" do
75
+ it "should return false for a page whose filepath matches a page exclude regular expression." do
76
76
  filepath = 'about.md'
77
77
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
78
78
  'theme' => "twitter",
79
- 'exclude' => filepath
79
+ 'pages' => {'exclude' => "#{filepath}$"}
80
80
  })
81
81
  Ruhoh.setup(:source => SampleSitePath)
82
-
83
82
  Ruhoh::Parsers::Pages.is_valid_page?(filepath).should == false
84
83
  end
85
84
 
86
- it "should return false for a filepath matching a regular expression in exclude array" do
85
+ it "should return false for a page filepath matching a regular expression in pages exclude array" do
87
86
  filepath1 = 'test/about.md'
88
87
  filepath2 = 'test/yay.md'
89
88
  filepath3 = 'vest/yay.md'
90
89
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
91
90
  'theme' => "twitter",
92
- 'exclude' => /^test/
91
+ 'pages' => {'exclude' => ['^test', 'blah'] }
93
92
  })
94
93
  Ruhoh.setup(:source => SampleSitePath)
95
94
 
data/spec/setup_spec.rb CHANGED
@@ -35,14 +35,14 @@ module Setup
35
35
  Ruhoh.config.permalink.should == custom_permalink
36
36
  Ruhoh.config.theme.should == custom_theme
37
37
  Ruhoh.config.theme_path.should == "/_templates/themes/#{custom_theme}"
38
- Ruhoh.config.exclude.should == custom_exclude
38
+ Ruhoh.config.exclude['posts'].should == custom_exclude
39
39
  end
40
40
  end
41
41
  end
42
42
 
43
43
  describe "#setup_filters" do
44
44
  it 'should add custom exclude filters to the filters variable' do
45
- custom_exclude = ['.secret', /^test/]
45
+ custom_exclude = ['.secret', '^test']
46
46
  Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
47
47
  'theme' => "twitter",
48
48
  'exclude' => custom_exclude
@@ -50,8 +50,8 @@ module Setup
50
50
  Ruhoh.setup_config
51
51
  Ruhoh.setup_filters
52
52
 
53
- Ruhoh.filters.pages['names'].should include('.secret')
54
- Ruhoh.filters.pages['regexes'].should include(/^test/)
53
+ Ruhoh.filters.posts.should include(/.secret/)
54
+ Ruhoh.filters.posts.should include(/^test/)
55
55
  end
56
56
  end
57
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruhoh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-04 00:00:00.000000000 Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70148787084820 !ruby/object:Gem::Requirement
16
+ requirement: &70126524196260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70148787084820
24
+ version_requirements: *70126524196260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mustache
27
- requirement: &70148787084320 !ruby/object:Gem::Requirement
27
+ requirement: &70126524225960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.99'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70148787084320
35
+ version_requirements: *70126524225960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: directory_watcher
38
- requirement: &70148787083860 !ruby/object:Gem::Requirement
38
+ requirement: &70126524225500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70148787083860
46
+ version_requirements: *70126524225500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: maruku
49
- requirement: &70148787083400 !ruby/object:Gem::Requirement
49
+ requirement: &70126524225040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.6'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70148787083400
57
+ version_requirements: *70126524225040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: psych
60
- requirement: &70148787113120 !ruby/object:Gem::Requirement
60
+ requirement: &70126524224580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '1.3'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70148787113120
68
+ version_requirements: *70126524224580
69
69
  description: Ruhoh is a Universal API for your static blog.
70
70
  email: plusjade@gmail.com
71
71
  executables:
@@ -78,7 +78,7 @@ files:
78
78
  - Rakefile
79
79
  - bin/ruhoh
80
80
  - dash.html
81
- - history.txt
81
+ - history.json
82
82
  - lib/ruhoh.rb
83
83
  - lib/ruhoh/client/client.rb
84
84
  - lib/ruhoh/client/help.yml
data/history.txt DELETED
@@ -1,25 +0,0 @@
1
-
2
- 4.5.2012
3
- 0.2.0 - API changes:
4
- - [change] Dates in post filenames are now optional but will be required in metadata.
5
- - [remove] _draft folder. Drafts are now simply a 'type' of post.
6
- - [remove] publish and un-publish in favor of specifying 'type' meta attribute.
7
- - [add] titleize method to client which renames draft filenames to their titles if set.
8
- - [change] /_draft panel is now /dash with updated UI.
9
- - [change] - rackup configuration is now through Ruhoh::Program.preview.
10
- - FEATURES:
11
- - Maintain file extensions for files that don't respond to a converter.
12
- - Add 'development'/'production' environment configuration flag.
13
- - @ben-biddington Introduces local temporary directory as SampleSitePath.
14
- - @ben-biddington adds Travis integration.
15
- 0.1.4 - BUG: Fix invalid byte sequence in US-ASCII by forcing UTF-8
16
- 19.4.2012
17
- 0.1.3 - BUG: Fix drafts not maintaining file extension when publishing
18
- BUG: tags helper should use tags database.
19
- BUG: Fix for properly handling filepaths on Windows machines.
20
- 18.4.2012
21
- 0.1.2 - BUG: Fix bug with YAML psych/syck errors.
22
- 0.1.1 - @tkellen tidies up partials + fix 'paths.theme' error in theme scaffold.
23
- 12.4.2012
24
- 0.1.0 - Initial public release.
25
-