YurtCMS 0.2.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/README +18 -0
- data/bin/yurt +282 -0
- data/lib/yurtcms.rb +175 -0
- data/site/content/index +14 -0
- data/site/htdocs/includes/content/index.html +11 -0
- data/site/htdocs/includes/content/index.metatags.html +1 -0
- data/site/htdocs/includes/template.html +22 -0
- data/site/htdocs/includes/template.metatags.html +4 -0
- data/site/htdocs/index.html +2 -0
- data/site/htdocs/media/css/styles.css +106 -0
- data/site/htdocs/media/images/admin_bg.gif +0 -0
- data/site/htdocs/media/images/admin_head.jpg +0 -0
- data/site/htdocs/media/images/directory.png +0 -0
- data/site/htdocs/media/images/file.png +0 -0
- data/site/htdocs/media/images/pane_bg.gif +0 -0
- data/site/htdocs/media/js/prototype.js +1781 -0
- data/site/log/access.log +0 -0
- data/site/log/error.log +0 -0
- data/site/yurt/index.html +135 -0
- data/site/yurt/media/css/styles.css +155 -0
- data/site/yurt/media/images/admin_bg.gif +0 -0
- data/site/yurt/media/images/admin_head.jpg +0 -0
- data/site/yurt/media/images/directory.png +0 -0
- data/site/yurt/media/images/file.png +0 -0
- data/site/yurt/media/images/pane_bg.gif +0 -0
- data/site/yurt/media/js/prototype.js +1781 -0
- data/site/yurt/yurt.cgi +250 -0
- data/site/yurt.conf +53 -0
- data/test/cms_filesystem.rb +111 -0
- data/test/cms_strings.rb +132 -0
- metadata +106 -0
data/site/yurt/yurt.cgi
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
|
3
|
+
require 'yurtcms'
|
4
|
+
require 'camping'
|
5
|
+
require 'BlueCloth'
|
6
|
+
|
7
|
+
Camping.goes :Yurt
|
8
|
+
|
9
|
+
module Yurt::Models
|
10
|
+
def get_yurtcms
|
11
|
+
YurtCMS.new(File.dirname(__FILE__) +'/..')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Yurt::Controllers
|
16
|
+
|
17
|
+
# The root slash shows the `index' view.
|
18
|
+
class Index < R '/'
|
19
|
+
def get
|
20
|
+
render :index
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Open_Folder < R '/open/([\w\/\.\-\_]*)'
|
25
|
+
def get path
|
26
|
+
@y = get_yurtcms
|
27
|
+
@p = path
|
28
|
+
@contents = @y.get_dir_listing( @p )
|
29
|
+
@contents.each do |file, type|
|
30
|
+
if type[0] == "directory"
|
31
|
+
dir_contents = @y.get_dir_listing( [@p, file].join("/") )
|
32
|
+
@contents[file] = [ type[0], dir_contents.length ]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
render :open_folder
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class New_Folder < R '/new_folder/([\w\/\.\-\_]*)'
|
40
|
+
def get path
|
41
|
+
@y = get_yurtcms
|
42
|
+
@p = @y.sanitize_path( path )
|
43
|
+
render :new_folder
|
44
|
+
end
|
45
|
+
|
46
|
+
def post path
|
47
|
+
@y = get_yurtcms
|
48
|
+
@y.make_new_dir( input.path, input.foldername )
|
49
|
+
render :folder_created
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class New_File < R '/new_file/([\w\/\.\-\_]*)'
|
54
|
+
def get path
|
55
|
+
@y = get_yurtcms
|
56
|
+
@p = @y.sanitize_path( path )
|
57
|
+
|
58
|
+
@f = Hash.new
|
59
|
+
@f['title'] = "page_title"
|
60
|
+
@f['description'] = "description"
|
61
|
+
@f['keywords'] = "keywords"
|
62
|
+
@f['content'] = ""
|
63
|
+
@f['filename'] = "file_name"
|
64
|
+
@f['partial'] = ""
|
65
|
+
|
66
|
+
render :new_file
|
67
|
+
end
|
68
|
+
def post path
|
69
|
+
@y = get_yurtcms
|
70
|
+
@y.write_all_files input
|
71
|
+
|
72
|
+
render :file_created
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class Delete < R '/delete/([\w\/\.\-\_]+)'
|
77
|
+
def get path
|
78
|
+
@y = get_yurtcms
|
79
|
+
@y.delete( path )
|
80
|
+
|
81
|
+
render :delete
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Edit < R '/edit/([\w\/\.\-\_]+)'
|
86
|
+
def get path
|
87
|
+
@y = get_yurtcms
|
88
|
+
|
89
|
+
@f = @y.get_file_metadata( path )
|
90
|
+
|
91
|
+
render :new_file
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Preview < R '/preview/'
|
96
|
+
def post
|
97
|
+
@y = get_yurtcms
|
98
|
+
@p = @y.parse_content input.c + "\n\n----\n\n**Note:** *The actual file has **not** been saved.*"
|
99
|
+
render :preview
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class Cancel < R '/cancel/[\w\/\.\-\_]*'
|
104
|
+
def get
|
105
|
+
render :cancel
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
module Yurt::Helpers
|
111
|
+
def generate_template_options selected
|
112
|
+
options = ""
|
113
|
+
Dir.glob( @y.web_root + "includes/*template.html" ) do |candidate|
|
114
|
+
candidate_basename = File.basename( candidate )
|
115
|
+
if( ( candidate_basename == selected ) or ( selected == nil and candidate_basename == "template.html" ) )
|
116
|
+
options << %Q( <option value="#{ candidate_basename }" selected="selected">#{ candidate_basename }</option>
|
117
|
+
)
|
118
|
+
else
|
119
|
+
options << %Q( <option value="#{ candidate_basename }">#{ candidate_basename }</option>
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
options
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
module Yurt::Views
|
128
|
+
|
129
|
+
# If you have a `layout' method like this, it
|
130
|
+
# will wrap the HTML in the other methods. The
|
131
|
+
# `self << yield' is where the HTML is inserted.
|
132
|
+
# def layout
|
133
|
+
# html do
|
134
|
+
# title { 'My Yurt' }
|
135
|
+
# body { self << yield }
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
|
139
|
+
# The `index' view. Inside your views, you express
|
140
|
+
# the HTML in Ruby. See http://code.whytheluckystiff.net/markaby/.
|
141
|
+
def index
|
142
|
+
p 'This is the index view.'
|
143
|
+
end
|
144
|
+
|
145
|
+
def open_folder
|
146
|
+
text '<ul class="listing">'
|
147
|
+
@contents.each do |file, type|
|
148
|
+
li :class => type[0] do
|
149
|
+
a :href => "#", :onclick => "return false;", :id => @p + "/" + file do
|
150
|
+
text file
|
151
|
+
text [ " (", type[1], ")"].join if type[1]
|
152
|
+
end
|
153
|
+
if type[0] == "directory"
|
154
|
+
div :id => "directory_" + @p + "/" + file do
|
155
|
+
text " "
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
text '</ul>'
|
161
|
+
script do
|
162
|
+
text " x = new Array();"
|
163
|
+
@contents.keys.each do |file|
|
164
|
+
text " x[x.length] = '" +@p + "/" + file + "';"
|
165
|
+
end
|
166
|
+
text " new EventDispenser(x);"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def new_file
|
171
|
+
text %Q(
|
172
|
+
<form action="/yurt/yurt.cgi/new_file/" method="post" name="newfile" class="dialog_box" id="newfile">
|
173
|
+
<fieldset>
|
174
|
+
<legend>
|
175
|
+
<a href="#" onclick="toggleTabs('nf_dialog', 'nf_preview', 'nf_help');">New File</a> |
|
176
|
+
<a href="#" onclick="toggleTabs('nf_preview', 'nf_dialog', 'nf_help');preview(document.forms['newfile'].content.value);">Preview</a> |
|
177
|
+
<a href="#" onclick="toggleTabs('nf_help', 'nf_dialog', 'nf_preview');">Help</a>
|
178
|
+
</legend>
|
179
|
+
<div id="nf_dialog" class="dialog">
|
180
|
+
<label><input type="text" name="filename" value="#{ @f['filename'] }" /> File name</label>
|
181
|
+
<label><input type="checkbox" name="partial" class="checkbox" value="y" onclick="Element.toggle('metadata');" #{ 'checked="checked"' if @f['partial'] == 'y' }/> Partial?</label>
|
182
|
+
<div id="metadata"#{ ' style="display: none;"' if @f['partial'] == 'y' }>
|
183
|
+
<label><select name="template">#{ generate_template_options( @f['template'] ) }</select> Template</label>
|
184
|
+
<label><input type="text" name="title" value="#{ @f['title'] }" /> Title</label>
|
185
|
+
<label><input type="text" name="description" value="#{ @f['description'] }" /> Description</label>
|
186
|
+
<label><input type="text" name="keywords" value="#{ @f['keywords'] }" /> Keywords</label>
|
187
|
+
</div>
|
188
|
+
<textarea name="content" class="contentarea">#{ @f['content'] }</textarea>
|
189
|
+
<input type="hidden" name="path" value="#{@f['path']}" />
|
190
|
+
<input type="button" name="add" value="Add" onclick="dispatch_post('/yurt/yurt.cgi/new_file/', 'newfile')" />
|
191
|
+
<input type="button" name="cancel" value="Cancel" onclick="dispatch('/yurt/yurt.cgi/cancel')" />
|
192
|
+
</div>
|
193
|
+
<div id="nf_preview" class="preview" style="display: none;">
|
194
|
+
</div>
|
195
|
+
<div id="nf_help" class="help" style="display: none;">
|
196
|
+
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line � a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
|
197
|
+
</div>
|
198
|
+
</fieldset>
|
199
|
+
</form>
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
203
|
+
def new_folder
|
204
|
+
text %Q(
|
205
|
+
<form action="/yurt/yurt.cgi/new_folder/" method="post" name="newfolder" class="dialog_box" id="newfolder">
|
206
|
+
<fieldset>
|
207
|
+
<legend>
|
208
|
+
<a href="#" onclick="toggleTabs('nf_dialog', 'nf_help');">New Folder</a> |
|
209
|
+
<a href="#" onclick="toggleTabs('nf_help', 'nf_dialog');">Help</a>
|
210
|
+
</legend>
|
211
|
+
<div id="nf_dialog" class="dialog">
|
212
|
+
<label><input type="text" name="foldername" value="" /> Folder name</label>
|
213
|
+
<input type="hidden" name="path" value="#{@p}" />
|
214
|
+
<input type="button" name="add" value="Add" onclick="dispatch_post('/yurt/yurt.cgi/new_folder/', 'newfolder')" />
|
215
|
+
<input type="button" name="cancel" value="Cancel" onclick="dispatch('/yurt/yurt.cgi/cancel')" />
|
216
|
+
</div>
|
217
|
+
<div id="nf_help" class="help" style="display: none;">
|
218
|
+
<p>Please use characters that you would normally expect to be valid for your folder/directory name. We suggest using upper and lower case letters, numbers, and the following punctuation (sans quotes): ".", "_", "-". If you try to type in illegal characters, the application will convert them to underscores.</p>
|
219
|
+
</div>
|
220
|
+
</fieldset>
|
221
|
+
</form>
|
222
|
+
)
|
223
|
+
end
|
224
|
+
|
225
|
+
def preview
|
226
|
+
text @p
|
227
|
+
end
|
228
|
+
|
229
|
+
def folder_created
|
230
|
+
text %q(<p>The folder was successfully created.</p>)
|
231
|
+
end
|
232
|
+
|
233
|
+
def file_created
|
234
|
+
text %q(<p>The file was successfully created.</p>)
|
235
|
+
end
|
236
|
+
|
237
|
+
def delete
|
238
|
+
text %q(<p>The Deletion was successful.</p>)
|
239
|
+
end
|
240
|
+
|
241
|
+
def cancel
|
242
|
+
text " "
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
if __FILE__ == $0
|
248
|
+
puts Yurt.run
|
249
|
+
end
|
250
|
+
|
data/site/yurt.conf
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Yurt CMS config file for Apache
|
2
|
+
#
|
3
|
+
# This file has been generated by a yurt newsite command, and is ready to use.
|
4
|
+
# All you have to do is merge this with your standard htdocs.conf file and
|
5
|
+
# restart Apache.
|
6
|
+
#
|
7
|
+
# on Mac OS X:
|
8
|
+
#
|
9
|
+
# you can easily get this going by copying this file into /etc/httpd/users/ and
|
10
|
+
# restarting apache. Here are the commands you need to use:
|
11
|
+
#
|
12
|
+
# $ sudo cp yoursitename.conf /etc/httpd/users/
|
13
|
+
# <enter your admin password when prompted>
|
14
|
+
# $ sudo apachectl restart
|
15
|
+
#
|
16
|
+
# Once the server has been restarted, fire up the browser and go to
|
17
|
+
# http://localhost:<%= port %>/yurt/ and begin editing!
|
18
|
+
|
19
|
+
# add cgi support:
|
20
|
+
AddHandler cgi-script .cgi
|
21
|
+
|
22
|
+
Listen <%= port %>
|
23
|
+
|
24
|
+
<VirtualHost *:<%= port %>>
|
25
|
+
ServerName *
|
26
|
+
DirectoryIndex index.html index.cgi
|
27
|
+
DocumentRoot <%= yurt_root %>/htdocs
|
28
|
+
CustomLog <%= yurt_root %>/log/access.log common
|
29
|
+
ErrorLog <%= yurt_root %>/log/error.log
|
30
|
+
|
31
|
+
Alias /yurt <%= yurt_root %>/yurt
|
32
|
+
<Directory "<%= yurt_root %>/htdocs">
|
33
|
+
AllowOverride All
|
34
|
+
Options Indexes ExecCGI Includes
|
35
|
+
AddHandler server-parsed .html
|
36
|
+
|
37
|
+
<IfModule mod_dir.c>
|
38
|
+
DirectoryIndex index.html index.htm
|
39
|
+
</IfModule>
|
40
|
+
</Directory>
|
41
|
+
|
42
|
+
<Directory "<%= yurt_root %>/yurt">
|
43
|
+
AllowOverride All
|
44
|
+
Options Indexes ExecCGI Includes
|
45
|
+
AddHandler server-parsed .html
|
46
|
+
|
47
|
+
<IfModule mod_dir.c>
|
48
|
+
DirectoryIndex index.html index.htm
|
49
|
+
</IfModule>
|
50
|
+
</Directory>
|
51
|
+
</VirtualHost>
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) +'/../lib/yurtcms'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class Input
|
7
|
+
attr_reader :title, :keywords, :description, :partial, :content, :path, :filename
|
8
|
+
attr_writer :title, :keywords, :description, :partial, :content, :path, :filename
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestYurtFS < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
Dir.mkdir( "yurt_test/" )
|
15
|
+
Dir.mkdir( "yurt_test/content/" )
|
16
|
+
Dir.mkdir( "yurt_test/htdocs/" )
|
17
|
+
Dir.mkdir( "yurt_test/htdocs/includes" )
|
18
|
+
Dir.mkdir( "yurt_test/htdocs/includes/content" )
|
19
|
+
Dir.chdir( "yurt_test/")
|
20
|
+
|
21
|
+
@y = YurtCMS.new( Dir.getwd )
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
Dir.chdir( ".." )
|
26
|
+
system("rm -rf yurt_test")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_make_new_dir
|
30
|
+
@y.make_new_dir( "/", "solutions" )
|
31
|
+
|
32
|
+
assert_equal( File.ftype( [ @y.data_store, "/solutions" ].join ), "directory")
|
33
|
+
assert_equal( File.ftype( [ @y.includes, "/solutions" ].join ), "directory")
|
34
|
+
assert_equal( File.ftype( [ @y.web_root, "/solutions" ].join ), "directory")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_add_content
|
38
|
+
i = Input.new
|
39
|
+
|
40
|
+
i.title = "my title"
|
41
|
+
i.keywords = "keywords here"
|
42
|
+
i.description = "my clever description"
|
43
|
+
i.content = "This is *the* content of the file."
|
44
|
+
i.path = "/"
|
45
|
+
i.filename = "my_file"
|
46
|
+
|
47
|
+
@y.write_all_files( i )
|
48
|
+
|
49
|
+
[ :path_to_orig_content,
|
50
|
+
:path_to_metatags,
|
51
|
+
:path_to_content,
|
52
|
+
:path_to_placeholder ].each do |p|
|
53
|
+
f = @y.send( p, "/my_file" )
|
54
|
+
assert_equal( File.ftype( f ), "file")
|
55
|
+
assert( File.readable?( f ) )
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_delete_file
|
61
|
+
test_add_content
|
62
|
+
|
63
|
+
@y.delete("/my_file")
|
64
|
+
|
65
|
+
[ :path_to_orig_content,
|
66
|
+
:path_to_metatags,
|
67
|
+
:path_to_content,
|
68
|
+
:path_to_placeholder ].each do |p|
|
69
|
+
f = @y.send( p, "/my_file" )
|
70
|
+
assert( !( File.exists?( f ) ) )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_delete_dir
|
75
|
+
test_make_new_dir
|
76
|
+
@y.delete( "/solutions" )
|
77
|
+
|
78
|
+
[ :path_to_orig_content,
|
79
|
+
:path_to_content,
|
80
|
+
:path_to_placeholder ].each do |p|
|
81
|
+
f = @y.send( p, "/solutions" ).gsub(/\.html/, '')
|
82
|
+
assert( !( File.exists?( f ) ) )
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_get_dir_listing
|
87
|
+
test_add_content
|
88
|
+
test_make_new_dir
|
89
|
+
|
90
|
+
listing = @y.get_dir_listing( '/' )
|
91
|
+
|
92
|
+
assert( listing.is_a?( Hash ) )
|
93
|
+
assert_equal( 'file', listing[ 'my_file' ][ 0 ] )
|
94
|
+
assert_equal( 'directory', listing[ 'solutions' ][ 0 ] )
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_get_file_metadata
|
98
|
+
test_add_content
|
99
|
+
|
100
|
+
metadata = @y.get_file_metadata 'my_file'
|
101
|
+
|
102
|
+
assert( metadata.is_a?( Hash ) )
|
103
|
+
|
104
|
+
assert_equal( 'my title', metadata[ 'title' ] )
|
105
|
+
assert_equal( 'keywords here', metadata[ 'keywords' ] )
|
106
|
+
assert_equal( 'my clever description', metadata[ 'description' ] )
|
107
|
+
assert_equal( 'This is *the* content of the file.', metadata[ 'content' ] )
|
108
|
+
assert_equal( 'my_file', metadata[ 'filename' ] )
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
data/test/cms_strings.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) +'/../lib/yurtcms'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class Input
|
7
|
+
attr_reader :title, :keywords, :description, :partial, :content, :template
|
8
|
+
attr_writer :title, :keywords, :description, :partial, :content, :template
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestYurtCMS < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@y = YurtCMS.new( '/Users/rhahn/Business/yurt/' )
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_attributes
|
18
|
+
assert_equal( '/Users/rhahn/Business/yurt/content/', @y.data_store, 'data_store path incorrect' )
|
19
|
+
assert_equal( '/Users/rhahn/Business/yurt/htdocs/', @y.web_root, 'web_root path incorrect' )
|
20
|
+
assert_equal( '/Users/rhahn/Business/yurt/htdocs/includes/content/', @y.includes, 'includes path incorrect' )
|
21
|
+
assert_equal( '.metatags', @y.metatags, 'metatags modifier incorrect' )
|
22
|
+
assert_equal( '.partial', @y.partial, 'partial modifier incorrect' )
|
23
|
+
assert_equal( '.html', @y.ext, 'html extension incorrect' )
|
24
|
+
|
25
|
+
test_file = @y.merge( 'solutions', 'foo' )
|
26
|
+
assert_equal( 'solutions/foo', test_file )
|
27
|
+
|
28
|
+
test_file = @y.merge( 'solutions', '/foo' )
|
29
|
+
assert_equal( 'solutions/foo', test_file )
|
30
|
+
|
31
|
+
test_file = @y.merge( 'solutions/', '///foo' )
|
32
|
+
assert_equal( 'solutions/foo', test_file )
|
33
|
+
|
34
|
+
test_file = @y.merge( 'solutions/', '/foo' )
|
35
|
+
assert_equal( 'solutions/foo', test_file )
|
36
|
+
|
37
|
+
assert_equal( '/Users/rhahn/Business/yurt/content/solutions/foo', @y.path_to_orig_content( test_file ), 'path_to_orig_content incorrectly reported' )
|
38
|
+
assert_equal( '/Users/rhahn/Business/yurt/htdocs/includes/content/solutions/foo.metatags.html', @y.path_to_metatags( test_file ), 'path_to_metatags incorrectly reported' )
|
39
|
+
assert_equal( '/Users/rhahn/Business/yurt/htdocs/includes/content/solutions/foo.html', @y.path_to_content( test_file ), 'path_to_content incorrectly reported' )
|
40
|
+
assert_equal( '/Users/rhahn/Business/yurt/htdocs/solutions/foo.html', @y.path_to_placeholder( test_file ), 'path_to_placeholder incorrectly reported' )
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_sanitizations
|
44
|
+
assert_equal( '/', @y.sanitize_path( '' ), 'empty path not returning as "/"' )
|
45
|
+
assert_equal( '/foo/', @y.sanitize_path( 'foo' ), 'non-empty path not returning as "/whatever/"' )
|
46
|
+
assert_equal( '/solutions/foo/', @y.sanitize_path( 'solutions///foo' ) )
|
47
|
+
|
48
|
+
|
49
|
+
assert_equal( 'my_file_', @y.sanitize_filename( 'my file/' ) )
|
50
|
+
assert_equal( 'my_file_', @y.sanitize_filename( 'my\'file/' ) )
|
51
|
+
assert_equal( 'my._file', @y.sanitize_filename( 'my. file' ) )
|
52
|
+
assert_equal( 'my-file_', @y.sanitize_filename( 'my-file/' ) )
|
53
|
+
assert_equal( 'my_file', @y.sanitize_filename( '/my file' ) )
|
54
|
+
assert_equal( '12345', @y.sanitize_filename( '12345' ) )
|
55
|
+
assert_equal( 'yodel_.._lee_.._who_', @y.sanitize_filename( 'yodel/../lee/../who?' ) )
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_make_content_as_yaml
|
59
|
+
input = Input.new
|
60
|
+
|
61
|
+
input.title = "my title"
|
62
|
+
input.keywords = "keyword thing"
|
63
|
+
input.template = "template.html"
|
64
|
+
input.description = "This is my description."
|
65
|
+
input.content = "This is my content."
|
66
|
+
|
67
|
+
serialized_content = @y.make_content_as_yaml( input )
|
68
|
+
|
69
|
+
assert( serialized_content.is_a?( String ) )
|
70
|
+
|
71
|
+
deserialized_content = YAML.load( serialized_content )
|
72
|
+
|
73
|
+
assert_equal( 'my title', deserialized_content[ 'title' ] )
|
74
|
+
assert_equal( 'keyword thing', deserialized_content[ 'keywords' ] )
|
75
|
+
assert_equal( 'template.html', deserialized_content[ 'template' ] )
|
76
|
+
assert_equal( 'This is my description.', deserialized_content[ 'description' ] )
|
77
|
+
assert_equal( 'This is my content.', deserialized_content[ 'content' ] )
|
78
|
+
|
79
|
+
input = nil
|
80
|
+
|
81
|
+
input = Input.new
|
82
|
+
|
83
|
+
input.partial = "y"
|
84
|
+
input.content = "This is my content."
|
85
|
+
|
86
|
+
serialized_content = @y.make_content_as_yaml( input )
|
87
|
+
|
88
|
+
deserialized_content = YAML.load( serialized_content )
|
89
|
+
|
90
|
+
assert_equal( 'y', deserialized_content[ 'partial' ] )
|
91
|
+
assert_equal( 'This is my content.', deserialized_content[ 'content' ] )
|
92
|
+
|
93
|
+
input = nil
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_make_metatags
|
97
|
+
input = Input.new
|
98
|
+
|
99
|
+
input.title = "my title"
|
100
|
+
|
101
|
+
assert_equal( "<!--#set var=\"TITLE\" value=\"my title\" -->\n", @y.make_metatags( input ) )
|
102
|
+
|
103
|
+
input.keywords = "keyword thing"
|
104
|
+
|
105
|
+
assert_equal( "<!--#set var=\"TITLE\" value=\"my title\" -->\n<!--#set var=\"KEYWORDS\" value=\"keyword thing\" -->\n", @y.make_metatags( input ) )
|
106
|
+
|
107
|
+
input.description = "This is my description."
|
108
|
+
|
109
|
+
assert_equal( "<!--#set var=\"TITLE\" value=\"my title\" -->\n<!--#set var=\"DESCRIPTION\" value=\"This is my description.\" -->\n<!--#set var=\"KEYWORDS\" value=\"keyword thing\" -->\n", @y.make_metatags( input ) )
|
110
|
+
|
111
|
+
input.title = ''
|
112
|
+
|
113
|
+
assert_equal( "<!--#set var=\"DESCRIPTION\" value=\"This is my description.\" -->\n<!--#set var=\"KEYWORDS\" value=\"keyword thing\" -->\n", @y.make_metatags( input ) )
|
114
|
+
|
115
|
+
input.keywords = ''
|
116
|
+
|
117
|
+
assert_equal( "<!--#set var=\"DESCRIPTION\" value=\"This is my description.\" -->\n", @y.make_metatags( input ) )
|
118
|
+
|
119
|
+
input = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_parse_content
|
123
|
+
c = "A **quick** test"
|
124
|
+
|
125
|
+
assert_equal( '<p>A <strong>quick</strong> test</p>', @y.parse_content( c ) )
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_make_placeholder
|
129
|
+
assert_equal( "<!--#set var=\"PAGE\" value=\"solutions/foo\" -->\n<!--#include virtual=\"/includes/template.html\" -->\n", @y.make_placeholder( 'solutions/foo', 'template.html' ) )
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: YurtCMS
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-10-11 00:00:00 -04:00
|
8
|
+
summary: The Web CMS that does less!
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: yurt@roberthahn.ca
|
12
|
+
homepage: http://yurt.roberthahn.ca
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: yurtcms
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Robert Hahn
|
30
|
+
files:
|
31
|
+
- bin/yurt
|
32
|
+
- lib/yurtcms.rb
|
33
|
+
- site/content
|
34
|
+
- site/htdocs
|
35
|
+
- site/log
|
36
|
+
- site/yurt
|
37
|
+
- site/yurt.conf
|
38
|
+
- site/content/index
|
39
|
+
- site/htdocs/includes
|
40
|
+
- site/htdocs/index.html
|
41
|
+
- site/htdocs/media
|
42
|
+
- site/htdocs/includes/content
|
43
|
+
- site/htdocs/includes/template.html
|
44
|
+
- site/htdocs/includes/template.metatags.html
|
45
|
+
- site/htdocs/includes/content/index.html
|
46
|
+
- site/htdocs/includes/content/index.metatags.html
|
47
|
+
- site/htdocs/media/css
|
48
|
+
- site/htdocs/media/images
|
49
|
+
- site/htdocs/media/js
|
50
|
+
- site/htdocs/media/css/styles.css
|
51
|
+
- site/htdocs/media/images/admin_bg.gif
|
52
|
+
- site/htdocs/media/images/admin_head.jpg
|
53
|
+
- site/htdocs/media/images/directory.png
|
54
|
+
- site/htdocs/media/images/file.png
|
55
|
+
- site/htdocs/media/images/pane_bg.gif
|
56
|
+
- site/htdocs/media/js/prototype.js
|
57
|
+
- site/log/access.log
|
58
|
+
- site/log/error.log
|
59
|
+
- site/yurt/index.html
|
60
|
+
- site/yurt/media
|
61
|
+
- site/yurt/yurt.cgi
|
62
|
+
- site/yurt/media/css
|
63
|
+
- site/yurt/media/images
|
64
|
+
- site/yurt/media/js
|
65
|
+
- site/yurt/media/css/styles.css
|
66
|
+
- site/yurt/media/images/admin_bg.gif
|
67
|
+
- site/yurt/media/images/admin_head.jpg
|
68
|
+
- site/yurt/media/images/directory.png
|
69
|
+
- site/yurt/media/images/file.png
|
70
|
+
- site/yurt/media/images/pane_bg.gif
|
71
|
+
- site/yurt/media/js/prototype.js
|
72
|
+
- test/cms_filesystem.rb
|
73
|
+
- test/cms_strings.rb
|
74
|
+
- README
|
75
|
+
test_files:
|
76
|
+
- test/cms_filesystem.rb
|
77
|
+
- test/cms_strings.rb
|
78
|
+
rdoc_options: []
|
79
|
+
|
80
|
+
extra_rdoc_files:
|
81
|
+
- README
|
82
|
+
executables:
|
83
|
+
- yurt
|
84
|
+
extensions: []
|
85
|
+
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
dependencies:
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: BlueCloth
|
91
|
+
version_requirement:
|
92
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.0.0
|
97
|
+
version:
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: camping
|
100
|
+
version_requirement:
|
101
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.4.2
|
106
|
+
version:
|