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.
Files changed (79) hide show
  1. data/History.txt +48 -0
  2. data/License.txt +20 -0
  3. data/README.txt +1 -0
  4. data/Rakefile +140 -0
  5. data/bin/smc +16 -0
  6. data/lib/smallcage.rb +18 -0
  7. data/lib/smallcage/application.rb +164 -0
  8. data/lib/smallcage/commands/auto.rb +158 -0
  9. data/lib/smallcage/commands/base.rb +19 -0
  10. data/lib/smallcage/commands/clean.rb +32 -0
  11. data/lib/smallcage/commands/export.rb +41 -0
  12. data/lib/smallcage/commands/import.rb +217 -0
  13. data/lib/smallcage/commands/manifest.rb +39 -0
  14. data/lib/smallcage/commands/server.rb +15 -0
  15. data/lib/smallcage/commands/update.rb +121 -0
  16. data/lib/smallcage/document_path.rb +46 -0
  17. data/lib/smallcage/erb_base.rb +16 -0
  18. data/lib/smallcage/http_server.rb +66 -0
  19. data/lib/smallcage/loader.rb +278 -0
  20. data/lib/smallcage/misc.rb +13 -0
  21. data/lib/smallcage/renderer.rb +19 -0
  22. data/lib/smallcage/resources/Manifest.erb +19 -0
  23. data/lib/smallcage/resources/auto.html +119 -0
  24. data/lib/smallcage/runner.rb +51 -0
  25. data/lib/smallcage/version.rb +9 -0
  26. data/project/base/_smc/helpers/base_helper.rb +41 -0
  27. data/project/base/_smc/helpers/site_helper.rb +5 -0
  28. data/project/base/_smc/templates/default.rhtml +5 -0
  29. data/project/base/_smc/templates/footer.rhtml +0 -0
  30. data/project/base/_smc/templates/header.rhtml +0 -0
  31. data/project/bluecloth/_smc/helpers/blue_cloth_helper.rb +10 -0
  32. data/project/bluecloth/_smc/templates/markdown.rhtml +5 -0
  33. data/project/lang/_smc/helpers/lang_helper.rb +19 -0
  34. data/project/lang/_smc/templates/other_lang.rhtml +6 -0
  35. data/project/news/_smc/helpers/news_helper.rb +36 -0
  36. data/project/nkf/_smc/filters/filters.yml +3 -0
  37. data/project/nkf/_smc/filters/nkf_filter.rb +15 -0
  38. data/project/rake/_smc/Rakefile +68 -0
  39. data/project/redcloth/_smc/helpers/red_cloth_helper.rb +10 -0
  40. data/project/redcloth/_smc/templates/textile.rhtml +5 -0
  41. data/project/relpath/_smc/filters/filters.yml +2 -0
  42. data/project/relpath/_smc/filters/relpath_filter.rb +13 -0
  43. data/project/standard/_dir.smc +2 -0
  44. data/project/standard/_smc/helpers/base_helper.rb +34 -0
  45. data/project/standard/_smc/helpers/menu_helper.rb +23 -0
  46. data/project/standard/_smc/templates/default.rhtml +5 -0
  47. data/project/standard/_smc/templates/footer.rhtml +13 -0
  48. data/project/standard/_smc/templates/header.rhtml +37 -0
  49. data/project/standard/_smc/templates/menu.rhtml +6 -0
  50. data/project/standard/_smc/templates/redirect.rhtml +13 -0
  51. data/project/standard/_smc/templates/sidebar.rhtml +7 -0
  52. data/project/standard/_smc/templates/topic_path.rhtml +6 -0
  53. data/project/standard/common/css/default.css +145 -0
  54. data/project/standard/common/css/print.css +0 -0
  55. data/project/standard/index.html.smc +3 -0
  56. data/project/standard/sample/_dir.smc +1 -0
  57. data/project/standard/sample/index.html.smc +7 -0
  58. data/project/standard/sample/redirect.html.smc +2 -0
  59. data/project/standard/sample/sub/_dir.smc +1 -0
  60. data/project/standard/sample/sub/contents.html.smc +3 -0
  61. data/project/standard/sample/sub/index.html.smc +7 -0
  62. data/spec/data/htdocs1/_dir.smc +0 -0
  63. data/spec/data/htdocs1/a/b/c/index.html.smc +6 -0
  64. data/spec/data/htdocs2/_smc/templates/dummy.rhtml +0 -0
  65. data/spec/data/htdocs2/a/b/c/test.html +1 -0
  66. data/spec/data/htdocs2/a/b/test.html +1 -0
  67. data/spec/data/htdocs2/a/test.html.smc +2 -0
  68. data/spec/document_path_spec.rb +42 -0
  69. data/spec/export_spec.rb +45 -0
  70. data/spec/import_spec.rb +20 -0
  71. data/spec/loader_spec.rb +55 -0
  72. data/spec/manifest_spec.rb +39 -0
  73. data/spec/misc_spec.rb +25 -0
  74. data/spec/smallcage_spec.rb +40 -0
  75. data/spec/spec.opts +1 -0
  76. data/spec/spec_helper.rb +9 -0
  77. data/test/test_helper.rb +2 -0
  78. data/test/test_smallcage.rb +11 -0
  79. metadata +193 -0
