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
data/staticpress.gemspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path('../lib/staticpress/version', __FILE__)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'staticpress'
|
|
7
|
+
s.version = Staticpress::Version.to_s
|
|
8
|
+
s.authors = ['Raving Genius']
|
|
9
|
+
s.email = ['rg+code@ravinggenius.com']
|
|
10
|
+
s.summary = %q{...}
|
|
11
|
+
s.license = 'MIT'
|
|
12
|
+
|
|
13
|
+
s.rubyforge_project = 'staticpress'
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ['lib']
|
|
19
|
+
|
|
20
|
+
s.signing_key = '/home/thomas/Code/___/certificates/gem-private_key.pem'
|
|
21
|
+
s.cert_chain = [
|
|
22
|
+
'/home/thomas/Code/___/certificates/gem-public_cert.pem'
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
s.add_development_dependency 'minitest'
|
|
26
|
+
s.add_development_dependency 'rack'
|
|
27
|
+
s.add_development_dependency 'ruby-debug19'
|
|
28
|
+
|
|
29
|
+
s.add_runtime_dependency 'bundler'
|
|
30
|
+
s.add_runtime_dependency 'rack'
|
|
31
|
+
s.add_runtime_dependency 'thor'
|
|
32
|
+
s.add_runtime_dependency 'tilt'
|
|
33
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
|
|
6
|
+
require 'staticpress/cli'
|
|
7
|
+
require 'staticpress/helpers'
|
|
8
|
+
|
|
9
|
+
class CLITest < TestHelper
|
|
10
|
+
include Staticpress::Helpers
|
|
11
|
+
|
|
12
|
+
TEMP_BLOG = SAMPLE_SITES + 'temp_blog'
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
Staticpress.blog_path = TEMP_BLOG
|
|
16
|
+
@cli = Staticpress::CLI.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown
|
|
20
|
+
FileUtils.rm_rf TEMP_BLOG if TEMP_BLOG.directory?
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_help
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_new
|
|
28
|
+
refute TEMP_BLOG.directory?
|
|
29
|
+
@cli.new TEMP_BLOG
|
|
30
|
+
assert_equal 5, TEMP_BLOG.children.count
|
|
31
|
+
assert_equal 'Temp Blog', config.title
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_new_with_custom_title
|
|
35
|
+
@cli.new TEMP_BLOG, 'This is my blog'
|
|
36
|
+
assert_equal 'This is my blog', config.title
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_create
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_create_page
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_fork_plugin
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_fork_theme
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_build
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_serve
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_push
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_deploy
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_version
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/category'
|
|
4
|
+
require 'staticpress/route'
|
|
5
|
+
require 'staticpress/theme'
|
|
6
|
+
|
|
7
|
+
class ContentCategoryTest < ContentBaseTest
|
|
8
|
+
def setup
|
|
9
|
+
super
|
|
10
|
+
|
|
11
|
+
@template_dir = Staticpress::Theme.theme.root + 'views'
|
|
12
|
+
|
|
13
|
+
@category_page_route = Staticpress::Route.from_url_path '/category/programming'
|
|
14
|
+
@category_page = Staticpress::Content::Category.new @category_page_route, @template_dir + 'default.haml'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test__equalsequals
|
|
18
|
+
assert_operator @category_page, :==, Staticpress::Content::Category.new(@category_page_route, @template_dir + 'default.haml')
|
|
19
|
+
refute_operator @category_page, :==, nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_categories
|
|
23
|
+
assert_equal [ 'programming', 'travel' ], Staticpress::Content::Category.categories
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_exist?
|
|
27
|
+
assert @category_page.exist?, '@category_page does not exist'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_find_by_route
|
|
31
|
+
assert_equal @category_page, Staticpress::Content::Category.find_by_route(@category_page_route)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_inspect
|
|
35
|
+
assert_equal '#<Staticpress::Content::Category url_path=/category/programming>', @category_page.inspect
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_sub_content
|
|
39
|
+
assert_equal 3, @category_page.sub_content.count
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_raw
|
|
43
|
+
assert_equal '= partial :list_posts, :posts => page.sub_content', @category_page.raw
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_route
|
|
47
|
+
assert_equal '/category/programming', @category_page.route.url_path
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_all
|
|
51
|
+
assert_equal 2, Staticpress::Content::Category.all.count
|
|
52
|
+
assert Staticpress::Content::Category.all.include?(@category_page)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_content_by_category
|
|
56
|
+
[
|
|
57
|
+
Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '01', :title => 'announcing-staticpress').content,
|
|
58
|
+
Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '02', :title => 'staticpress').content,
|
|
59
|
+
Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '06', :title => 'blogging-with-staticpress').content
|
|
60
|
+
].each { |content| assert_includes Staticpress::Content::Category.content_by_category['programming'], content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/index'
|
|
4
|
+
require 'staticpress/route'
|
|
5
|
+
|
|
6
|
+
class ContentIndexTest < ContentBaseTest
|
|
7
|
+
def setup
|
|
8
|
+
super
|
|
9
|
+
|
|
10
|
+
@template_dir = Staticpress::Theme.theme.root + 'views'
|
|
11
|
+
|
|
12
|
+
@home_route = Staticpress::Route.from_url_path '/'
|
|
13
|
+
@home = Staticpress::Content::Index.new @home_route, @template_dir + 'default.haml'
|
|
14
|
+
|
|
15
|
+
@home_two_route = Staticpress::Route.from_url_path '/page/2'
|
|
16
|
+
@home_two = Staticpress::Content::Index.new @home_two_route, @template_dir + 'default.haml'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test__equalsequals
|
|
20
|
+
assert_operator @home, :==, Staticpress::Content::Index.new(@home_route, @template_dir + 'default.haml')
|
|
21
|
+
refute_operator @home, :==, @home_two
|
|
22
|
+
refute_operator @home, :==, nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_exist?
|
|
26
|
+
assert @home.exist?, '@home does not exist'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_find_by_route
|
|
30
|
+
assert_equal @home, Staticpress::Content::Index.find_by_route(@home_route)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_inspect
|
|
34
|
+
assert_equal '#<Staticpress::Content::Index url_path=/>', @home.inspect
|
|
35
|
+
assert_equal '#<Staticpress::Content::Index url_path=/page/2>', @home_two.inspect
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_raw
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_route
|
|
42
|
+
assert_equal '/', @home.route.url_path
|
|
43
|
+
assert_equal '/page/2', @home_two.route.url_path
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/page'
|
|
4
|
+
require 'staticpress/helpers'
|
|
5
|
+
require 'staticpress/route'
|
|
6
|
+
|
|
7
|
+
class ContentPageTest < ContentBaseTest
|
|
8
|
+
include Staticpress::Helpers
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
super
|
|
12
|
+
|
|
13
|
+
@page_dir = Staticpress.blog_path + config.source
|
|
14
|
+
|
|
15
|
+
@page_route = Staticpress::Route.from_url_path '/about'
|
|
16
|
+
@page = Staticpress::Content::Page.new @page_route, @page_dir + 'about.markdown'
|
|
17
|
+
|
|
18
|
+
@second_page_route = Staticpress::Route.from_url_path '/contact'
|
|
19
|
+
@second_page = Staticpress::Content::Page.new @second_page_route, @page_dir + 'contact.markdown'
|
|
20
|
+
|
|
21
|
+
@style2_route = Staticpress::Route.from_url_path '/style2.css'
|
|
22
|
+
@style2 = Staticpress::Content::Page.new @style2_route, @page_dir + 'style2.css.sass'
|
|
23
|
+
|
|
24
|
+
@nested_route = Staticpress::Route.from_url_path '/foo/bar/baz'
|
|
25
|
+
@nested = Staticpress::Content::Page.new @nested_route, @page_dir + 'foo' + 'bar' + 'baz'
|
|
26
|
+
|
|
27
|
+
@static_bin_route = Staticpress::Route.from_url_path '/ruby.png'
|
|
28
|
+
@static_bin = Staticpress::Content::Page.new @static_bin_route, @page_dir + 'ruby.png'
|
|
29
|
+
|
|
30
|
+
@static_txt_route = Staticpress::Route.from_url_path '/plain.txt'
|
|
31
|
+
@static_txt = Staticpress::Content::Page.new @static_txt_route, @page_dir + 'plain.txt'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test__equalsequals
|
|
35
|
+
assert_operator @page, :==, Staticpress::Content::Page.new(@page_route, @page_dir + 'about.markdown')
|
|
36
|
+
refute_operator @page, :==, @second_page
|
|
37
|
+
refute_operator @page, :==, nil
|
|
38
|
+
assert_operator @static_bin, :==, Staticpress::Content::Page.new(@static_bin_route, @page_dir + 'ruby.png')
|
|
39
|
+
refute_operator @static_bin, :==, nil
|
|
40
|
+
refute_operator @static_bin, :==, @static_txt
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_all
|
|
44
|
+
assert_equal 8, Staticpress::Content::Page.all.count
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_exist?
|
|
48
|
+
assert @page.exist?, '@page does not exist'
|
|
49
|
+
assert @second_page.exist?, '@second_page does not exist'
|
|
50
|
+
assert @static_bin.exist?, '@static_bin does not exist'
|
|
51
|
+
assert @static_txt.exist?, '@static_txt does not exist'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_find_by_path
|
|
55
|
+
@page_dir = Staticpress.blog_path + config.source
|
|
56
|
+
assert_equal @page, Staticpress::Content::Page.find_by_path(@page_dir + 'about.markdown')
|
|
57
|
+
assert_nil Staticpress::Content::Page.find_by_path(@page_dir + 'i' + 'dont' + 'exist.markdown')
|
|
58
|
+
assert_equal @static_bin, Staticpress::Content::Page.find_by_path(@page_dir + 'ruby.png')
|
|
59
|
+
assert_nil Staticpress::Content::Page.find_by_path(@page_dir + 'i' + 'dont' + 'exist.jpg')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_find_by_route
|
|
63
|
+
assert_equal @page, Staticpress::Content::Page.find_by_route(@page_route)
|
|
64
|
+
assert_nil Staticpress::Content::Page.find_by_route(nil)
|
|
65
|
+
assert_equal @static_bin, Staticpress::Content::Page.find_by_route(@static_bin_route)
|
|
66
|
+
assert_nil Staticpress::Content::Page.find_by_route(nil)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_inspect
|
|
70
|
+
assert_equal '#<Staticpress::Content::Page url_path=/about>', @page.inspect
|
|
71
|
+
assert_equal '#<Staticpress::Content::Page url_path=/ruby.png>', @static_bin.inspect
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_output_path
|
|
75
|
+
assert_equal (Staticpress.blog_path + 'public' + 'about' + 'index.html'), @page.output_path
|
|
76
|
+
assert_equal (Staticpress.blog_path + 'public' + 'style2.css'), @style2.output_path
|
|
77
|
+
assert_equal (Staticpress.blog_path + 'public' + 'ruby.png'), @static_bin.output_path
|
|
78
|
+
assert_equal (Staticpress.blog_path + 'public' + 'plain.txt'), @static_txt.output_path
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_raw
|
|
82
|
+
assert_equal 'in page', @page.raw
|
|
83
|
+
assert_equal "in page\n\nin page", @second_page.raw
|
|
84
|
+
assert_equal 'this file intentionally left blank', @static_txt.raw
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_render
|
|
88
|
+
expected_page = <<-HTML
|
|
89
|
+
<html>
|
|
90
|
+
<head>
|
|
91
|
+
<title>/about</title>
|
|
92
|
+
</head>
|
|
93
|
+
<body>
|
|
94
|
+
<p>in page</p>
|
|
95
|
+
</body>
|
|
96
|
+
</html>
|
|
97
|
+
HTML
|
|
98
|
+
assert_equal expected_page, @page.render
|
|
99
|
+
|
|
100
|
+
expected_style2 = <<-CSS
|
|
101
|
+
body {
|
|
102
|
+
color: green; }
|
|
103
|
+
CSS
|
|
104
|
+
assert_equal expected_style2, @style2.render
|
|
105
|
+
assert_equal 'this file intentionally left blank', @static_txt.render
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_render_partial
|
|
109
|
+
assert_equal "<p>in page</p>\n", @page.render_partial
|
|
110
|
+
assert_equal "<p>in page</p>\n\n<p>in page</p>\n", @second_page.render_partial
|
|
111
|
+
expected_style2 = <<-CSS
|
|
112
|
+
body {
|
|
113
|
+
color: green; }
|
|
114
|
+
CSS
|
|
115
|
+
assert_equal expected_style2, @style2.render_partial
|
|
116
|
+
assert_equal 'this file intentionally left blank', @static_txt.render_partial
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_route
|
|
120
|
+
assert_equal '/about', @page.route.url_path
|
|
121
|
+
assert_equal '/contact', @second_page.route.url_path
|
|
122
|
+
assert_equal '/ruby.png', @static_bin.route.url_path
|
|
123
|
+
assert_equal '/plain.txt', @static_txt.route.url_path
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_save
|
|
127
|
+
@static_bin.save
|
|
128
|
+
assert_equal @static_bin.template_path.binread, @static_bin.output_path.binread
|
|
129
|
+
|
|
130
|
+
@static_txt.save
|
|
131
|
+
assert_equal @static_txt.template_path.read, @static_txt.output_path.read
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/post'
|
|
4
|
+
require 'staticpress/helpers'
|
|
5
|
+
require 'staticpress/route'
|
|
6
|
+
|
|
7
|
+
class ContentPostTest < ContentBaseTest
|
|
8
|
+
include Staticpress::Helpers
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
super
|
|
12
|
+
|
|
13
|
+
@post_dir = Staticpress.blog_path + config.posts_source
|
|
14
|
+
|
|
15
|
+
@post_route = Staticpress::Route.from_url_path '/2011/07/20/hello'
|
|
16
|
+
@post = Staticpress::Content::Post.new @post_route, @post_dir + '2011-07-20-hello.markdown'
|
|
17
|
+
|
|
18
|
+
@another_post_route = Staticpress::Route.from_url_path '/2011/08/20/forever'
|
|
19
|
+
@another_post = Staticpress::Content::Post.new @another_post_route, @post_dir + '2011-08-20-forever.markdown'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test__equalsequals
|
|
23
|
+
assert_operator @post, :==, Staticpress::Content::Post.new(@post_route, @post_dir + '2011-07-20-hello.markdown')
|
|
24
|
+
refute_operator @post, :==, nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test__spaceship
|
|
28
|
+
assert_operator @post, :<=>, @another_post
|
|
29
|
+
assert_operator @another_post, :<=>, @post
|
|
30
|
+
assert_equal [ @post, @another_post ], [ @post, @another_post ].sort
|
|
31
|
+
assert_equal [ @post, @another_post ], [ @another_post, @post ].sort
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_created_at
|
|
35
|
+
assert_equal Time.utc(2011, 7, 20, 13, 9, 52), @post.created_at
|
|
36
|
+
assert_equal Time.utc(2011, 8, 20), @another_post.created_at
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_created_on
|
|
40
|
+
assert_equal Time.utc(2011, 7, 20), @post.created_on
|
|
41
|
+
assert_equal Time.utc(2011, 8, 20), @another_post.created_on
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_exist?
|
|
45
|
+
assert @post.exist?, '@post does not exist'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_find_by_path
|
|
49
|
+
@post_dir = Staticpress.blog_path + config.posts_source
|
|
50
|
+
assert_equal @post, Staticpress::Content::Post.find_by_path(@post_dir + '2011-07-20-hello.markdown')
|
|
51
|
+
assert_nil Staticpress::Content::Post.find_by_path(@post_dir + '2011-07-20-goodbye.markdown')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_find_by_route
|
|
55
|
+
assert_equal @post, Staticpress::Content::Post.find_by_route(@post_route)
|
|
56
|
+
assert_nil Staticpress::Content::Post.find_by_route(nil)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_inspect
|
|
60
|
+
assert_equal '#<Staticpress::Content::Post url_path=/2011/07/20/hello>', @post.inspect
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_output_path
|
|
64
|
+
assert_equal (Staticpress.blog_path + 'public' + '2011' + '07' + '20' + 'hello' + 'index.html'), @post.output_path
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_raw
|
|
68
|
+
assert_equal 'in post', @post.raw
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_render
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_render_partial
|
|
75
|
+
assert_equal "<p>in post</p>\n", @post.render_partial
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_route
|
|
79
|
+
assert_equal '/2011/07/20/hello', @post.route.url_path
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/tag'
|
|
4
|
+
require 'staticpress/route'
|
|
5
|
+
require 'staticpress/theme'
|
|
6
|
+
|
|
7
|
+
class ContentTagTest < ContentBaseTest
|
|
8
|
+
def setup
|
|
9
|
+
super
|
|
10
|
+
|
|
11
|
+
@template_dir = Staticpress::Theme.theme.root + 'views'
|
|
12
|
+
|
|
13
|
+
@tag_page_route = Staticpress::Route.from_url_path '/tag/charlotte'
|
|
14
|
+
@tag_page = Staticpress::Content::Tag.new @tag_page_route, @template_dir + 'default.haml'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test__equalsequals
|
|
18
|
+
assert_operator @tag_page, :==, Staticpress::Content::Tag.new(@tag_page_route, @template_dir + 'default.haml')
|
|
19
|
+
refute_operator @tag_page, :==, nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_tags
|
|
23
|
+
assert_equal [ 'charlotte' ], Staticpress::Content::Tag.tags
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_exist?
|
|
27
|
+
assert @tag_page.exist?, '@tag_page does not exist'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_find_by_route
|
|
31
|
+
assert_equal @tag_page, Staticpress::Content::Tag.find_by_route(@tag_page_route)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_inspect
|
|
35
|
+
assert_equal '#<Staticpress::Content::Tag url_path=/tag/charlotte>', @tag_page.inspect
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_sub_content
|
|
39
|
+
assert_equal 1, @tag_page.sub_content.count
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_raw
|
|
43
|
+
assert_equal '= partial :list_posts, :posts => page.sub_content', @tag_page.raw
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_route
|
|
47
|
+
assert_equal '/tag/charlotte', @tag_page.route.url_path
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_all
|
|
51
|
+
assert_equal 1, Staticpress::Content::Tag.all.count
|
|
52
|
+
assert Staticpress::Content::Tag.all.include?(@tag_page)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_content_by_tag
|
|
56
|
+
[
|
|
57
|
+
Staticpress::Route.new(:content_type => Staticpress::Content::Post, :year => '2011', :month => '08', :day => '06', :title => 'in-charlotte').content
|
|
58
|
+
].each { |content| assert_includes Staticpress::Content::Tag.content_by_tag['charlotte'], content }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require_relative 'base_test'
|
|
2
|
+
|
|
3
|
+
require 'staticpress/content/theme'
|
|
4
|
+
require 'staticpress/helpers'
|
|
5
|
+
require 'staticpress/route'
|
|
6
|
+
|
|
7
|
+
class ContentThemeTest < ContentBaseTest
|
|
8
|
+
include Staticpress::Helpers
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
super
|
|
12
|
+
|
|
13
|
+
Staticpress::Content::Theme.all
|
|
14
|
+
|
|
15
|
+
@theme_dir = Staticpress::Theme.theme.root
|
|
16
|
+
|
|
17
|
+
@asset_style_route = Staticpress::Route.from_url_path '/assets/classic/styles/all'
|
|
18
|
+
@asset_style = Staticpress::Content::Theme.new @asset_style_route, @theme_dir + 'assets' + 'styles' + 'all.sass'
|
|
19
|
+
|
|
20
|
+
@asset_script_route = Staticpress::Route.from_url_path '/assets/classic/scripts/application.js'
|
|
21
|
+
@asset_script = Staticpress::Content::Theme.new @asset_script_route, @theme_dir + 'assets' + 'scripts' + 'application.js'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test__equalsequals
|
|
25
|
+
assert_operator @asset_style, :==, Staticpress::Content::Theme.new(@asset_style_route, @theme_dir + 'assets' + 'styles' + 'all.sass')
|
|
26
|
+
refute_operator @asset_style, :==, nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_all
|
|
30
|
+
assert_equal 2, Staticpress::Content::Theme.all.count
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_exist?
|
|
34
|
+
assert @asset_style.exist?, '@asset_style does not exist'
|
|
35
|
+
assert @asset_script.exist?, '@asset_script does not exist'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_find_by_path
|
|
39
|
+
assert_equal @asset_style, Staticpress::Content::Theme.find_by_path(@theme_dir + 'assets' + 'styles' + 'all.sass')
|
|
40
|
+
assert_nil Staticpress::Content::Theme.find_by_path(@theme_dir + 'i' + 'dont' + 'exist.markdown')
|
|
41
|
+
path = (@theme_dir + 'assets' + 'scripts' + 'application.js')
|
|
42
|
+
actual = Staticpress::Content::Theme.find_by_path(@theme_dir + 'assets' + 'scripts' + 'application.js')
|
|
43
|
+
assert_equal @asset_script, actual
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_find_by_route
|
|
47
|
+
assert_equal @asset_style, Staticpress::Content::Theme.find_by_route(@asset_style_route)
|
|
48
|
+
assert_nil Staticpress::Content::Theme.find_by_route(nil)
|
|
49
|
+
assert_equal @asset_script, Staticpress::Content::Theme.find_by_route(@asset_script_route)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_inspect
|
|
53
|
+
assert_equal '#<Staticpress::Content::Theme url_path=/assets/classic/styles/all>', @asset_style.inspect
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_output_path
|
|
57
|
+
assert_equal (Staticpress.blog_path + 'public' + 'assets' + 'classic' + 'styles' + 'all'), @asset_style.output_path
|
|
58
|
+
assert_equal (Staticpress.blog_path + 'public' + 'assets' + 'classic' + 'scripts' + 'application.js'), @asset_script.output_path
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_raw
|
|
62
|
+
expected = <<-SASS
|
|
63
|
+
SASS
|
|
64
|
+
assert_equal expected, @asset_style.raw
|
|
65
|
+
expected = <<-JS
|
|
66
|
+
(function ($) {
|
|
67
|
+
$(document).ready(function () {
|
|
68
|
+
});
|
|
69
|
+
})(jQuery);
|
|
70
|
+
JS
|
|
71
|
+
assert_equal expected.strip, @asset_script.raw
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_render
|
|
75
|
+
expected = <<-SASS
|
|
76
|
+
SASS
|
|
77
|
+
assert_equal expected, @asset_style.render
|
|
78
|
+
expected = <<-JS
|
|
79
|
+
(function ($) {
|
|
80
|
+
$(document).ready(function () {
|
|
81
|
+
});
|
|
82
|
+
})(jQuery);
|
|
83
|
+
JS
|
|
84
|
+
assert_equal expected, @asset_script.render
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_render_partial
|
|
88
|
+
expected = <<-SASS
|
|
89
|
+
SASS
|
|
90
|
+
assert_equal expected, @asset_style.render_partial
|
|
91
|
+
expected = <<-JS
|
|
92
|
+
(function ($) {
|
|
93
|
+
$(document).ready(function () {
|
|
94
|
+
});
|
|
95
|
+
})(jQuery);
|
|
96
|
+
JS
|
|
97
|
+
assert_equal expected, @asset_script.render_partial
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_route
|
|
101
|
+
assert_equal '/assets/classic/styles/all', @asset_style.route.url_path
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
5
|
+
require 'staticpress/helpers'
|
|
6
|
+
|
|
7
|
+
class HelpersTest < TestHelper
|
|
8
|
+
include Staticpress::Helpers
|
|
9
|
+
|
|
10
|
+
def test_extensionless_basename
|
|
11
|
+
assert_equal 'extensionless', extensionless_basename(Pathname.new('extensionless'))
|
|
12
|
+
assert_equal '.htaccess', extensionless_basename(Pathname.new('.htaccess'))
|
|
13
|
+
assert_equal 'tyrannasaurus_rex', extensionless_basename(Pathname.new('tyrannasaurus_rex.rb'))
|
|
14
|
+
assert_equal 'stegosaurus', extensionless_basename(Pathname.new('dinosaurs/stegosaurus.rb'))
|
|
15
|
+
assert_equal 'stegosaurus', extensionless_basename(Pathname.new('/dinosaurs/stegosaurus.rb'))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_extensionless_path
|
|
19
|
+
assert_equal Pathname.new('extensionless'), extensionless_path(Pathname.new('extensionless'))
|
|
20
|
+
assert_equal Pathname.new('.htaccess'), extensionless_path(Pathname.new('.htaccess'))
|
|
21
|
+
assert_equal Pathname.new('tyrannasaurus_rex'), extensionless_path(Pathname.new('tyrannasaurus_rex.rb'))
|
|
22
|
+
assert_equal Pathname.new('dinosaurs/stegosaurus'), extensionless_path(Pathname.new('dinosaurs/stegosaurus.rb'))
|
|
23
|
+
assert_equal Pathname.new('/dinosaurs/stegosaurus'), extensionless_path(Pathname.new('/dinosaurs/stegosaurus.rb'))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_hash_from_empty_array
|
|
27
|
+
actual = hash_from_array [] {}
|
|
28
|
+
assert_equal({}, actual)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_hash_from_array
|
|
32
|
+
expected = {
|
|
33
|
+
1 => { :key => 1 },
|
|
34
|
+
2 => { :key => 2 },
|
|
35
|
+
3 => { :key => 3 }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
actual = hash_from_array [
|
|
39
|
+
{ :key => 1 },
|
|
40
|
+
{ :key => 2 },
|
|
41
|
+
{ :key => 3 }
|
|
42
|
+
] { |hash| hash[:key] }
|
|
43
|
+
|
|
44
|
+
assert_equal expected, actual
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_paginate
|
|
48
|
+
assert_equal 3, paginate(:a..:z).count
|
|
49
|
+
assert_equal (:a..:j).to_a, paginate(:a..:z)[0]
|
|
50
|
+
assert_equal (:k..:t).to_a, paginate(:a..:z)[1]
|
|
51
|
+
assert_equal (:u..:z).to_a, paginate(:a..:z)[2]
|
|
52
|
+
assert_equal [], paginate(:a..:z)[5], 'Accessing an invalid index on anything that has been paginated should return an empty array'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_spider_directory
|
|
56
|
+
end
|
|
57
|
+
end
|