ruhoh 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/README.md +5 -53
- data/Rakefile +56 -0
- data/bin/ruhoh +23 -14
- data/lib/ruhoh/client/client.rb +310 -0
- data/lib/ruhoh/client/help.yml +56 -0
- data/lib/ruhoh/compiler.rb +16 -19
- data/lib/ruhoh/converters/converter.rb +30 -3
- data/lib/ruhoh/db.rb +7 -17
- data/lib/ruhoh/deployers/s3.rb +71 -0
- data/lib/ruhoh/friend.rb +71 -0
- data/lib/ruhoh/page.rb +41 -11
- data/lib/ruhoh/parsers/drafts.rb +54 -0
- data/lib/ruhoh/parsers/layouts.rb +14 -9
- data/lib/ruhoh/parsers/pages.rb +47 -35
- data/lib/ruhoh/parsers/partials.rb +14 -2
- data/lib/ruhoh/parsers/posts.rb +139 -88
- data/lib/ruhoh/parsers/routes.rb +4 -8
- data/lib/ruhoh/parsers/site.rb +2 -8
- data/lib/ruhoh/previewer.rb +48 -0
- data/lib/ruhoh/templaters/base.rb +53 -0
- data/lib/ruhoh/templaters/helpers.rb +159 -0
- data/lib/ruhoh/templaters/rmustache.rb +29 -0
- data/lib/ruhoh/utils.rb +25 -7
- data/lib/ruhoh/version.rb +1 -1
- data/lib/ruhoh/watch.rb +22 -9
- data/lib/ruhoh.rb +74 -29
- data/ruhoh.gemspec +70 -9
- data/scaffolds/blog/_config.yml +33 -0
- data/scaffolds/blog/_drafts/.gitkeep +0 -0
- data/scaffolds/blog/_posts/.gitkeep +0 -0
- data/scaffolds/blog/_site.yml +16 -0
- data/scaffolds/blog/_templates/partials/categories_list +3 -0
- data/scaffolds/blog/_templates/partials/pages_list +7 -0
- data/scaffolds/blog/_templates/partials/posts_collate +9 -0
- data/scaffolds/blog/_templates/partials/posts_list +1 -0
- data/scaffolds/blog/_templates/partials/tags_list +3 -0
- data/scaffolds/blog/_templates/syntax/google_prettify/default.css +52 -0
- data/scaffolds/blog/_templates/syntax/google_prettify/desert.css +34 -0
- data/scaffolds/blog/_templates/syntax/google_prettify/sons-of-obsidian.css +117 -0
- data/scaffolds/blog/_templates/syntax/google_prettify/sunburst.css +51 -0
- data/scaffolds/blog/_templates/syntax/google_prettify/twitter-bootstrap.css +30 -0
- data/scaffolds/blog/_templates/themes/twitter/bootstrap/css/bootstrap.min.css +689 -0
- data/scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings.png +0 -0
- data/scaffolds/blog/_templates/themes/twitter/css/style.css +68 -0
- data/scaffolds/blog/_templates/themes/twitter/layouts/default.html +64 -0
- data/scaffolds/blog/_templates/themes/twitter/layouts/page.html +13 -0
- data/scaffolds/blog/_templates/themes/twitter/layouts/post.html +55 -0
- data/scaffolds/blog/_templates/themes/twitter/manifest.yml +11 -0
- data/scaffolds/blog/about.md +5 -0
- data/scaffolds/blog/archive.html +11 -0
- data/scaffolds/blog/categories.html +21 -0
- data/scaffolds/blog/config.ru +9 -0
- data/scaffolds/blog/index.html +13 -0
- data/scaffolds/blog/pages.html +14 -0
- data/scaffolds/blog/tags.html +21 -0
- data/scaffolds/layout.html +3 -0
- data/scaffolds/page.html +6 -0
- data/scaffolds/post.html +8 -0
- data/scaffolds/theme/css/style.css +0 -0
- data/scaffolds/theme/images/.gitkeep +0 -0
- data/scaffolds/theme/layouts/default.html +17 -0
- data/scaffolds/theme/layouts/page.html +7 -0
- data/scaffolds/theme/layouts/post.html +8 -0
- data/scaffolds/theme/partials/.gitkeep +0 -0
- data/spec/db_spec.rb +88 -0
- data/spec/page_spec.rb +200 -0
- data/spec/parsers/layouts_spec.rb +32 -0
- data/spec/parsers/pages_spec.rb +97 -0
- data/spec/parsers/posts_spec.rb +301 -0
- data/spec/parsers/routes_spec.rb +45 -0
- data/spec/parsers/site_spec.rb +32 -0
- data/spec/setup_spec.rb +72 -0
- data/spec/spec_helper.rb +23 -0
- data/system_partials/analytics/getclicky +12 -0
- data/system_partials/analytics/google +11 -0
- data/system_partials/comments/disqus +13 -0
- data/system_partials/comments/facebook +9 -0
- data/system_partials/comments/intensedebate +6 -0
- data/system_partials/comments/livefyre +6 -0
- data/system_partials/syntax/google_prettify +11 -0
- metadata +84 -23
- data/lib/ruhoh/client.rb +0 -28
- data/lib/ruhoh/preview.rb +0 -36
- data/lib/ruhoh/templaters/helper_mustache.rb +0 -109
- data/lib/ruhoh/templaters/templater.rb +0 -39
Binary file
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* Override some defaults */
|
2
|
+
html, body {
|
3
|
+
background-color: #eee;
|
4
|
+
}
|
5
|
+
.navbar {
|
6
|
+
margin-bottom: 0;
|
7
|
+
}
|
8
|
+
.navbar .container{
|
9
|
+
width:940px;
|
10
|
+
}
|
11
|
+
.container > footer {
|
12
|
+
margin-top: 20px;
|
13
|
+
}
|
14
|
+
.container > footer p {
|
15
|
+
text-align: center; /* center align it with the container */
|
16
|
+
}
|
17
|
+
|
18
|
+
/* The white background content wrapper */
|
19
|
+
.content {
|
20
|
+
background-color: #fff;
|
21
|
+
padding: 20px;
|
22
|
+
margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */
|
23
|
+
-webkit-border-radius: 0 0 6px 6px;
|
24
|
+
-moz-border-radius: 0 0 6px 6px;
|
25
|
+
border-radius: 0 0 6px 6px;
|
26
|
+
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
|
27
|
+
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
|
28
|
+
box-shadow: 0 1px 2px rgba(0,0,0,.15);
|
29
|
+
}
|
30
|
+
|
31
|
+
/* Page header tweaks */
|
32
|
+
.page-header {
|
33
|
+
background-color: #f5f5f5;
|
34
|
+
padding: 20px 20px 10px;
|
35
|
+
margin: -20px -20px 20px;
|
36
|
+
}
|
37
|
+
|
38
|
+
/* tag_box ======================================================== */
|
39
|
+
|
40
|
+
.tag_box {
|
41
|
+
list-style:none;
|
42
|
+
margin:0;
|
43
|
+
padding:5px 0 ;
|
44
|
+
overflow:hidden;
|
45
|
+
}
|
46
|
+
.tag_box li {
|
47
|
+
line-height:28px;
|
48
|
+
}
|
49
|
+
.tag_box.inline li {
|
50
|
+
float:left;
|
51
|
+
}
|
52
|
+
.tag_box a {
|
53
|
+
padding: 3px 6px;
|
54
|
+
margin: 2px;
|
55
|
+
background: #eee;
|
56
|
+
color:#005F6B;
|
57
|
+
border-radius: 3px;
|
58
|
+
text-decoration:none;
|
59
|
+
}
|
60
|
+
.tag_box a span{
|
61
|
+
vertical-align:super;
|
62
|
+
font-size:0.8em;
|
63
|
+
}
|
64
|
+
.tag_box a.active {
|
65
|
+
background:#57A957;
|
66
|
+
border:1px solid #4C964D;
|
67
|
+
color:#FFF;
|
68
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
<!DOCTYPE html>
|
4
|
+
<html lang="en">
|
5
|
+
<head>
|
6
|
+
<meta charset="utf-8">
|
7
|
+
<title>{{ page.title }}</title>
|
8
|
+
{{# page.description }}
|
9
|
+
<meta name="description" content="{{ . }}">
|
10
|
+
{{/ page.description }}
|
11
|
+
<meta name="author" content="{{ site.author.name }}">
|
12
|
+
|
13
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
14
|
+
<!--[if lt IE 9]>
|
15
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
16
|
+
<![endif]-->
|
17
|
+
|
18
|
+
<!-- Le styles -->
|
19
|
+
<link href="{{ THEME_PATH }}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
20
|
+
<link href="{{ THEME_PATH }}/css/style.css?body=1" rel="stylesheet" type="text/css" media="all">
|
21
|
+
|
22
|
+
<!-- Le fav and touch icons -->
|
23
|
+
<!-- Update these with your own images
|
24
|
+
<link rel="shortcut icon" href="images/favicon.ico">
|
25
|
+
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
|
26
|
+
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
|
27
|
+
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
|
28
|
+
-->
|
29
|
+
</head>
|
30
|
+
|
31
|
+
<body>
|
32
|
+
|
33
|
+
<div class="navbar">
|
34
|
+
<div class="navbar-inner">
|
35
|
+
<div class="container">
|
36
|
+
<a class="brand" href="/">{{ site.title }}</a>
|
37
|
+
<ul class="nav">
|
38
|
+
{{# site.navigation?to_pages }}
|
39
|
+
{{> pages_list }}
|
40
|
+
{{/ site.navigation?to_pages }}
|
41
|
+
</ul>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div class="container">
|
47
|
+
|
48
|
+
<div class="content">
|
49
|
+
{{ content }}
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<footer>
|
53
|
+
<p>© {{ site.author.name }} 2012
|
54
|
+
with help from <a href="http://ruhoh.com" target="_blank" title="The Definitive Technical Blogging Framework">ruhoh</a>
|
55
|
+
and <a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap</a>
|
56
|
+
</p>
|
57
|
+
</footer>
|
58
|
+
|
59
|
+
</div> <!-- /container -->
|
60
|
+
|
61
|
+
{{{ syntax }}}
|
62
|
+
{{{ analytics }}}
|
63
|
+
</body>
|
64
|
+
</html>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
layout : default
|
3
|
+
---
|
4
|
+
<div class="page-header">
|
5
|
+
<h1>{{ page.title }} {{# page.tagline }} <small>{{ . }}</small>{{/ page.tagline }}</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="row">
|
9
|
+
<div class="span8">
|
10
|
+
{{ content }}
|
11
|
+
<hr>
|
12
|
+
<div class="pagination">
|
13
|
+
<ul>
|
14
|
+
<ul>
|
15
|
+
{{# page?previous }}
|
16
|
+
<li class="prev"><a href="{{ url }}" title="{{ title }}">← Previous</a></li>
|
17
|
+
{{/ page?previous }}
|
18
|
+
{{^ page?previous }}
|
19
|
+
<li class="prev disabled"><a>← Previous</a></li>
|
20
|
+
{{/ page?previous }}
|
21
|
+
|
22
|
+
<li><a href="/archive.html">Archive</a></li>
|
23
|
+
|
24
|
+
{{# page?next }}
|
25
|
+
<li class="next"><a href="{{ url }}" title="{{ title }}">Next →</a></li>
|
26
|
+
{{/ page?next }}
|
27
|
+
{{^ page?next }}
|
28
|
+
<li class="next disabled"><a>Next →</a>
|
29
|
+
{{/ page?next }}
|
30
|
+
</ul>
|
31
|
+
</ul>
|
32
|
+
</div>
|
33
|
+
<hr>
|
34
|
+
{{{ comments }}}
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="span4">
|
38
|
+
<h4>Published</h4>
|
39
|
+
<div class="date"><span>{{ page.date }}</span></div>
|
40
|
+
<br>
|
41
|
+
<h4>Categories</h4>
|
42
|
+
<ul class="tag_box">
|
43
|
+
{{# page.categories?to_categories }}
|
44
|
+
{{> categories_list }}
|
45
|
+
{{/ page.categories?to_categories }}
|
46
|
+
</ul>
|
47
|
+
<br>
|
48
|
+
<h4>Tags</h4>
|
49
|
+
<ul class="tag_box">
|
50
|
+
{{# page.tags?to_tags }}
|
51
|
+
{{> tags_list }}
|
52
|
+
{{/ page.tags?to_tags }}
|
53
|
+
</ul>
|
54
|
+
</div>
|
55
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
name : twitter
|
3
|
+
website : http://twitter.github.com/bootstrap
|
4
|
+
git_url : git://github.com/ruhoh/theme-twitter.git
|
5
|
+
source_url : https://github.com/ruhoh/theme-twitter
|
6
|
+
author:
|
7
|
+
name : "Jacob Thornton and Mark Otto"
|
8
|
+
website : http://twitter.github.com/bootstrap
|
9
|
+
|
10
|
+
ruhoh:
|
11
|
+
version: '0.0.x'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: Categories
|
4
|
+
header: Posts By Category
|
5
|
+
group: navigation
|
6
|
+
---
|
7
|
+
|
8
|
+
<ul class="tag_box inline">
|
9
|
+
{{# ?to_categories }}
|
10
|
+
{{> categories_list }}
|
11
|
+
{{/ ?to_categories }}
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
{{# ?to_categories }}
|
15
|
+
<h2>{{ name }} ({{ count }})</h2>
|
16
|
+
<ul>
|
17
|
+
{{# posts?to_posts }}
|
18
|
+
{{> posts_list }}
|
19
|
+
{{/ posts?to_posts }}
|
20
|
+
</ul>
|
21
|
+
{{/ ?to_categories }}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: Tags
|
4
|
+
header: Posts By Tag
|
5
|
+
group: navigation
|
6
|
+
---
|
7
|
+
|
8
|
+
|
9
|
+
<ul class="tag_box inline">
|
10
|
+
{{# ?to_tags }}
|
11
|
+
{{> tags_list }}
|
12
|
+
{{/ ?to_tags }}
|
13
|
+
</ul>
|
14
|
+
|
15
|
+
|
16
|
+
{{# ?to_tags }}
|
17
|
+
<h2 id="{{name}}-ref">{{name}}</h2>
|
18
|
+
{{# posts?to_posts }}
|
19
|
+
<li><a href="{{url}}">{{title}}</a></li>
|
20
|
+
{{/ posts?to_posts }}
|
21
|
+
{{/ ?to_tags }}
|
data/scaffolds/page.html
ADDED
data/scaffolds/post.html
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
<!DOCTYPE html>
|
4
|
+
<html lang="en">
|
5
|
+
<head>
|
6
|
+
<meta charset="utf-8">
|
7
|
+
<link href="{{ THEME_PATH }}/css/style.css" rel="stylesheet" type="text/css" media="all">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<div class="content">
|
12
|
+
{{ content }}
|
13
|
+
</div>
|
14
|
+
|
15
|
+
{{{ analytics }}}
|
16
|
+
</body>
|
17
|
+
</html>
|
File without changes
|
data/spec/db_spec.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DB
|
4
|
+
|
5
|
+
describe Ruhoh::DB do
|
6
|
+
let(:whitelist){
|
7
|
+
[:site, :routes, :posts, :pages, :layouts, :partials]
|
8
|
+
}
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
Ruhoh::Utils.stub(:parse_file_as_yaml).and_return({'theme' => "twitter"})
|
12
|
+
Ruhoh.setup(SampleSitePath)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "database has not been updated" do
|
16
|
+
it "should return nil for all whitelisted variables" do
|
17
|
+
whitelist.each do |var|
|
18
|
+
result = Ruhoh::DB.__send__ var
|
19
|
+
result.should be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#update" do
|
25
|
+
|
26
|
+
it "should raise an exception when updating a variable not whitelisted" do
|
27
|
+
lambda { Ruhoh::DB.update(:table) }.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should run the site parser when updating :site, then set the variable to the result" do
|
31
|
+
Ruhoh::Parsers::Site.should_receive(:generate).and_return({'test' => 'hi'})
|
32
|
+
Ruhoh::DB.update(:site)
|
33
|
+
Ruhoh::DB.site.should == {'test' => 'hi'}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should run the routes parser when updating :routes" do
|
37
|
+
Ruhoh::Parsers::Routes.should_receive(:generate).and_return({'test' => 'hi'})
|
38
|
+
Ruhoh::DB.update(:routes)
|
39
|
+
Ruhoh::DB.routes.should == {'test' => 'hi'}
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should run the posts parser when updating :posts" do
|
43
|
+
Ruhoh::Parsers::Posts.should_receive(:generate).and_return({'test' => 'hi'})
|
44
|
+
Ruhoh::DB.update(:posts)
|
45
|
+
Ruhoh::DB.posts.should == {'test' => 'hi'}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should run the drafts parser when updating :drafts" do
|
49
|
+
Ruhoh::Parsers::Drafts.should_receive(:generate).and_return({'test' => 'hi'})
|
50
|
+
Ruhoh::DB.update(:drafts)
|
51
|
+
Ruhoh::DB.drafts.should == {'test' => 'hi'}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should run the pages parser when updating :pages" do
|
55
|
+
Ruhoh::Parsers::Pages.should_receive(:generate).and_return({'test' => 'hi'})
|
56
|
+
Ruhoh::DB.update(:pages)
|
57
|
+
Ruhoh::DB.pages.should == {'test' => 'hi'}
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should run the layouts parser when updating :layouts" do
|
61
|
+
Ruhoh::Parsers::Layouts.should_receive(:generate).and_return({'test' => 'hi'})
|
62
|
+
Ruhoh::DB.update(:layouts)
|
63
|
+
Ruhoh::DB.layouts.should == {'test' => 'hi'}
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should run the partials parser when updating :partials" do
|
67
|
+
Ruhoh::Parsers::Partials.should_receive(:generate).and_return({'test' => 'hi'})
|
68
|
+
Ruhoh::DB.update(:partials)
|
69
|
+
Ruhoh::DB.partials.should == {'test' => 'hi'}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#update!" do
|
74
|
+
it "should call update for all WhiteListed variables." do
|
75
|
+
Ruhoh::DB.should_receive(:update).with(:site).ordered
|
76
|
+
Ruhoh::DB.should_receive(:update).with(:posts).ordered
|
77
|
+
Ruhoh::DB.should_receive(:update).with(:drafts).ordered
|
78
|
+
Ruhoh::DB.should_receive(:update).with(:pages).ordered
|
79
|
+
Ruhoh::DB.should_receive(:update).with(:routes).ordered
|
80
|
+
Ruhoh::DB.should_receive(:update).with(:layouts).ordered
|
81
|
+
Ruhoh::DB.should_receive(:update).with(:partials).ordered
|
82
|
+
Ruhoh::DB.update!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
data/spec/page_spec.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Page
|
4
|
+
|
5
|
+
describe Ruhoh::Page do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Ruhoh::Utils.stub(:parse_file_as_yaml).and_return({'theme' => "twitter"})
|
9
|
+
Ruhoh.setup(SampleSitePath)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "Page initialization" do
|
13
|
+
it "should setup default templater and converter" do
|
14
|
+
page = Ruhoh::Page.new
|
15
|
+
|
16
|
+
page.templater.should == Ruhoh::Templaters::Base
|
17
|
+
page.converter.should == Ruhoh::Converter
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#change" do
|
22
|
+
let(:page){ Ruhoh::Page.new }
|
23
|
+
let(:posts) {
|
24
|
+
{
|
25
|
+
"dictionary" => {
|
26
|
+
"_posts/sample-id.md" => {"title" => "a cool title"}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
let(:pages) {
|
31
|
+
{
|
32
|
+
"about/index.md" => {"title" => "about me =)"}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
context "A page with invalid id" do
|
37
|
+
it "should raise error" do
|
38
|
+
lambda { page.change('some-id.md') }.should raise_error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "A page with valid id" do
|
43
|
+
context "belonging to a post" do
|
44
|
+
before(:all) do
|
45
|
+
Ruhoh::Parsers::Posts.stub(:generate).and_return(posts)
|
46
|
+
Ruhoh::DB.update(:posts)
|
47
|
+
page.change("_posts/sample-id.md")
|
48
|
+
end
|
49
|
+
it "should query the posts dictionary and set @data to result" do
|
50
|
+
page.data.should == {"title" => "a cool title"}
|
51
|
+
end
|
52
|
+
it "should set @id to the valid id" do
|
53
|
+
page.id.should == "_posts/sample-id.md"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "belonging to a page" do
|
58
|
+
before(:all) do
|
59
|
+
Ruhoh::Parsers::Pages.stub(:generate).and_return(pages)
|
60
|
+
Ruhoh::DB.update(:pages)
|
61
|
+
page.change("about/index.md")
|
62
|
+
end
|
63
|
+
it "should query the pages dictionary and set @data to result." do
|
64
|
+
page.data.should == {"title" => "about me =)"}
|
65
|
+
end
|
66
|
+
it "should set @id to the valid id" do
|
67
|
+
page.id.should == "about/index.md"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#change_with_url" do
|
76
|
+
let(:page){ Ruhoh::Page.new }
|
77
|
+
|
78
|
+
context "An invalid URL" do
|
79
|
+
it "should raise error" do
|
80
|
+
lambda { page.change_with_url('/cool-url') }.should raise_error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "A valid URL" do
|
85
|
+
let(:routes){
|
86
|
+
{ "/super/cool/page-id.html" => "page-id.md" }
|
87
|
+
}
|
88
|
+
before(:all) do
|
89
|
+
Ruhoh::Parsers::Routes.stub(:generate).and_return(routes)
|
90
|
+
Ruhoh::DB.update(:routes)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should call self.change with the proper id from the routes hash" do
|
94
|
+
page.should_receive(:change).with("page-id.md")
|
95
|
+
page.change_with_url("/super/cool/page-id.html")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#render" do
|
101
|
+
let(:page){ Ruhoh::Page.new }
|
102
|
+
it "should raise error if id not set" do
|
103
|
+
lambda{ page.render }.should raise_error
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should process layouts, content, then render using the @templater" do
|
107
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {}})
|
108
|
+
page.change('blah.md')
|
109
|
+
|
110
|
+
page.should_receive(:process_layouts)
|
111
|
+
page.should_receive(:process_content)
|
112
|
+
page.templater.should_receive(:render).with(page)
|
113
|
+
page.render
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
pending "#process_layouts"
|
118
|
+
|
119
|
+
describe "#process_content" do
|
120
|
+
let(:page){ Ruhoh::Page.new }
|
121
|
+
|
122
|
+
it "should raise error if id not set" do
|
123
|
+
lambda{ page.process_content }.should raise_error
|
124
|
+
end
|
125
|
+
|
126
|
+
context "Id has been set" do
|
127
|
+
# Set the id
|
128
|
+
before(:all) do
|
129
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {}})
|
130
|
+
page.change('blah.md')
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should raise an error if the page file is malformed" do
|
134
|
+
Ruhoh::Utils.should_receive(:parse_file).and_return({})
|
135
|
+
lambda { page.process_content }.should raise_error
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should send the files content to the templater" do
|
139
|
+
Ruhoh::Utils.should_receive(:parse_file).and_return({"content" => "meep"})
|
140
|
+
page.templater.should_receive(:parse).with("meep", page)
|
141
|
+
page.converter.stub(:convert)
|
142
|
+
page.process_content
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should send the page to the converter, then set the result as @content" do
|
146
|
+
Ruhoh::Utils.should_receive(:parse_file).and_return({"content" => "meep"})
|
147
|
+
page.templater.stub(:parse)
|
148
|
+
page.converter.should_receive(:convert).with(page).and_return("yay")
|
149
|
+
page.process_content
|
150
|
+
page.content.should == "yay"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#attributes" do
|
156
|
+
let(:page){ Ruhoh::Page.new }
|
157
|
+
|
158
|
+
it "should raise error if id not set" do
|
159
|
+
lambda{ page.attributes }.should raise_error
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be a hash with content value set" do
|
163
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {}})
|
164
|
+
page.change('blah.md')
|
165
|
+
|
166
|
+
page.attributes.should be_a_kind_of Hash
|
167
|
+
page.attributes.should have_key("content")
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#compiled_path" do
|
173
|
+
let(:page){ Ruhoh::Page.new }
|
174
|
+
|
175
|
+
it "should raise error if id not set" do
|
176
|
+
lambda{ page.compiled_path }.should raise_error
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should return a relative filepath (no leading slash)" do
|
180
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {"url" => "/super/cool/blah-post.html"}})
|
181
|
+
page.change('blah.md')
|
182
|
+
page.compiled_path.should == "super/cool/blah-post.html"
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should CGI.unescape the url ensure the filepath is correct." do
|
186
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {"url" => "/super/cool/%21blah-post%3D%29.html"}})
|
187
|
+
page.change('blah.md')
|
188
|
+
page.compiled_path.should == "super/cool/!blah-post=).html"
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should specify an index.html file if url does not end in an .html extension" do
|
192
|
+
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {"url" => "/super/cool/blah-post"}})
|
193
|
+
page.change('blah.md')
|
194
|
+
page.compiled_path.should == "super/cool/blah-post/index.html"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|