@@ -0,0 +1,13 @@
1
+ module SmallCage
2
+ class RelpathFilter
3
+
4
+ def initialize(opts)
5
+ end
6
+
7
+ def after_rendering_filter(obj, str)
8
+ relpath = "../" * (obj["dirs"].size - 1)
9
+ return str.gsub(%r{="/}, "=\"#{relpath}")
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ lang: en
2
+ topic: Home
@@ -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,5 @@
1
+ <%= header %>
2
+
3
+ <%= body %>
4
+
5
+ <%= footer %>
@@ -0,0 +1,13 @@
1
+ </div>
2
+ </div>
3
+
4
+ <%= sidebar %>
5
+
6
+
7
+ <div id="footer">
8
+ <div class="copyright">&copy;<%= Time.now.year %> Site Owner All rights reserved.</div>
9
+ </div>
10
+
11
+ </div>
12
+ </body>
13
+ </html>
@@ -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,6 @@
1
+ <div id="menu">
2
+ <ul>
3
+ <li class="<%= menu_active_rex(%r{^/index.html$}) %>"><a href="/index.html">Home</a></li>
4
+ <li class="<%= menu_active("sample") %>"><a href="/sample/index.html">Sample</a></li>
5
+ </ul>
6
+ </div>
@@ -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,7 @@
1
+ <div id="sidebar">
2
+ <h2>Links</h2>
3
+ <ul>
4
+ <li><a href="http://rubyforge.org/projects/smallcage/">RubyForge</a></li>
5
+ <li><a href="http://www.smallcage.org/ja/documents/">Documents</a></li>
6
+ </ul>
7
+ </div>
@@ -0,0 +1,6 @@
1
+ <% topic_dirs.each do |d| %>
2
+ <a href="<%= d["uri"]%>index.html"><%= d["topic"] %></a>
3
+ <% if topic_dirs.last != d %>
4
+ <span class="delimiter"> &gt; </span>
5
+ <% end %>
6
+ <% end %>
@@ -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,3 @@
1
+ --- |
2
+ <h2>About</h2>
3
+ <p>SmallCageは、静的なウェブサイトを効率よく構築するためのアプリケーション/フレームワークです。</p>
@@ -0,0 +1 @@
1
+ topic: Sample
@@ -0,0 +1,7 @@
1
+ title: Sample
2
+ --- |
3
+ <h2>Sample index</h2>
4
+ <ul>
5
+ <li><a href="./sub/index.html">Subcategory</a></li>
6
+ <li><a href="redirect.html">Redirect</a></li>
7
+ </ul>
@@ -0,0 +1,2 @@
1
+ template: redirect
2
+ redirect_uri: ./sub/index.html
@@ -0,0 +1 @@
1
+ topic: Subcategory
@@ -0,0 +1,3 @@
1
+ title: Subcategory contents
2
+ --- |
3
+ <p>/sample/sub/以下のコンテンツです。</p>
@@ -0,0 +1,7 @@
1
+ title: Subcategory
2
+ --- |
3
+ <p>_dir.smcのtopicの値でパンくずリストを設定しています。</p>
4
+ <ul>
5
+ <li><a href="contents.html">contents</a></li>
6
+ </ul>
7
+
File without changes
@@ -0,0 +1,6 @@
1
+ xyz: 123
2
+ --- |
3
+ abc
4
+ def
5
+
6
+ ghi
File without changes
@@ -0,0 +1 @@
1
+ c
@@ -0,0 +1 @@
1
+ b
@@ -0,0 +1,2 @@
1
+ --- |
2
+ <p>xxx</p>
@@ -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
@@ -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