staticpress 0.1.0
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/.gitignore +9 -0
- data/.rbenv-version +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Rakefile +21 -0
- data/bin/staticpress +6 -0
- data/lib/skeleton/Gemfile +10 -0
- data/lib/skeleton/README.markdown +21 -0
- data/lib/skeleton/config.rb +14 -0
- data/lib/skeleton/config.ru +8 -0
- data/lib/skeleton/config.yml +63 -0
- data/lib/staticpress/booter.rb +7 -0
- data/lib/staticpress/cli.rb +123 -0
- data/lib/staticpress/configuration.rb +24 -0
- data/lib/staticpress/content/base.rb +122 -0
- data/lib/staticpress/content/category.rb +34 -0
- data/lib/staticpress/content/collection_content.rb +13 -0
- data/lib/staticpress/content/index.rb +20 -0
- data/lib/staticpress/content/page.rb +64 -0
- data/lib/staticpress/content/post.rb +88 -0
- data/lib/staticpress/content/resource_content.rb +28 -0
- data/lib/staticpress/content/static_content.rb +24 -0
- data/lib/staticpress/content/tag.rb +34 -0
- data/lib/staticpress/content/theme.rb +48 -0
- data/lib/staticpress/error.rb +4 -0
- data/lib/staticpress/helpers.rb +57 -0
- data/lib/staticpress/js_object.rb +51 -0
- data/lib/staticpress/metadata.rb +24 -0
- data/lib/staticpress/plugin.rb +33 -0
- data/lib/staticpress/plugins/blockquote.rb +6 -0
- data/lib/staticpress/plugins/gist.rb +6 -0
- data/lib/staticpress/plugins/titlecase.rb +6 -0
- data/lib/staticpress/plugins.rb +6 -0
- data/lib/staticpress/route.rb +123 -0
- data/lib/staticpress/server.rb +21 -0
- data/lib/staticpress/site.rb +57 -0
- data/lib/staticpress/theme.rb +43 -0
- data/lib/staticpress/version.rb +12 -0
- data/lib/staticpress/view_helpers.rb +35 -0
- data/lib/staticpress.rb +15 -0
- data/lib/themes/classic/assets/scripts/application.js +4 -0
- data/lib/themes/classic/assets/styles/all.sass +0 -0
- data/lib/themes/classic/includes/list_posts.haml +3 -0
- data/lib/themes/classic/layouts/archive.haml +0 -0
- data/lib/themes/classic/layouts/atom.haml +0 -0
- data/lib/themes/classic/layouts/default.haml +5 -0
- data/lib/themes/classic/layouts/index.haml +0 -0
- data/lib/themes/classic/layouts/post_index.haml +5 -0
- data/lib/themes/classic/views/default.haml +5 -0
- data/staticpress.gemspec +33 -0
- data/tests/lib/staticpress/cli_test.rb +65 -0
- data/tests/lib/staticpress/configuration_test.rb +4 -0
- data/tests/lib/staticpress/content/base_test.rb +9 -0
- data/tests/lib/staticpress/content/category_test.rb +62 -0
- data/tests/lib/staticpress/content/index_test.rb +45 -0
- data/tests/lib/staticpress/content/page_test.rb +133 -0
- data/tests/lib/staticpress/content/post_test.rb +81 -0
- data/tests/lib/staticpress/content/tag_test.rb +60 -0
- data/tests/lib/staticpress/content/theme_test.rb +103 -0
- data/tests/lib/staticpress/helpers_test.rb +57 -0
- data/tests/lib/staticpress/js_object_test.rb +45 -0
- data/tests/lib/staticpress/metadata_test.rb +19 -0
- data/tests/lib/staticpress/plugin_test.rb +4 -0
- data/tests/lib/staticpress/route_test.rb +210 -0
- data/tests/lib/staticpress/server_test.rb +4 -0
- data/tests/lib/staticpress/site_test.rb +25 -0
- data/tests/lib/staticpress/theme_test.rb +68 -0
- data/tests/lib/staticpress/view_helpers_test.rb +32 -0
- data/tests/lib/staticpress_test.rb +15 -0
- data/tests/sample_sites/test_blog/Gemfile +10 -0
- data/tests/sample_sites/test_blog/README.markdown +21 -0
- data/tests/sample_sites/test_blog/config.rb +14 -0
- data/tests/sample_sites/test_blog/config.ru +8 -0
- data/tests/sample_sites/test_blog/config.yml +4 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-07-20-hello.markdown +5 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-01-announcing-staticpress.markdown +7 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-02-staticpress.markdown +7 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-06-blogging-with-staticpress.markdown +7 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-06-conferences.markdown +5 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-06-in-charlotte.markdown +9 -0
- data/tests/sample_sites/test_blog/content/_posts/2011-08-20-forever.markdown +1 -0
- data/tests/sample_sites/test_blog/content/about.markdown +1 -0
- data/tests/sample_sites/test_blog/content/contact.markdown +3 -0
- data/tests/sample_sites/test_blog/content/foo/bar/baz.markdown +1 -0
- data/tests/sample_sites/test_blog/content/plain.txt +1 -0
- data/tests/sample_sites/test_blog/content/ruby.png +0 -0
- data/tests/sample_sites/test_blog/content/style1.css +3 -0
- data/tests/sample_sites/test_blog/content/style2.css.sass +2 -0
- data/tests/sample_sites/test_blog/content/style3.sass +2 -0
- data/tests/test_helper.rb +17 -0
- data.tar.gz.sig +0 -0
- metadata +255 -0
- metadata.gz.sig +3 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/js_object'
|
|
4
|
+
|
|
5
|
+
class JSObjectTest < TestHelper
|
|
6
|
+
JSO = Staticpress::JSObject
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@js_object = JSO.new :key => :value, :nested => { :a => :b }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test__minus
|
|
13
|
+
assert_equal(JSO.new({ :key => :value, :nested => { :a => :b } }), @js_object - {})
|
|
14
|
+
assert_equal(JSO.new({ :nested => { :a => :b } }), @js_object - { :key => :value })
|
|
15
|
+
assert_equal(JSO.new({ :key => :value }), @js_object - { :nested => { :a => :b } })
|
|
16
|
+
assert_equal(JSO.new({}), @js_object - { :key => :value, :nested => { :a => :b } })
|
|
17
|
+
|
|
18
|
+
assert_equal(JSO.new({ :key => :value, :nested => { :a => :b } }), @js_object - JSO.new({}))
|
|
19
|
+
assert_equal(JSO.new({ :nested => { :a => :b } }), @js_object - JSO.new({ :key => :value }))
|
|
20
|
+
assert_equal(JSO.new({ :key => :value }), @js_object - JSO.new({ :nested => { :a => :b } }))
|
|
21
|
+
assert_equal(JSO.new({}), @js_object - JSO.new({ :key => :value, :nested => { :a => :b } }))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test__squares
|
|
25
|
+
assert_nil @js_object[:some_random]
|
|
26
|
+
assert_equal :value, @js_object[:key]
|
|
27
|
+
assert_equal :value, @js_object['key']
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_regular_access
|
|
31
|
+
assert_equal :value, @js_object.key
|
|
32
|
+
assert_equal :b, @js_object.nested.a
|
|
33
|
+
assert_nil @js_object.nested.other
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_assignment
|
|
37
|
+
assert_nil @js_object.hoopla
|
|
38
|
+
@js_object.hoopla = :hullabaloo
|
|
39
|
+
assert_equal :hullabaloo, @js_object.hoopla
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_to_hash
|
|
43
|
+
assert_equal({ :key => :value, :nested => { :a => :b } }, @js_object.to_hash)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative 'js_object_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/metadata'
|
|
4
|
+
|
|
5
|
+
class MetadataTest < JSObjectTest
|
|
6
|
+
def setup
|
|
7
|
+
super
|
|
8
|
+
@meta = Staticpress::Metadata.new
|
|
9
|
+
@another_meta = Staticpress::Metadata.new :layout => 'post_index', :categories => %w[programming], :tags => %w[code tutorial]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test__chevron
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_inspect
|
|
16
|
+
assert_equal '#<Staticpress::Metadata>', @meta.inspect
|
|
17
|
+
assert_equal '#<Staticpress::Metadata categories=["programming"], layout="post_index", tags=["code", "tutorial"]>', @another_meta.inspect
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/route'
|
|
4
|
+
|
|
5
|
+
class RouteTest < TestHelper
|
|
6
|
+
def setup
|
|
7
|
+
Staticpress.blog_path = TEST_BLOG
|
|
8
|
+
|
|
9
|
+
@route_category_0 = Staticpress::Route.new :content_type => Staticpress::Content::Category, :name => 'programming', :number => nil
|
|
10
|
+
@route_category_1 = Staticpress::Route.new :content_type => Staticpress::Content::Category, :name => 'programming', :number => '1'
|
|
11
|
+
@route_category_2 = Staticpress::Route.new :content_type => Staticpress::Content::Category, :name => 'programming', :number => '2'
|
|
12
|
+
@route_page = Staticpress::Route.new :content_type => Staticpress::Content::Page, :slug => 'about'
|
|
13
|
+
@route_post = Staticpress::Route.new :content_type => Staticpress::Content::Post, :year => '2011', :month => '07', :day => '20', :title => 'hello'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test__equalsequals
|
|
17
|
+
assert_operator @route_category_0, :==, @route_category_1
|
|
18
|
+
refute_operator @route_category_0, :==, @route_category_2
|
|
19
|
+
assert_operator @route_page, :==, Staticpress::Route.new(:content_type => Staticpress::Content::Page, :slug => 'about')
|
|
20
|
+
refute_operator @route_page, :==, @route_post
|
|
21
|
+
refute_operator @route_page, :==, nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_content
|
|
25
|
+
assert_equal Staticpress::Content::Page.new(@route_page, :markdown), @route_page.content
|
|
26
|
+
assert_equal Staticpress::Content::Post.new(@route_post, :markdown), @route_post.content
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_inspect
|
|
30
|
+
assert_equal '#<Staticpress::Route url_path=/about, content_type=Staticpress::Content::Page, params={:slug=>"about"}>', @route_page.inspect
|
|
31
|
+
assert_equal '#<Staticpress::Route url_path=/2011/07/20/hello, content_type=Staticpress::Content::Post, params={:day=>"20", :month=>"07", :title=>"hello", :year=>"2011"}>', @route_post.inspect
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_params
|
|
35
|
+
assert_equal({ :content_type => Staticpress::Content::Category, :name => 'programming', :number => '1' }, @route_category_0.params)
|
|
36
|
+
assert_equal({ :content_type => Staticpress::Content::Category, :name => 'programming', :number => '1' }, @route_category_1.params)
|
|
37
|
+
assert_equal({ :content_type => Staticpress::Content::Page, :slug => 'about' }, @route_page.params)
|
|
38
|
+
assert_equal({ :content_type => Staticpress::Content::Post, :year => '2011', :month => '07', :day => '20', :title => 'hello' }, @route_post.params)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_url_path
|
|
42
|
+
assert_equal '/category/programming', @route_category_0.url_path
|
|
43
|
+
assert_equal '/category/programming', @route_category_1.url_path
|
|
44
|
+
assert_equal '/category/programming/page/2', @route_category_2.url_path
|
|
45
|
+
assert_equal '/about', @route_page.url_path
|
|
46
|
+
assert_equal '/2011/07/20/hello', @route_post.url_path
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_from_url_path
|
|
50
|
+
assert_equal Staticpress::Route.from_url_path('/about'), @route_page
|
|
51
|
+
assert_equal Staticpress::Route.from_url_path('/2011/07/20/hello'), @route_post
|
|
52
|
+
assert_nil Staticpress::Route.from_url_path('/i/dont/exist')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_regex_for_pattern_index
|
|
56
|
+
pattern = '/(page/:number)?'
|
|
57
|
+
|
|
58
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
59
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/page/1'
|
|
60
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/page/2'
|
|
61
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/page/17'
|
|
62
|
+
|
|
63
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about'
|
|
64
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
65
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/contact/page/27'
|
|
66
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about'
|
|
67
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
68
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_regex_for_pattern_page_1
|
|
72
|
+
pattern = '/:slug'
|
|
73
|
+
|
|
74
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/page/1'
|
|
75
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/about'
|
|
76
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
77
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about'
|
|
78
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about/us'
|
|
79
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
80
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
81
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
82
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
83
|
+
|
|
84
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_regex_for_pattern_page_2
|
|
88
|
+
pattern = '/static_text/:slug'
|
|
89
|
+
|
|
90
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/page/123'
|
|
91
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/page/xyz'
|
|
92
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about'
|
|
93
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about/us'
|
|
94
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/plain.txt'
|
|
95
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/files/profile.jpg'
|
|
96
|
+
|
|
97
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
98
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about'
|
|
99
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_regex_for_pattern_post_1
|
|
103
|
+
pattern = '/:year/:month/:day/:title'
|
|
104
|
+
|
|
105
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
106
|
+
|
|
107
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about'
|
|
108
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about/us'
|
|
109
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
110
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
111
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_regex_for_pattern_post_2
|
|
115
|
+
pattern = '/blog/:year/:month/:day/:title'
|
|
116
|
+
|
|
117
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
118
|
+
|
|
119
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
120
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
121
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/about'
|
|
122
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
123
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
124
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_regex_for_pattern_post_3
|
|
128
|
+
pattern = '/:year/:title'
|
|
129
|
+
|
|
130
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/2011/hello-world'
|
|
131
|
+
|
|
132
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
133
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
134
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/hello-world'
|
|
135
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
136
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
137
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def test_regex_for_pattern_post_4
|
|
141
|
+
pattern = '/blog/:year/:title'
|
|
142
|
+
|
|
143
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/hello-world'
|
|
144
|
+
|
|
145
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
146
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
147
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/hello-world'
|
|
148
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
149
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
150
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
151
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_regex_for_pattern_tag_1
|
|
155
|
+
pattern = '/tag/:name(/page/:number)?'
|
|
156
|
+
|
|
157
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/tag/programming'
|
|
158
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/tag/programming/page/0'
|
|
159
|
+
|
|
160
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/'
|
|
161
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
162
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about'
|
|
163
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
164
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/something/tag/programming'
|
|
165
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
166
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def test_regex_for_pattern_tag_2
|
|
170
|
+
pattern = '/something/tag/:name(/page/:number)?'
|
|
171
|
+
|
|
172
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/something/tag/programming'
|
|
173
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/something/tag/programming/page/123456'
|
|
174
|
+
|
|
175
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
176
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about/us'
|
|
177
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
178
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/tag/programming'
|
|
179
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
180
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_regex_for_pattern_category_1
|
|
184
|
+
pattern = '/category/:name(/page/:number)?'
|
|
185
|
+
|
|
186
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/category/programming'
|
|
187
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/category/programming/page/5'
|
|
188
|
+
|
|
189
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about'
|
|
190
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about/us'
|
|
191
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/2011/07/20/hello-world'
|
|
192
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
193
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
194
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def test_regex_for_pattern_category_2
|
|
198
|
+
pattern = '/blog/category/:name(/page/:number)?'
|
|
199
|
+
|
|
200
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/blog/category/programming'
|
|
201
|
+
assert_match Staticpress::Route.regex_for_pattern(pattern), '/blog/category/programming/page/20'
|
|
202
|
+
|
|
203
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/about/us'
|
|
204
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/static_text/about'
|
|
205
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/blog/2011/07/20/hello-world'
|
|
206
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/category/programming'
|
|
207
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/plain.txt'
|
|
208
|
+
refute_match Staticpress::Route.regex_for_pattern(pattern), '/files/profile.jpg'
|
|
209
|
+
end
|
|
210
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/page'
|
|
4
|
+
require 'staticpress/content/post'
|
|
5
|
+
require 'staticpress/route'
|
|
6
|
+
require 'staticpress/site'
|
|
7
|
+
|
|
8
|
+
class SiteTest < TestHelper
|
|
9
|
+
def setup
|
|
10
|
+
Staticpress.blog_path = TEST_BLOG
|
|
11
|
+
@site = Staticpress::Site.new
|
|
12
|
+
|
|
13
|
+
@page_route = Staticpress::Route.from_url_path '/about'
|
|
14
|
+
@page = Staticpress::Content::Page.new @page_route, :markdown
|
|
15
|
+
|
|
16
|
+
@post_route = Staticpress::Route.from_url_path '/2011/07/20/hello'
|
|
17
|
+
@post = Staticpress::Content::Post.new @post_route, :markdown
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_find_content_by_url_path
|
|
21
|
+
assert_equal @page, @site.find_content_by_url_path('/about')
|
|
22
|
+
assert_equal @post, @site.find_content_by_url_path('/2011/07/20/hello')
|
|
23
|
+
assert_nil @site.find_content_by_url_path('/i/dont/exist')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/theme'
|
|
4
|
+
|
|
5
|
+
class ThemeTest < TestHelper
|
|
6
|
+
def setup
|
|
7
|
+
@theme = Staticpress::Theme.new :classic
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_default_include
|
|
12
|
+
refute_respond_to @theme, :default_include
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_keyed_includes
|
|
16
|
+
assert_equal((@theme.root + 'includes' + 'list_posts.haml'), @theme.keyed_includes['list_posts'])
|
|
17
|
+
assert_nil @theme.keyed_includes['fake']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_include_for
|
|
21
|
+
assert_equal (@theme.root + 'includes' + 'list_posts.haml'), @theme.include_for(:list_posts)
|
|
22
|
+
assert_nil @theme.include_for(:fake)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_includes
|
|
26
|
+
assert_equal 1, @theme.includes.count
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_default_layout
|
|
31
|
+
assert_equal (@theme.root + 'layouts' + 'default.haml'), @theme.default_layout
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_keyed_layouts
|
|
35
|
+
assert_equal((@theme.root + 'layouts' + 'default.haml'), @theme.keyed_layouts['default'])
|
|
36
|
+
assert_equal((@theme.root + 'layouts' + 'post_index.haml'), @theme.keyed_layouts['post_index'])
|
|
37
|
+
assert_nil @theme.keyed_layouts['fake']
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_layout_for
|
|
41
|
+
assert_equal (@theme.root + 'layouts' + 'default.haml'), @theme.layout_for(:default)
|
|
42
|
+
assert_equal (@theme.root + 'layouts' + 'post_index.haml'), @theme.layout_for(:post_index)
|
|
43
|
+
assert_nil @theme.layout_for(:fake)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_layouts
|
|
47
|
+
assert_equal 5, @theme.layouts.count
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_default_view
|
|
52
|
+
assert_equal (@theme.root + 'views' + 'default.haml'), @theme.default_view
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_keyed_views
|
|
56
|
+
assert_equal((@theme.root + 'views' + 'default.haml'), @theme.keyed_views['default'])
|
|
57
|
+
assert_nil @theme.keyed_views['fake']
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_view_for
|
|
61
|
+
assert_equal (@theme.root + 'views' + 'default.haml'), @theme.view_for(:default)
|
|
62
|
+
assert_nil @theme.view_for(:fake)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_views
|
|
66
|
+
assert_equal 1, @theme.views.count
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/helpers'
|
|
4
|
+
require 'staticpress/view_helpers'
|
|
5
|
+
|
|
6
|
+
class ViewHelpersTest < TestHelper
|
|
7
|
+
include Staticpress::Helpers
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
Staticpress.blog_path = TEST_BLOG
|
|
11
|
+
@post_route = Staticpress::Route.from_url_path '/2011/07/20/hello'
|
|
12
|
+
@post = Staticpress::Content::Post.new @post_route, Staticpress.blog_path + config.posts_source + '2011-07-20-hello.markdown'
|
|
13
|
+
@view_helpers = Staticpress::ViewHelpers.new @post
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_partial_with_one_post
|
|
17
|
+
expected = <<-HTML
|
|
18
|
+
<section>
|
|
19
|
+
<article>#{@post.render_partial.strip}</article>
|
|
20
|
+
</section>
|
|
21
|
+
HTML
|
|
22
|
+
assert_equal expected, @view_helpers.partial(:list_posts, :posts => [ @post ])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_partial_with_no_posts
|
|
26
|
+
expected = <<-HTML
|
|
27
|
+
<section>
|
|
28
|
+
</section>
|
|
29
|
+
HTML
|
|
30
|
+
assert_equal expected, @view_helpers.partial(:list_posts, :posts => [ ])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
5
|
+
class StaticpressTest < TestHelper
|
|
6
|
+
def test_blog_path
|
|
7
|
+
assert_equal Pathname.new('.').expand_path, Staticpress.blog_path
|
|
8
|
+
Staticpress.blog_path = 'tests/test_blog'
|
|
9
|
+
assert_equal Pathname.new('tests/test_blog').expand_path, Staticpress.blog_path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_root
|
|
13
|
+
assert_equal Pathname.new('lib/').expand_path, Staticpress.root
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
* copies lib/skeletons/new to <path-to-blog>
|
|
2
|
+
* this should edit the blog's config.yml to include [name-of-blog] (prompt for [name-of-blog] if blank)
|
|
3
|
+
$ staticpress new <path-to-blog> [name-of-blog]
|
|
4
|
+
$ cd <path-to-blog>
|
|
5
|
+
|
|
6
|
+
* copies <plugin-name> into <path-to-blog>/plugins/
|
|
7
|
+
$ staticpress fork_plugin <plugin-name>
|
|
8
|
+
|
|
9
|
+
* setting the theme is done in the main config file, this command is optional and
|
|
10
|
+
* just copies the theme's file into <path-to-blog>/themes/[theme-name] for customizations
|
|
11
|
+
* if [theme-name] is blank, default to the currently configured theme
|
|
12
|
+
$ staticpress fork_theme [theme-name]
|
|
13
|
+
|
|
14
|
+
* turn on local server for development
|
|
15
|
+
$ staticpress serve
|
|
16
|
+
|
|
17
|
+
* prepare blog for deployment
|
|
18
|
+
$ staticpress package
|
|
19
|
+
|
|
20
|
+
* deploy blog
|
|
21
|
+
$ staticpress deploy
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Require any additional compass plugins here.
|
|
2
|
+
project_type = :stand_alone
|
|
3
|
+
|
|
4
|
+
# Set this to the root of your project when deployed:
|
|
5
|
+
http_path = '/'
|
|
6
|
+
css_dir = 'public/stylesheets'
|
|
7
|
+
sass_dir = 'sass'
|
|
8
|
+
images_dir = 'source/images'
|
|
9
|
+
http_images_dir = 'images'
|
|
10
|
+
fonts_dir = 'source/fonts'
|
|
11
|
+
http_fonts_dir = 'fonts'
|
|
12
|
+
|
|
13
|
+
line_comments = false
|
|
14
|
+
output_style = :compressed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
in post
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
in page
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
in page
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
this file intentionally left blank
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
require 'ruby-debug'
|
|
5
|
+
|
|
6
|
+
require 'staticpress'
|
|
7
|
+
|
|
8
|
+
class TestHelper < MiniTest::Unit::TestCase
|
|
9
|
+
SAMPLE_SITES = (Staticpress.root + '..' + 'tests' + 'sample_sites').expand_path
|
|
10
|
+
TEST_BLOG = SAMPLE_SITES + 'test_blog'
|
|
11
|
+
|
|
12
|
+
def teardown
|
|
13
|
+
Staticpress.blog_path = '.'
|
|
14
|
+
test_blog_public = TEST_BLOG + 'public'
|
|
15
|
+
FileUtils.rm_rf test_blog_public if test_blog_public.directory?
|
|
16
|
+
end
|
|
17
|
+
end
|
data.tar.gz.sig
ADDED
|
Binary file
|