zena 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/{README.txt → README.rdoc} +13 -19
- data/app/controllers/documents_controller.rb +7 -2
- data/app/controllers/nodes_controller.rb +4 -0
- data/app/models/iformat.rb +43 -1
- data/app/models/skin.rb +1 -2
- data/app/models/text_document.rb +2 -2
- data/app/models/version.rb +1 -0
- data/app/views/documents/new.rhtml +2 -2
- data/app/views/iformats/_form.rhtml +5 -4
- data/app/views/iformats/_li.rhtml +1 -0
- data/app/views/iformats/index.rhtml +1 -1
- data/app/views/nodes/_import_results.rhtml +1 -1
- data/app/views/nodes/edit.html.erb +2 -2
- data/app/views/templates/edit_tabs/_custom.rhtml +2 -2
- data/app/views/templates/edit_tabs/_document.rhtml +3 -3
- data/app/views/versions/_tr.rhtml +5 -6
- data/app/views/versions/edit.rhtml +2 -2
- data/bin/zena +2 -2
- data/bricks/captcha/patch/application_controller.rb +1 -1
- data/bricks/captcha/zafu/captcha.rb +1 -1
- data/config/deploy.rb +36 -380
- data/config/gems.yml +2 -7
- data/db/migrate/20091018200734_add_popup_info_to_image_format.rb +9 -0
- data/db/schema.rb +3 -2
- data/lib/gettext_strings.rb +8 -0
- data/lib/tasks/zena.rake +30 -12
- data/lib/zena/app.rb +2 -0
- data/{config → lib/zena/deploy}/awstats.conf.rhtml +0 -0
- data/{config → lib/zena/deploy}/database.rhtml +0 -0
- data/lib/zena/deploy/httpd.rhtml +22 -0
- data/{config → lib/zena/deploy}/start.html +2 -2
- data/{config → lib/zena/deploy}/stats.vhost.rhtml +0 -0
- data/{config/zena.rb → lib/zena/deploy/template.rb} +13 -8
- data/{config → lib/zena/deploy}/vhost.rhtml +28 -14
- data/{config → lib/zena/deploy}/vhost_www.rhtml +0 -0
- data/lib/zena/deploy.rb +377 -0
- data/lib/zena/info.rb +13 -0
- data/lib/zena/parser/zena_tags.rb +3 -0
- data/lib/zena/parser.rb +1 -0
- data/lib/zena/use/calendar.rb +2 -1
- data/lib/zena/use/dates.rb +6 -1
- data/lib/zena/use/fixtures.rb +9 -0
- data/lib/zena/use/html_tags.rb +44 -5
- data/lib/zena/use/node_query_finders.rb +1 -2
- data/lib/zena/use/refactor.rb +0 -13
- data/lib/zena/use/rendering.rb +13 -0
- data/lib/zena/use/zafu.rb +21 -9
- data/lib/zena.rb +4 -11
- data/locale/en/LC_MESSAGES/zena.mo +0 -0
- data/locale/en/zena.po +29 -1
- data/locale/fr/LC_MESSAGES/zena.mo +0 -0
- data/locale/fr/zena.po +29 -1
- data/locale/zena.pot +28 -0
- data/public/images/popup_next.png +0 -0
- data/public/images/popup_prev.png +0 -0
- data/public/javascripts/upload-progress.js +13 -3
- data/public/javascripts/zena.js +177 -23
- data/public/stylesheets/popup.css +5 -3
- data/public/stylesheets/zena.css +10 -1
- data/{lib/zena/use → test}/custom_queries/complex.host.yml +0 -0
- data/test/fixtures/iformats.yml +1 -0
- data/test/fixtures/nodes.yml +1 -1
- data/test/fixtures/versions.yml +3 -1
- data/test/sites/zena/iformats.yml +1 -0
- data/test/sites/zena/versions.yml +3 -1
- data/test/test_helper.rb +2 -0
- data/test/unit/iformat_test.rb +53 -1
- data/test/unit/text_document_test.rb +3 -0
- data/test/unit/zena/use/html_tags_test.rb +24 -2
- data/test/unit/zena/use/refactor_test.rb +0 -4
- data/test/unit/zena/use/zafu_test.rb +12 -0
- data/test/unit/zena/use/zazen_test.rb +6 -3
- data/test/unit/zena/zena_tags/basic.yml +3 -3
- data/vendor/apache2_upload_progress/MIT-LICENSE +22 -0
- data/vendor/apache2_upload_progress/README +53 -0
- data/vendor/apache2_upload_progress/mod_upload_progress.c +813 -0
- metadata +45 -45
- data/config/deploy_config_example.rb +0 -7
- data/config/httpd.rhtml +0 -18
- data/config/locales/de.yml +0 -120
- data/config/locales/fr-CH.yml +0 -123
- data/config/locales/fr.yml +0 -123
- data/lib/zena/root.rb +0 -3
data/test/unit/iformat_test.rb
CHANGED
@@ -16,7 +16,7 @@ class IformatTest < Zena::Unit::TestCase
|
|
16
16
|
login(:lion)
|
17
17
|
fmt = Iformat['med']
|
18
18
|
assert_not_equal ImageBuilder::DEFAULT_FORMATS['med'], fmt
|
19
|
-
assert_equal ({:name => 'med', :width=>300, :height=>200, :gravity=>Magick::CenterGravity, :size=>:limit, :hash_id => 389519063846}), fmt
|
19
|
+
assert_equal ({:name => 'med', :width=>300, :height=>200, :gravity=>Magick::CenterGravity, :size=>:limit, :hash_id => 389519063846, :popup => {:show=> %w{navigation v_title v_summary}, :name=>'std', :options=>{'v_title'=>'link'}}}), fmt
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_format_hash_id
|
@@ -187,4 +187,56 @@ class IformatTest < Zena::Unit::TestCase
|
|
187
187
|
assert_equal 70, imf[:width]
|
188
188
|
assert_equal 2, imf[:size]
|
189
189
|
end
|
190
|
+
|
191
|
+
context 'An image format with popup' do
|
192
|
+
setup do
|
193
|
+
login(:lion)
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'defined with name' do
|
197
|
+
setup do
|
198
|
+
Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force', :popup => "pop")
|
199
|
+
@imf = Iformat['header']
|
200
|
+
end
|
201
|
+
|
202
|
+
should 'use default fields and navigation' do
|
203
|
+
assert_equal({:show=>%w{navigation v_title v_summary}, :name=>"pop", :options=>{'v_title' => 'link'}}, @imf[:popup])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'defined with name and json' do
|
208
|
+
setup do
|
209
|
+
Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force',
|
210
|
+
:popup => 'pop {"v_title":"link", "a":true}')
|
211
|
+
@imf = Iformat['header']
|
212
|
+
end
|
213
|
+
|
214
|
+
should 'respect key order' do
|
215
|
+
assert_equal({:show=>%w{v_title a}, :name=>"pop", :options=>{'v_title' => 'link'}}, @imf[:popup])
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'defined with name and list' do
|
220
|
+
setup do
|
221
|
+
Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force', :popup => "pop (link,navigation,created_at)")
|
222
|
+
@imf = Iformat['header']
|
223
|
+
end
|
224
|
+
|
225
|
+
should 'respect key order' do
|
226
|
+
assert_equal({:show=>%w{v_title navigation created_at}, :name=>"pop", :options=>{'v_title' => 'link'}}, @imf[:popup])
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'defined with name and empty list' do
|
231
|
+
setup do
|
232
|
+
Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force', :popup => "pop ()")
|
233
|
+
@imf = Iformat['header']
|
234
|
+
end
|
235
|
+
|
236
|
+
should 'show image alone' do
|
237
|
+
assert_equal({:show=>[], :name=>"pop", :options=>{}}, @imf[:popup])
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
190
242
|
end
|
@@ -58,6 +58,7 @@ class TextDocumentTest < Zena::Unit::TestCase
|
|
58
58
|
#header { background:url('bird.jpg') }
|
59
59
|
#pv { background:url('bird_pv.jpg') }
|
60
60
|
#footer { background:url('/projects/wiki/flower.jpg') }
|
61
|
+
#back { background:url('../../projects/wiki/flower.jpg') }
|
61
62
|
#no_stamp { background:url('/en/image30_pv.jpg') }
|
62
63
|
END_CSS
|
63
64
|
node.version.text = start.dup
|
@@ -71,6 +72,7 @@ class TextDocumentTest < Zena::Unit::TestCase
|
|
71
72
|
#header { background:url('/en/image30.jpg?1144713600') }
|
72
73
|
#pv { background:url('/en/image30_pv.jpg?967816914293') }
|
73
74
|
#footer { background:url('/en/image31.jpg?1144713600') }
|
75
|
+
#back { background:url('/en/image31.jpg?1144713600') }
|
74
76
|
#no_stamp { background:url('/en/image30_pv.jpg?967816914293') }
|
75
77
|
END_CSS
|
76
78
|
assert_equal res, text
|
@@ -82,6 +84,7 @@ class TextDocumentTest < Zena::Unit::TestCase
|
|
82
84
|
#header { background:url('bird.jpg') }
|
83
85
|
#pv { background:url('bird_pv.jpg') }
|
84
86
|
#footer { background:url('/projects/wiki/flower.jpg') }
|
87
|
+
#back { background:url('/projects/wiki/flower.jpg') }
|
85
88
|
#no_stamp { background:url('bird_pv.jpg') }
|
86
89
|
END_CSS
|
87
90
|
assert_equal unparsed, text
|
@@ -32,6 +32,15 @@ class HtmlTagsTest < Zena::View::TestCase
|
|
32
32
|
@controller.send(:flash)
|
33
33
|
end
|
34
34
|
|
35
|
+
# ============ stubs ============
|
36
|
+
def js_data
|
37
|
+
@js_data ||= []
|
38
|
+
end
|
39
|
+
def zazen(txt)
|
40
|
+
txt
|
41
|
+
end
|
42
|
+
# ===============================
|
43
|
+
|
35
44
|
def test_img_tag
|
36
45
|
login(:ant)
|
37
46
|
img = secure!(Node) { nodes(:bird_jpg) }
|
@@ -67,8 +76,8 @@ class HtmlTagsTest < Zena::View::TestCase
|
|
67
76
|
img_tag(img, :mode=>nil, :id=>'yo')
|
68
77
|
assert_equal "<img src='/en/image30_pv.jpg?967816914293' width='70' height='70' alt='bird' id='yo' class='super'/>",
|
69
78
|
img_tag(img, :mode=>'pv', :id=>'yo', :class=>'super')
|
70
|
-
assert_equal "<img src='/en/
|
71
|
-
img_tag(img, :mode=>'
|
79
|
+
assert_equal "<img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='super man' class='side'/>",
|
80
|
+
img_tag(img, :mode=>'side', :alt=>'super man')
|
72
81
|
end
|
73
82
|
|
74
83
|
def test_img_tag_other
|
@@ -241,4 +250,17 @@ class HtmlTagsTest < Zena::View::TestCase
|
|
241
250
|
node = secure!(Node) { nodes(:status) }
|
242
251
|
assert_match %r{opener.Zena.version_preview\('/nodes/#{node.zip}/versions/#{node.version.number}'\)}, version_actions(node.version, :actions => :view)
|
243
252
|
end
|
253
|
+
|
254
|
+
def test_popup_images
|
255
|
+
login(:anon)
|
256
|
+
img = secure!(Node) { nodes(:bird_jpg) }
|
257
|
+
@js_data = nil
|
258
|
+
img_tag(img)
|
259
|
+
assert_nil @js_data
|
260
|
+
img_tag(img, :mode => 'med', :id => 'flop') # med has a popup setting
|
261
|
+
popup_data = JSON.load(@js_data[0][%r{\A.*?(\{.*\}).*\Z},1])
|
262
|
+
assert_equal '/en/image30_std.jpg?929831698949', popup_data['src']
|
263
|
+
assert_equal 400, popup_data['height']
|
264
|
+
assert_equal 440, popup_data['width']
|
265
|
+
end
|
244
266
|
end
|
@@ -26,10 +26,6 @@ class RefactorTest < Zena::View::TestCase
|
|
26
26
|
assert ((Time.now.to_i-1 <= rnd) && (rnd <= Time.now.to_i+2))
|
27
27
|
end
|
28
28
|
|
29
|
-
def test_javascript
|
30
|
-
assert_nothing_raised { javascript('test') }
|
31
|
-
end
|
32
|
-
|
33
29
|
def test_change_lang
|
34
30
|
assert_equal ({:overwrite_params=>{:prefix=>'io'}}), change_lang('io')
|
35
31
|
login(:ant)
|
@@ -4,6 +4,12 @@ class ZafuTest < Zena::View::TestCase
|
|
4
4
|
include Zena::Use::Zafu::ViewMethods
|
5
5
|
include Zena::Use::Zafu::ControllerMethods
|
6
6
|
|
7
|
+
# mocks
|
8
|
+
def session; {} end
|
9
|
+
def lang; 'en' end
|
10
|
+
def zafu_helper; self end
|
11
|
+
def method_missing(m, *args); [m,args].inspect end
|
12
|
+
|
7
13
|
def test_page_numbers
|
8
14
|
s = ""
|
9
15
|
page_numbers(2, 3, ',') {|p,j| s << "#{j}#{p}"}
|
@@ -18,4 +24,10 @@ class ZafuTest < Zena::View::TestCase
|
|
18
24
|
page_numbers(28, 30, ' | ') {|p,j| s << "#{j}#{p}"}
|
19
25
|
assert_equal "21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30", s
|
20
26
|
end
|
27
|
+
|
28
|
+
def test_render_body_ends_with_js_render
|
29
|
+
@node = secure!(Node) { nodes(:status) }
|
30
|
+
compiled_template = template_url
|
31
|
+
assert_match %r{<%= render_js %></body>}, File.read(File.join(SITES_ROOT, compiled_template))
|
32
|
+
end
|
21
33
|
end
|
@@ -11,6 +11,9 @@ class ZazenTest < Zena::View::TestCase
|
|
11
11
|
def _(str)
|
12
12
|
ApplicationController.send(:_, str)
|
13
13
|
end
|
14
|
+
def js_data
|
15
|
+
@js_data ||= []
|
16
|
+
end
|
14
17
|
# ===============================
|
15
18
|
|
16
19
|
def assert_zazen_match(css, code)
|
@@ -179,12 +182,12 @@ class ZazenTest < Zena::View::TestCase
|
|
179
182
|
|
180
183
|
@node = secure!(Node) { nodes(:people) }
|
181
184
|
assert_equal '<p>Read <a href="/oo/projects/cleanWater/page22.html">projects/cleanWater/status</a></p>', zazen('Read "":(/projects/cleanWater/status)')
|
182
|
-
assert_equal "<p>See <img src='/en/
|
183
|
-
assert_equal "<p>See <a href=\"/oo/contact15.html\"><img src='/en/
|
185
|
+
assert_equal "<p>See <img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='bird' class='side'/></p>", zazen('See !:(/projects/wiki/bird)_side!')
|
186
|
+
assert_equal "<p>See <a href=\"/oo/contact15.html\"><img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='bird' class='side'/></a></p>", zazen('See !:(/projects/wiki/bird)_side!:(status)')
|
184
187
|
assert_equal '<p>Read <a href="/oo/contact15.html">people/status</a></p>', zazen('Read "":(status)')
|
185
188
|
|
186
189
|
@node = secure!(Node) { nodes(:wiki) }
|
187
|
-
assert_equal "<p>See <a href=\"/oo/projects/cleanWater\"><img src='/en/
|
190
|
+
assert_equal "<p>See <a href=\"/oo/projects/cleanWater\"><img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='bird' class='side'/></a></p>", zazen('See !:(bird)_side!:(/projects/cleanWater)')
|
188
191
|
end
|
189
192
|
|
190
193
|
def test_bad_pseudo_path
|
@@ -421,7 +421,7 @@ show_path_options:
|
|
421
421
|
|
422
422
|
uses_datebox:
|
423
423
|
src: "<r:uses_datebox/>"
|
424
|
-
tem: "/<script.*calendar.js.*calendar-setup.js.*calendar-en-utf8.js.*calendar-brown.css.*
|
424
|
+
tem: "/<script.*calendar.js.*calendar-setup.js.*calendar-en-utf8.js.*calendar-brown.css.*DEF_DATE_FORMAT.*%Y-%m-%d %H:%M.*FIRST_DAY.*0/"
|
425
425
|
|
426
426
|
calendar:
|
427
427
|
context:
|
@@ -776,14 +776,14 @@ img_image:
|
|
776
776
|
context:
|
777
777
|
node: 'bird_jpg'
|
778
778
|
src: "<r:img/><r:img mode='med'/>"
|
779
|
-
res: "
|
779
|
+
res: "/<img src='/en/image30_std.jpg\?929831698949' width='440' height='400' alt='bird' class='std'/><img src='/en/image30_med.jpg\?390663777446' width='220' height='200' alt='bird' id='.*' class='med' onclick='Zena.popup\(this\)'/>/"
|
780
780
|
|
781
781
|
img_image_not_public:
|
782
782
|
context:
|
783
783
|
visitor: 'ant'
|
784
784
|
node: 'tree_jpg'
|
785
785
|
src: "<r:img/><r:img mode='med'/>"
|
786
|
-
res: "
|
786
|
+
res: "/<img src='/oo/image40_std.jpg\?929831698949' width='600' height='399' alt='Autumn Tree' class='std'/><img src='/oo/image40_med.jpg\?390663777446' width='300' height='200' alt='Autumn Tree' id='.*' class='med' onclick='Zena.popup\(this\)'/>/"
|
787
787
|
|
788
788
|
img_href:
|
789
789
|
context:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2008 Piotr Sarnacki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Apache upload progress module. Works with mod_passenger (aka mod_rails). It's MIT license.
|
2
|
+
|
3
|
+
More info here: http://drogomir.com/blog/2008/6/18/upload-progress-bar-with-mod_passenger-and-apache
|
4
|
+
|
5
|
+
Tutorials showing how to use apache upload progress module:
|
6
|
+
http://www.drogomir.com/blog/2008/7/3/tweaking-rails-app-with-jquery-part-i (using jQuery)
|
7
|
+
http://www.railsillustrated.com/screencast-file-uploads-progress-in-rails-passenger.html (tutorial with screencast using prototype)
|
8
|
+
|
9
|
+
To install and activate module:
|
10
|
+
apxs2 -c -i -a mod_upload_progress.c
|
11
|
+
|
12
|
+
-c -> compile
|
13
|
+
-i -> install (copy upload_progress_module.so to apache lib folder)
|
14
|
+
-a -> activate (add LoadModule line to httpd.conf)
|
15
|
+
|
16
|
+
To compile it on mac you may need to:
|
17
|
+
sudo apxs -c -i -Wc,-arch -Wc,ppc7400 -Wl,-arch -Wl,ppc7400 -Wc,-arch -Wc,ppc64 -Wl,-arch -Wl,ppc64 -Wc,-arch -Wc,x86_64 -Wl,-arch -Wl,x86_64 -Wc,-arch -Wc,i386 -Wl,-arch -Wl,i386 mod_upload_progress.c
|
18
|
+
|
19
|
+
on an Intel mac: sudo apxs -c -i -a -Wc,-arch -Wc,x86_64 -Wl,-arch -Wl,x86_64 -Wc,-arch -Wc,i386 -Wl,-arch -Wl,i386 mod_upload_progress.c
|
20
|
+
|
21
|
+
Global config:
|
22
|
+
you can define maximum size for shared memory (default is 50kB):
|
23
|
+
UploadProgressSharedMemorySize 1024000 # sets memory size to 1MB
|
24
|
+
|
25
|
+
Note:
|
26
|
+
If you get "(12)Cannot allocate memory: Upload Progress cache: could not create shared memory segment Configuration Failed"
|
27
|
+
error you should try to set memory size to smaller value.
|
28
|
+
|
29
|
+
Config for vhost:
|
30
|
+
<Location />
|
31
|
+
# enable tracking uploads in /
|
32
|
+
TrackUploads On
|
33
|
+
</Location>
|
34
|
+
|
35
|
+
<Location /progress>
|
36
|
+
# enable upload progress reports in /progress
|
37
|
+
ReportUploads On
|
38
|
+
</Location>
|
39
|
+
|
40
|
+
- JSON-P Support
|
41
|
+
You can also request progress updates by using JSON-P, if you are uploading the file from a different domain or subdomain than the web server that is handling your original request. Adding a "callback=yourCallbackFunction" parameter to your request to the progress server will activate this functionality.
|
42
|
+
|
43
|
+
For example, a request like:
|
44
|
+
http://uploads.yourdomain.com/progress?callback=jsonp123&X-Progress-ID=1234
|
45
|
+
|
46
|
+
Would return the JSON-P function:
|
47
|
+
jsonp123(new Object({ 'state' : 'uploading', 'received' : 35587, 'size' : 716595, 'speed' : 35587 }));
|
48
|
+
|
49
|
+
The normal JSON request:
|
50
|
+
http://www.yourdomain.com/progress?X-Progress-ID=1234
|
51
|
+
|
52
|
+
Would return the JSON data:
|
53
|
+
new Object({ 'state' : 'uploading', 'received' : 35587, 'size' : 716595, 'speed' : 35587 })
|