staticpress 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/NOTES.markdown +23 -0
  2. data/Rakefile +1 -6
  3. data/docs/content/docs/plugins/pagination.haml +30 -0
  4. data/docs/content/docs/samples/page.markdown +14 -0
  5. data/docs/content/docs/samples/post.markdown +18 -0
  6. data/docs/content/docs/themes.markdown +47 -0
  7. data/lib/skeleton/config.yml +1 -0
  8. data/lib/staticpress/cli.rb +5 -9
  9. data/lib/staticpress/content/base.rb +8 -10
  10. data/lib/staticpress/content/category.rb +17 -4
  11. data/lib/staticpress/content/collection_content.rb +1 -3
  12. data/lib/staticpress/content/index.rb +6 -3
  13. data/lib/staticpress/content/page.rb +4 -0
  14. data/lib/staticpress/content/post.rb +4 -1
  15. data/lib/staticpress/content/resource_content.rb +2 -8
  16. data/lib/staticpress/content/tag.rb +17 -4
  17. data/lib/staticpress/content/theme.rb +1 -1
  18. data/lib/staticpress/helpers.rb +5 -5
  19. data/lib/staticpress/plugins/menu.rb +1 -1
  20. data/lib/staticpress/plugins/pagination.rb +38 -0
  21. data/lib/staticpress/theme.rb +45 -17
  22. data/lib/staticpress/version.rb +1 -1
  23. data/lib/themes/basic/includes/github.haml +2 -0
  24. data/lib/themes/basic/layouts/default.haml +1 -0
  25. data/lib/themes/basic/views/page_paged.haml +6 -0
  26. data/{tests → spec/fixtures}/test_blog/Gemfile +0 -0
  27. data/{tests → spec/fixtures}/test_blog/README.markdown +0 -0
  28. data/{tests → spec/fixtures}/test_blog/config.ru +0 -0
  29. data/{tests → spec/fixtures}/test_blog/config.yml +0 -0
  30. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-07-20-hello.markdown +0 -0
  31. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-01-announcing-staticpress.markdown +0 -0
  32. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-02-staticpress.markdown +0 -0
  33. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-blogging-with-staticpress.markdown +0 -0
  34. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-conferences.markdown +0 -0
  35. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-06-in-charlotte.markdown +0 -0
  36. data/{tests → spec/fixtures}/test_blog/content/_posts/2011-08-20-forever.markdown +0 -0
  37. data/{tests → spec/fixtures}/test_blog/content/_posts/2012-09-19-unpublished.markdown +0 -0
  38. data/{tests → spec/fixtures}/test_blog/content/about.markdown +0 -0
  39. data/{tests → spec/fixtures}/test_blog/content/chain.html.markdown.erb +0 -0
  40. data/{tests → spec/fixtures}/test_blog/content/chained.markdown.erb +0 -0
  41. data/{tests → spec/fixtures}/test_blog/content/contact.markdown +0 -0
  42. data/{tests → spec/fixtures}/test_blog/content/foo/bar/baz.markdown +0 -0
  43. data/{tests → spec/fixtures}/test_blog/content/index.markdown +0 -0
  44. data/{tests → spec/fixtures}/test_blog/content/plain.txt +0 -0
  45. data/{tests → spec/fixtures}/test_blog/content/ruby.png +0 -0
  46. data/{tests → spec/fixtures}/test_blog/content/style1.css +0 -0
  47. data/{tests → spec/fixtures}/test_blog/content/style2.css.sass +0 -0
  48. data/{tests → spec/fixtures}/test_blog/content/style3.sass +0 -0
  49. data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/scripts/application.js +0 -0
  50. data/{tests → spec/fixtures}/test_blog/themes/test_theme/assets/styles/all.sass +0 -0
  51. data/{tests → spec/fixtures}/test_blog/themes/test_theme/includes/list_posts.haml +0 -0
  52. data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/archive.haml +0 -0
  53. data/{lib/themes/basic → spec/fixtures/test_blog/themes/test_theme}/layouts/atom.haml +0 -0
  54. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/default.haml +0 -0
  55. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/index.haml +0 -0
  56. data/{tests → spec/fixtures}/test_blog/themes/test_theme/layouts/post_index.haml +0 -0
  57. data/{tests → spec/fixtures}/test_blog/themes/test_theme/views/default.haml +0 -0
  58. data/spec/integration/editing_blog_contents_spec.rb +52 -0
  59. data/spec/integration/editing_blog_spec.rb +42 -0
  60. data/spec/integration/getting_started_spec.rb +29 -0
  61. data/spec/spec_helper.rb +35 -0
  62. data/spec/support/custom_matchers.rb +15 -0
  63. data/spec/support/fixtures.rb +35 -0
  64. data/spec/support/integration_support.rb +230 -0
  65. data/spec/support/unit_support.rb +18 -0
  66. data/spec/unit/staticpress/content/base_spec.rb +327 -0
  67. data/spec/unit/staticpress/content/category_spec.rb +60 -0
  68. data/spec/unit/staticpress/content/index_spec.rb +48 -0
  69. data/spec/unit/staticpress/content/page_spec.rb +70 -0
  70. data/spec/unit/staticpress/content/post_spec.rb +54 -0
  71. data/spec/unit/staticpress/content/resource_content_spec.rb +21 -0
  72. data/spec/unit/staticpress/content/tag_spec.rb +53 -0
  73. data/spec/unit/staticpress/content/theme_spec.rb +31 -0
  74. data/spec/unit/staticpress/helpers_spec.rb +72 -0
  75. data/spec/unit/staticpress/js_object_spec.rb +61 -0
  76. data/spec/unit/staticpress/metadata_spec.rb +15 -0
  77. data/spec/unit/staticpress/route_spec.rb +219 -0
  78. data/spec/unit/staticpress/server_spec.rb +23 -0
  79. data/spec/unit/staticpress/settings_spec.rb +19 -0
  80. data/spec/unit/staticpress/site_spec.rb +26 -0
  81. data/spec/unit/staticpress/theme_spec.rb +80 -0
  82. data/spec/unit/staticpress/view_helpers_spec.rb +40 -0
  83. data/spec/unit/staticpress_spec.rb +27 -0
  84. data/staticpress.gemspec +3 -4
  85. metadata +133 -136
  86. data/features/editing_blog.feature +0 -24
  87. data/features/editing_blog_contents.feature +0 -40
  88. data/features/getting_started.feature +0 -17
  89. data/features/step_definitions/editing_blog_contents_steps.rb +0 -128
  90. data/features/step_definitions/editing_blog_steps.rb +0 -52
  91. data/features/step_definitions/getting_started_steps.rb +0 -51
  92. data/features/support/env.rb +0 -30
  93. data/lib/themes/basic/layouts/post_index.haml +0 -15
  94. data/lib/themes/basic/views/default.haml +0 -10
  95. data/tests/staticpress/configuration_test.rb +0 -4
  96. data/tests/staticpress/content/base_test.rb +0 -291
  97. data/tests/staticpress/content/category_test.rb +0 -48
  98. data/tests/staticpress/content/index_test.rb +0 -40
  99. data/tests/staticpress/content/page_test.rb +0 -56
  100. data/tests/staticpress/content/post_test.rb +0 -42
  101. data/tests/staticpress/content/resource_content_test.rb +0 -17
  102. data/tests/staticpress/content/tag_test.rb +0 -39
  103. data/tests/staticpress/content/theme_test.rb +0 -26
  104. data/tests/staticpress/helpers_test.rb +0 -63
  105. data/tests/staticpress/js_object_test.rb +0 -47
  106. data/tests/staticpress/metadata_test.rb +0 -14
  107. data/tests/staticpress/plugin_test.rb +0 -4
  108. data/tests/staticpress/pusher_test.rb +0 -9
  109. data/tests/staticpress/route_test.rb +0 -186
  110. data/tests/staticpress/server_test.rb +0 -17
  111. data/tests/staticpress/settings_test.rb +0 -13
  112. data/tests/staticpress/site_test.rb +0 -20
  113. data/tests/staticpress/theme_test.rb +0 -83
  114. data/tests/staticpress/view_helpers_test.rb +0 -32
  115. data/tests/staticpress_test.rb +0 -18
  116. data/tests/test_blog/themes/test_theme/layouts/archive.haml +0 -0
  117. data/tests/test_blog/themes/test_theme/layouts/atom.haml +0 -0
  118. data/tests/test_case.rb +0 -54
