vraptor-scaffold 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/CHANGELOG.rdoc +164 -0
- data/Gemfile.lock +5 -8
- data/README.textile +20 -7
- data/bin/vraptor +1 -1
- data/index.sample.html +169 -0
- data/lib/vraptor-scaffold.rb +10 -29
- data/lib/vraptor-scaffold/configuration.rb +27 -4
- data/lib/vraptor-scaffold/execution.rb +24 -0
- data/lib/vraptor-scaffold/generators/app/app_generator.rb +196 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/dependency.rb +0 -0
- data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +53 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine.rb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine.rb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle.erb +19 -1
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.xml +6 -2
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/classpath.erb +0 -5
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/project.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.jdt.core.prefs +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.component.tt +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/freemarker-web.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/macros/html.ftl +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/main.ftl +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy-2.2.0.jar +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.erb +1 -1
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/jsp-web.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/main.jsp +2 -2
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/prelude.jspf +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src/models/Entity.java.tt → app/templates/models/Entity.erb} +1 -1
- data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src/repositories/Repository.java.tt → app/templates/orm/Repository-jpa.java.tt} +3 -3
- data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/pom.erb +29 -13
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources-test/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources/messages.properties +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +7 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/webapp/WEB-INF/web.xml → app/templates/webapp/WEB-INF/web.xml.tt} +2 -2
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src-test/controllers → app/templates/webapp/images}/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/index.jsp +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/common.css +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/scaffold.css +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/stylesheets.css +0 -0
- data/lib/vraptor-scaffold/generators/plugin/plugin_generator.rb +42 -0
- data/lib/vraptor-scaffold/generators/plugin/vraptor_gem.rb +36 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute.rb +1 -1
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/base_scaffold.rb +6 -2
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator.rb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller.erb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +20 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model.erb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +27 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository.erb +3 -3
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator.rb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +18 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/edit.erb +0 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/form.erb +4 -4
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/index.erb +36 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/new.erb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/show.erb +14 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +18 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/edit.erb +0 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/form.erb +4 -4
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/index.erb +6 -6
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/new.erb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/show.erb +14 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +21 -0
- data/lib/vraptor-scaffold/load_paths.rb +13 -21
- data/lib/vraptor-scaffold/runner.rb +11 -0
- data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
- data/lib/vraptor-scaffold/runner/configure.rb +21 -0
- data/lib/vraptor-scaffold/runner/generator.rb +15 -0
- data/lib/vraptor-scaffold/runner/help.rb +12 -0
- data/lib/vraptor-scaffold/runner/plugin.rb +19 -0
- data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
- data/lib/vraptor-scaffold/version.rb +1 -1
- data/spec/resources/vraptor-scaffold.properties +5 -0
- data/spec/simple_custom_plugin.rb +10 -0
- data/spec/spec_helper.rb +5 -6
- data/spec/vraptor-scaffold/configuration_spec.rb +88 -4
- data/spec/vraptor-scaffold/execution_spec.rb +47 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/app_generator_spec.rb +136 -54
- data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_manager_spec.rb +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_spec.rb +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine_spec.rb +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine_spec.rb +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Entity.java +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/FreemarkerPathResolver.java +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Repository.java +3 -3
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle +24 -5
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators-jsp.xml +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.xml +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker-web.xml +2 -2
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.xml +6 -5
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/jsp-web.xml +1 -1
- data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +168 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/pom.xml +11 -14
- data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +61 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +61 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +40 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +147 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +40 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +147 -0
- data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +130 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute_spec.rb +13 -9
- data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator_spec.rb +18 -9
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/ProductController.java +3 -3
- data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +74 -0
- data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +75 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +50 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/Product.java +6 -6
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +60 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepository.java +3 -3
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepositoryImpl.java +3 -3
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator_spec.rb +0 -0
- data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
- data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
- data/spec/vraptor-scaffold/runner/plugin_spec.rb +45 -0
- data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
- data/spec/vraptor-scaffold_spec.rb +1 -94
- data/vraptor-scaffold.gemspec +3 -3
- metadata +137 -140
- data/History.txt +0 -128
- data/lib/vraptor-scaffold/generators/app_generator/app_generator.rb +0 -102
- data/lib/vraptor-scaffold/generators/app_generator/dependency_manager.rb +0 -37
- data/lib/vraptor-scaffold/generators/app_generator/templates/ivysettings.xml +0 -9
- data/lib/vraptor-scaffold/generators/app_generator/templates/resources/META-INF/persistence.xml +0 -20
- data/lib/vraptor-scaffold/generators/app_generator/templates/resources/log4j.properties +0 -4
- data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/vraptor-scaffold.erb +0 -2
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/application.js +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/jquery.min.js +0 -16
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +0 -22
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/index.erb +0 -36
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/show.erb +0 -14
- data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator.rb +0 -22
- data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/templates/show.erb +0 -14
- data/lib/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator.rb +0 -11
- data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator.rb +0 -12
- data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +0 -16
- data/spec/vraptor-scaffold/generators/scaffold_generator/base_scaffold_spec.rb +0 -41
- data/spec/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +0 -36
- data/spec/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +0 -34
- data/spec/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator_spec.rb +0 -25
- data/spec/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +0 -31
@@ -0,0 +1,27 @@
|
|
1
|
+
class RepositoryGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.join File.dirname(__FILE__), "templates"
|
5
|
+
end
|
6
|
+
|
7
|
+
def build
|
8
|
+
template("repository.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_interface_name}.java"))
|
9
|
+
template("repository_impl.erb", Configuration.main_class_path(Configuration.repositories_package, "#{repository_impl_name}.java"))
|
10
|
+
template("repository_test.erb", Configuration.test_class_path(Configuration.repositories_package, "#{repository_test_class_name}.java"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def orm_import
|
14
|
+
return "org.hibernate.Session" if Configuration.hibernate?
|
15
|
+
"javax.persistence.EntityManager"
|
16
|
+
end
|
17
|
+
|
18
|
+
def orm_parameter_name
|
19
|
+
return "session" if Configuration.hibernate?
|
20
|
+
"entityManager"
|
21
|
+
end
|
22
|
+
|
23
|
+
def orm_class
|
24
|
+
orm_parameter_name.camelize
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package <%= Configuration.package
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
|
2
2
|
|
3
3
|
import java.util.List;
|
4
4
|
|
5
|
-
import <%= Configuration.
|
5
|
+
import <%= Configuration.full_models_package %>.<%= class_name %>;
|
6
6
|
|
7
7
|
public interface <%= repository_interface_name %> {
|
8
8
|
/*
|
@@ -11,7 +11,7 @@ public interface <%= repository_interface_name %> {
|
|
11
11
|
|
12
12
|
void create(<%= class_name %> entity);
|
13
13
|
|
14
|
-
|
14
|
+
<%= class_name %> update(<%= class_name %> entity);
|
15
15
|
|
16
16
|
void destroy(<%= class_name %> entity);
|
17
17
|
|
data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
package <%= Configuration.package %>.<%= Configuration.repositories_package %>;
|
2
|
+
|
3
|
+
import <%= orm_import %>;
|
4
|
+
|
5
|
+
import br.com.caelum.vraptor.ioc.Component;
|
6
|
+
import <%= Configuration.full_models_package %>.<%= class_name %>;
|
7
|
+
|
8
|
+
@Component
|
9
|
+
public class <%= repository_impl_name %>
|
10
|
+
extends Repository<<%= class_name %>, Long>
|
11
|
+
implements <%= repository_interface_name %> {
|
12
|
+
|
13
|
+
<%= repository_impl_name %>(<%= orm_class %> <%= orm_parameter_name %>) {
|
14
|
+
super(<%= orm_parameter_name %>);
|
15
|
+
}
|
16
|
+
}
|
File without changes
|
File without changes
|
@@ -6,15 +6,15 @@
|
|
6
6
|
|
7
7
|
<form action="<%= path %>" method="post">
|
8
8
|
|
9
|
-
<#if <%= "#{
|
10
|
-
<input type="hidden" name="<%= "#{
|
9
|
+
<#if <%= "#{model_parameter_name}.id" %>??>
|
10
|
+
<input type="hidden" name="<%= "#{model_parameter_name}.id" %>" value="<%= "${#{model_parameter_name}.id}" %>"/>
|
11
11
|
<input type="hidden" name="_method" value="put"/>
|
12
12
|
</#if>
|
13
13
|
|
14
14
|
<% @attributes.each do |att| -%>
|
15
15
|
<div class="field">
|
16
|
-
<%= att.name.
|
17
|
-
<%= "<@html.#{att.html_input} \"#{
|
16
|
+
<%= att.name.camelize %>:<br />
|
17
|
+
<%= "<@html.#{att.html_input} \"#{model_parameter_name}.#{att.name}\" #{model_parameter_name}.#{att.name}/>" %>
|
18
18
|
</div>
|
19
19
|
<% end -%>
|
20
20
|
<div class="actions">
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<body>
|
2
|
+
<h1>Listing <%= class_name.pluralize %></h1>
|
3
|
+
|
4
|
+
<table>
|
5
|
+
<tr>
|
6
|
+
<% @attributes.each do |att| -%>
|
7
|
+
<th><%= att.name.camelize %></th>
|
8
|
+
<% end -%>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<#list <%= "#{model_parameter_name}List as #{model_parameter_name}" %>>
|
15
|
+
<tr>
|
16
|
+
<% @attributes.each do |att| -%>
|
17
|
+
<td>
|
18
|
+
<%= "${#{model_parameter_name}.#{att.name}!\"\"}" unless att.boolean? %>
|
19
|
+
<%= "${#{model_parameter_name}.#{att.name}?string}" if att.boolean? %>
|
20
|
+
</td>
|
21
|
+
<% end -%>
|
22
|
+
<td><a href="<%= "#{path}/${#{model_parameter_name}.id}" %>">show</a></td>
|
23
|
+
<td><a href="<%= "#{path}/${#{model_parameter_name}.id}/edit" %>">edit</a></td>
|
24
|
+
<td>
|
25
|
+
<form action="<%= "#{path}/${#{model_parameter_name}.id}" %>" method="post">
|
26
|
+
<input type="hidden" name="_method" value="delete"/>
|
27
|
+
<button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
|
28
|
+
</form>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
</#list>
|
32
|
+
</table>
|
33
|
+
|
34
|
+
<br />
|
35
|
+
<a href="<%= path %>/new">New <%= class_name %></a>
|
36
|
+
</body>
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<body>
|
2
|
+
|
3
|
+
<% @attributes.each do |att| -%>
|
4
|
+
<p>
|
5
|
+
<b><%= att.name.camelize %>:</b>
|
6
|
+
<%= "${#{model_parameter_name}.#{att.name}!\"\"}" unless att.boolean? %>
|
7
|
+
<%= "${#{model_parameter_name}.#{att.name}?string}" if att.boolean? %>
|
8
|
+
</p>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<a href="<%= "#{path}/${#{model_parameter_name}.id}/edit" %>">Edit</a>
|
12
|
+
<a href="<%= path %>">Back</a>
|
13
|
+
|
14
|
+
</body>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class JspGenerator < TemplateEngineGenerator
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.dirname(__FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def view_folder
|
8
|
+
"jsp"
|
9
|
+
end
|
10
|
+
|
11
|
+
def extension
|
12
|
+
"jsp"
|
13
|
+
end
|
14
|
+
|
15
|
+
def path url=""
|
16
|
+
%Q{${pageContext.request.contextPath}/#{base_path}#{url}}
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -6,15 +6,15 @@
|
|
6
6
|
|
7
7
|
<form action="<%= path %>" method="post">
|
8
8
|
|
9
|
-
<c:if test="${not empty <%=
|
10
|
-
<input type="hidden" name="<%=
|
9
|
+
<c:if test="${not empty <%= model_parameter_name %>.id}">
|
10
|
+
<input type="hidden" name="<%= model_parameter_name %>.id" value="${<%= model_parameter_name%>.id}"/>
|
11
11
|
<input type="hidden" name="_method" value="put"/>
|
12
12
|
</c:if>
|
13
13
|
|
14
14
|
<% @attributes.each do |att| -%>
|
15
15
|
<div class="field">
|
16
|
-
<%= att.name.
|
17
|
-
<input type="text" name="<%=
|
16
|
+
<%= att.name.camelize %>:<br />
|
17
|
+
<input type="text" name="<%= model_parameter_name %>.<%=att.name%>" value="${<%=model_parameter_name%>.<%=att.name%>}"/>
|
18
18
|
</div>
|
19
19
|
<% end -%>
|
20
20
|
|
@@ -7,22 +7,22 @@
|
|
7
7
|
<table>
|
8
8
|
<tr>
|
9
9
|
<%- @attributes.each do |att| -%>
|
10
|
-
<th><%= att.name %></th>
|
10
|
+
<th><%= att.name.camelize %></th>
|
11
11
|
<%- end -%>
|
12
12
|
<th></th>
|
13
13
|
<th></th>
|
14
14
|
<th></th>
|
15
15
|
</tr>
|
16
16
|
|
17
|
-
<c:forEach items="${
|
17
|
+
<c:forEach items="${<%=model_parameter_name%>List}" var="<%=model_parameter_name%>">
|
18
18
|
<tr>
|
19
19
|
<%- @attributes.each do |att| -%>
|
20
|
-
<td><%= "${#{
|
20
|
+
<td><%= "${#{model_parameter_name}.#{att.name}}" %></td>
|
21
21
|
<%- end -%>
|
22
|
-
<td><a href="<%= path "/${#{
|
23
|
-
<td><a href="<%= path "/${#{
|
22
|
+
<td><a href="<%= path "/${#{model_parameter_name}.id}" %>">show</a></td>
|
23
|
+
<td><a href="<%= path "/${#{model_parameter_name}.id}/edit" %>">edit</a></td>
|
24
24
|
<td>
|
25
|
-
<form action="<%= path "/${#{
|
25
|
+
<form action="<%= path "/${#{model_parameter_name}.id}" %>" method="post">
|
26
26
|
<input type="hidden" name="_method" value="delete"/>
|
27
27
|
<button type="submit" onclick="return confirm('Are you sure?')">destroy</button>
|
28
28
|
</form>
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<head>
|
2
|
+
<title><%= class_name %> [show]</title>
|
3
|
+
</head>
|
4
|
+
<body>
|
5
|
+
<%- @attributes.each do |att| -%>
|
6
|
+
<p>
|
7
|
+
<b><%= att.name.camelize %>:</b>
|
8
|
+
<%= "${#{model_parameter_name}.#{att.name}}" %>
|
9
|
+
</p>
|
10
|
+
<% end -%>
|
11
|
+
|
12
|
+
<a href="<%= path "/${#{model_parameter_name}.id}/edit" %>">Edit</a>
|
13
|
+
<a href="<%= path %>">Back</a>
|
14
|
+
</body>
|
data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class TemplateEngineGenerator < BaseScaffold
|
2
|
+
|
3
|
+
def build
|
4
|
+
create_view("index")
|
5
|
+
create_view("show")
|
6
|
+
create_view("form")
|
7
|
+
create_view("edit")
|
8
|
+
create_view("new", "new#{class_name}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_view(template_name, file_name=template_name)
|
12
|
+
template("templates/#{template_name}.erb", "#{views_path}/#{file_name}.#{extension}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def views_path
|
16
|
+
File.join Configuration::WEB_INF, view_folder, model_parameter_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require File.dirname(__FILE__) + "/jsp_generator/jsp_generator"
|
21
|
+
require File.dirname(__FILE__) + "/freemarker_generator/freemarker_generator"
|
@@ -1,22 +1,14 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
require 'thor/actions'
|
4
|
-
require 'thor/group'
|
5
|
-
require 'active_support/inflector'
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
require File.dirname(__FILE__) + '/configuration'
|
9
1
|
require File.dirname(__FILE__) + '/generators/base'
|
10
|
-
require File.dirname(__FILE__) + '/generators/
|
11
|
-
require File.dirname(__FILE__) + '/generators/app_generator
|
12
|
-
require File.dirname(__FILE__) + '/generators/
|
13
|
-
require File.dirname(__FILE__) + '/generators/
|
14
|
-
require File.dirname(__FILE__) + '/generators/
|
15
|
-
require File.dirname(__FILE__) + '/generators/
|
16
|
-
require File.dirname(__FILE__) + '/generators/
|
17
|
-
require File.dirname(__FILE__) + '/generators/scaffold_generator
|
18
|
-
require File.dirname(__FILE__) + '/generators/
|
19
|
-
require File.dirname(__FILE__) + '/generators/
|
20
|
-
require File.dirname(__FILE__) + '/generators/
|
21
|
-
require File.dirname(__FILE__) + '/generators/
|
22
|
-
require File.dirname(__FILE__) + '/generators/
|
2
|
+
require File.dirname(__FILE__) + '/generators/plugin/plugin_generator'
|
3
|
+
require File.dirname(__FILE__) + '/generators/app/app_generator'
|
4
|
+
require File.dirname(__FILE__) + '/generators/app/dependency'
|
5
|
+
require File.dirname(__FILE__) + '/generators/app/dependency_manager'
|
6
|
+
require File.dirname(__FILE__) + '/generators/app/freemarker_template_engine'
|
7
|
+
require File.dirname(__FILE__) + '/generators/app/jsp_template_engine'
|
8
|
+
require File.dirname(__FILE__) + '/generators/scaffold/attribute'
|
9
|
+
require File.dirname(__FILE__) + '/generators/scaffold/scaffold_generator'
|
10
|
+
require File.dirname(__FILE__) + '/generators/scaffold/base_scaffold'
|
11
|
+
require File.dirname(__FILE__) + '/generators/scaffold/model_generator/model_generator'
|
12
|
+
require File.dirname(__FILE__) + '/generators/scaffold/repository_generator/repository_generator'
|
13
|
+
require File.dirname(__FILE__) + '/generators/scaffold/controller_generator/controller_generator'
|
14
|
+
require File.dirname(__FILE__) + '/generators/scaffold/template_engine_generator/template_engine_generator'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'vraptor-scaffold/runner/help'
|
7
|
+
require 'vraptor-scaffold/runner/scaffold'
|
8
|
+
require 'vraptor-scaffold/runner/generator'
|
9
|
+
require 'vraptor-scaffold/runner/commands_help'
|
10
|
+
require 'vraptor-scaffold/runner/plugin'
|
11
|
+
require 'vraptor-scaffold/runner/configure'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
class CommandsHelp
|
5
|
+
def run(args)
|
6
|
+
Kernel.puts "Available runners for vraptor are: #{VraptorScaffold::COMMANDS.keys.join(', ')}"
|
7
|
+
Kernel.puts "Usage:"
|
8
|
+
Kernel.puts " vraptor runner"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
class Configure
|
5
|
+
|
6
|
+
#def run(args)
|
7
|
+
# if VraptorScaffold::Runner::Help.help?(args.first) || args.size < 2
|
8
|
+
# Kernel.puts "vraptor configure usage:"
|
9
|
+
# Kernel.puts "\tvraptor configure PLUGIN_NAME"
|
10
|
+
# else
|
11
|
+
# plugin_name = args.first
|
12
|
+
# require plugin_name
|
13
|
+
# puts "Configuring plugin '#{plugin_name}'"
|
14
|
+
# plugin = plugin_name.gsub('-','_').camelize.constantize.new(args)
|
15
|
+
# plugin.invoke_all
|
16
|
+
# plugin
|
17
|
+
# end
|
18
|
+
#end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
class Generator
|
5
|
+
def run(args)
|
6
|
+
project_path = args.shift
|
7
|
+
if VraptorScaffold::Runner::Help.help? project_path
|
8
|
+
AppGenerator.start(["-h"])
|
9
|
+
else
|
10
|
+
AppGenerator.new(project_path, args).invoke_all
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
class Plugin
|
5
|
+
|
6
|
+
def run(args)
|
7
|
+
if VraptorScaffold::Runner::Help.help?(args.first) || args.size < 2
|
8
|
+
PluginGenerator.start(["-h"])
|
9
|
+
elsif File.exist?("src")
|
10
|
+
PluginGenerator.new(args.shift, args).invoke_all
|
11
|
+
else
|
12
|
+
puts "To run vraptor plugin please go to the project root folder."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VraptorScaffold
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
class Scaffold
|
5
|
+
def run(args)
|
6
|
+
if VraptorScaffold::Runner::Help.help? args.first
|
7
|
+
ScaffoldGenerator.start(["-h"])
|
8
|
+
elsif File.exist?("src")
|
9
|
+
ScaffoldGenerator.new(args).invoke_all
|
10
|
+
else
|
11
|
+
puts "To run vraptor scaffold please go to the project root folder."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|