bluemark-smallcage 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +48 -0
- data/License.txt +20 -0
- data/README.txt +1 -0
- data/Rakefile +140 -0
- data/bin/smc +16 -0
- data/lib/smallcage.rb +18 -0
- data/lib/smallcage/application.rb +164 -0
- data/lib/smallcage/commands/auto.rb +158 -0
- data/lib/smallcage/commands/base.rb +19 -0
- data/lib/smallcage/commands/clean.rb +32 -0
- data/lib/smallcage/commands/export.rb +41 -0
- data/lib/smallcage/commands/import.rb +217 -0
- data/lib/smallcage/commands/manifest.rb +39 -0
- data/lib/smallcage/commands/server.rb +15 -0
- data/lib/smallcage/commands/update.rb +121 -0
- data/lib/smallcage/document_path.rb +46 -0
- data/lib/smallcage/erb_base.rb +16 -0
- data/lib/smallcage/http_server.rb +66 -0
- data/lib/smallcage/loader.rb +278 -0
- data/lib/smallcage/misc.rb +13 -0
- data/lib/smallcage/renderer.rb +19 -0
- data/lib/smallcage/resources/Manifest.erb +19 -0
- data/lib/smallcage/resources/auto.html +119 -0
- data/lib/smallcage/runner.rb +51 -0
- data/lib/smallcage/version.rb +9 -0
- data/project/base/_smc/helpers/base_helper.rb +41 -0
- data/project/base/_smc/helpers/site_helper.rb +5 -0
- data/project/base/_smc/templates/default.rhtml +5 -0
- data/project/base/_smc/templates/footer.rhtml +0 -0
- data/project/base/_smc/templates/header.rhtml +0 -0
- data/project/bluecloth/_smc/helpers/blue_cloth_helper.rb +10 -0
- data/project/bluecloth/_smc/templates/markdown.rhtml +5 -0
- data/project/lang/_smc/helpers/lang_helper.rb +19 -0
- data/project/lang/_smc/templates/other_lang.rhtml +6 -0
- data/project/news/_smc/helpers/news_helper.rb +36 -0
- data/project/nkf/_smc/filters/filters.yml +3 -0
- data/project/nkf/_smc/filters/nkf_filter.rb +15 -0
- data/project/rake/_smc/Rakefile +68 -0
- data/project/redcloth/_smc/helpers/red_cloth_helper.rb +10 -0
- data/project/redcloth/_smc/templates/textile.rhtml +5 -0
- data/project/relpath/_smc/filters/filters.yml +2 -0
- data/project/relpath/_smc/filters/relpath_filter.rb +13 -0
- data/project/standard/_dir.smc +2 -0
- data/project/standard/_smc/helpers/base_helper.rb +34 -0
- data/project/standard/_smc/helpers/menu_helper.rb +23 -0
- data/project/standard/_smc/templates/default.rhtml +5 -0
- data/project/standard/_smc/templates/footer.rhtml +13 -0
- data/project/standard/_smc/templates/header.rhtml +37 -0
- data/project/standard/_smc/templates/menu.rhtml +6 -0
- data/project/standard/_smc/templates/redirect.rhtml +13 -0
- data/project/standard/_smc/templates/sidebar.rhtml +7 -0
- data/project/standard/_smc/templates/topic_path.rhtml +6 -0
- data/project/standard/common/css/default.css +145 -0
- data/project/standard/common/css/print.css +0 -0
- data/project/standard/index.html.smc +3 -0
- data/project/standard/sample/_dir.smc +1 -0
- data/project/standard/sample/index.html.smc +7 -0
- data/project/standard/sample/redirect.html.smc +2 -0
- data/project/standard/sample/sub/_dir.smc +1 -0
- data/project/standard/sample/sub/contents.html.smc +3 -0
- data/project/standard/sample/sub/index.html.smc +7 -0
- data/spec/data/htdocs1/_dir.smc +0 -0
- data/spec/data/htdocs1/a/b/c/index.html.smc +6 -0
- data/spec/data/htdocs2/_smc/templates/dummy.rhtml +0 -0
- data/spec/data/htdocs2/a/b/c/test.html +1 -0
- data/spec/data/htdocs2/a/b/test.html +1 -0
- data/spec/data/htdocs2/a/test.html.smc +2 -0
- data/spec/document_path_spec.rb +42 -0
- data/spec/export_spec.rb +45 -0
- data/spec/import_spec.rb +20 -0
- data/spec/loader_spec.rb +55 -0
- data/spec/manifest_spec.rb +39 -0
- data/spec/misc_spec.rb +25 -0
- data/spec/smallcage_spec.rb +40 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/test/test_helper.rb +2 -0
- data/test/test_smallcage.rb +11 -0
- metadata +193 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module SmallCage
|
|
2
|
+
module BaseHelper
|
|
3
|
+
include ERB::Util
|
|
4
|
+
|
|
5
|
+
def _glob(relpath, rex)
|
|
6
|
+
base_dir = Pathname.new(@obj["path"]).parent
|
|
7
|
+
base_dir = base_dir.join(relpath)
|
|
8
|
+
|
|
9
|
+
entries = Dir.glob("#{base_dir}/**/*")
|
|
10
|
+
result = []
|
|
11
|
+
entries.each do |path|
|
|
12
|
+
result << path if path.to_s =~ rex
|
|
13
|
+
end
|
|
14
|
+
return result.sort
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def _with(o)
|
|
18
|
+
tmpobj = @obj
|
|
19
|
+
@obj = o
|
|
20
|
+
yield
|
|
21
|
+
@obj = tmpobj
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def _load(path)
|
|
25
|
+
path = Pathname.new(path)
|
|
26
|
+
@loader.load(path)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def _erb(body)
|
|
30
|
+
@renderer.render_string(body, @obj)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module SmallCage
|
|
2
|
+
module MenuHelper
|
|
3
|
+
|
|
4
|
+
def menu_active(name)
|
|
5
|
+
p = @obj["menu_path"]
|
|
6
|
+
p ||= @obj["uri"]
|
|
7
|
+
return p =~ %r{^/#{name}/} ? "active" : "inactive"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def menu_active_rex(rex)
|
|
11
|
+
p = @obj["menu_path"]
|
|
12
|
+
p ||= @obj["uri"]
|
|
13
|
+
return p =~ rex ? "active" : "inactive"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def topic_dirs
|
|
17
|
+
result = @obj["dirs"].dup
|
|
18
|
+
result.reject! {|d| d["topic"].nil? }
|
|
19
|
+
return result
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja-JP" lang="ja-JP">
|
|
4
|
+
<head>
|
|
5
|
+
|
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
7
|
+
<meta name="keywords" content="" />
|
|
8
|
+
<%- unless description.nil? -%>
|
|
9
|
+
<meta name="description" content="<%=h description %>" />
|
|
10
|
+
<%- end -%>
|
|
11
|
+
|
|
12
|
+
<link rev="made" href="mailto:info@example.com" />
|
|
13
|
+
<link rel="index" href="./index.html" />
|
|
14
|
+
<link rel="stylesheet" type="text/css" href="/common/css/default.css" media="screen"/>
|
|
15
|
+
<link rel="stylesheet" type="text/css" href="/common/css/print.css" media="print" />
|
|
16
|
+
<link rel="shortcut icon" href="/common/favicon.ico" />
|
|
17
|
+
|
|
18
|
+
<title><% unless title.to_s.empty? %><%=h title %> | <% end %>Standard Site Template</title>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="container">
|
|
22
|
+
|
|
23
|
+
<div id="header">
|
|
24
|
+
<h1 class="site_title"><a href="/index.html">SmallCage</a></h1>
|
|
25
|
+
<h2 class="description">Lightweight CMS Package.</h2>
|
|
26
|
+
<%= menu %>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<div id="topic_path">
|
|
31
|
+
<%= topic_path %>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<div id="main">
|
|
36
|
+
<div class="contents">
|
|
37
|
+
<% unless title.to_s.empty? %><h1><%=h title %></h1><% end %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja-JP" lang="ja-JP">
|
|
6
|
+
<head>
|
|
7
|
+
<title></title>
|
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
9
|
+
<meta http-equiv="refresh" content="0;URL=<%= redirect_uri %>">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
@charset "utf-8";
|
|
2
|
+
|
|
3
|
+
* {
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
a:link { text-decoration: none; color:#03c; }
|
|
9
|
+
a:visited { text-decoration: none; color:#03c; }
|
|
10
|
+
a:hover { text-decoration: none; color:#fff; background: #03c}
|
|
11
|
+
a:active { text-decoration: none; color:#03c; background: #fff}
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
line-height: 1.7em;
|
|
15
|
+
font-family:Helvetica, sans-serif;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#container {
|
|
19
|
+
height: 100%;
|
|
20
|
+
min-width:760px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#header {
|
|
24
|
+
background: #03c;
|
|
25
|
+
color: #FFF;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#header a:link { text-decoration: none; color:#fff; }
|
|
31
|
+
#header a:visited { text-decoration: none; color:#fff; }
|
|
32
|
+
#header a:hover { text-decoration: none; color:#fff; background: none}
|
|
33
|
+
#header a:active { text-decoration: none; color: none; background: none}
|
|
34
|
+
|
|
35
|
+
#header h1.site_title,
|
|
36
|
+
#header h2.site_title {
|
|
37
|
+
font-weight: normal;
|
|
38
|
+
font-size: 2em;
|
|
39
|
+
margin: 0.9em 0.9em 0.6em 0.9em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#header h2.description,
|
|
43
|
+
#header h3.description {
|
|
44
|
+
font-size: 1em;
|
|
45
|
+
font-weight: normal;
|
|
46
|
+
margin: 0 1.8em 1.8em 1.8em;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#menu li {
|
|
50
|
+
display: inline;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#menu a{
|
|
54
|
+
padding: 0.6em 1.8em 0.6em 1.8em;
|
|
55
|
+
background: #36f;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#menu a:hover{
|
|
59
|
+
color:#03c;
|
|
60
|
+
background: #fff;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#menu .active a,
|
|
64
|
+
#menu .active a:active{
|
|
65
|
+
color:#03c;
|
|
66
|
+
background: #eee
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#topic_path {
|
|
70
|
+
padding: 0.3em 1.8em 0.3em 1.8em;
|
|
71
|
+
margin-bottom: 1.2em;
|
|
72
|
+
background: #eee;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#topic_path .delimiter {
|
|
76
|
+
color: black;
|
|
77
|
+
margin-left: 0.3em;
|
|
78
|
+
margin-right: 0.3em;
|
|
79
|
+
font-size: 0.85em;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#topic_path a {
|
|
83
|
+
font-size: 0.85em;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#main {
|
|
87
|
+
float: left;
|
|
88
|
+
width: 100%;
|
|
89
|
+
margin-right : -12em;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
#main .contents {
|
|
93
|
+
padding: 0 1.8em 1.8em 1.8em;
|
|
94
|
+
margin-right: 12em;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#main h1{
|
|
98
|
+
margin-bottom: 0.9em;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#main h2{
|
|
102
|
+
font-size: 1.2em;
|
|
103
|
+
margin-bottom: 0.3em;
|
|
104
|
+
font-weight: bold;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#main h3{
|
|
108
|
+
font-size: 1em;
|
|
109
|
+
font-weight: bold;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#main p{
|
|
113
|
+
margin-bottom: 1.8em;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#main ul{
|
|
117
|
+
margin-left: 1.2em;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#sidebar{
|
|
121
|
+
float: right;
|
|
122
|
+
width: 12em;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#sidebar h2{
|
|
126
|
+
font-size: 1.2em;
|
|
127
|
+
margin-bottom: .3em;
|
|
128
|
+
font-weight: bold;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#sidebar ul{
|
|
132
|
+
margin-left: 1.2em;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#footer {
|
|
136
|
+
clear: both;
|
|
137
|
+
padding: 1.2em 0 1.2em 0;
|
|
138
|
+
margin-top: 24em;
|
|
139
|
+
font-size: 0.85em;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#footer .copyright{
|
|
143
|
+
margin-left: 1.8em;
|
|
144
|
+
font-size: 85%;
|
|
145
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topic: Sample
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topic: Subcategory
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
require 'smallcage'
|
|
3
|
+
|
|
4
|
+
describe SmallCage::DocumentPath do
|
|
5
|
+
root = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@docpath = SmallCage::DocumentPath.new(root, root + "a/b/c/index.html.smc")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should have uri property" do
|
|
12
|
+
@docpath.uri.should == "/a/b/c/index.html.smc"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return smc file or not" do
|
|
16
|
+
@docpath.smc?.should be_true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should return output file" do
|
|
20
|
+
out = @docpath.outfile
|
|
21
|
+
out.should be_an_instance_of(SmallCage::DocumentPath)
|
|
22
|
+
out.path.basename.to_s.should == "index.html"
|
|
23
|
+
out.path.to_s.should match(%r{^/.+/a/b/c/index.html$})
|
|
24
|
+
@docpath.path.to_s[0..-5].should == out.path.to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should return output file uri" do
|
|
28
|
+
out = @docpath.outuri
|
|
29
|
+
out.should == "/a/b/c/index.html"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return root uri" do
|
|
33
|
+
docpath = SmallCage::DocumentPath.new(root, root)
|
|
34
|
+
docpath.uri.should == "/"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should return directory uri" do
|
|
38
|
+
docpath = SmallCage::DocumentPath.new(root, root + "a/b")
|
|
39
|
+
docpath.uri.should == "/a/b"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
data/spec/export_spec.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
require 'smallcage'
|
|
3
|
+
|
|
4
|
+
describe "SmallCage::Commands::Export" do
|
|
5
|
+
|
|
6
|
+
docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs2")
|
|
7
|
+
outdir = Pathname.new(File.dirname(__FILE__) + "/data/out")
|
|
8
|
+
|
|
9
|
+
it "should export not smc files" do
|
|
10
|
+
begin
|
|
11
|
+
opts = { :command => "export",
|
|
12
|
+
:path => docroot.to_s,
|
|
13
|
+
:out => outdir.to_s,
|
|
14
|
+
:quiet => true }
|
|
15
|
+
SmallCage::Runner.run(opts)
|
|
16
|
+
|
|
17
|
+
(outdir + "./a/test.html.smc").exist?.should_not be_true
|
|
18
|
+
(outdir + "./a/test.html").exist?.should_not be_true
|
|
19
|
+
(outdir + "./a/b/test.html").exist?.should be_true
|
|
20
|
+
(outdir + "./a/b/c/test.html").exist?.should be_true
|
|
21
|
+
ensure
|
|
22
|
+
FileUtils.rm_r(outdir)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should export project subdirectory" do
|
|
27
|
+
begin
|
|
28
|
+
path = docroot + "a/b/c"
|
|
29
|
+
opts = { :command => "export",
|
|
30
|
+
:path => path.to_s,
|
|
31
|
+
:out => outdir.to_s,
|
|
32
|
+
:quiet => true }
|
|
33
|
+
SmallCage::Runner.run(opts)
|
|
34
|
+
|
|
35
|
+
(outdir + "./a/test.html.smc").exist?.should_not be_true
|
|
36
|
+
(outdir + "./a/test.html").exist?.should_not be_true
|
|
37
|
+
(outdir + "./a/b/test.html").exist?.should_not be_true
|
|
38
|
+
|
|
39
|
+
(outdir + "./a/b/c/test.html").exist?.should be_true
|
|
40
|
+
ensure
|
|
41
|
+
FileUtils.rm_r(outdir)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|