@@ -1,17 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class ServerTest < TestCase
4
- let(:server) { Staticpress::Server.new }
5
-
6
- def test_call_root
7
- response = server.call(env('/'))
8
- assert_equal 200, response.first
9
- assert_equal 'text/html', response[1]['Content-Type']
10
- end
11
-
12
- def test_call_image
13
- response = server.call(env('/ruby.png'))
14
- assert_equal 200, response.first
15
- assert_equal 'image/png', response[1]['Content-Type']
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class SettingsTest < TestCase
4
- def test_default
5
- refute Staticpress::Settings.instance.verbose
6
- end
7
-
8
- def test_set!
9
- assert_equal nil, Staticpress::Settings.instance.favorite_number
10
- Staticpress::Settings.set! :favorite_number => 42
11
- assert_equal 42, Staticpress::Settings.instance.favorite_number
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class SiteTest < TestCase
4
- let(:site) { Staticpress::Site.new }
5
-
6
- let(:index) { Staticpress::Content::Page.new :slug => '' }
7
- let(:page) { Staticpress::Content::Page.new :slug => 'about' }
8
- let(:post) { Staticpress::Content::Post.new :year => '2011', :month => '07', :day => '20', :title => 'hello' }
9
-
10
- def test_find_content_by_env
11
- assert_equal index, site.find_content_by_env(env('/'))
12
- assert_equal page, site.find_content_by_env(env('/about'))
13
- assert_equal post, site.find_content_by_env(env('/2011/07/20/hello'))
14
- assert_nil site.find_content_by_env(env('/i/dont/exist'))
15
- end
16
-
17
- def test_save
18
- refute_raises(ArgumentError) { site.save }
19
- end
20
- end
@@ -1,83 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class ThemeTest < TestCase
4
- include Staticpress::Helpers
5
-
6
- let(:theme) { Staticpress::Theme.new :test_theme }
7
-
8
- def setup
9
- super
10
- config.theme = :test_theme
11
- end
12
-
13
- def test__equalsequals
14
- assert_operator theme, :==, Staticpress::Theme.new(:test_theme)
15
- end
16
-
17
- def test_root
18
- assert_equal theme.root, (Staticpress.blog_path + 'themes' + 'test_theme')
19
- end
20
-
21
- def test_theme
22
- assert_equal theme, Staticpress::Theme.theme
23
- end
24
-
25
-
26
- def test_default_include
27
- refute_respond_to theme, :default_include
28
- end
29
-
30
- def test_keyed_includes
31
- assert_equal((theme.root + 'includes' + 'list_posts.haml'), theme.keyed_includes['list_posts'])
32
- assert_nil theme.keyed_includes['fake']
33
- end
34
-
35
- def test_include_for
36
- assert_equal (theme.root + 'includes' + 'list_posts.haml'), theme.include_for(:list_posts)
37
- assert_nil theme.include_for(:fake)
38
- end
39
-
40
- def test_includes
41
- assert_equal 1, theme.includes.count
42
- end
43
-
44
-
45
- def test_default_layout
46
- assert_equal (theme.root + 'layouts' + 'default.haml'), theme.default_layout
47
- end
48
-
49
- def test_keyed_layouts
50
- assert_equal((theme.root + 'layouts' + 'default.haml'), theme.keyed_layouts['default'])
51
- assert_equal((theme.root + 'layouts' + 'post_index.haml'), theme.keyed_layouts['post_index'])
52
- assert_nil theme.keyed_layouts['fake']
53
- end
54
-
55
- def test_layout_for
56
- assert_equal (theme.root + 'layouts' + 'default.haml'), theme.layout_for(:default)
57
- assert_equal (theme.root + 'layouts' + 'post_index.haml'), theme.layout_for(:post_index)
58
- assert_nil theme.layout_for(:fake)
59
- end
60
-
61
- def test_layouts
62
- assert_equal 5, theme.layouts.count
63
- end
64
-
65
-
66
- def test_default_view
67
- assert_equal (theme.root + 'views' + 'default.haml'), theme.default_view
68
- end
69
-
70
- def test_keyed_views
71
- assert_equal((theme.root + 'views' + 'default.haml'), theme.keyed_views['default'])
72
- assert_nil theme.keyed_views['fake']
73
- end
74
-
75
- def test_view_for
76
- assert_equal (theme.root + 'views' + 'default.haml'), theme.view_for(:default)
77
- assert_nil theme.view_for(:fake)
78
- end
79
-
80
- def test_views
81
- assert_equal 1, theme.views.count
82
- end
83
- end
@@ -1,32 +0,0 @@
1
- require_relative '../test_case'
2
-
3
- class ViewHelpersTest < TestCase
4
- include Staticpress::Helpers
5
-
6
- let(:post) { Staticpress::Content::Post.new :year => '2011', :month => '07', :day => '20', :title => 'hello' }
7
- let(:view_helpers) { Staticpress::ViewHelpers.new post }
8
-
9
- def test_partial_with_one_post
10
- expected = <<-HTML
11
- <section>
12
- <article>#{post.render_partial.strip}</article>
13
- </section>
14
- HTML
15
- assert_equal expected, view_helpers.partial(:list_posts, :posts => [ post ])
16
- end
17
-
18
- def test_partial_with_no_posts
19
- expected = <<-HTML
20
- <section>
21
- </section>
22
- HTML
23
- assert_equal expected, view_helpers.partial(:list_posts, :posts => [ ])
24
- end
25
-
26
- def test_tag
27
- assert_equal '<t></t>', view_helpers.tag(:t)
28
- assert_equal '<t one="1"></t>', view_helpers.tag(:t, :one => 1)
29
- assert_equal '<t>content</t>', view_helpers.tag(:t) { 'content' }
30
- assert_equal '<t><n></n></t>', view_helpers.tag(:t) { view_helpers.tag(:n) }
31
- end
32
- end
@@ -1,18 +0,0 @@
1
- require_relative 'test_case'
2
-
3
- require 'pathname'
4
-
5
- class StaticpressTest < TestCase
6
- def test_blog_path
7
- assert_equal Pathname('tests/test_blog').expand_path, Staticpress.blog_path
8
- end
9
-
10
- def test_blog_path=
11
- Staticpress.blog_path = 'some/other/directory'
12
- assert_equal Pathname('some/other/directory').expand_path, Staticpress.blog_path
13
- end
14
-
15
- def test_root
16
- assert_equal Pathname('lib/').expand_path, Staticpress.root
17
- end
18
- end
File without changes
data/tests/test_case.rb DELETED
@@ -1,54 +0,0 @@
1
- require 'minitest/autorun'
2
-
3
- require 'compass'
4
- require 'debugger'
5
- require 'haml'
6
- require 'redcarpet'
7
- require 'sass'
8
-
9
- require_relative '../lib/staticpress'
10
-
11
- class TestCase < MiniTest::Spec
12
- TEST_BLOG = (Staticpress.root + '..' + 'tests' + 'test_blog').expand_path
13
-
14
- def setup
15
- Staticpress.blog_path = TEST_BLOG
16
- end
17
-
18
- def teardown
19
- Staticpress.blog_path = '.'
20
- test_blog_public = TEST_BLOG + 'public'
21
- FileUtils.rm_rf test_blog_public if test_blog_public.directory?
22
- end
23
-
24
- def env(path)
25
- {
26
- 'REQUEST_PATH' => path
27
- }
28
- end
29
-
30
- def assert_eql(expected, actual, message = nil)
31
- assert actual.eql?(expected), (message || "Expected #{actual} to have same content as #{expected}")
32
- end
33
-
34
- def refute_raises(exception, &block)
35
- begin
36
- block.call
37
- assert true
38
- rescue Exception => e
39
- refute e.is_an?(exception), exception_details(e, "Expected #{e} not to be raised")
40
- raise e
41
- end
42
- end
43
-
44
- def with_config(options, &block)
45
- original = self.config
46
-
47
- begin
48
- self.config.merge(options).save
49
- block.call
50
- ensure
51
- original.save
52
- end
53
- end
54
- end