hydeweb 0.1.5 → 0.1.6

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.
data/HISTORY.md CHANGED
@@ -1,6 +1,7 @@
1
- v0.1.5
1
+ v0.1.6
2
2
  ------
3
3
 
4
+ - Fix an edge case where files containing '---' somewhere is treated wrong.
4
5
  - Ruby 1.8 compatibility.
5
6
 
6
7
  v0.1.4
data/lib/hyde/page.rb CHANGED
@@ -8,7 +8,7 @@ class Page
8
8
  return nil if site_path.nil?
9
9
 
10
10
  site = lambda { |*x| File.join site_path, *(x.compact) }
11
- try = lambda { |id| p = new(id, project); p if p.exists? }
11
+ try = lambda { |_id| p = new(_id, project); p if p.exists? }
12
12
 
13
13
  # Account for:
14
14
  # ~/mysite/site/about/us.html.haml
@@ -26,9 +26,10 @@ class Page
26
26
  # Subclass
27
27
  if page && page.tilt? && page.meta[:type]
28
28
  klass = Page.get_type(page.meta[:type])
29
- raise Error, "#{page.filepath}: Class for type '#{page.meta.type}' not found" unless klass
29
+ raise Error, "#{page.filepath}: Class for type '#{page.meta[:type]}' not found" unless klass
30
30
  page = klass.new(id, project)
31
31
  end
32
+
32
33
  page
33
34
  end
34
35
 
@@ -108,13 +109,14 @@ class Page
108
109
  # Returns a page subtype.
109
110
  # @example Page.get_type('post') => Hyde::Page::Post
110
111
  def self.get_type(type)
111
- klass = type[0].upcase + type[1..-1].downcase
112
+ type = type.to_s
113
+ klass = type[0..0].upcase + type[1..-1].downcase
112
114
  klass = klass.to_sym
113
115
  self.const_get(klass) if self.const_defined?(klass)
114
116
  end
115
117
 
116
118
  def exists?
117
- @file and File.file?(@file) and valid?
119
+ @file and File.file?(@file||'') and valid?
118
120
  end
119
121
 
120
122
  # Make sure that it's in the right folder.
@@ -242,7 +244,7 @@ class Page
242
244
  end
243
245
 
244
246
  def breadcrumbs
245
- Set.new (parent? ? (parent.breadcrumbs + [self]) : [self])
247
+ Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])
246
248
  end
247
249
 
248
250
  def index?
@@ -286,7 +288,7 @@ protected
286
288
  @parts ||= begin
287
289
  t = File.open(@file).read
288
290
  t = t.force_encoding('UTF-8') if t.respond_to?(:force_encoding)
289
- m = t.match(/^(.*)--+\n(.*)$/m)
291
+ m = t.match(/^(.*?)\n--+\n(.*)$/m)
290
292
 
291
293
  if m.nil?
292
294
  [{}, t]
data/lib/hyde.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $:.push *Dir[File.expand_path('../../vendor/*/lib', __FILE__)]
2
2
 
3
+ require 'rubygems' if !Object.respond_to?(:gem)
4
+
3
5
  gem 'shake', '>= 0.1.2'
4
6
  gem 'tilt', '>= 1.2.2'
5
7
 
@@ -13,7 +15,7 @@ require 'shake'
13
15
  Tilt.mappings['html'] = Tilt.mappings['erb']
14
16
 
15
17
  class Hyde
16
- VERSION = "0.1.5"
18
+ VERSION = "0.1.6"
17
19
  PREFIX = File.expand_path('../', __FILE__)
18
20
 
19
21
  Error = Class.new(StandardError)
