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 +2 -1
- data/lib/hyde/page.rb +8 -6
- data/lib/hyde.rb +3 -1
- data/test/fixture/metadata/control/index.html +4 -0
- data/test/fixture/metadata/hyde.conf +8 -0
- data/test/fixture/metadata/site/index.haml +8 -0
- data/test/helper.rb +9 -0
- data/test/unit/fixture_test.rb +4 -0
- data/test/unit/page_test.rb +5 -5
- data/test/unit/set_test.rb +1 -1
- metadata +4 -1
data/HISTORY.md
CHANGED
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 { |
|
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
|
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
|
-
|
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
|
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(/^(
|
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.
|
18
|
+
VERSION = "0.1.6"
|
17
19
|
PREFIX = File.expand_path('../', __FILE__)
|
18
20
|
|
19
21
|
Error = Class.new(StandardError)
|
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
|
data/test/unit/fixture_test.rb
CHANGED
data/test/unit/page_test.rb
CHANGED
@@ -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.
|
18
|
-
assert_equal %w(/index.html /about/index.css /about/us.html), Page['/about/us.html'].breadcrumbs.
|
19
|
-
assert_equal %w(/index.html /css/style.css), Page['/css/style.css'].breadcrumbs.
|
20
|
-
assert_equal %w(/index.html), Page['/'].breadcrumbs.
|
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.
|
34
|
+
assert_equal %w(/cheers.html /hello.html /hi.html), page.siblings.paths
|
35
35
|
end
|
36
36
|
|
37
37
|
test "mimes" do
|
data/test/unit/set_test.rb
CHANGED
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
|
+
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
|