Module: Zena
- Defined in:
- lib/gettext_strings.rb,
lib/zena.rb,
lib/zena/db.rb,
lib/zena/app.rb,
lib/zena/use.rb,
lib/zena/info.rb,
lib/zena/parser.rb,
lib/zena/remote.rb,
lib/zena/routes.rb,
lib/zena/status.rb,
lib/zena/console.rb,
lib/zena/migrator.rb,
lib/zena/use/ajax.rb,
lib/zena/use/grid.rb,
lib/zena/use/i18n.rb,
lib/zena/use/urls.rb,
lib/zena/use/dates.rb,
lib/zena/use/forms.rb,
lib/zena/use/kpath.rb,
lib/zena/use/zazen.rb,
lib/zena/use/action.rb,
lib/zena/use/search.rb,
lib/zena/use/upload.rb,
lib/zena/acts/secure.rb,
lib/zena/code_syntax.rb,
lib/zena/foxy_parser.rb,
lib/zena/remote/mock.rb,
lib/zena/remote/node.rb,
lib/zena/site_worker.rb,
lib/zena/use/context.rb,
lib/zena/use/display.rb,
lib/zena/remote/klass.rb,
lib/zena/use/ancestry.rb,
lib/zena/use/calendar.rb,
lib/zena/use/fixtures.rb,
lib/zena/use/fulltext.rb,
lib/zena/use/ml_index.rb,
lib/zena/use/refactor.rb,
lib/zena/use/workflow.rb,
lib/zena/use/authlogic.rb,
lib/zena/use/html_tags.rb,
lib/zena/use/prop_eval.rb,
lib/zena/use/recursion.rb,
lib/zena/use/relations.rb,
lib/zena/use/rendering.rb,
lib/zena/use/zafu_eval.rb,
lib/zena/zafu_compiler.rb,
lib/zena/base_additions.rb,
lib/zena/unit/test_case.rb,
lib/zena/use/query_node.rb,
lib/zena/view/test_case.rb,
lib/zena/webdav_adapter.rb,
lib/zena/acts/enrollable.rb,
lib/zena/db_helper/mysql.rb,
lib/zena/test_controller.rb,
lib/zena/use/field_index.rb,
lib/zena/use/scope_index.rb,
lib/zena/use/test_helper.rb,
lib/zena/acts/secure_node.rb,
lib/zena/parser/zafu_tags.rb,
lib/zena/remote/interface.rb,
lib/zena/use/node_context.rb,
lib/zena/use/version_hash.rb,
lib/zena/acts/serializable.rb,
lib/zena/db_helper/sqlite3.rb,
lib/zena/parser/zafu_rules.rb,
lib/zena/parser/zazen_tags.rb,
lib/zena/parser/zena_rules.rb,
lib/zena/remote/connection.rb,
lib/zena/use/image_builder.rb,
lib/zena/use/query_builder.rb,
lib/zena/use/query_comment.rb,
lib/zena/loader/yaml_loader.rb,
lib/zena/parser/zazen_rules.rb,
lib/zena/use/dyn_attributes.rb,
lib/zena/use/zafu_templates.rb,
lib/zena/code/default_syntax.rb,
lib/zena/use/error_rendering.rb,
lib/zena/use/zafu_attributes.rb,
lib/zena/controller/test_case.rb,
lib/zena/db_helper/postgresql.rb,
lib/zena/db_helper/abstract_db.rb,
lib/zena/integration/test_case.rb,
lib/zena/crypto_provider/initial.rb,
lib/zena/refactor/act_as_content.rb,
lib/zena/remote/serializable_array.rb,
lib/zena/use/zafu_safe_definitions.rb,
lib/zena/use/nested_attributes_alias.rb
Overview
Copyright © 2007 Gaspard Bucher
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Modules: Acts, App, Code, Console, Controller, CryptoProvider, DbHelper, Integration, Loader, Parser, Refactor, Remote, Routes, Status, Unit, Use, View, WebDav
Classes: AccessViolation, BadConfiguration, CodeSyntax, FoxyAttachmentsParser, FoxyColumnsParser, FoxyCommentsParser, FoxyGroupsUsersParser, FoxyIformatsParser, FoxyLinksParser, FoxyNodesParser, FoxyNodesRolesParser, FoxyParser, FoxyRelationsParser, FoxyRolesParser, FoxySitesParser, FoxyUsersParser, FoxyVersionsParser, FoxyZipsParser, InvalidRecord, Migrator, RecordNotSecured, SiteWorker, TestController
Constant Summary
collapse
- ASSET_PORT =
Bricks.raw_config['asset_port'].to_i
- ENABLE_LATEX =
enable LateX post-rendering
true && has_executable('pdflatex')
- ENABLE_FOP =
enable xsl-fo post-rendering
true && has_executable('fop', 'xsltproc')
- ENABLE_MATH =
true && has_executable('latex', 'dvips', 'convert', 'gs')
- VERSION =
'1.1.3'
- ROOT =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
- ZafuCompiler =
Zena::Use::ZafuSafeDefinitions::ZafuMethods
Zafu.parser_with_rules([
Zafu::All,
Zena::Use::Conditional::ZafuMethods,
Zena::Use::Context::ZafuMethods,
Zena::Use::Urls::ZafuMethods,
Zena::Use::ZafuAttributes::ZafuMethods,
Zena::Use::ZafuEval::ZafuMethods,
Zena::Use::QueryBuilder::ZafuMethods,
Zena::Use::Display::ZafuMethods,
Zena::Use::Calendar::ZafuMethods,
Zena::Use::I18n::ZafuMethods,
Zena::Use::Action::ZafuMethods,
Zena::Use::Dates::ZafuMethods,
Zena::Use::Forms::ZafuMethods,
Zena::Use::Recursion::ZafuMethods,
Zena::Use::Rendering::ZafuMethods,
Zena::Use::Search::ZafuMethods,
Zena::Use::Ajax::ZafuMethods,
Zena::Use::ZafuSafeDefinitions::ZafuMethods,
Zena::Acts::Enrollable::ZafuMethods,
])
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
Returns the value of attribute tools_enabled.
33
34
35
|
# File 'lib/zena.rb', line 33
def tools_enabled
@tools_enabled
end
|
Class Method Details
.add_inflections ⇒ Object
197
198
199
200
201
|
# File 'lib/zena.rb', line 197
def add_inflections
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable %w( children )
end
end
|
.add_load_paths(config = nil) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/zena.rb', line 49
def add_load_paths(config = nil)
paths_to_add = (
Dir["#{Zena::ROOT}/vendor/gems/*/lib"] +
Dir["#{Zena::ROOT}/vendor/plugins/*/lib"] +
Bricks.models_paths
)
if config
["#{Zena::ROOT}/vendor", "#{Zena::ROOT}/lib"].each do |path|
ActiveSupport::Dependencies.autoload_paths << path
ActiveSupport::Dependencies.autoload_once_paths << path
$LOAD_PATH << path
end
else
paths_to_add.each do |path|
$LOAD_PATH.push path
end
end
end
|
.config_gems(config) ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/zena.rb', line 137
def config_gems(config)
gem_configuration.each do |gem_name, gem_config|
if gem_config
conf = gem_config.symbolize_keys
conf[:version].gsub!(/\A=\s*/,'')
if conf[:optional]
if brick = conf[:brick]
if Bricks::CONFIG[brick]
config.gem gem_name, conf
end
else
begin
config.gem gem_name, conf
rescue LoadError
end
end
else
config.gem gem_name, conf
end
else
config.gem gem_name
end
end
end
|
.gem_configuration ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/zena.rb', line 101
def gem_configuration
conf = open("#{Zena::ROOT}/config/gems.yml") {|f| YAML.load(f.read)}
res = {}
conf.each do |k, v|
if v.kind_of?(String)
res[k] = {'version' => v}
else
res[k] = v
end
end
res
end
|
.gems_setup ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/zena.rb', line 114
def gems_setup
gem_configuration.each do |gem_name, gem_config|
if gem_config
if gem_config['optional']
if brick_name = gem_config['brick']
unless Bricks::CONFIG[brick_name]
next
end
end
begin
gem gem_name, gem_config['version']
rescue LoadError
end
else
gem gem_name, gem_config['version']
end
else
gem gem_name
end
end
end
|
.has_executable(*list) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/zena.rb', line 15
def self.has_executable(*list)
return false if RUBY_PLATFORM =~ /mswin32/
list.inject(true) do |s,e|
s && !(`which #{e} || echo 'no #{e}'` =~ /^no #{e}/)
end
end
|
.include_modules ⇒ Object
.init ⇒ Object
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
# File 'lib/zena.rb', line 220
def init
config = Rails.configuration
enable_tools
puts "** zena #{Zena::VERSION} starting (c) Gaspard Bucher 2011"
puts "** Bricks: #{Bricks::CONFIG.map{|k,v| k}.sort.join(', ')}"
add_load_paths(config)
config_gems(config)
set_default_timezone(config)
Zena::Db.prepare_connection
require_ordered_dependencies
Zena::Db.insert_dummy_ids
load_plugins if RAILS_ROOT != Zena::ROOT
include_modules
Bricks.load_bricks
add_inflections
initialize_authlogic
initialize_gettext
end
|
.initialize_authlogic ⇒ Object
211
212
213
|
# File 'lib/zena.rb', line 211
def initialize_authlogic
require "authlogic"
end
|
.initialize_gettext ⇒ Object
203
204
205
206
207
208
209
|
# File 'lib/zena.rb', line 203
def initialize_gettext
require 'fast_gettext'
FastGettext.add_text_domain 'zena', :path => "#{Zena::ROOT}/locale" FastGettext.default_text_domain = 'zena'
FastGettext.text_domain = 'zena'
end
|
.load_custom_extensions ⇒ Object
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/zena.rb', line 172
def load_custom_extensions
lib_path = File.join(Zena::ROOT, 'lib/zena')
Dir.foreach(File.join(lib_path, 'core_ext')) do |f|
next unless f =~ /\.rb\Z/
require File.join(lib_path, 'core_ext', f)
end
require File.join(lib_path, 'base_additions')
require File.join(lib_path, 'fix_rails_layouts.rb') end
|
.load_plugins ⇒ Object
163
164
165
166
167
168
169
170
|
# File 'lib/zena.rb', line 163
def load_plugins
Dir.foreach("#{Zena::ROOT}/vendor/plugins") do |plugin_name|
next if plugin_name =~ /\A\./
require_in_lib plugin_name, "#{Zena::ROOT}/vendor/plugins"
end
ActionController::Base.send :include, RespondsToParent
end
|
.log_path ⇒ Object
68
69
70
|
# File 'lib/zena.rb', line 68
def log_path
"#{RAILS_ROOT}/log/#{RAILS_ENV}.log"
end
|
.require_in_lib(name, dir, lib_name = nil) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/zena.rb', line 87
def require_in_lib(name, dir, lib_name = nil)
if defined?(ActiveRecord)
base = Dir["#{dir}/*#{name}*"].first
lib_path = "#{base}/lib/#{lib_name || name}"
lib_path += '.rb' unless lib_path =~ /\.rb$/
if File.exist?(lib_path)
require lib_path
else
puts "Could not require #{lib_path.inspect}"
end
end
end
|
.require_ordered_dependencies ⇒ Object
The dependencies listed here need to be loaded in this order to make sure AfterCommit is included before the first connection to the database.
185
186
187
188
|
# File 'lib/zena.rb', line 185
def require_ordered_dependencies
require 'versions'
require 'property'
end
|
.resolve_const(klass) ⇒ Object
Resolve a fully defined constant like ‘Bricks::Pdf::Engine::Prince’
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/zena.rb', line 36
def resolve_const(klass)
if klass.kind_of?(String)
constant = nil
if klass =~ /\A[^A-Z\:]|[^0-9a-zA-Z\:]/
raise NameError.new("Invalid constant name: #{klass.inspect}.")
end
eval "::#{klass}"
else
klass
end
end
|
.set_default_timezone(config) ⇒ Object
190
191
192
193
194
195
|
# File 'lib/zena.rb', line 190
def set_default_timezone(config)
ActiveRecord::Base.default_timezone = :utc
ENV['TZ'] = 'UTC'
end
|
.use(*args) ⇒ Object
Nicer syntax: Zena.use Bricks:Foobar instead of Zena::Use.module Bricks::Foobar
216
217
218
|
# File 'lib/zena.rb', line 216
def use(*args)
Zena::Use.module(*args)
end
|
Instance Method Details
#CustomGettext ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/gettext_strings.rb', line 3
def CustomGettext
N_('help_tab')
N_('drive_tab') N_('links_tab')
N_('text_tab') N_('title_tab') N_('import_tab') N_('textdocument_tab') N_('image_tab') N_('document_tab') N_('contact_tab')
N_('attach_img') N_('dettach_img')
N_('file_tab') N_('template_tab') N_('text_document_tab') N_('custom_tab')
N_('btn_add_doc') N_('btn_add') N_('btn_add_comment') N_('btn_title_edit')
N_('btn_title_drive')
N_('relation_img')
N_('relations_img')
N_('site_img')
N_('btn_site_add')
N_('options')
N_('public group')
N_('site group')
N_('btn_relation_add')
N_('virtual_class_img')
N_('virtual_class_error_img')
N_('btn_virtual_class_add')
N_('posted by')
N_('original by')
N_('modified by')
N_('img_public') N_('img_private') N_('img_custom_inherit') N_('img_user') N_('img_user_admin') N_('img_user_su') N_('img_user_pub') N_('img_group') N_('img_group_pub') N_('img_group_site') N_('img_comments') N_('img_comments_inside') N_('inside') N_('outside') N_('open') N_('closed')
N_('img_prev_page') N_('img_next_page')
N_('admin') N_('user') N_('commentator') N_('moderated') N_('reader') N_('deleted')
N_('%{ext} document') N_('%{type} node')
N_('no result found') N_('search results')
N_('btn_unpublish') N_('btn_destroy')
N_('btn_propose')
N_('btn_edit')
N_('btn_drive')
N_('btn_refuse')
N_('btn_destroy_version')
N_('btn_redit')
N_('status_50') N_('status_60') N_('status_65') N_('status_70') N_('status_20') N_('status_10') N_('status_0')
N_('status_50_img') N_('status_60_img') N_('status_65_img') N_('status_70_img') N_('status_20_img') N_('status_10_img') N_('status_0_img')
N_('en')
N_('fr')
N_('de')
N_('Monday')
N_('Tuesday')
N_('Wednesday')
N_('Thursday')
N_('Friday')
N_('Saturday')
N_('Sunday')
N_('datetime') N_(Zena::Use::Dates::DATETIME)
N_('%Y-%m-%d %H:%M') N_('news_date')
N_('Mon')
N_('Tue')
N_('Wed')
N_('Thu')
N_('Fri')
N_('Sat')
N_('Sun')
N_('January')
N_('February')
N_('March')
N_('April')
N_('May')
N_('June')
N_('July')
N_('August')
N_('September')
N_('October')
N_('November')
N_('December')
N_('Jan')
N_('Feb')
N_('Mar')
N_('Apr')
N_('May')
N_('Jun')
N_('Jul')
N_('Aug')
N_('Sep')
N_('Oct')
N_('Nov')
N_('Dec')
N_('User name:') N_('Password:')
N_('you are editing the original')
N_('redaction saved')
N_('rebuild') N_('rebuild_btn') N_('turn_dev_off_btn') N_('first_name')
N_('last_name')
N_('address')
N_('postal_code')
N_('locality')
N_('country')
N_('telephone')
N_('mobile')
N_('email')
N_('birthday')
N_('clear_cache')
N_('clear_cache done.')
N_('rebuild_index')
N_('rebuild_index done.')
N_('img_string')
N_('img_integer')
N_('img_float')
N_('img_datetime')
end
|