@@ -0,0 +1,4 @@
1
+ <h1>Hyde is it</h1>
2
+ <pre class='prettyprint lang-html'>title: Hello world!
3
+ ---
4
+ <div class='highlight'> &lt;h1&gt;Hi&lt;/hi&gt;</div></pre>
@@ -0,0 +1,8 @@
1
+ hyde_requirement: 0.1
2
+ site_path: site
3
+ extensions_path: extensions
4
+ output_path: public
5
+ ignore:
6
+ - **/*~
7
+ - **/compass/**/*
8
+ - **/_*.scss
@@ -0,0 +1,8 @@
1
+ title: Hyde is it
2
+ ---
3
+ %h1= meta.title
4
+ %pre.prettyprint.lang-html
5
+ :escaped
6
+ title: Hello world!
7
+ ---
8
+ .highlight=" <h1>Hi</hi>"
data/test/helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $:.push File.expand_path('../../lib', __FILE__)
2
2
 
3
+ require 'rubygems' if !Object.respond_to?(:gem)
4
+
3
5
  gem "contest", "~> 0.1"
4
6
 
5
7
  require 'hyde'
@@ -25,3 +27,10 @@ class TestCase < Test::Unit::TestCase
25
27
  FileUtils.rm_rf project.path(:output)
26
28
  end
27
29
  end
30
+
31
+ class Hyde::Set
32
+ # Because 1.8.6 doesn't support map(&:path)
33
+ def paths
34
+ map { |page| page.path }
35
+ end
36
+ end
@@ -65,6 +65,10 @@ class HydeTest < TestCase
65
65
  assert_fixture_works fixture('sort')
66
66
  end
67
67
 
68
+ test "fixture metadata" do
69
+ assert_fixture_works fixture('metadata')
70
+ end
71
+
68
72
  test "fixture nested_layout" do
69
73
  assert_fixture_works fixture('nested_layout')
70
74
  end
@@ -14,10 +14,10 @@ class PageTest < TestCase
14
14
  end
15
15
 
16
16
  test "breadcrumbs" do
17
- assert_equal %w(/index.html /about/index.css), Page['/about/index.css'].breadcrumbs.map(&:path)
18
- assert_equal %w(/index.html /about/index.css /about/us.html), Page['/about/us.html'].breadcrumbs.map(&:path)
19
- assert_equal %w(/index.html /css/style.css), Page['/css/style.css'].breadcrumbs.map(&:path)
20
- assert_equal %w(/index.html), Page['/'].breadcrumbs.map(&:path)
17
+ assert_equal %w(/index.html /about/index.css), Page['/about/index.css'].breadcrumbs.paths
18
+ assert_equal %w(/index.html /about/index.css /about/us.html), Page['/about/us.html'].breadcrumbs.paths
19
+ assert_equal %w(/index.html /css/style.css), Page['/css/style.css'].breadcrumbs.paths
20
+ assert_equal %w(/index.html), Page['/'].breadcrumbs.paths
21
21
  end
22
22
 
23
23
  test "parent" do
@@ -31,7 +31,7 @@ class PageTest < TestCase
31
31
  assert page.siblings.empty?
32
32
 
33
33
  page = Page['/hello.html']
34
- assert_equal %w(/cheers.html /hello.html /hi.html), page.siblings.map(&:path)
34
+ assert_equal %w(/cheers.html /hello.html /hi.html), page.siblings.paths
35
35
  end
36
36
 
37
37
  test "mimes" do
@@ -21,6 +21,6 @@ class SetTest < TestCase
21
21
 
22
22
  test "children" do
23
23
  set = Page['/'].children.find(:hello => 'world')
24
- assert set.map(&:path) == ['/hello.html']
24
+ assert set.paths == ['/hello.html']
25
25
  end
26
26
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hydeweb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.5
5
+ version: 0.1.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rico Sta. Cruz
@@ -105,6 +105,9 @@ files:
105
105
  - test/fixture/html/control/index.html
106
106
  - test/fixture/html/hyde.conf
107
107
  - test/fixture/html/site/index.html
108
+ - test/fixture/metadata/control/index.html
109
+ - test/fixture/metadata/hyde.conf
110
+ - test/fixture/metadata/site/index.haml
108
111
  - test/fixture/nested_layout/control/index.html
109
112
  - test/fixture/nested_layout/hyde.conf
110
113
  - test/fixture/nested_layout/layouts/default.haml