zena 0.15.0 → 0.15.1
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 +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
@@ -1,21 +1,21 @@
|
|
1
|
-
# zena apache2 vhost for <%= host %>
|
1
|
+
# zena apache2 vhost for <%= config[:host] %>
|
2
2
|
# automatically generated file
|
3
3
|
|
4
4
|
<VirtualHost *>
|
5
|
-
ServerName <%= host %>
|
5
|
+
ServerName <%= config[:host] %>
|
6
6
|
|
7
|
-
DocumentRoot
|
8
|
-
ErrorLog
|
9
|
-
CustomLog
|
7
|
+
DocumentRoot <%= config[:sites_root] %>/<%= config[:host] %>/public
|
8
|
+
ErrorLog <%= config[:sites_root] %>/<%= config[:host] %>/log/apache2.error.log
|
9
|
+
CustomLog <%= config[:sites_root] %>/<%= config[:host] %>/log/apache2.access.log combined
|
10
10
|
|
11
|
-
<Directory "
|
11
|
+
<Directory "<%= config[:sites_root] %>/<%= config[:host] %>/public">
|
12
12
|
Options FollowSymLinks
|
13
13
|
AllowOverride None
|
14
14
|
Order allow,deny
|
15
15
|
Allow from all
|
16
16
|
</Directory>
|
17
17
|
|
18
|
-
<% if static.include?('cgi-bin') %>
|
18
|
+
<% if config[:static].include?('cgi-bin') %>
|
19
19
|
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
|
20
20
|
<Directory "/usr/lib/cgi-bin">
|
21
21
|
AllowOverride None
|
@@ -24,7 +24,7 @@
|
|
24
24
|
Allow from all
|
25
25
|
</Directory>
|
26
26
|
<% end %>
|
27
|
-
<% if static.include?('awstats-icon') %>
|
27
|
+
<% if config[:static].include?('awstats-icon') %>
|
28
28
|
Alias /awstats-icon/ /usr/share/awstats/icon/
|
29
29
|
<Directory "/usr/share/awstats/icon">
|
30
30
|
Options None
|
@@ -42,10 +42,11 @@
|
|
42
42
|
Satisfy All
|
43
43
|
</DirectoryMatch>
|
44
44
|
|
45
|
+
<% if config[:app_type] == :mongrel %>
|
45
46
|
RewriteEngine On
|
46
|
-
<% if debug_rewrite %>
|
47
|
+
<% if config[:debug_rewrite] %>
|
47
48
|
# rewrite debugging
|
48
|
-
RewriteLog
|
49
|
+
RewriteLog <%= config[:sites_root] %>/<%= config[:host] %>/log/rewrite.log
|
49
50
|
RewriteLogLevel 9
|
50
51
|
|
51
52
|
<% end %>
|
@@ -63,9 +64,22 @@
|
|
63
64
|
|
64
65
|
# Redirect all non-static requests to cluster
|
65
66
|
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}%{QUERY_STRING} !-f
|
66
|
-
RewriteRule ^/(.*)$ balancer://<%= balancer %>%{REQUEST_URI} [P,QSA,L]
|
67
|
+
RewriteRule ^/(.*)$ balancer://<%= config[:balancer] %>%{REQUEST_URI} [P,QSA,L]
|
68
|
+
<% elsif config[:app_type] == :passenger %>
|
69
|
+
PassengerAppRoot <% config[:app_root] %>
|
67
70
|
|
68
|
-
|
71
|
+
<Location />
|
72
|
+
# enable tracking uploads in /
|
73
|
+
TrackUploads On
|
74
|
+
</Location>
|
75
|
+
|
76
|
+
<Location /upload_progress>
|
77
|
+
# enable upload progress reports
|
78
|
+
ReportUploads On
|
79
|
+
</Location>
|
80
|
+
<% end %>
|
81
|
+
|
82
|
+
<% if config[:deflate] %>
|
69
83
|
# Deflate (compress data before sending to browser)
|
70
84
|
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css
|
71
85
|
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
@@ -73,12 +87,12 @@
|
|
73
87
|
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
74
88
|
<% end %>
|
75
89
|
|
76
|
-
<% if debug_deflate && deflate %>
|
90
|
+
<% if config[:debug_deflate] && config[:deflate] %>
|
77
91
|
# Deflate debugging
|
78
92
|
DeflateFilterNote Input input_info
|
79
93
|
DeflateFilterNote Output output_info
|
80
94
|
DeflateFilterNote Ratio ratio_info
|
81
95
|
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
|
82
|
-
CustomLog
|
96
|
+
CustomLog <%= config[:sites_root] %>/<%= config[:host] %>/log/deflate.log deflate
|
83
97
|
<% end %>
|
84
98
|
</VirtualHost>
|
File without changes
|
data/lib/zena/deploy.rb
ADDED
@@ -0,0 +1,377 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Deployment 'recipe' for capistrano. Creates everything for your zena app.
|
4
|
+
|
5
|
+
Assumed:
|
6
|
+
- mysql root user has the same password as ssh
|
7
|
+
- you are using apache 2.2+ (using balance_proxy)
|
8
|
+
- server is running debian etch
|
9
|
+
- you have installed subversion on the server (aptitude install subversion)
|
10
|
+
- you have installed mysql on the server (aptitude install mysql...)
|
11
|
+
- you have installed the required dependencies (see main README file)
|
12
|
+
|
13
|
+
========== USAGE ==========
|
14
|
+
|
15
|
+
1. Copy the file 'deploy_config_example.rb' to 'deploy_config.rb' and edit the entries in this new file.
|
16
|
+
2. Run => cap initial_setup
|
17
|
+
3. Run => cap mksite -s host='example.com' -s pass='secret' -s lang='en'
|
18
|
+
|
19
|
+
If anything goes wrong, ask the mailing list (lists.zenadmin.org) or read the content of this file to understand what went wrong...
|
20
|
+
|
21
|
+
And yes, 'pass' is not as intuitive as 'password' but we cannot use the latter because it's used for the ssh login.
|
22
|
+
|
23
|
+
|
24
|
+
=end
|
25
|
+
require 'erb'
|
26
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
27
|
+
|
28
|
+
set :templates, File.join(File.dirname(__FILE__), 'deploy')
|
29
|
+
self[:app_type] ||= :mongrel
|
30
|
+
self[:app_root] ||= '/var/zena/current'
|
31
|
+
self[:sites_root] ||= '/var/www/zena'
|
32
|
+
self[:balancer] ||= db_name
|
33
|
+
|
34
|
+
set :in_current, "cd #{deploy_to}/current &&"
|
35
|
+
class RenderClass
|
36
|
+
def initialize(path)
|
37
|
+
@text = File.read(path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render(hash)
|
41
|
+
@values = hash
|
42
|
+
ERB.new(@text).result(binding)
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(sym)
|
46
|
+
return @values[sym] if @values.has_key?(sym)
|
47
|
+
super
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def render(file, hash)
|
52
|
+
RenderClass.new(file).render(hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
#========================== SOURCE CODE =========================#
|
56
|
+
|
57
|
+
|
58
|
+
desc "set permissions to www-data"
|
59
|
+
task :set_permissions, :roles => :app do
|
60
|
+
run "chown -R www-data:www-data #{deploy_to}/current/public #{deploy_to}/current/log"
|
61
|
+
end
|
62
|
+
|
63
|
+
"Update the currently released version of the software directly via an SCM update operation"
|
64
|
+
task :update_current do
|
65
|
+
source.sync(revision, self[:release_path])
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "clear all zafu compiled templates"
|
69
|
+
task :clear_zafu, :roles => :app do
|
70
|
+
run "#{in_current} rake zena:clear_zafu RAILS_ENV=production"
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "clear all cache compiled templates"
|
74
|
+
task :clear_cache, :roles => :app do
|
75
|
+
run "#{in_current} rake zena:clear_cache RAILS_ENV=production"
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "after code update"
|
79
|
+
task :after_update, :roles => :app do
|
80
|
+
app_update_symlinks
|
81
|
+
db_update_config
|
82
|
+
apache2_setup
|
83
|
+
migrate
|
84
|
+
clear_zafu
|
85
|
+
clear_cache
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "update symlink to 'sites' directory"
|
89
|
+
task :app_update_symlinks, :roles => :app do
|
90
|
+
run "test ! -e #{deploy_to}/current/sites || rm #{deploy_to}/current/sites"
|
91
|
+
run "ln -sf #{sites_root} #{deploy_to}/current/sites"
|
92
|
+
set_permissions
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "migrate database (zena version)"
|
96
|
+
task :migrate, :roles => :db do
|
97
|
+
run "#{in_current} rake zena:migrate RAILS_ENV=production"
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "initial app setup"
|
101
|
+
task :app_setup, :roles => :app do
|
102
|
+
gem_update
|
103
|
+
run "test -e #{deploy_to} || mkdir #{deploy_to}"
|
104
|
+
run "test -e #{sites_root} || mkdir #{sites_root}"
|
105
|
+
deploy::setup
|
106
|
+
end
|
107
|
+
|
108
|
+
#========================== MANAGE HOST =========================#
|
109
|
+
desc "create a new site"
|
110
|
+
task :mksite, :roles => :app do
|
111
|
+
run "#{in_current} rake zena:mksite HOST='#{self[:host]}' PASSWORD='#{self[:pass]}' RAILS_ENV='production' LANG='#{self[:lang] || 'en'}'"
|
112
|
+
create_vhost
|
113
|
+
create_awstats
|
114
|
+
run "chown -R www-data:www-data #{sites_root}/#{self[:host]}"
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "update code in the current version"
|
118
|
+
task :up, :roles => :app do
|
119
|
+
run "cd #{deploy_to}/current && #{self[:scm] == 'git' ? "git pull origin #{self[:branch] || 'master'}" : 'svn up'} && (echo #{strategy.configuration[:real_revision]} > #{deploy_to}/current/REVISION)"
|
120
|
+
db_update_config
|
121
|
+
clear_zafu
|
122
|
+
clear_cache
|
123
|
+
migrate
|
124
|
+
restart
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "light update code (no migration, no clear)"
|
128
|
+
task :lightup, :roles => :app do
|
129
|
+
run "cd #{deploy_to}/current && #{self[:scm] == 'git' ? "git pull origin #{self[:branch] || 'master'}" : 'svn up'}"
|
130
|
+
restart
|
131
|
+
end
|
132
|
+
|
133
|
+
#========================== MONGREL ===============================#
|
134
|
+
desc "configure mongrel"
|
135
|
+
task :mongrel_setup, :roles => :app do
|
136
|
+
run "#{in_current} mongrel_rails cluster::configure -e production -p #{mongrel_port} -N #{mongrel_count} -c #{deploy_to}/current -P log/mongrel.pid -l log/mongrel.log -a 127.0.0.1 --user www-data --group www-data"
|
137
|
+
run "#{in_current} echo 'config_script: config/mongrel_upload_progress.conf' >> config/mongrel_cluster.yml"
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Stop the drb upload_progress server"
|
141
|
+
task :stop_upload_progress , :roles => :app do
|
142
|
+
run "#{in_current} ruby lib/upload_progress_server.rb stop"
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "Start the drb upload_progress server"
|
146
|
+
task :start_upload_progress , :roles => :app do
|
147
|
+
run "#{in_current} lib/upload_progress_server.rb start"
|
148
|
+
end
|
149
|
+
|
150
|
+
desc "Restart the upload_progress server"
|
151
|
+
task :restart_upload_progress, :roles => :app do
|
152
|
+
stop_upload_progress
|
153
|
+
start_upload_progress
|
154
|
+
end
|
155
|
+
|
156
|
+
desc "Start mongrel"
|
157
|
+
task :start, :roles => :app do
|
158
|
+
restart_upload_progress
|
159
|
+
run "#{in_current} mongrel_rails cluster::start"
|
160
|
+
end
|
161
|
+
|
162
|
+
desc "Stop mongrel"
|
163
|
+
task :stop, :roles => :app do
|
164
|
+
stop_upload_progress
|
165
|
+
run "#{in_current} mongrel_rails cluster::stop"
|
166
|
+
end
|
167
|
+
|
168
|
+
desc "Restart mongrel"
|
169
|
+
task :restart, :roles => :app do
|
170
|
+
stop
|
171
|
+
restart_upload_progress
|
172
|
+
start
|
173
|
+
end
|
174
|
+
|
175
|
+
#========================== APACHE2 ===============================#
|
176
|
+
desc "Update vhost configuration file"
|
177
|
+
task :create_vhost, :roles => :web do
|
178
|
+
unless self[:host]
|
179
|
+
puts "HOST not set (use -s host=...)"
|
180
|
+
else
|
181
|
+
vhost = render("#{templates}/vhost.rhtml", :config => self)
|
182
|
+
put(vhost, "#{vhost_root}/#{self[:host]}")
|
183
|
+
|
184
|
+
run "test -e /etc/apache2/sites-enabled/#{self[:host]} || a2ensite #{self[:host]}" if debian_host
|
185
|
+
|
186
|
+
unless self[:host] =~ /^www/
|
187
|
+
vhost_www = render("#{templates}/vhost_www.rhtml",
|
188
|
+
:host => self[:host]
|
189
|
+
)
|
190
|
+
put(vhost_www, "#{vhost_root}/www.#{self[:host]}")
|
191
|
+
run "test -e /etc/apache2/sites-enabled/www.#{self[:host]} || a2ensite www.#{self[:host]}" if debian_host
|
192
|
+
end
|
193
|
+
run apache2_reload_cmd
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
#========================== APACHE2 ===============================#
|
198
|
+
desc "Update awstats configuration file"
|
199
|
+
task :create_awstats, :roles => :web do
|
200
|
+
unless debian_host
|
201
|
+
puts "skipping debian specific awstats"
|
202
|
+
else
|
203
|
+
unless self[:host] && self[:pass]
|
204
|
+
puts "host or password not set (use -s host=... -s pass=...)"
|
205
|
+
else
|
206
|
+
# create awstats config file
|
207
|
+
awstats_conf = render("#{templates}/awstats.conf.rhtml", :host => self[:host] )
|
208
|
+
put(awstats_conf, "/etc/awstats/awstats.#{self[:host]}.conf")
|
209
|
+
run "chown www-data:www-data /etc/awstats/awstats.#{self[:host]}.conf"
|
210
|
+
run "chmod 640 /etc/awstats/awstats.#{self[:host]}.conf"
|
211
|
+
|
212
|
+
# create stats vhost
|
213
|
+
stats_vhost = render("#{templates}/stats.vhost.rhtml", :host => self[:host] )
|
214
|
+
put(stats_vhost, "#{vhost_root}/stats.#{self[:host]}")
|
215
|
+
run "test -e /etc/apache2/sites-enabled/stats.#{self[:host]} || a2ensite stats.#{self[:host]}"
|
216
|
+
|
217
|
+
# directory setup for stats
|
218
|
+
run "test -e #{sites_root}/#{self[:host]}/log/awstats || mkdir #{sites_root}/#{self[:host]}/log/awstats"
|
219
|
+
run "chown www-data:www-data #{sites_root}/#{self[:host]}/log/awstats"
|
220
|
+
|
221
|
+
# setup cron task for awstats
|
222
|
+
run "cat /etc/cron.d/awstats | grep \"#{self[:host]}\" || echo \"0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.#{self[:host]}.conf -a -r #{sites_root}/#{self[:host]}/log/apache2.access.log ] && /usr/lib/cgi-bin/awstats.pl -config=#{self[:host]} -update >/dev/null\n\" >> /etc/cron.d/awstats"
|
223
|
+
|
224
|
+
# create .htpasswd file
|
225
|
+
run "test ! -e #{sites_root}/#{self[:host]}/log/.awstatspw || rm #{sites_root}/#{self[:host]}/log/.awstatspw"
|
226
|
+
run "htpasswd -c -b #{sites_root}/#{self[:host]}/log/.awstatspw 'admin' '#{self[:pass]}'"
|
227
|
+
|
228
|
+
# reload apache
|
229
|
+
apache2_reload_cmd
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
desc "Rename a webhost"
|
235
|
+
task :rename_host, :roles => :web do
|
236
|
+
unless self[:host] && self[:old_host] && self[:pass]
|
237
|
+
puts "host or old_host not set (use -s host=... -s pass=... -s old_host=...)"
|
238
|
+
else
|
239
|
+
run "#{in_current} rake zena:rename_host OLD_HOST='#{self[:old_host]}' HOST='#{self[:host]}' RAILS_ENV='production'"
|
240
|
+
old_vhosts = ["#{self[:old_host]}",
|
241
|
+
"stats.#{self[:old_host]}",
|
242
|
+
"www.#{self[:old_host]}"]
|
243
|
+
old_vhosts.each do |vhost|
|
244
|
+
run "test -e /etc/apache2/sites-enabled/#{vhost} && a2dissite #{vhost} || true"
|
245
|
+
vhost_path = "#{vhost_root}/#{vhost}"
|
246
|
+
run "test -e #{vhost_path} && rm #{vhost_path} || true"
|
247
|
+
end
|
248
|
+
|
249
|
+
awstat_conf = "/etc/awstats/awstats.#{self[:old_host]}.conf"
|
250
|
+
run "test -e#{awstat_conf} && rm #{awstat_conf} || true"
|
251
|
+
|
252
|
+
create_vhost
|
253
|
+
create_awstats
|
254
|
+
clear_zafu
|
255
|
+
clear_cache
|
256
|
+
set_permissions
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
desc "Apache2 initial setup"
|
261
|
+
task :apache2_setup, :roles => :web do
|
262
|
+
self[:ports] = (mongrel_port.to_i...(mongrel_port.to_i + mongrel_count.to_i)).to_a
|
263
|
+
httpd_conf = render("#{templates}/httpd.rhtml", :config => self)
|
264
|
+
if debian_host
|
265
|
+
put(httpd_conf, "/etc/apache2/conf.d/#{db_name}")
|
266
|
+
else
|
267
|
+
put(httpd_conf, "/etc/apache2/conf.d/#{db_name}")
|
268
|
+
end
|
269
|
+
|
270
|
+
run "test -e /etc/apache2/sites-enabled/000-default && a2dissite default || echo 'default already disabled'"
|
271
|
+
run "test -e /etc/apache2/mods-enabled/rewrite.load || a2enmod rewrite"
|
272
|
+
run "test -e /etc/apache2/mods-enabled/deflate.load || a2enmod deflate"
|
273
|
+
run "test -e /etc/apache2/mods-enabled/proxy_balancer.load || a2enmod proxy_balancer"
|
274
|
+
run "test -e /etc/apache2/mods-enabled/proxy.load || a2enmod proxy"
|
275
|
+
run "test -e /etc/apache2/mods-enabled/proxy_http.load || a2enmod proxy_http"
|
276
|
+
run "test -e /etc/apache2/mods-enabled/expires.load || a2enmod expires"
|
277
|
+
run "/etc/init.d/apache2 force-reload"
|
278
|
+
end
|
279
|
+
|
280
|
+
#========================== GEM ===============================#
|
281
|
+
|
282
|
+
desc "install zena gem on remote server"
|
283
|
+
task :gem_update, :roles => :app do
|
284
|
+
run "gem sources -a http://gems.github.com"
|
285
|
+
run "gem install zena"
|
286
|
+
end
|
287
|
+
|
288
|
+
#========================== MYSQL ===============================#
|
289
|
+
|
290
|
+
desc "set database.yml file according to settings"
|
291
|
+
task :db_update_config, :roles => :app do
|
292
|
+
db_app_config = render("#{templates}/database.rhtml",
|
293
|
+
:db_name => db_name,
|
294
|
+
:db_user => db_user,
|
295
|
+
:db_password => db_password
|
296
|
+
)
|
297
|
+
put(db_app_config, "#{deploy_to}/current/config/database.yml")
|
298
|
+
end
|
299
|
+
|
300
|
+
desc "create database"
|
301
|
+
task :db_create, :roles => :db do
|
302
|
+
on_rollback do
|
303
|
+
run "mysql -u root -p -e \"DROP DATABASE #{db_name};\"" do |channel, stream, data|
|
304
|
+
if data =~ /^Enter password:\s*/m
|
305
|
+
logger.info "#{channel[:host]} asked for password"
|
306
|
+
channel.send_data "#{password}\n"
|
307
|
+
end
|
308
|
+
puts data
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
run "mysql -u root -p -e \"CREATE DATABASE #{db_name} DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; GRANT ALL ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_password}';\"" do |channel, stream, data|
|
313
|
+
if data =~ /^Enter password:\s*/m
|
314
|
+
logger.info "#{channel[:host]} asked for password"
|
315
|
+
channel.send_data "#{password}\n"
|
316
|
+
end
|
317
|
+
puts data
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
desc "initial database setup"
|
322
|
+
task :db_setup, :roles => :db do
|
323
|
+
transaction do
|
324
|
+
db_create
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
desc "Full initial setup"
|
330
|
+
task :initial_setup do
|
331
|
+
transaction do
|
332
|
+
app_setup
|
333
|
+
|
334
|
+
db_setup
|
335
|
+
|
336
|
+
deploy::update
|
337
|
+
|
338
|
+
mongrel_setup
|
339
|
+
|
340
|
+
apache2_setup
|
341
|
+
|
342
|
+
set_permissions
|
343
|
+
|
344
|
+
start
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
desc "Database dump"
|
349
|
+
task :db_dump, :roles => :db do
|
350
|
+
run "mysqldump #{db_name} -u root -p > #{deploy_to}/current/#{db_name}.sql" do |channel, stream, data|
|
351
|
+
if data =~ /^Enter password:\s*/m
|
352
|
+
logger.info "#{channel[:host]} asked for password"
|
353
|
+
channel.send_data "#{password}\n"
|
354
|
+
end
|
355
|
+
puts data
|
356
|
+
end
|
357
|
+
run "#{in_current} tar czf #{db_name}.sql.tgz #{db_name}.sql"
|
358
|
+
run "#{in_current} rm #{db_name}.sql"
|
359
|
+
end
|
360
|
+
|
361
|
+
desc "Get backup file back"
|
362
|
+
task :get_backup, :roles => :app do
|
363
|
+
get "#{deploy_to}/current/#{db_name}_data.tgz", "./#{db_name}_#{Time.now.strftime '%Y-%m-%d-%H'}.tgz"
|
364
|
+
end
|
365
|
+
|
366
|
+
# FIXME: backup not loading data for every site...
|
367
|
+
desc "Backup all data and bring it backup here"
|
368
|
+
task :backup, :roles => :app do
|
369
|
+
db_dump
|
370
|
+
# key track of the current svn revision for app
|
371
|
+
|
372
|
+
run "#{in_current} svn info > #{deploy_to}/current/zena_version.txt"
|
373
|
+
run "#{in_current} rake zena:full_backup RAILS_ENV='production'"
|
374
|
+
run "#{in_current} tar czf #{db_name}_data.tgz #{db_name}.sql.tgz sites_data.tgz zena_version.txt"
|
375
|
+
get_backup
|
376
|
+
end
|
377
|
+
end
|
data/lib/zena/info.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
if defined?(RAILS_ROOT)
|
2
|
+
SITES_ROOT = "#{RAILS_ROOT}/sites"
|
3
|
+
end
|
4
|
+
AUTHENTICATED_PREFIX = "oo"
|
5
|
+
PASSWORD_SALT = "jf93jfnvnas09093nas0923" # type anything here (but change this line !)
|
6
|
+
ZENA_CALENDAR_LANGS = ["en", "fr"] # FIXME: build this dynamically from existing files
|
7
|
+
ENABLE_XSENDFILE = false
|
8
|
+
|
9
|
+
module Zena
|
10
|
+
VERSION = '0.15.1'
|
11
|
+
REVISION = 1336
|
12
|
+
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
13
|
+
end
|
@@ -41,6 +41,7 @@ require 'yaml'
|
|
41
41
|
|
42
42
|
module Zena
|
43
43
|
module Parser
|
44
|
+
include RubyLess::SafeClass
|
44
45
|
# Zafu tags used to display / edit nodes and versions
|
45
46
|
module ZenaTags
|
46
47
|
PSEUDO_ATTRIBUTES = {
|
@@ -3029,6 +3030,8 @@ module Zena
|
|
3029
3030
|
params[:mode] = @params[:mode] if @params[:mode]
|
3030
3031
|
params[:format] = @params[:format] if @params[:format]
|
3031
3032
|
"zen_#{real_attribute}(#{node}#{params_to_erb(params)})"
|
3033
|
+
elsif type = safe_method_type([real_attribute])
|
3034
|
+
type[:method]
|
3032
3035
|
elsif type = klass.safe_method_type([real_attribute])
|
3033
3036
|
"#{att_node}.#{type[:method]}"
|
3034
3037
|
else
|
data/lib/zena/parser.rb
CHANGED
data/lib/zena/use/calendar.rb
CHANGED
@@ -114,7 +114,8 @@ module Zena
|
|
114
114
|
if state == 'used' && remove_used.nil?
|
115
115
|
res << title
|
116
116
|
else
|
117
|
-
|
117
|
+
date_format = "%Y-%m-%d+%H"
|
118
|
+
opts = {:url => "/nodes/#{node.zip}?node[rel][#{role}][date]=#{date.strftime(date_format)}&node[rel][#{role}][other_id]=#{state == 'free' ? target_zip : ''}&s=#{target_zip}&dom_id=#{full_dom_id}&t_url=#{CGI.escape(template_url)}&date=#{date.strftime(date_format)}", :method => :put}
|
118
119
|
if state == 'used' && remove_used == 'warn'
|
119
120
|
opts[:confirm] = _("Delete relation '%{role}' between '%{source}' and '%{target}' ?") % {:role => role, :source => node.version.title, :target => node.linked_node.version.title}
|
120
121
|
end
|
data/lib/zena/use/dates.rb
CHANGED
@@ -170,7 +170,12 @@ module Zena
|
|
170
170
|
hash['%S'] ||= 0
|
171
171
|
if hash['%Y'] && hash['%m'] && hash['%d']
|
172
172
|
res = Time.utc(hash['%Y'], hash['%m'], hash['%d'], hash['%H'], hash['%M'], hash['%S'])
|
173
|
-
|
173
|
+
begin
|
174
|
+
timezone ? timezone.local_to_utc(res, true) : res
|
175
|
+
rescue TZInfo::AmbiguousTime
|
176
|
+
# Better a bad date then nothing
|
177
|
+
res
|
178
|
+
end
|
174
179
|
else
|
175
180
|
nil
|
176
181
|
end
|
data/lib/zena/use/fixtures.rb
CHANGED
@@ -127,6 +127,15 @@ module Zena
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
130
|
+
|
131
|
+
unless File.exist?("#{SITES_ROOT}/test.host/public")
|
132
|
+
FileUtils::mkpath("#{SITES_ROOT}/test.host/public")
|
133
|
+
['images', 'calendar', 'stylesheets', 'javascripts'].each do |dir|
|
134
|
+
FileUtils.ln_s("../../../public/#{dir}", "#{SITES_ROOT}/test.host/public/#{dir}")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
FileUtils::mkpath("#{SITES_ROOT}/test.host/log") unless File.exist?("#{SITES_ROOT}/test.host/log")
|
130
139
|
end
|
131
140
|
end # Fixtures
|
132
141
|
end # use
|
data/lib/zena/use/html_tags.rb
CHANGED
@@ -43,7 +43,7 @@ module Zena
|
|
43
43
|
|
44
44
|
if res.kind_of?(Hash)
|
45
45
|
out = "<img"
|
46
|
-
[:src, :width, :height, :alt, :id, :class, :style, :border].each do |k|
|
46
|
+
[:src, :width, :height, :alt, :id, :class, :style, :border, :onclick].each do |k|
|
47
47
|
next unless v = res[k]
|
48
48
|
out << " #{k}='#{v}'"
|
49
49
|
end
|
@@ -73,6 +73,43 @@ module Zena
|
|
73
73
|
# compute image size
|
74
74
|
res[:width] = content.width(format)
|
75
75
|
res[:height] = content.height(format)
|
76
|
+
if popup = format[:popup]
|
77
|
+
|
78
|
+
if popup_fmt = Iformat[popup[:name]]
|
79
|
+
options = popup[:options]
|
80
|
+
keys = popup[:show]
|
81
|
+
res[:onclick] = 'Zena.popup(this)'
|
82
|
+
res[:id] ||= unique_id
|
83
|
+
data = {}
|
84
|
+
data['src'] = data_path(obj, :mode => (popup[:size] == :keep ? nil : popup[:name]), :host => opts[:host])
|
85
|
+
data['width'] = content.width(popup_fmt)
|
86
|
+
data['height'] = content.height(popup_fmt)
|
87
|
+
|
88
|
+
data['fields'] = fields = {}
|
89
|
+
data['keys'] = field_keys = []
|
90
|
+
keys.each do |k|
|
91
|
+
case k
|
92
|
+
when 'navigation'
|
93
|
+
field_keys << k
|
94
|
+
data[k] = true
|
95
|
+
else
|
96
|
+
if v = obj.safe_read(k)
|
97
|
+
field_keys << k
|
98
|
+
case options[k]
|
99
|
+
when 'raw'
|
100
|
+
fields[k] = v
|
101
|
+
when 'link'
|
102
|
+
fields[k] = link_to(v, zen_path(obj))
|
103
|
+
else
|
104
|
+
fields[k] = zazen(v)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
self.js_data << "$('#{res[:id]}')._popup = #{data.to_json};"
|
111
|
+
end
|
112
|
+
end
|
76
113
|
res
|
77
114
|
elsif obj.kind_of?(Document) && obj.version.content.ext == 'mp3' && (opts[:mode].nil? || opts[:mode] == 'std' || opts[:mode] == 'button')
|
78
115
|
# rough wrap to use the 'button'
|
@@ -171,10 +208,10 @@ module Zena
|
|
171
208
|
<script src="/calendar/calendar-setup.js" type="text/javascript"></script>
|
172
209
|
<script src="/calendar/lang/calendar-#{l}-utf8.js" type="text/javascript"></script>
|
173
210
|
<link href="/calendar/calendar-brown.css" media="screen" rel="Stylesheet" type="text/css" />
|
174
|
-
|
211
|
+
<% javascript_tag do -%>
|
175
212
|
Calendar._TT["DEF_DATE_FORMAT"] = "#{_('datetime')}";
|
176
213
|
Calendar._TT["FIRST_DAY"] = #{_('week_start_day')};
|
177
|
-
|
214
|
+
<% end -%>
|
178
215
|
EOL
|
179
216
|
end
|
180
217
|
|
@@ -500,7 +537,7 @@ module Zena
|
|
500
537
|
"<a href='#{url}#{publish_after_save ? "?pub=#{publish_after_save}" : ''}' target='_blank' title='#{_('btn_title_edit')}' onclick=\"editor=window.open('#{url}#{publish_after_save ? "?pub=#{publish_after_save}" : ''}', \'#{current_site.host}#{node[:zip]}\', 'location=0,width=300,height=400,resizable=1');return false;\">" +
|
501
538
|
_('btn_edit') + "</a>"
|
502
539
|
when 'drive'
|
503
|
-
"<a href='#' title='#{_('btn_title_drive')}' onclick=\"editor=window.open('" +
|
540
|
+
"<a href='#{edit_node_url(:id => node[:zip])}' target='_blank' title='#{_('btn_title_drive')}' onclick=\"editor=window.open('" +
|
504
541
|
edit_node_url(:id => node[:zip] ) +
|
505
542
|
"', '_blank', 'location=0,width=300,height=400,resizable=1');return false;\">" +
|
506
543
|
_('btn_drive') + "</a>"
|
@@ -534,7 +571,9 @@ module Zena
|
|
534
571
|
def version_action_link(action,version)
|
535
572
|
if action == 'view'
|
536
573
|
# FIXME
|
537
|
-
link_to_function(
|
574
|
+
link_to_function(
|
575
|
+
_("status_#{version.status}_img"),
|
576
|
+
"opener.Zena.version_preview('/nodes/#{version.node.zip}/versions/#{version.number}');", :title => _("status_#{version.status}"))
|
538
577
|
else
|
539
578
|
if action == 'destroy_version'
|
540
579
|
action = 'destroy'
|
@@ -8,8 +8,7 @@ class NodeQuery < QueryBuilder
|
|
8
8
|
set_main_class 'Node'
|
9
9
|
@@filter_fields = {'id' => {:key => 'zip'}}
|
10
10
|
|
11
|
-
#
|
12
|
-
load_custom_queries File.join(File.dirname(__FILE__), 'custom_queries')
|
11
|
+
load_custom_queries ["#{RAILS_ROOT}/bricks/*/queries"]
|
13
12
|
|
14
13
|
def self.insert_zero_link(link_class)
|
15
14
|
return if link_class.find_by_id(0)
|
data/lib/zena/use/refactor.rb
CHANGED
@@ -37,19 +37,6 @@ module Zena
|
|
37
37
|
include Common
|
38
38
|
|
39
39
|
# TODO: use Rails native helper.
|
40
|
-
def javascript( string )
|
41
|
-
javascript_start +
|
42
|
-
string +
|
43
|
-
javascript_end
|
44
|
-
end
|
45
|
-
|
46
|
-
def javascript_start
|
47
|
-
"<script type=\"text/javascript\" charset=\"utf-8\">\n// <![CDATA[\n"
|
48
|
-
end
|
49
|
-
|
50
|
-
def javascript_end
|
51
|
-
"\n// ]]>\n</script>"
|
52
|
-
end
|
53
40
|
|
54
41
|
# Quote for html values (input tag, alt attribute, etc)
|
55
42
|
def fquote(text)
|