spiderfw 0.5.7 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -6
- data/apps/cas_server/controllers/mixins/cas_login_mixin.rb +18 -5
- data/apps/cas_server/lib/cas.rb +1 -1
- data/apps/cms/models/content.rb +16 -0
- data/apps/cms/models/news_item.rb +7 -0
- data/apps/cms/models/translation.rb +14 -0
- data/apps/cms/views/admin/admin.shtml +16 -0
- data/apps/cms/views/admin/content.shtml +4 -0
- data/apps/core/acl/_init.rb +10 -0
- data/apps/core/acl/controllers/acl_controller.rb +14 -0
- data/apps/core/acl/models/permission.rb +11 -0
- data/apps/core/acl/views/acl.layout.shtml +8 -0
- data/apps/core/acl/views/index.shtml +3 -0
- data/apps/core/auth/controllers/mixins/auth_helper.rb +3 -3
- data/apps/core/auth/lib/authenticable.rb +4 -0
- data/apps/core/auth/models/super_user.rb +1 -0
- data/apps/core/auth/po/it/spider_auth.po +18 -10
- data/apps/core/auth/po/spider_auth.pot +13 -1
- data/apps/core/components/_init.rb +2 -1
- data/apps/core/components/po/it/spider_components.po +3 -3
- data/apps/core/components/po/spider_components.pot +3 -3
- data/apps/core/components/public/css/month_calendar.css +24 -0
- data/apps/core/components/public/js/jquery/jquery-1.4.2-min.js +154 -0
- data/apps/core/components/public/js/jquery/jquery-1.4.2.js +6240 -0
- data/apps/core/components/public/js/jquery/plugins/jquery.form.js +1 -1
- data/apps/core/components/public/js/spider.js +26 -20
- data/apps/core/components/widgets/admin/admin.rb +1 -1
- data/apps/core/components/widgets/crud/crud.rb +1 -1
- data/apps/core/components/widgets/list/list.rb +2 -2
- data/apps/core/components/widgets/month_calendar/month_calendar.rb +67 -0
- data/apps/core/components/widgets/month_calendar/month_calendar.shtml +21 -0
- data/apps/core/components/widgets/table/table.rb +4 -2
- data/apps/core/components/widgets/table/table.shtml +37 -31
- data/apps/core/forms/_init.rb +2 -1
- data/apps/core/forms/po/it/spider_forms.po +14 -2
- data/apps/core/forms/po/spider_forms.pot +13 -1
- data/apps/core/forms/public/css/file_input.css +15 -0
- data/apps/core/forms/public/{form.css → css/form.css} +8 -0
- data/apps/core/forms/public/file_input.js +37 -0
- data/apps/core/forms/tags/element_label.erb +4 -1
- data/apps/core/forms/tags/element_row.erb +7 -2
- data/apps/core/forms/tags/row.erb +10 -1
- data/apps/core/forms/widgets/form/form.rb +43 -10
- data/apps/core/forms/widgets/form/form.shtml +12 -5
- data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +1 -0
- data/apps/core/forms/widgets/inputs/file_input/file_input.rb +43 -0
- data/apps/core/forms/widgets/inputs/file_input/file_input.shtml +12 -0
- data/apps/core/forms/widgets/inputs/input/input.rb +23 -1
- data/apps/core/forms/widgets/inputs/password/password.rb +1 -0
- data/apps/core/forms/widgets/inputs/text/text.shtml +1 -1
- data/apps/core/forms/widgets/inputs/text_area/text_area.shtml +2 -2
- data/apps/git_model_versioning/models/mixins/git_versioned.rb +91 -0
- data/apps/hippo/models/mixins/hippo_struct.rb +42 -26
- data/apps/master/controllers/git.rb +32 -0
- data/apps/messenger/_init.rb +1 -1
- data/apps/messenger/config/options.rb +2 -0
- data/apps/messenger/config/worker/queue.rb +3 -0
- data/apps/messenger/controllers/mixins/{messenger_controller_mixin.rb → messenger_helper.rb} +8 -6
- data/apps/messenger/messenger.rb +10 -3
- data/apps/messenger/models/message.rb +2 -2
- data/apps/messenger/po/it/spider_messenger.po +1 -1
- data/apps/messenger/po/spider_messenger.pot +1 -1
- data/apps/saml/_init.rb +13 -0
- data/apps/saml/controllers/saml2idp.rb +18 -0
- data/apps/saml/lib/bindings/http_redirect_binding.rb +14 -0
- data/apps/saml/lib/messages/authn_request.rb +52 -0
- data/apps/saml/lib/saml.rb +10 -0
- data/apps/soap/controllers/soap_controller.rb +12 -2
- data/apps/soap/lib/soap.rb +16 -1
- data/apps/soap/soap.gemspec +10 -0
- data/apps/webdav/lib/locking.rb +2 -2
- data/apps/worker/_init.rb +2 -0
- data/apps/worker/config/options.rb +1 -0
- data/apps/worker/worker.rb +17 -4
- data/blueprints/app/__APP__.appspec +4 -0
- data/blueprints/app/_init.rb +5 -8
- data/blueprints/app/controllers/__APP___controller.rb +2 -1
- data/blueprints/app/views/__APP__.layout.shtml +4 -1
- data/blueprints/install/config/config.yml +2 -4
- data/blueprints/model.rb +15 -0
- data/data/locale/it/LC_MESSAGES/spider.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_auth.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_components.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_forms.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_messenger.mo +0 -0
- data/lib/spiderfw/app.rb +93 -31
- data/lib/spiderfw/autoload.rb +1 -0
- data/lib/spiderfw/cmd/cmd.rb +8 -1
- data/lib/spiderfw/cmd/commands/config.rb +54 -0
- data/lib/spiderfw/config/configuration.rb +30 -0
- data/lib/spiderfw/config/options/spider.rb +18 -6
- data/lib/spiderfw/controller/controller.rb +12 -11
- data/lib/spiderfw/controller/dispatcher.rb +5 -4
- data/lib/spiderfw/controller/http_controller.rb +16 -2
- data/lib/spiderfw/controller/mixins/http_mixin.rb +3 -2
- data/lib/spiderfw/controller/mixins/static_content.rb +8 -2
- data/lib/spiderfw/controller/mixins/visual.rb +72 -52
- data/lib/spiderfw/controller/request.rb +7 -3
- data/lib/spiderfw/controller/scene.rb +6 -0
- data/lib/spiderfw/controller/session.rb +12 -8
- data/lib/spiderfw/env.rb +1 -1
- data/lib/spiderfw/http/adapters/mongrel.rb +1 -1
- data/lib/spiderfw/http/http.rb +48 -19
- data/lib/spiderfw/i18n/cldr.rb +53 -3
- data/lib/spiderfw/i18n/i18n.rb +52 -2
- data/lib/spiderfw/i18n/provider.rb +24 -0
- data/lib/spiderfw/i18n/rails.rb +24 -0
- data/lib/spiderfw/model/active_record.rb +3 -3
- data/lib/spiderfw/model/base_model.rb +45 -14
- data/lib/spiderfw/model/condition.rb +11 -2
- data/lib/spiderfw/model/data_type.rb +15 -7
- data/lib/spiderfw/model/datatypes/decimal.rb +15 -3
- data/lib/spiderfw/model/datatypes/file_path.rb +50 -0
- data/lib/spiderfw/model/datatypes/serialized_object.rb +0 -4
- data/lib/spiderfw/model/datatypes/uuid.rb +3 -3
- data/lib/spiderfw/model/datatypes.rb +1 -0
- data/lib/spiderfw/model/extended_models/managed.rb +11 -2
- data/lib/spiderfw/model/mappers/db_mapper.rb +116 -52
- data/lib/spiderfw/model/mappers/mapper.rb +36 -14
- data/lib/spiderfw/model/mixins/state_machine.rb +45 -9
- data/lib/spiderfw/model/mixins/versioned.rb +1 -1
- data/lib/spiderfw/model/model.rb +2 -1
- data/lib/spiderfw/model/query_set.rb +21 -3
- data/lib/spiderfw/model/request.rb +7 -0
- data/lib/spiderfw/model/storage/db/adapters/mssql.rb +2 -1
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +4 -1
- data/lib/spiderfw/model/storage/db/adapters/oci8.rb +35 -18
- data/lib/spiderfw/model/storage/db/adapters/sqlite.rb +68 -34
- data/lib/spiderfw/model/storage/db/connectors/odbc.rb +1 -1
- data/lib/spiderfw/model/storage/db/db_schema.rb +33 -4
- data/lib/spiderfw/model/storage/db/db_storage.rb +27 -8
- data/lib/spiderfw/requires.rb +2 -0
- data/lib/spiderfw/tag/tag.rb +1 -1
- data/lib/spiderfw/templates/blocks/attr_if.rb +7 -1
- data/lib/spiderfw/templates/blocks/each.rb +8 -3
- data/lib/spiderfw/templates/blocks/html.rb +12 -22
- data/lib/spiderfw/templates/blocks/render.rb +3 -3
- data/lib/spiderfw/templates/blocks/run.rb +47 -11
- data/lib/spiderfw/templates/blocks/tag_if.rb +2 -2
- data/lib/spiderfw/templates/blocks/text.rb +2 -1
- data/lib/spiderfw/templates/blocks/widget.rb +5 -3
- data/lib/spiderfw/templates/blocks/yield.rb +1 -1
- data/lib/spiderfw/templates/template.rb +27 -24
- data/lib/spiderfw/templates/template_blocks.rb +37 -14
- data/lib/spiderfw/utils/monkey/exception.rb +1 -1
- data/lib/spiderfw/utils/monkey/nil_class.rb +7 -0
- data/lib/spiderfw/utils/monkey/numeric.rb +15 -0
- data/lib/spiderfw/version.rb +1 -1
- data/lib/spiderfw/widget/widget.rb +36 -33
- data/lib/spiderfw/widget/widget_attributes.rb +1 -1
- data/lib/spiderfw.rb +18 -5
- data/spider.gemspec +5 -5
- metadata +44 -18
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.js +0 -187
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.min.js +0 -1
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.spider.1.0.js +0 -193
- data/apps/core/forms/widgets/inputs/subform/subform.rb +0 -10
- data/apps/core/forms/widgets/inputs/subform/subform.shtml +0 -5
- data/apps/messenger/config/worker.rb +0 -3
- data/lib/spiderfw/controller/app_controller.rb +0 -14
- data/lib/spiderfw/utils/test_case.rb +0 -24
@@ -1,11 +1,18 @@
|
|
1
1
|
<div class="{ @widget[:css_class] }">
|
2
|
-
<tpl:asset type="css" src="form.css" />
|
2
|
+
<tpl:asset type="css" src="css/form.css" />
|
3
3
|
<tpl:asset type="js" src="form.js" />
|
4
4
|
<div sp:if="@error" class='errors'>
|
5
|
-
Errori:
|
6
5
|
<ul>
|
7
|
-
|
8
|
-
|
6
|
+
<li sp:if="@errors[nil]" sp:each="@errors[nil] |err|">
|
7
|
+
{ err }
|
8
|
+
</li>
|
9
|
+
<sp:pass sp:each="@names |element|">
|
10
|
+
<li sp:if="@errors[element]" sp:each="@errors[element] |err|">
|
11
|
+
{ err }
|
12
|
+
</li>
|
13
|
+
</sp:pass>
|
14
|
+
<sp:pass sp:each="(@errors.keys - @names) |element|">
|
15
|
+
<li sp:if="@errors[element]" sp:each="@errors[element] |err|">
|
9
16
|
{ err }
|
10
17
|
</li>
|
11
18
|
</sp:pass>
|
@@ -19,7 +26,7 @@
|
|
19
26
|
<sp:run obj="input" />
|
20
27
|
</sp:pass>
|
21
28
|
<div class="fields">
|
22
|
-
<forms:element_row sp:each="@names |element|" element="element"
|
29
|
+
<forms:element_row sp:each="@names |element|" element="element" required="@inputs[element].required?"/>
|
23
30
|
</div>
|
24
31
|
<div class="row buttons">
|
25
32
|
<input type='submit' name='_w{ @widget[:param] }[submit]' value='{ @submit_text }'>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'ftools'
|
2
|
+
|
3
|
+
module Spider; module Forms
|
4
|
+
|
5
|
+
class FileInput < Input
|
6
|
+
tag 'file'
|
7
|
+
is_attr_accessor :save_path, :type => String, :default => lambda{ Spider.paths[:data]+'/uploaded_files' }
|
8
|
+
|
9
|
+
def needs_multipart?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def prepare
|
14
|
+
raise "No save path defined" unless @save_path
|
15
|
+
raise "Save path #{@save_path} is not a directory" unless File.directory?(@save_path)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def prepare_value(val)
|
21
|
+
return nil if !val || val.empty?
|
22
|
+
if val['file'] && !val['file'].is_a?(String)
|
23
|
+
dest_path = @save_path+'/'+val['file'].filename
|
24
|
+
File.copy(val['file'].path, dest_path)
|
25
|
+
return dest_path
|
26
|
+
elsif val['clear']
|
27
|
+
self.value = nil
|
28
|
+
return
|
29
|
+
end
|
30
|
+
return @value
|
31
|
+
end
|
32
|
+
|
33
|
+
__.action
|
34
|
+
def view_file
|
35
|
+
raise NotFound.new(@value.to_s) unless @value && @value.file?
|
36
|
+
@response.headers['Content-Description'] = 'File Transfer'
|
37
|
+
@response.headers['Content-Disposition'] = "attachment; filename=\"#{@value.basename}\""
|
38
|
+
output_static(@value.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end; end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="input">
|
2
|
+
<tpl:asset type="css" src="css/file_input.css" />
|
3
|
+
<tpl:asset type="js" src="input.js" />
|
4
|
+
<tpl:asset type="js" src="file_input.js" />
|
5
|
+
<div sp:if="@value && !@value.to_s.empty?">
|
6
|
+
<a class="file-link" href="{ widget_action('view_file') }">{ @formatted_value }</a>
|
7
|
+
<span class="clear">(<input type="checkbox" name="{ @name }[clear]"> _(Clear))</span>
|
8
|
+
</div>
|
9
|
+
<div class="change"><span sp:if="@value && !@value.to_s.empty?"><span class="change-label">_(Change)</span>:</span>
|
10
|
+
<input type="file" name="{ @name }[file]" value="{ @value }" size="{ @size }">
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -5,6 +5,7 @@ module Spider; module Forms
|
|
5
5
|
i_attr_accessor :name
|
6
6
|
is_attribute :value
|
7
7
|
is_attr_accessor :label
|
8
|
+
is_attr_accessor :required, :type => Spider::DataTypes::Bool
|
8
9
|
|
9
10
|
def self.template_path_parent
|
10
11
|
File.dirname(File.dirname(__FILE__))
|
@@ -24,6 +25,8 @@ module Spider; module Forms
|
|
24
25
|
return scene
|
25
26
|
end
|
26
27
|
|
28
|
+
# Returns the value to be stored. If nil is returned, the value will not be unset; in this case,
|
29
|
+
# the method should modify the value directly.
|
27
30
|
def prepare_value(val)
|
28
31
|
val == {} ? nil : val
|
29
32
|
end
|
@@ -43,7 +46,7 @@ module Spider; module Forms
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def format_value
|
46
|
-
@value
|
49
|
+
@value.respond_to?(:format) ? @value.format : @value
|
47
50
|
end
|
48
51
|
|
49
52
|
def done?
|
@@ -63,6 +66,10 @@ module Spider; module Forms
|
|
63
66
|
@modified
|
64
67
|
end
|
65
68
|
|
69
|
+
def has_value?
|
70
|
+
@value && (!@value.is_a?(String) || !@value.empty?)
|
71
|
+
end
|
72
|
+
|
66
73
|
def read_only
|
67
74
|
@read_only = true
|
68
75
|
if template_exists?(@use_template+'_readonly')
|
@@ -78,7 +85,18 @@ module Spider; module Forms
|
|
78
85
|
@read_only
|
79
86
|
end
|
80
87
|
|
88
|
+
def required?
|
89
|
+
@attributes[:required]
|
90
|
+
end
|
91
|
+
|
92
|
+
def check
|
93
|
+
if required? && !has_value?
|
94
|
+
add_error( _("%s is required") % self.label )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
81
98
|
def parse_runtime_content(doc, src_path=nil)
|
99
|
+
doc = super
|
82
100
|
doc.search('input:connect').each do |connect|
|
83
101
|
options = {}
|
84
102
|
options[:required] = connect.attributes['required'] ? true : false
|
@@ -93,6 +111,10 @@ module Spider; module Forms
|
|
93
111
|
@css_classes << "connect-#{target}"
|
94
112
|
end
|
95
113
|
|
114
|
+
def needs_multipart?
|
115
|
+
false
|
116
|
+
end
|
117
|
+
|
96
118
|
|
97
119
|
# def execute
|
98
120
|
# @scene.name =
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<textarea name="{ @name }" rows="{ @rows }" cols="{ @cols }"><tpl:asset type="js" src="text_area.js" />
|
2
|
-
<tpl:asset type="js" app="core/components" src="js/jquery/plugins/autogrow/jquery.autogrow.js" />{ @value }</textarea>
|
1
|
+
<textarea name="{ @name }" rows="{ @rows }" cols="{ @cols }"><tpl:asset type="js" src="input.js" /><tpl:asset type="js" src="text_area.js" />
|
2
|
+
<tpl:asset type="js" app="core/components" src="js/jquery/plugins/autogrow/jquery.autogrow.js" />{ @value }</textarea>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'grit'
|
2
|
+
require 'grit/git-ruby'
|
3
|
+
|
4
|
+
module Spider; module GitModelVersioning;
|
5
|
+
|
6
|
+
module GitVersioned
|
7
|
+
|
8
|
+
def self.included(model)
|
9
|
+
model.extend(ClassMethods)
|
10
|
+
model.mapper_include(MapperMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
def git_sha1
|
14
|
+
git_blob.sha1
|
15
|
+
end
|
16
|
+
|
17
|
+
def git_blob
|
18
|
+
Grit::GitRuby::Blob.new(self.to_yaml)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ClassMethods
|
22
|
+
|
23
|
+
def git_root
|
24
|
+
Spider.paths[:var]+'/model_git'
|
25
|
+
end
|
26
|
+
|
27
|
+
def git_repo
|
28
|
+
@repo ||= Grit::GitRuby::Repository.new(git_root)
|
29
|
+
end
|
30
|
+
|
31
|
+
def git_tree
|
32
|
+
commit = git_head
|
33
|
+
tree = git_repo.get_object_by_sha1(commit.tree)
|
34
|
+
tree.entry.each do |entry|
|
35
|
+
return entry.sha1 if entry.name == self.name
|
36
|
+
end
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def git_head(sha1=nil)
|
41
|
+
if (sha1)
|
42
|
+
File.open(git_root+'/refs/heads/master', 'w') do |f|
|
43
|
+
f << sha1
|
44
|
+
end
|
45
|
+
else
|
46
|
+
sha1 = File.read(git_repo.git_dir+'/refs/heads/master')
|
47
|
+
end
|
48
|
+
return git_repo.get_object_by_sha1(sha1) || ""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module MapperMethods
|
53
|
+
|
54
|
+
# def before_save(obj, mode)
|
55
|
+
# repo = @model.git_repo
|
56
|
+
# tree = @model.git_repo.get_object_by_sha1(@model.git_tree)
|
57
|
+
# pks_string = obj.primary_keys.join('$')
|
58
|
+
# if (mode == :insert)
|
59
|
+
# tree.entry.push(Grit::GitRuby::DirectoryEntry.new('0100000', pks_string, obj.git_sha1))
|
60
|
+
# else
|
61
|
+
# cur = nil
|
62
|
+
# tree.entry.each do |e|
|
63
|
+
# if (e.name == pks_string)
|
64
|
+
# cur = e
|
65
|
+
# break
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
# raise "Object #{obj} not found in tree" unless cur
|
69
|
+
# cur.sha1 = obj.git_sha1
|
70
|
+
# end
|
71
|
+
# tree_real_raw = tree_contents.collect{ |e| e.raw }.join("")
|
72
|
+
# tree = GitRuby::Tree.from_raw(RawObject.new(tree_real_raw), repo)
|
73
|
+
# tree_sha1 = repo.put_raw_object(tree_real_raw, 'tree')
|
74
|
+
# commit = GitRuby::Commit.new(tree_sha1, [], 'spider', 'spider', "#{mode} #{DateTime.now}", @model.git_head, repo)
|
75
|
+
# repo.put_raw_object(commit.raw_content, 'commit')
|
76
|
+
# @model.git_head(commit.sha1)
|
77
|
+
# end
|
78
|
+
|
79
|
+
def before_save(obj, mode)
|
80
|
+
git_index.add(obj.git_path, obj.to_yaml)
|
81
|
+
@model.write_git_index
|
82
|
+
super
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
@@ -8,6 +8,7 @@ module Hippo
|
|
8
8
|
def self.included(mod)
|
9
9
|
mod.extend(ClassMethods)
|
10
10
|
mod.mapper_include(Mapper)
|
11
|
+
mod.remove_element :id
|
11
12
|
mod.element :id, Fixnum, :primary_key => true
|
12
13
|
mod.element :cr_date, DateTime
|
13
14
|
mod.element :mod_date, DateTime
|
@@ -25,8 +26,8 @@ module Hippo
|
|
25
26
|
el = super
|
26
27
|
if (el.attributes[:junction])
|
27
28
|
el.model.elements[:id].attributes[:primary_key] = false
|
28
|
-
el.model.elements[el.attributes[:reverse]].attributes[:primary_key] =
|
29
|
-
el.model.elements[el.attributes[:junction_their_element]].attributes[:primary_key] =
|
29
|
+
el.model.elements[el.attributes[:reverse]].attributes[:primary_key] = false
|
30
|
+
el.model.elements[el.attributes[:junction_their_element]].attributes[:primary_key] = false
|
30
31
|
end
|
31
32
|
return el
|
32
33
|
end
|
@@ -134,26 +135,37 @@ module Hippo
|
|
134
135
|
def generate_schema(schema=nil)
|
135
136
|
return super unless @model.binding
|
136
137
|
schema = Spider::Model::Storage::Db::DbSchema.new
|
137
|
-
schema.table = @model.binding[:table]
|
138
|
+
schema.table = Spider::Model::Storage::Db::Table.new(@model.binding[:table])
|
138
139
|
@model.binding[:elements].each do |el, binding|
|
139
140
|
element = @model.elements[el.to_sym]
|
140
141
|
next unless element
|
141
142
|
if (binding[:type] == 'mmbind')
|
142
143
|
junction = element.model.mapper.schema
|
143
|
-
junction.table = binding[:table]
|
144
|
+
junction.table = Spider::Model::Storage::Db::Table.new(binding[:table])
|
145
|
+
junction.columns[:id] = Spider::Model::Storage::Db::Field.new(junction.table, 'ID', @storage.column_type(Fixnum, {}))
|
144
146
|
junction.foreign_keys[element.attributes[:reverse]] ||= {}
|
145
|
-
|
146
|
-
junction.
|
147
|
+
r_key_type = @storage.column_type(Spider::Model.base_type(@model.primary_keys[0].type), @model.primary_keys[0].attributes)
|
148
|
+
r_key_field = Spider::Model::Storage::Db::Field.new(junction.table, binding[:local_id], r_key_type)
|
149
|
+
junction.foreign_keys[element.attributes[:reverse]][@model.primary_keys[0].name] = r_key_field
|
147
150
|
junction.foreign_keys[element.attributes[:junction_their_element]] ||= {}
|
148
|
-
|
149
|
-
junction.
|
151
|
+
t_key_type = @storage.column_type(Spider::Model.base_type(element.type.primary_keys[0].type), element.type.primary_keys[0].attributes)
|
152
|
+
t_key_field = Spider::Model::Storage::Db::Field.new(junction.table, binding[:remote_id], t_key_type)
|
153
|
+
junction.foreign_keys[element.attributes[:junction_their_element]][element.type.primary_keys[0].name] = t_key_field
|
154
|
+
if (binding[:elements])
|
155
|
+
binding[:elements].each do |j_el_name, j_el_binding|
|
156
|
+
j_el = element.model.elements[j_el_name.to_sym]
|
157
|
+
j_el_storage_type = Spider::Model.base_type(j_el.type)
|
158
|
+
junction.columns[j_el.name] = Spider::Model::Storage::Db::Field.new(junction.table, j_el_binding[:field], @storage.column_type(j_el_storage_type, j_el.attributes))
|
159
|
+
end
|
160
|
+
end
|
150
161
|
elsif (element.model? && !element.multiple?)
|
162
|
+
key_storage_type = Spider::Model.base_type(element.model.primary_keys[0].type)
|
163
|
+
key_db_type = @storage.column_type(key_storage_type, element.model.primary_keys[0].attributes)
|
151
164
|
schema.foreign_keys[element.name] ||= {}
|
152
|
-
schema.foreign_keys[element.name][element.model.primary_keys[0].name]
|
153
|
-
schema.foreign_keys[element.name][element.model.primary_keys[0].name][:name] = binding[:field]
|
165
|
+
schema.foreign_keys[element.name][element.model.primary_keys[0].name] = Spider::Model::Storage::Db::Field.new(schema.table, binding[:field], key_db_type)
|
154
166
|
else
|
155
|
-
|
156
|
-
schema.columns[element.name]
|
167
|
+
storage_type = Spider::Model.base_type(element.type)
|
168
|
+
schema.columns[element.name] = Spider::Model::Storage::Db::Field.new(schema.table, binding[:field], @storage.column_type(storage_type, element.attributes))
|
157
169
|
end
|
158
170
|
end
|
159
171
|
if (@model.binding[:parent_ref])
|
@@ -163,33 +175,31 @@ module Hippo
|
|
163
175
|
element = @model.elements[@model.extended_models[extended]]
|
164
176
|
schema.foreign_keys.delete(@model.extended_models[extended])
|
165
177
|
junction = element.model.mapper.schema
|
166
|
-
junction.table = pr[:table]
|
178
|
+
junction.table = Spider::Model::Storage::Db::Table.new(pr[:table])
|
179
|
+
junction.columns[:id] = Spider::Model::Storage::Db::Field.new(junction.table, 'ID', @storage.column_type(Fixnum, {}))
|
180
|
+
r_key_type = @storage.column_type(Spider::Model.base_type(@model.primary_keys[0].type), @model.primary_keys[0].attributes)
|
181
|
+
r_key_field = Spider::Model::Storage::Db::Field.new(junction.table, pr[:child_id], r_key_type)
|
167
182
|
junction.foreign_keys[element.attributes[:reverse]] ||= {}
|
168
|
-
junction.foreign_keys[element.attributes[:reverse]][@model.primary_keys[0].name]
|
169
|
-
junction.foreign_keys[element.attributes[:reverse]][@model.primary_keys[0].name][:name] = pr[:child_id]
|
183
|
+
junction.foreign_keys[element.attributes[:reverse]][@model.primary_keys[0].name] = r_key_field
|
170
184
|
junction.foreign_keys[element.attributes[:junction_their_element]] ||= {}
|
171
|
-
|
172
|
-
junction.
|
185
|
+
t_key_type = @storage.column_type(Spider::Model.base_type(element.type.primary_keys[0].type), element.type.primary_keys[0].attributes)
|
186
|
+
t_key_field = Spider::Model::Storage::Db::Field.new(junction.table, pr[:parent_id], t_key_type)
|
187
|
+
junction.foreign_keys[element.attributes[:junction_their_element]][element.type.primary_keys[0].name] = t_key_field
|
173
188
|
end
|
174
189
|
@model.elements_array.each do |el|
|
175
190
|
unless @model.binding[:elements][el.name.to_s] || HippoStruct.base_elements.include?(el.name)
|
176
191
|
schema.pass[el.name] = true
|
177
192
|
end
|
178
193
|
end
|
179
|
-
# debugger if @model.name.to_s == "AgendaHippo::Ordine"
|
180
194
|
return super(schema)
|
181
195
|
end
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
module HippoStorage
|
186
|
-
|
187
|
-
def column_type(type, attributes)
|
196
|
+
|
197
|
+
def storage_column_type(type, attributes)
|
188
198
|
return super(String, attributes) if (type == DateTime)
|
189
199
|
return super
|
190
200
|
end
|
191
|
-
|
192
|
-
def
|
201
|
+
|
202
|
+
def storage_value_to_mapper(type, value)
|
193
203
|
return value unless value
|
194
204
|
case type.name
|
195
205
|
when 'DateTime'
|
@@ -201,6 +211,12 @@ module Hippo
|
|
201
211
|
end
|
202
212
|
return super
|
203
213
|
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
module HippoStorage
|
218
|
+
|
219
|
+
|
204
220
|
|
205
221
|
end
|
206
222
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'apps/webdav/lib/vfs/local'
|
2
|
+
|
3
|
+
module Spider; module Master
|
4
|
+
|
5
|
+
class GitController < Spider::WebDAV::WebDAVController
|
6
|
+
|
7
|
+
def init_vfs
|
8
|
+
Spider::WebDAV::VFS::Local.new(Spider.paths[:apps])
|
9
|
+
end
|
10
|
+
|
11
|
+
def before(action='', *params)
|
12
|
+
action.gsub!(/[^a-zA-Z]+\//, '') # ??? sanitize
|
13
|
+
app = find_app(action)
|
14
|
+
if (app.access = :restricted)
|
15
|
+
redirect 'https://'+@request.env['HTTP_HOST']+request_path if @request.protocol != 'https'
|
16
|
+
raise Unauthorized.new(action) unless @request.ssl && @request.ssl.key
|
17
|
+
key = @request.ssl.key
|
18
|
+
host = Hosts.find1{ key == @request.ssl.key }
|
19
|
+
raise Unauthorized.new(action) unless host && host.allowed?(app)
|
20
|
+
end
|
21
|
+
|
22
|
+
m.html, m.private
|
23
|
+
def find_app(action)
|
24
|
+
action =
|
25
|
+
end
|
26
|
+
|
27
|
+
def unauthorized
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end; end
|
data/apps/messenger/_init.rb
CHANGED
@@ -19,6 +19,6 @@ end
|
|
19
19
|
|
20
20
|
require 'apps/messenger/messenger'
|
21
21
|
require 'apps/messenger/controllers/messenger_controller'
|
22
|
-
require 'apps/messenger/controllers/mixins/
|
22
|
+
require 'apps/messenger/controllers/mixins/messenger_helper'
|
23
23
|
|
24
24
|
# gem dependencies: mailfactory for sending email from templates
|
@@ -11,5 +11,7 @@ module Spider
|
|
11
11
|
config_option 'messenger.email.retries', :type => Fixnum, :default => 5
|
12
12
|
config_option 'messenger.email.retry_time', _("Seconds to wait until retry (will be incremented at each retry)"),
|
13
13
|
:type => Fixnum, :default => 10
|
14
|
+
config_option 'messenger.queue.run_every', _("Time in seconds between queue runs"), :type => Fixnum, :default => 60
|
15
|
+
|
14
16
|
|
15
17
|
end
|
data/apps/messenger/controllers/mixins/{messenger_controller_mixin.rb → messenger_helper.rb}
RENAMED
@@ -5,7 +5,7 @@ Spider.register_resource_type(:email, :extensions => ['erb'], :path => 'template
|
|
5
5
|
|
6
6
|
module Spider; module Messenger
|
7
7
|
|
8
|
-
module
|
8
|
+
module MessengerHelper
|
9
9
|
|
10
10
|
# Compiles an e-mail from given template and scene, and sends it using
|
11
11
|
# #Messenger::email
|
@@ -15,16 +15,20 @@ module Spider; module Messenger
|
|
15
15
|
# {:file => '/full/file/path', :type => 'mime type', :file_name => 'optional email file name',
|
16
16
|
# :headers => 'optional string or array of additional headers'}
|
17
17
|
def email(template, scene, from, to, headers={}, attachments=[], params={})
|
18
|
-
|
18
|
+
Spider::Messenger::MessengerHelper.email(self.class, template, scene, from, to, headers, attachments, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.email(klass, template, scene, from, to, headers={}, attachments=[], params={})
|
22
|
+
path_txt = klass.find_resource_path(:email, template+'.txt')
|
19
23
|
path_txt = nil unless File.exist?(path_txt)
|
20
|
-
path_html =
|
24
|
+
path_html = klass.find_resource_path(:email, template+'.txt')
|
21
25
|
path_html = nil unless File.exist?(path_html)
|
22
26
|
scene_binding = scene.instance_eval{ binding }
|
23
27
|
if (path_txt || path_html)
|
24
28
|
text = ERB.new(IO.read(path_txt)).result(scene_binding) if path_txt
|
25
29
|
html = ERB.new(IO.read(path_html)).result(scene_binding) if path_html
|
26
30
|
else
|
27
|
-
path =
|
31
|
+
path = klass.find_resource_path(:email, template)
|
28
32
|
text = ERB.new(IO.read(path)).result(scene_binding)
|
29
33
|
end
|
30
34
|
mail = MailFactory.new
|
@@ -35,7 +39,6 @@ module Spider; module Messenger
|
|
35
39
|
end
|
36
40
|
mail.html = html if html
|
37
41
|
mail.text = text if text
|
38
|
-
debugger
|
39
42
|
if (attachments && !attachments.empty?)
|
40
43
|
attachments.each do |att|
|
41
44
|
if (att[:file_name])
|
@@ -48,7 +51,6 @@ module Spider; module Messenger
|
|
48
51
|
mail_headers, mail_body = mail.to_s.split("\r\n\r\n")
|
49
52
|
Messenger.email(from, to, mail_headers, mail_body, params)
|
50
53
|
end
|
51
|
-
|
52
54
|
end
|
53
55
|
|
54
56
|
end; end
|
data/apps/messenger/messenger.rb
CHANGED
@@ -13,13 +13,20 @@ module Spider
|
|
13
13
|
}
|
14
14
|
}
|
15
15
|
end
|
16
|
+
|
17
|
+
def self.process_queues
|
18
|
+
self.queues.each_key do |queue|
|
19
|
+
self.process_queue(queue)
|
20
|
+
end
|
21
|
+
end
|
16
22
|
|
17
23
|
def self.process_queue(queue)
|
18
|
-
@mutex ||= Mutex.new
|
19
|
-
return if @mutex.locked?
|
20
24
|
raise ArgumentError, "Queue #{name} not found" unless self.queues[queue]
|
25
|
+
@mutexes ||= {}
|
26
|
+
mutex = @mutexes[queue] ||= Mutex.new
|
27
|
+
return if mutex.locked?
|
21
28
|
model = self.queues[queue][:model]
|
22
|
-
|
29
|
+
mutex.synchronize do
|
23
30
|
now = DateTime.now
|
24
31
|
list = model.where{ (sent == nil) & (next_try <= now) }
|
25
32
|
list.each do |msg|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'uuidtools'
|
2
2
|
|
3
3
|
module Spider; module Messenger
|
4
4
|
|
@@ -34,7 +34,7 @@ module Spider; module Messenger
|
|
34
34
|
|
35
35
|
with_mapper do
|
36
36
|
def before_save(obj, mode)
|
37
|
-
obj.ticket = ::UUID.
|
37
|
+
obj.ticket = UUIDTools::UUID.random_create.to_s if mode == :insert
|
38
38
|
super
|
39
39
|
end
|
40
40
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
9
|
"Project-Id-Version: Spider::Messenger 0.1\n"
|
10
|
-
"POT-Creation-Date:
|
10
|
+
"POT-Creation-Date: 2010-03-24 16:27+0100\n"
|
11
11
|
"PO-Revision-Date: 2009-06-30 16:44+0200\n"
|
12
12
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13
13
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
@@ -7,7 +7,7 @@
|
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
9
|
"Project-Id-Version: Spider::Messenger 0.1\n"
|
10
|
-
"POT-Creation-Date:
|
10
|
+
"POT-Creation-Date: 2010-03-24 16:27+0100\n"
|
11
11
|
"PO-Revision-Date: 2009-06-30 16:44+0200\n"
|
12
12
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13
13
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
data/apps/saml/_init.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spider; module SAML
|
2
|
+
|
3
|
+
class HTTPRedirectBinding
|
4
|
+
|
5
|
+
|
6
|
+
def self.decode_request(saml_request)
|
7
|
+
request = Zlib::GzipReader.open(StringIO.new(Base64.decode(saml_request)){ |gz| gz.read }
|
8
|
+
return AuthnRequest.new(request)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
end
|