ixtlan 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +11 -1
- data/Rakefile +20 -3
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/gwt_ixtlan_datamapper_rspec_scaffold_generator.rb +157 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/AbstractApplicationResourceTestGwt.java +13 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Fields.java +43 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/GwtTestSuite.java +14 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Model.java +103 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/ModelFactory.java +50 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Screen.java +60 -0
- data/generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/TestGwt.java +110 -0
- data/generators/ixtlan_datamapper_model/templates/model.rb +9 -0
- data/lib/dm-serializer/to_xml.rb +3 -1
- data/lib/ixtlan/child_path.rb +18 -0
- data/lib/ixtlan/controllers/phrases_controller.rb +149 -0
- data/lib/ixtlan/controllers/texts_controller.rb +10 -2
- data/lib/ixtlan/guard.rb +17 -1
- data/lib/ixtlan/logger_config.rb +1 -0
- data/lib/ixtlan/models/{text.rb → i18n_text.rb} +5 -4
- data/lib/ixtlan/models/phrase.rb +2 -2
- data/lib/ixtlan/models/translation.rb +2 -2
- data/lib/ixtlan/models/user.rb +1 -1
- data/lib/ixtlan/models/word.rb +1 -1
- data/lib/ixtlan/models.rb +1 -1
- data/lib/ixtlan/rails/error_handling.rb +2 -1
- data/lib/ixtlan/rails/unrestful_authentication.rb +1 -1
- data/lib/ixtlan/version.rb +1 -1
- data/lib/models.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- metadata +13 -3
data/Manifest.txt
CHANGED
@@ -7,6 +7,14 @@ generators/ixtlan_datamapper_rspec_scaffold/templates/controller.rb
|
|
7
7
|
generators/ixtlan_datamapper_rspec_scaffold/templates/controller_spec.rb
|
8
8
|
generators/ixtlan_datamapper_rspec_scaffold/templates/guard.rb
|
9
9
|
generators/ixtlan_datamapper_rspec_scaffold/templates/i18n.rb
|
10
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/gwt_ixtlan_datamapper_rspec_scaffold_generator.rb
|
11
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Model.java
|
12
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/ModelFactory.java
|
13
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Fields.java
|
14
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Screen.java
|
15
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/TestGwt.java
|
16
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/GwtTestSuite.java
|
17
|
+
generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/AbstractApplicationResourceTestGwt.java
|
10
18
|
lib/models.rb
|
11
19
|
lib/ixtlan.rb
|
12
20
|
lib/dm-serializer.rb
|
@@ -27,11 +35,12 @@ lib/ixtlan/models/configuration_locale.rb
|
|
27
35
|
lib/ixtlan/models/word.rb
|
28
36
|
lib/ixtlan/models/configuration.rb
|
29
37
|
lib/ixtlan/models/authentication.rb
|
30
|
-
lib/ixtlan/models/
|
38
|
+
lib/ixtlan/models/i18n_text.rb
|
31
39
|
lib/ixtlan/models/group_user.rb
|
32
40
|
lib/ixtlan/models/group.rb
|
33
41
|
lib/ixtlan/rolling_file.rb
|
34
42
|
lib/ixtlan/cms_script.rb
|
43
|
+
lib/ixtlan/child_path.rb
|
35
44
|
lib/ixtlan/logger_config.rb
|
36
45
|
lib/ixtlan/models.rb
|
37
46
|
lib/ixtlan/audit_config.rb
|
@@ -43,6 +52,7 @@ lib/ixtlan/optimistic_persistence_module.rb
|
|
43
52
|
lib/ixtlan/optimistic_persistence_validation.rb
|
44
53
|
lib/ixtlan/error_notifier/error_notification.rhtml
|
45
54
|
lib/ixtlan/controllers/texts_controller.rb
|
55
|
+
lib/ixtlan/controllers/phrases_controller.rb
|
46
56
|
lib/ixtlan/controllers/permissions_controller.rb
|
47
57
|
lib/ixtlan/controllers/authentications_controller.rb
|
48
58
|
lib/ixtlan/controllers/configurations_controller.rb
|
data/Rakefile
CHANGED
@@ -24,15 +24,32 @@ end
|
|
24
24
|
desc 'generate rails using all generators and run the specs'
|
25
25
|
task :integration_tests => [:spec, :install] do
|
26
26
|
require 'datamapper4rails/integration_test'
|
27
|
-
Datamapper4Rails::IntegrationTest.new do |t|
|
27
|
+
tests = Datamapper4Rails::IntegrationTest.new do |t|
|
28
28
|
t.directory = 'temp'
|
29
|
+
ENV['GWT'] = "true"
|
29
30
|
t.rails_template = 'ixtlan_rails_templates.rb'
|
30
31
|
t.generate "ixtlan_datamapper_model name name:string"
|
31
32
|
t.generate "ixtlan_datamapper_rspec_model domain name:string"
|
32
|
-
t.generate "ixtlan_datamapper_rspec_scaffold
|
33
|
-
|
33
|
+
t.generate "ixtlan_datamapper_rspec_scaffold player name:string"
|
34
|
+
t.generate "gwt_ixtlan_datamapper_rspec_scaffold word name:string"
|
35
|
+
end
|
36
|
+
tests.command("mvn clean integration-test")
|
34
37
|
end
|
35
38
|
|
36
39
|
YARD::Rake::YardocTask.new
|
37
40
|
|
41
|
+
module Datamapper4Rails
|
42
|
+
class IntegrationTest
|
43
|
+
def command(command)
|
44
|
+
FileUtils.cd(@directory) do
|
45
|
+
unless system("#{command}")
|
46
|
+
puts
|
47
|
+
puts "error in: #{command}"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
38
55
|
# vim: syntax=Ruby
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'datamapper4rails/overlay'
|
2
|
+
require 'datamapper4rails/rspec_default_values'
|
3
|
+
|
4
|
+
class String
|
5
|
+
def javanize
|
6
|
+
s = camelize
|
7
|
+
s[0,1].downcase! + s[1,1000]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class GwtIxtlanDatamapperRspecScaffoldGenerator < IxtlanDatamapperRspecScaffoldGenerator
|
12
|
+
|
13
|
+
attr_reader :package
|
14
|
+
|
15
|
+
def find_client_dir(dir)
|
16
|
+
dir.entries.each do |entry|
|
17
|
+
path = File.join(dir.path, entry)
|
18
|
+
if File.directory? path
|
19
|
+
if entry == "client"
|
20
|
+
return path
|
21
|
+
elsif entry != ".." && entry != "."
|
22
|
+
return find_client_dir(Dir.new(path))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def manifest
|
30
|
+
overlay_dirs.add_generator("ixtlan_datamapper_rspec_scaffold")
|
31
|
+
|
32
|
+
m = super
|
33
|
+
|
34
|
+
base = "src/main/java/"
|
35
|
+
|
36
|
+
basedir = find_client_dir(Dir.new(base))
|
37
|
+
basedir_test = basedir.sub(/main/, 'test')
|
38
|
+
|
39
|
+
@package = basedir.sub(/#{base}/, "").gsub(/\//, ".")
|
40
|
+
|
41
|
+
m.directory(File.join(basedir, 'models', controller_class_path))
|
42
|
+
m.template 'Model.java', File.join(basedir, 'models', controller_class_path, "#{class_name}.java")
|
43
|
+
m.template 'ModelFactory.java', File.join(basedir, 'models', controller_class_path, "#{class_name}Factory.java")
|
44
|
+
|
45
|
+
m.directory(File.join(basedir, 'views', controller_class_path, controller_file_name))
|
46
|
+
|
47
|
+
m.template 'Fields.java', File.join(basedir, 'views', controller_class_path, controller_file_name, "#{class_name}Fields.java")
|
48
|
+
m.template 'Screen.java', File.join(basedir, 'views', controller_class_path, controller_file_name, "#{class_name}Screen.java")
|
49
|
+
|
50
|
+
m.directory(File.join(basedir_test, 'models', controller_class_path))
|
51
|
+
m.template 'AbstractApplicationResourceTestGwt.java', File.join(basedir_test, 'models', controller_class_path, "AbstractApplicationResourceTestGwt.java")
|
52
|
+
m.template 'TestGwt.java', File.join(basedir_test, 'models', controller_class_path, "#{class_name}TestGwt.java")
|
53
|
+
suiteFile = File.join(basedir_test, controller_class_path, "GwtTestSuite.java")
|
54
|
+
unless File.exists?(suiteFile)
|
55
|
+
m.template 'GwtTestSuite.java', suiteFile
|
56
|
+
end
|
57
|
+
m.add_testcase @package, suiteFile, class_name
|
58
|
+
m.add_screen File.join(basedir, "Application.java"), @package, class_name, singular_name, plural_name
|
59
|
+
|
60
|
+
m
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
module Rails
|
66
|
+
module Generator
|
67
|
+
module Commands
|
68
|
+
class Create < Base
|
69
|
+
|
70
|
+
def route_resources(*resources)
|
71
|
+
unless options[:pretend]
|
72
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
73
|
+
skip_route = false
|
74
|
+
gsub_file 'config/routes.rb', /(map.resources #{resource_list})/mi do |match|
|
75
|
+
skip_route = true
|
76
|
+
"#{match}"
|
77
|
+
end
|
78
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
79
|
+
|
80
|
+
logger.route "map.resources #{resource_list}" + (skip_route ? " - skipped" : " - added")
|
81
|
+
unless skip_route
|
82
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
83
|
+
"#{match}\n map.resources #{resource_list}\n"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_testcase(package, suite_file, class_name)
|
90
|
+
unless options[:pretend]
|
91
|
+
skip_testcase = false
|
92
|
+
gsub_file suite_file, /(import #{package}.models.#{class_name}TestGwt;)/mi do |match|
|
93
|
+
skip_testcase = true
|
94
|
+
"#{match}"
|
95
|
+
end
|
96
|
+
logger.testcase(class_name + "TestGwt" + (skip_testcase ? " - skipped" : " - added"))
|
97
|
+
unless skip_testcase
|
98
|
+
gsub_file suite_file, /(^package\s+[a-z.]*;)/mi do |match|
|
99
|
+
"#{match}\n\nimport #{package}.models.#{class_name}TestGwt;"
|
100
|
+
end
|
101
|
+
gsub_file suite_file, /(^\s+return suite;)/mi do |match|
|
102
|
+
" suite.addTestSuite(#{class_name}TestGwt.class);\n#{match}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_screen(application_file, java_package, class_name, singular_name, plural_name)
|
109
|
+
unless options[:pretend]
|
110
|
+
variable = "#{class_name[0,1].downcase}#{class_name[1,100]}"
|
111
|
+
skip_screen = false
|
112
|
+
gsub_file application_file, /(import #{java_package}.models.#{class_name}Factory;)/mi do |match|
|
113
|
+
skip_screen = true
|
114
|
+
"#{match}"
|
115
|
+
end
|
116
|
+
logger.screen(class_name + "Screen" + (skip_screen ? " - skipped" : " - added"))
|
117
|
+
unless skip_screen
|
118
|
+
skip_binding = false
|
119
|
+
gsub_file application_file, /(import de.saumya.gwt.translation.common.client.widget.ResourceBindings;)/mi do |match|
|
120
|
+
skip_binding = true
|
121
|
+
"#{match}"
|
122
|
+
end
|
123
|
+
unless skip_binding
|
124
|
+
gsub_file application_file, /(^package\s+[a-z.]*;)/mi do |match|
|
125
|
+
"#{match}\n\nimport de.saumya.gwt.translation.common.client.widget.ResourceBindings;"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
gsub_file application_file, /(^package\s+[a-z.]*;)/mi do |match|
|
129
|
+
"#{match}\n\nimport #{java_package}.models.#{class_name}Factory;\nimport #{java_package}.models.#{class_name};\nimport #{java_package}.views.#{plural_name}.#{class_name}Screen;"
|
130
|
+
end
|
131
|
+
gsub_file application_file, /(screenController = [a-zA-Z.]+;)/mi do |match|
|
132
|
+
"#{match}\n\n #{class_name}Factory #{variable}Factory = new #{class_name}Factory(container.repository,\n container.notifications,\n container.userFactory);\n #{class_name}Screen #{variable}Screen = new #{class_name}Screen(container.loadingNotice,\n container.getTextController,\n #{variable}Factory,\n container.session,\n new ResourceBindings<#{class_name}>(),\n container.notifications);\n screenController.addScreen(#{variable}Screen, \"#{plural_name}\");"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
class GeneratedAttribute
|
140
|
+
def sample_value(first = true)
|
141
|
+
value = (first ? @first_value : @second_value)
|
142
|
+
value ||= case type
|
143
|
+
when :int, :integer then first ? "1" : "2"
|
144
|
+
when :float then first ? "1.5" : "2.5"
|
145
|
+
when :decimal, :big_decimal then first ? "9.99" : "3.33"
|
146
|
+
when :date_time, :datetime,
|
147
|
+
:timestamp, :time then first ? "2009-09-09 09:09:09.0" : "2010-10-10 10:10:10.0"
|
148
|
+
when :date then first ? "2009-09-09" : "2010-10-10"
|
149
|
+
when :string, :text then first ? "first valule of #{@name}" : "second value of #{name}"
|
150
|
+
when :boolean then first ? "false" : "true"
|
151
|
+
else
|
152
|
+
""
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
package <%= package %>.models;
|
2
|
+
|
3
|
+
import de.saumya.gwt.persistence.client.Resource;
|
4
|
+
import de.saumya.gwt.session.client.AbstractUserResourceTestGwt;
|
5
|
+
|
6
|
+
abstract class AbstractApplicationResourceTestGwt<E extends Resource<E>>
|
7
|
+
extends AbstractUserResourceTestGwt<E> {
|
8
|
+
|
9
|
+
@Override
|
10
|
+
public String getModuleName() {
|
11
|
+
return "<%= package.sub(/\.client/, '') %>.Application";
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
package <%= package %>.views.<%= plural_name %>;
|
5
|
+
|
6
|
+
import <%= package %>.models.<%= class_name %>;
|
7
|
+
|
8
|
+
import de.saumya.gwt.translation.common.client.GetTextController;
|
9
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceBindings;
|
10
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceFields;
|
11
|
+
import de.saumya.gwt.translation.gui.client.bindings.CheckBoxBinding;
|
12
|
+
import de.saumya.gwt.translation.gui.client.bindings.IntegerTextBoxBinding;
|
13
|
+
import de.saumya.gwt.translation.gui.client.bindings.TextBoxBinding;
|
14
|
+
|
15
|
+
public class <%= class_name %>Fields extends ResourceFields<<%= class_name %>> {
|
16
|
+
|
17
|
+
public <%= class_name %>Fields(final GetTextController getTextController,
|
18
|
+
final ResourceBindings<<%= class_name %>> bindings) {
|
19
|
+
super(getTextController, bindings);
|
20
|
+
<% Array(attributes).each do |attribute| -%>
|
21
|
+
add("<%= attribute.name %>", new <% if attribute.type == :integer %>IntegerText<% elsif attribute.type == :boolean %>Check<% else %>Text<% end -%>BoxBinding<<%= class_name %>>() {
|
22
|
+
|
23
|
+
@Override
|
24
|
+
public void pullFrom(final <%= class_name %> resource) {
|
25
|
+
<% if attribute.type == :boolean -%>
|
26
|
+
setValue(resource.<%= attribute.name.javanize %>);
|
27
|
+
<% else -%>
|
28
|
+
setText(resource.<%= attribute.name.javanize %>);
|
29
|
+
<% end -%>
|
30
|
+
}
|
31
|
+
|
32
|
+
@Override
|
33
|
+
public void pushInto(final <%= class_name %> resource) {
|
34
|
+
<% if attribute.type == :boolean -%>
|
35
|
+
resource.<%= attribute.name.javanize %> = getValue();
|
36
|
+
<% else -%>
|
37
|
+
resource.<%= attribute.name.javanize %> = getText<% if attribute.type == :integer %>AsInt<% end -%>();
|
38
|
+
<% end -%>
|
39
|
+
}
|
40
|
+
}<% if attribute.type == :integer %>, 0, 123456<% elsif attribute.type == :boolean %><% else %>, true, 64<% end -%>);
|
41
|
+
<% end -%>
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
package <%= package %>;
|
2
|
+
|
3
|
+
import junit.framework.Test;
|
4
|
+
import junit.framework.TestSuite;
|
5
|
+
|
6
|
+
import com.google.gwt.junit.tools.GWTTestSuite;
|
7
|
+
|
8
|
+
public class GwtTestSuite extends GWTTestSuite {
|
9
|
+
|
10
|
+
public static Test suite() {
|
11
|
+
final TestSuite suite = new TestSuite("Test for GWT Application");
|
12
|
+
return suite;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
package <%= package %>.models;
|
5
|
+
|
6
|
+
<% if Array(attributes).find { |attr| attr.type == :date } -%>
|
7
|
+
import java.sql.Date;
|
8
|
+
<% end -%>
|
9
|
+
<% if Array(attributes).find { |attr| attr.type == :timestamp } || ! options[:skip_timestamps] -%>
|
10
|
+
import java.sql.Timestamp;
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
import com.google.gwt.xml.client.Element;
|
14
|
+
|
15
|
+
import de.saumya.gwt.persistence.client.Repository;
|
16
|
+
import de.saumya.gwt.persistence.client.ResourceWithID;
|
17
|
+
<% unless options[:skip_modified_by] -%>
|
18
|
+
import de.saumya.gwt.session.client.models.User;
|
19
|
+
import de.saumya.gwt.session.client.models.UserFactory;
|
20
|
+
<% end -%>
|
21
|
+
|
22
|
+
public class <%= class_name %> extends ResourceWithID<<%= class_name %>> {
|
23
|
+
|
24
|
+
<% unless options[:skip_modified_by] -%>
|
25
|
+
private final UserFactory userFactory;
|
26
|
+
|
27
|
+
<% end -%>
|
28
|
+
protected <%= class_name %>(final Repository repository, final <%= class_name %>Factory factory<% unless options[:skip_modified_by] -%>,
|
29
|
+
final UserFactory userFactory<% end -%>) {
|
30
|
+
super(repository, factory);
|
31
|
+
<% unless options[:skip_modified_by] -%>
|
32
|
+
this.userFactory = userFactory;
|
33
|
+
<% end -%>
|
34
|
+
}
|
35
|
+
|
36
|
+
<% Array(attributes).each do |attribute| -%>
|
37
|
+
public <% if attribute.type == :date %>Date <% elsif attribute.type == :integer %>int <% elsif attribute.type == :boolean %>boolean <% else %>String <% end -%> <%= attribute.name.javanize %>;
|
38
|
+
<% end -%>
|
39
|
+
<% unless options[:skip_timestamps] -%>
|
40
|
+
public Timestamp createdAt;
|
41
|
+
public Timestamp updatedAt;
|
42
|
+
<% end -%>
|
43
|
+
<% unless options[:skip_modified_by] -%>
|
44
|
+
public User createdBy;
|
45
|
+
public User updatedBy;
|
46
|
+
<% end -%>
|
47
|
+
|
48
|
+
@Override
|
49
|
+
protected void appendXml(final StringBuilder buf) {
|
50
|
+
super.appendXml(buf);
|
51
|
+
<% Array(attributes).each do |attribute| -%>
|
52
|
+
appendXml(buf, "<%= attribute.name %>", this.<%= attribute.name.javanize %>);
|
53
|
+
<% end -%>
|
54
|
+
<% unless options[:skip_timestamps] -%>
|
55
|
+
appendXml(buf, "created_at", this.createdAt);
|
56
|
+
appendXml(buf, "updated_at", this.updatedAt);
|
57
|
+
<% end -%>
|
58
|
+
<% unless options[:skip_modified_by] -%>
|
59
|
+
appendXml(buf, "created_by", this.createdBy);
|
60
|
+
appendXml(buf, "updated_by", this.updatedBy);
|
61
|
+
<% end -%>
|
62
|
+
}
|
63
|
+
|
64
|
+
@Override
|
65
|
+
protected void fromXml(final Element root) {
|
66
|
+
super.fromXml(root);
|
67
|
+
<% Array(attributes).each do |attribute| -%>
|
68
|
+
this.<%= attribute.name.javanize %> = get<% if attribute.type == :date %>Date<% elsif attribute.type == :integer %>Int<% elsif attribute.type == :boolean %>Boolean<% else %>String<% end -%>(root, "<%= attribute.name %>");
|
69
|
+
<% end -%>
|
70
|
+
<% unless options[:skip_timestamps] -%>
|
71
|
+
this.createdAt = getTimestamp(root, "created_at");
|
72
|
+
this.updatedAt = getTimestamp(root, "updated_at");
|
73
|
+
<% end -%>
|
74
|
+
<% unless options[:skip_modified_by] -%>
|
75
|
+
this.createdBy = this.userFactory.getChildResource(root, "created_by");
|
76
|
+
this.updatedBy = this.userFactory.getChildResource(root, "updated_by");
|
77
|
+
<% end -%>
|
78
|
+
}
|
79
|
+
|
80
|
+
@Override
|
81
|
+
public void toString(final StringBuilder buf) {
|
82
|
+
super.toString(buf);
|
83
|
+
<% Array(attributes).each do |attribute| -%>
|
84
|
+
toString(buf, "<%= attribute.name %>", this.<%= attribute.name.javanize %>);
|
85
|
+
<% end -%>
|
86
|
+
<% unless options[:skip_timestamps] -%>
|
87
|
+
toString(buf, "created_at", this.createdAt);
|
88
|
+
toString(buf, "updated_at", this.updatedAt);
|
89
|
+
<% end -%>
|
90
|
+
<% unless options[:skip_modified_by] -%>
|
91
|
+
toString(buf, "created_by", this.createdBy);
|
92
|
+
toString(buf, "updated_by", this.updatedBy);
|
93
|
+
<% end -%>
|
94
|
+
}
|
95
|
+
|
96
|
+
@Override
|
97
|
+
public String display() {
|
98
|
+
final StringBuilder builder = new StringBuilder("<%= class_name %>");
|
99
|
+
builder.append("(").append(this.id).append(")");
|
100
|
+
return builder.toString();
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
package <%= package %>.models;
|
5
|
+
|
6
|
+
|
7
|
+
import de.saumya.gwt.persistence.client.Repository;
|
8
|
+
import de.saumya.gwt.persistence.client.ResourceFactory;
|
9
|
+
import de.saumya.gwt.persistence.client.ResourceNotifications;
|
10
|
+
|
11
|
+
<% unless options[:skip_modified_by] -%>
|
12
|
+
import de.saumya.gwt.session.client.models.UserFactory;
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
public class <%= class_name %>Factory extends ResourceFactory<<%= class_name %>> {
|
16
|
+
|
17
|
+
<% unless options[:skip_modified_by] -%>
|
18
|
+
private final UserFactory userFactory;
|
19
|
+
|
20
|
+
<% end -%>
|
21
|
+
public <%= class_name %>Factory(final Repository repository,
|
22
|
+
final ResourceNotifications notifications<% unless options[:skip_modified_by] -%>,
|
23
|
+
final UserFactory userFactory<% end -%>) {
|
24
|
+
super(repository, notifications);
|
25
|
+
<% unless options[:skip_modified_by] -%>
|
26
|
+
this.userFactory = userFactory;
|
27
|
+
<% end -%>
|
28
|
+
}
|
29
|
+
|
30
|
+
@Override
|
31
|
+
public String keyName() {
|
32
|
+
return "id";
|
33
|
+
}
|
34
|
+
|
35
|
+
@Override
|
36
|
+
public <%= class_name %> newResource() {
|
37
|
+
return new <%= class_name %>(this.repository, this<% unless options[:skip_modified_by] -%>, this.userFactory<% end -%>);
|
38
|
+
}
|
39
|
+
|
40
|
+
@Override
|
41
|
+
public String storageName() {
|
42
|
+
return "<%= singular_name %>";
|
43
|
+
}
|
44
|
+
|
45
|
+
@Override
|
46
|
+
public String defaultSearchParameterName() {
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
|
50
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
package <%= package %>.views.<%= plural_name %>;
|
5
|
+
|
6
|
+
import <%= package %>.models.<%= class_name %>;
|
7
|
+
import <%= package %>.models.<%= class_name %>Factory;
|
8
|
+
|
9
|
+
import de.saumya.gwt.persistence.client.ResourceNotifications;
|
10
|
+
import de.saumya.gwt.session.client.Session;
|
11
|
+
import de.saumya.gwt.translation.common.client.GetTextController;
|
12
|
+
import de.saumya.gwt.translation.common.client.widget.DefaultResourceActionPanel;
|
13
|
+
import de.saumya.gwt.translation.common.client.widget.LoadingNotice;
|
14
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceBindings;
|
15
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceCollectionListing;
|
16
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceCollectionNavigation;
|
17
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceCollectionPanel;
|
18
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceHeaderPanel;
|
19
|
+
import de.saumya.gwt.translation.common.client.widget.ResourcePanel;
|
20
|
+
import de.saumya.gwt.translation.common.client.widget.ResourceScreen;
|
21
|
+
|
22
|
+
public class <%= class_name %>Screen extends ResourceScreen<<%= class_name %>> {
|
23
|
+
|
24
|
+
private static class <%= class_name %>Headers extends ResourceHeaderPanel<<%= class_name %>> {
|
25
|
+
|
26
|
+
public <%= class_name %>Headers(final GetTextController getTextController) {
|
27
|
+
super(getTextController);
|
28
|
+
}
|
29
|
+
|
30
|
+
public void reset(final <%= class_name %> resource) {
|
31
|
+
reset(resource, <% if options[:skip_timestamps] %>null<% else %>resource.updatedAt<% end -%>, <% if options[:skip_modified_by] %>null<% else %>resource.updatedBy<% end -%>);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
public <%= class_name %>Screen(final LoadingNotice loadingNotice,
|
36
|
+
final GetTextController getTextController,
|
37
|
+
final <%= class_name %>Factory factory, final Session session,
|
38
|
+
final ResourceBindings<<%= class_name %>> bindings,
|
39
|
+
final ResourceNotifications notifications) {
|
40
|
+
super(loadingNotice,
|
41
|
+
factory,
|
42
|
+
session,
|
43
|
+
new ResourcePanel<<%= class_name %>>(new <%= class_name %>Headers(getTextController),
|
44
|
+
new <%= class_name %>Fields(getTextController, bindings)),
|
45
|
+
new ResourceCollectionPanel<<%= class_name %>>(loadingNotice,
|
46
|
+
new ResourceCollectionNavigation<<%= class_name %>>(loadingNotice,
|
47
|
+
factory,
|
48
|
+
getTextController),
|
49
|
+
new ResourceCollectionListing<<%= class_name %>>(session,
|
50
|
+
factory,
|
51
|
+
getTextController)),
|
52
|
+
new DefaultResourceActionPanel<<%= class_name %>>(getTextController,
|
53
|
+
bindings,
|
54
|
+
session,
|
55
|
+
factory,
|
56
|
+
notifications),
|
57
|
+
notifications);
|
58
|
+
}
|
59
|
+
|
60
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
package <%= package %>.models;
|
5
|
+
|
6
|
+
import de.saumya.gwt.persistence.client.Resource;
|
7
|
+
import de.saumya.gwt.persistence.client.ResourceFactory;
|
8
|
+
|
9
|
+
/**
|
10
|
+
* GWT JUnit tests must extend GWTTestCase.
|
11
|
+
*/
|
12
|
+
public class <%= class_name %>TestGwt extends AbstractApplicationResourceTestGwt<<%= class_name %>> {
|
13
|
+
|
14
|
+
|
15
|
+
private <%= class_name %> resource;
|
16
|
+
|
17
|
+
private static final String RESOURCE_XML = "<<%= singular_name%>>"
|
18
|
+
+ "<id>1</id>"
|
19
|
+
<% Array(attributes).each do |attribute| -%>
|
20
|
+
+ "<<%= attribute.name %>><%= attribute.sample_value %></<%= attribute.name %>>"
|
21
|
+
<% end -%>
|
22
|
+
<% unless options[:skip_timestamps] -%>
|
23
|
+
+ "<created_at>2009-07-09 17:14:48.0</created_at>"
|
24
|
+
+ "<updated_at>2009-07-09 17:14:48.0</updated_at>"
|
25
|
+
<% end -%>
|
26
|
+
+ "</<%= singular_name%>>";
|
27
|
+
|
28
|
+
@Override
|
29
|
+
protected String resourceNewXml() {
|
30
|
+
return RESOURCE_XML<% unless options[:skip_timestamps] -%>.replaceFirst("<created_at>[0-9-:. ]*</created_at>", "").replaceFirst("<updated_at>[0-9-:. ]*</updated_at>", "")<% end -%>.replace("<id>1</id>", "");
|
31
|
+
}
|
32
|
+
|
33
|
+
@Override
|
34
|
+
protected String resource1Xml() {
|
35
|
+
return RESOURCE_XML;
|
36
|
+
}
|
37
|
+
|
38
|
+
@Override
|
39
|
+
protected String resource2Xml() {
|
40
|
+
return RESOURCE_XML.replace(">1<", ">2<");
|
41
|
+
}
|
42
|
+
|
43
|
+
@Override
|
44
|
+
protected String resourcesXml() {
|
45
|
+
return "<<%= plural_name %>>" + resource1Xml() + resource2Xml() + "</<%= plural_name %>>";
|
46
|
+
}
|
47
|
+
|
48
|
+
@Override
|
49
|
+
protected ResourceFactory<<%= class_name %>> factorySetUp() {
|
50
|
+
return new <%= class_name %>Factory(this.repository,
|
51
|
+
this.notifications<% unless options[:skip_modified_by] -%>, this.userFactory<% end -%>);
|
52
|
+
}
|
53
|
+
|
54
|
+
@Override
|
55
|
+
protected Resource<<%= class_name %>> resourceSetUp() {
|
56
|
+
this.resource = this.factory.newResource();
|
57
|
+
|
58
|
+
this.resource.id = 1;
|
59
|
+
this.resource.<%= attributes.first.name.javanize %> = <% if [:date, :time, :date_time].member? attributes.first.type %>new de.saumya.gwt.persistence.client.TimestampFactory("<%= attributes.first.sample_value %>").toDate()<% else %>"<%= attributes.first.sample_value %>"<% end -%>;
|
60
|
+
|
61
|
+
this.repository.addXmlResponse(RESOURCE_XML);
|
62
|
+
|
63
|
+
this.resource.save();
|
64
|
+
|
65
|
+
return this.resource;
|
66
|
+
}
|
67
|
+
|
68
|
+
@Override
|
69
|
+
public void doTestCreate() {
|
70
|
+
assertEquals("<%= attributes.first.sample_value %>", this.resource.<%= attributes.first.name.javanize %><% if [:date, :time, :date_time].member? attributes.first.type %>.toString()<% end -%>);
|
71
|
+
}
|
72
|
+
|
73
|
+
@Override
|
74
|
+
public void doTestUpdate() {
|
75
|
+
this.resource.<%= attributes.first.name.javanize %> = <% if [:date, :time, :date_time].member? attributes.first.type %>new de.saumya.gwt.persistence.client.TimestampFactory(changedValue()).toDate()<% else %>changedValue()<% end -%>;
|
76
|
+
this.resource.save();
|
77
|
+
assertEquals(this.resource.<%= attributes.first.name.javanize %><% if [:date, :time, :date_time].member? attributes.first.type %>.toString()<% end -%>, changedValue());
|
78
|
+
}
|
79
|
+
|
80
|
+
private final static String XML = "<<%= singular_name%>>"
|
81
|
+
+ "<id>1</id>"
|
82
|
+
<% Array(attributes).each do |attribute| -%>
|
83
|
+
+ "<<%= attribute.name %>><%= attribute.sample_value %></<%= attribute.name %>>"
|
84
|
+
<% end -%>
|
85
|
+
<% unless options[:skip_timestamps] -%>
|
86
|
+
+ "<created_at>2009-07-09 17:14:48.0</created_at>"
|
87
|
+
+ "<updated_at>2007-07-09 17:14:48.0</updated_at>"
|
88
|
+
<% end -%>
|
89
|
+
+ "</<%= singular_name%>>";
|
90
|
+
|
91
|
+
@Override
|
92
|
+
protected String changedValue() {
|
93
|
+
return "<%= attributes.first.sample_value(false) %>";
|
94
|
+
}
|
95
|
+
|
96
|
+
@Override
|
97
|
+
protected String keyValue() {
|
98
|
+
return "1";
|
99
|
+
}
|
100
|
+
|
101
|
+
@Override
|
102
|
+
protected String marshallingXml() {
|
103
|
+
return XML;
|
104
|
+
}
|
105
|
+
|
106
|
+
@Override
|
107
|
+
protected String value() {
|
108
|
+
return "<%= attributes.first.sample_value %>";
|
109
|
+
}
|
110
|
+
}
|
@@ -12,6 +12,15 @@ class <%= class_name %>
|
|
12
12
|
|
13
13
|
<% unless options[:skip_modified_by] -%>
|
14
14
|
modified_by "Ixtlan::Models::User"
|
15
|
+
|
16
|
+
require 'dm-serializer'
|
17
|
+
alias :to_x :to_xml_document
|
18
|
+
def to_xml_document(opts = {}, doc = nil)
|
19
|
+
unless(opts[:methods])
|
20
|
+
opts.merge!({:methods => [:updated_by], :updated_by => {:methods => [], :exclude => [:created_at, :updated_at]}})
|
21
|
+
end
|
22
|
+
to_x(opts, doc)
|
23
|
+
end
|
15
24
|
<% end -%>
|
16
25
|
|
17
26
|
end
|
data/lib/dm-serializer/to_xml.rb
CHANGED
@@ -37,7 +37,9 @@ module DataMapper
|
|
37
37
|
value = __send__(meth)
|
38
38
|
unless value.nil?
|
39
39
|
if value.respond_to?(:to_xml_document)
|
40
|
-
|
40
|
+
options = value.is_a?(DataMapper::Collection) ? {:collection_element_name => xml_name} : {:element_name => xml_name}
|
41
|
+
options.merge!(opts[meth] || {})
|
42
|
+
xml.add_xml(root, value.__send__(:to_xml_document, options))
|
41
43
|
else
|
42
44
|
xml.add_node(root, xml_name, value.to_s)
|
43
45
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ixtlan
|
2
|
+
class ChildPath
|
3
|
+
def initialize(app, rootpath)
|
4
|
+
@app = app
|
5
|
+
@rootpath = rootpath
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
['REQUEST_PATH','PATH_INFO','REQUEST_URI','SCRIPT_NAME'].each do |key|
|
10
|
+
if(env[key] =~ /[.]xml$/)
|
11
|
+
env[key].gsub!(/^\/#{@rootpath}/, "")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
module Ixtlan
|
2
|
+
module Controllers
|
3
|
+
module PhrasesController
|
4
|
+
|
5
|
+
LOCALE = Object.full_const_get(::Ixtlan::Models::LOCALE)
|
6
|
+
TEXT = Object.full_const_get(::Ixtlan::Models::TEXT)
|
7
|
+
|
8
|
+
def index
|
9
|
+
version = params[:version]
|
10
|
+
|
11
|
+
locale = if params[:locale]
|
12
|
+
LOCALE.get!(params[:locale])
|
13
|
+
else
|
14
|
+
LOCALE.default
|
15
|
+
end
|
16
|
+
|
17
|
+
phraseMap = {}
|
18
|
+
Ixtlan::Models::Word.not_approved(:locale => Locale.default).each do |word|
|
19
|
+
phraseMap[word.code] = word_to_phrase(word, :text)
|
20
|
+
end
|
21
|
+
Ixtlan::Models::Word.latest_approved(:locale => Locale.default).each do |word|
|
22
|
+
phrase = phraseMap[word.code]
|
23
|
+
if phrase
|
24
|
+
merge_word_into_phrase(word, phrase)
|
25
|
+
else
|
26
|
+
phraseMap[word.code] = word_to_phrase(word, :current_text)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
phrases = ::DataMapper::Collection.new(::DataMapper::Query.new(repository, ::Ixtlan::Models::Phrase), [])
|
30
|
+
phraseMap.each { |k,v| phrases << v }
|
31
|
+
render :xml => phrases.to_xml
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def show
|
36
|
+
word = Ixtlan::Models::Word.not_approved(:locale => Locale.default, :code => params[:id]).first
|
37
|
+
if word
|
38
|
+
phrase = word_to_phrase(word, :text)
|
39
|
+
word = Ixtlan::Models::Word.latest_approved(:locale => Locale.default, :code => params[:id]).first
|
40
|
+
merge_word_into_phrase(word, phrase) if word
|
41
|
+
else
|
42
|
+
word = Ixtlan::Models::Word.latest_approved(:locale => Locale.default, :code => params[:id]).first
|
43
|
+
phrase = word_to_phrase(word, :current_text)
|
44
|
+
end
|
45
|
+
render :xml => phrase.to_xml
|
46
|
+
end
|
47
|
+
|
48
|
+
def create
|
49
|
+
phrase = params[:phrase]
|
50
|
+
|
51
|
+
# load the locale and delete the locale parameter array
|
52
|
+
locale = LOCALE.get!(phrase.delete(:locale)[:code])
|
53
|
+
|
54
|
+
if(TEXT.count(:version => nil, :code => phrase[:code], :locale => locale) == 1)
|
55
|
+
logger.warn "precondition failed: " + phrase.inspect
|
56
|
+
# mimic created action by just loading it
|
57
|
+
render :xml => TEXT.first(:version => nil, :code => phrase[:code], :locale => locale).to_xml, :status => :created
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
phrase[:text] ||= phrase.delete(:current_text)
|
62
|
+
|
63
|
+
@text = TEXT.new(phrase)
|
64
|
+
if(TEXT.count(:code => phrase[:code], :locale => locale) == 0)
|
65
|
+
approve_it = true
|
66
|
+
end
|
67
|
+
|
68
|
+
# set the missing attributes
|
69
|
+
@text.locale = locale
|
70
|
+
@text.current_user = current_user
|
71
|
+
|
72
|
+
respond_to do |format|
|
73
|
+
success = @text.save
|
74
|
+
if success && approve_it
|
75
|
+
@text.current_user = current_user
|
76
|
+
success = @text.approve
|
77
|
+
end
|
78
|
+
if success
|
79
|
+
flash[:notice] = 'Text was successfully created.'
|
80
|
+
format.html { redirect_to(text_url(@text.id)) }
|
81
|
+
format.xml { render :xml => @text, :status => :created }
|
82
|
+
else
|
83
|
+
format.html { render :action => "new" }
|
84
|
+
format.xml { render :xml => @text.errors, :status => :unprocessable_entity }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def update
|
90
|
+
new_text = params[:phrase][:text]
|
91
|
+
word = Ixtlan::Models::Text.not_approved(:locale => Locale.default, :code => params[:id]).first
|
92
|
+
if word
|
93
|
+
phrase = word_to_phrase(word, :text)
|
94
|
+
word_approved = Ixtlan::Models::Word.latest_approved(:locale => Locale.default, :code => params[:id]).first
|
95
|
+
merge_word_into_phrase(word_approved, phrase) if word_approved
|
96
|
+
else
|
97
|
+
# take the latest approved text for the given code and create a new
|
98
|
+
# text without version (!= not_approved text) for the given code
|
99
|
+
word = Ixtlan::Models::Text.latest_approved(:locale => Locale.default, :code => params[:id]).first
|
100
|
+
phrase = word_to_phrase(word, :current_text)
|
101
|
+
word = Ixtlan::Models::Text.new(:code => params[:id], :locale => Locale.default)
|
102
|
+
end
|
103
|
+
|
104
|
+
phrase.text = new_text
|
105
|
+
|
106
|
+
word.text = new_text
|
107
|
+
word.current_user = current_user
|
108
|
+
if word.save
|
109
|
+
render :xml => phrase, :status => :ok
|
110
|
+
else
|
111
|
+
render :xml => word.errors, :status => :unprocessable_entity
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
def approve
|
117
|
+
word = Ixtlan::Models::Text.not_approved(:locale => Locale.default, :code => params[:id]).first
|
118
|
+
if word
|
119
|
+
word.current_user = current_user
|
120
|
+
if word.approve
|
121
|
+
word = nil
|
122
|
+
else
|
123
|
+
render :xml => word.errors, :status => :unprocessable_entity
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# if there was no unapproved word or approval succeeded render
|
128
|
+
# the latest approved word
|
129
|
+
unless word
|
130
|
+
word = Ixtlan::Models::Word.latest_approved(:locale => Locale.default, :code => params[:id]).first
|
131
|
+
phrase = word_to_phrase(word, :current_text)
|
132
|
+
render :xml => phrase.to_xml, :status => :ok
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def merge_word_into_phrase(word, phrase)
|
139
|
+
phrase.current_text = word.text
|
140
|
+
# phrase.approved_by = word.updated_by
|
141
|
+
# phrase.approved_at = word.updated_at
|
142
|
+
end
|
143
|
+
|
144
|
+
def word_to_phrase(word, text_field)
|
145
|
+
Ixtlan::Models::Phrase.new(:code => word.code, text_field => word.text, :updated_by => word.updated_by, :updated_at => word.updated_at, :locale => LOCALE.default)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -27,7 +27,7 @@ module Ixtlan
|
|
27
27
|
|
28
28
|
if(TEXT.count(:version => nil, :code => phrase[:code], :locale => locale) == 1)
|
29
29
|
logger.warn "precondition failed: " + phrase.inspect
|
30
|
-
# mimic created action
|
30
|
+
# mimic created action by just loading it
|
31
31
|
render :xml => TEXT.first(:version => nil, :code => phrase[:code], :locale => locale).to_xml, :status => :created
|
32
32
|
return
|
33
33
|
end
|
@@ -35,13 +35,21 @@ module Ixtlan
|
|
35
35
|
phrase[:text] ||= phrase.delete(:current_text)
|
36
36
|
|
37
37
|
@text = TEXT.new(phrase)
|
38
|
+
if(TEXT.count(:code => phrase[:code], :locale => locale) == 0)
|
39
|
+
approve_it = true
|
40
|
+
end
|
38
41
|
|
39
42
|
# set the missing attributes
|
40
43
|
@text.locale = locale
|
41
44
|
@text.current_user = current_user
|
42
45
|
|
43
46
|
respond_to do |format|
|
44
|
-
|
47
|
+
success = @text.save
|
48
|
+
if success && approve_it
|
49
|
+
@text.current_user = current_user
|
50
|
+
success = @text.approve
|
51
|
+
end
|
52
|
+
if success
|
45
53
|
flash[:notice] = 'Text was successfully created.'
|
46
54
|
format.html { redirect_to(text_url(@text.id)) }
|
47
55
|
format.xml { render :xml => @text, :status => :created }
|
data/lib/ixtlan/guard.rb
CHANGED
@@ -63,11 +63,27 @@ module Ixtlan
|
|
63
63
|
logger.warn("guard directory #{guard_dir} not found, skip loading")
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
def self.symbolize(h)
|
68
|
+
result = {}
|
69
|
+
|
70
|
+
h.each do |k, v|
|
71
|
+
if v.is_a?(Hash)
|
72
|
+
result[k.to_sym] = symbolize_keys(v) unless v.size == 0
|
73
|
+
elsif v.is_a?(Array)
|
74
|
+
val = []
|
75
|
+
v.each {|vv| val << vv.to_sym }
|
76
|
+
result[k.to_sym] = val
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
result
|
81
|
+
end
|
66
82
|
|
67
83
|
def self.initialize(controller, map)
|
68
84
|
msg = map.collect{ |k,v| "\n\t#{k} => [#{v.join(',')}]"}
|
69
85
|
@@logger.debug("#{controller} guard: #{msg}")
|
70
|
-
@@map[controller] = map
|
86
|
+
@@map[controller.to_sym] = symbolize(map)
|
71
87
|
end
|
72
88
|
|
73
89
|
def self.export_xml
|
data/lib/ixtlan/logger_config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ixtlan
|
2
2
|
module Models
|
3
|
-
class
|
3
|
+
class I18nText
|
4
4
|
include DataMapper::Resource
|
5
5
|
|
6
6
|
def self.default_storage_name
|
@@ -98,14 +98,15 @@ module Ixtlan
|
|
98
98
|
:locale => locale).first
|
99
99
|
params[:version] = latest.nil? ? 1 : latest.version + 1
|
100
100
|
params[:current] = true
|
101
|
+
# TODO approved is not need since after approval the resource is inmutable !!!
|
101
102
|
params[:approved_at] = attribute_get(:updated_at)
|
102
|
-
params[:approved_by] = params[:current_user]
|
103
|
+
params[:approved_by] = params[:current_user] || current_user
|
103
104
|
|
104
105
|
p = (previous.nil? ? true : previous.update(:previous => false,
|
105
|
-
:current_user => params[:current_user]))
|
106
|
+
:current_user => params[:current_user] || current_user))
|
106
107
|
l = (latest.nil? ? true : latest.update(:current => false,
|
107
108
|
:previous => true,
|
108
|
-
:current_user => params[:current_user]))
|
109
|
+
:current_user => params[:current_user] || current_user))
|
109
110
|
u = update(params)
|
110
111
|
|
111
112
|
u && l && p
|
data/lib/ixtlan/models/phrase.rb
CHANGED
@@ -35,11 +35,11 @@ module Ixtlan
|
|
35
35
|
phrases = ::DataMapper::Collection.new(::DataMapper::Query.new(self.repository, Ixtlan::Models::Phrase), [])
|
36
36
|
map = {}
|
37
37
|
locale = (args[:locale] ||= Locale.default)
|
38
|
-
|
38
|
+
I18nText.not_approved(args.dup).each do |text|
|
39
39
|
phrase = Phrase.new(:code => text.code, :text => text.text, :current_text => text.text, :locale => locale, :updated_at => text.updated_at, :updated_by => text.updated_by)
|
40
40
|
map[phrase.code] = phrase
|
41
41
|
end
|
42
|
-
|
42
|
+
I18nText.latest_approved(args.dup).each do |text|
|
43
43
|
if (phrase = map[text.code])
|
44
44
|
phrase.current_text = text.text
|
45
45
|
else
|
@@ -19,10 +19,10 @@ module Ixtlan
|
|
19
19
|
|
20
20
|
def self.map_for(args = {})
|
21
21
|
map = {}
|
22
|
-
|
22
|
+
I18nText.latest_approved(args.dup).each do |text|
|
23
23
|
map[text.code] = Translation.create(:text => text.text, :approved_at => text.approved_at, :approved_by => text.approved_by)
|
24
24
|
end
|
25
|
-
|
25
|
+
I18nText.second_latest_approved(args.dup).each do |text|
|
26
26
|
translation = map[text.code]
|
27
27
|
translation.previous_text = text.text
|
28
28
|
end
|
data/lib/ixtlan/models/user.rb
CHANGED
data/lib/ixtlan/models/word.rb
CHANGED
data/lib/ixtlan/models.rb
CHANGED
@@ -8,6 +8,6 @@ module Ixtlan
|
|
8
8
|
LOCALE = "::Ixtlan::Models::Locale" unless const_defined? "LOCALE"
|
9
9
|
CONFIGURATION = "::Ixtlan::Models::Configuration" unless const_defined? "CONFIGURATION"
|
10
10
|
TRANSLATION = "::Ixtlan::Models::Translation" unless const_defined? "TRANSLATION"
|
11
|
-
TEXT = "::Ixtlan::Models::
|
11
|
+
TEXT = "::Ixtlan::Models::I18nText" unless const_defined? "TEXT"
|
12
12
|
end
|
13
13
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'ixtlan/user_logger'
|
1
2
|
module Ixtlan
|
2
3
|
module Rails
|
3
4
|
module ErrorHandling
|
4
5
|
|
5
6
|
def log_user_error(exception)
|
6
|
-
UserLogger.new(Ixtlan::Rails::ErrorHandling).log_action(self, " - #{exception.class} - #{exception.message}")
|
7
|
+
Ixtlan::UserLogger.new(Ixtlan::Rails::ErrorHandling).log_action(self, " - #{exception.class} - #{exception.message}")
|
7
8
|
log_error(exception)
|
8
9
|
end
|
9
10
|
|
@@ -9,7 +9,7 @@ module Rails
|
|
9
9
|
AUTHENTICATION = Object.full_const_get(Ixtlan::Models::AUTHENTICATION)
|
10
10
|
|
11
11
|
def authentication_logger
|
12
|
-
@authentication_logger ||= UserLogger.new(Ixtlan::Rails::UnrestfulAuthentication)
|
12
|
+
@authentication_logger ||= Ixtlan::UserLogger.new(Ixtlan::Rails::UnrestfulAuthentication)
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
data/lib/ixtlan/version.rb
CHANGED
data/lib/models.rb
CHANGED
@@ -3,12 +3,17 @@ require 'dm-timestamps'
|
|
3
3
|
require 'dm-validations'
|
4
4
|
require 'dm-serializer'
|
5
5
|
require 'ixtlan/models'
|
6
|
+
load 'ixtlan/models/authentication.rb'
|
6
7
|
load 'ixtlan/models/user.rb'
|
7
8
|
load 'ixtlan/models/group_locale_user.rb'
|
8
9
|
load 'ixtlan/models/group.rb'
|
9
10
|
load 'ixtlan/models/group_user.rb'
|
10
11
|
load 'ixtlan/models/locale.rb'
|
11
12
|
load 'ixtlan/models/permission.rb'
|
13
|
+
load 'ixtlan/models/i18n_text.rb'
|
14
|
+
load 'ixtlan/models/word.rb'
|
15
|
+
load 'ixtlan/models/phrase.rb'
|
16
|
+
load 'ixtlan/models/translation.rb'
|
12
17
|
load 'ixtlan/models/role.rb'
|
13
18
|
load 'ixtlan/models/configuration.rb'
|
14
19
|
load 'ixtlan/models/configuration_locale.rb'
|
data/spec/spec_helper.rb
CHANGED
@@ -20,7 +20,7 @@ require 'ixtlan' / 'models' / 'group_user'
|
|
20
20
|
require 'ixtlan' / 'models' / 'group_locale_user'
|
21
21
|
require 'ixtlan' / 'models' / 'permission'
|
22
22
|
require 'ixtlan' / 'models' / 'role'
|
23
|
-
require 'ixtlan' / 'models' / '
|
23
|
+
require 'ixtlan' / 'models' / 'i18n_text'
|
24
24
|
require 'ixtlan' / 'passwords'
|
25
25
|
require 'ixtlan' / 'digest'
|
26
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ixtlan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mkristian
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-03 00:00:00 +05:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -122,6 +122,14 @@ files:
|
|
122
122
|
- generators/ixtlan_datamapper_rspec_scaffold/templates/controller_spec.rb
|
123
123
|
- generators/ixtlan_datamapper_rspec_scaffold/templates/guard.rb
|
124
124
|
- generators/ixtlan_datamapper_rspec_scaffold/templates/i18n.rb
|
125
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/gwt_ixtlan_datamapper_rspec_scaffold_generator.rb
|
126
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Model.java
|
127
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/ModelFactory.java
|
128
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Fields.java
|
129
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/Screen.java
|
130
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/TestGwt.java
|
131
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/GwtTestSuite.java
|
132
|
+
- generators/gwt_ixtlan_datamapper_rspec_scaffold/templates/AbstractApplicationResourceTestGwt.java
|
125
133
|
- lib/models.rb
|
126
134
|
- lib/ixtlan.rb
|
127
135
|
- lib/dm-serializer.rb
|
@@ -142,11 +150,12 @@ files:
|
|
142
150
|
- lib/ixtlan/models/word.rb
|
143
151
|
- lib/ixtlan/models/configuration.rb
|
144
152
|
- lib/ixtlan/models/authentication.rb
|
145
|
-
- lib/ixtlan/models/
|
153
|
+
- lib/ixtlan/models/i18n_text.rb
|
146
154
|
- lib/ixtlan/models/group_user.rb
|
147
155
|
- lib/ixtlan/models/group.rb
|
148
156
|
- lib/ixtlan/rolling_file.rb
|
149
157
|
- lib/ixtlan/cms_script.rb
|
158
|
+
- lib/ixtlan/child_path.rb
|
150
159
|
- lib/ixtlan/logger_config.rb
|
151
160
|
- lib/ixtlan/models.rb
|
152
161
|
- lib/ixtlan/audit_config.rb
|
@@ -158,6 +167,7 @@ files:
|
|
158
167
|
- lib/ixtlan/optimistic_persistence_validation.rb
|
159
168
|
- lib/ixtlan/error_notifier/error_notification.rhtml
|
160
169
|
- lib/ixtlan/controllers/texts_controller.rb
|
170
|
+
- lib/ixtlan/controllers/phrases_controller.rb
|
161
171
|
- lib/ixtlan/controllers/permissions_controller.rb
|
162
172
|
- lib/ixtlan/controllers/authentications_controller.rb
|
163
173
|
- lib/ixtlan/controllers/configurations_controller.rb
|