katapult 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +9 -0
- data/README.md +122 -94
- data/Rakefile +13 -0
- data/bin/katapult +59 -25
- data/features/application_model.feature +55 -0
- data/features/authenticate.feature +88 -62
- data/features/basics.feature +64 -402
- data/features/binary.feature +56 -42
- data/features/configuration.feature +4 -4
- data/features/model.feature +21 -30
- data/features/navigation.feature +35 -48
- data/features/step_definitions/aruba_steps.rb +3 -0
- data/features/step_definitions/katapult_steps.rb +307 -8
- data/features/step_definitions/rails_steps.rb +74 -14
- data/features/step_definitions/test_steps.rb +5 -5
- data/features/step_definitions/version_steps.rb +22 -0
- data/features/support/env.rb +11 -3
- data/features/{wui.feature → web_ui.feature} +175 -148
- data/katapult.gemspec +8 -13
- data/lib/generators/katapult/app_model/app_model_generator.rb +12 -0
- data/lib/generators/katapult/app_model/templates/lib/katapult/application_model.rb +40 -0
- data/lib/generators/katapult/basics/basics_generator.rb +186 -51
- data/lib/generators/katapult/basics/templates/.browserslistrc +1 -0
- data/lib/generators/katapult/basics/templates/.gitignore +20 -21
- data/lib/generators/katapult/basics/templates/.rspec_parallel +3 -0
- data/lib/generators/katapult/basics/templates/Capfile +5 -1
- data/lib/generators/katapult/basics/templates/Gemfile +23 -34
- data/lib/generators/katapult/basics/templates/Guardfile +0 -12
- data/lib/generators/katapult/basics/templates/app/controllers/errors_controller.rb +9 -0
- data/lib/generators/katapult/basics/templates/app/helpers/unpoly_helper.rb +13 -0
- data/lib/generators/katapult/{haml → basics}/templates/app/views/layouts/_flashes.html.haml +1 -1
- data/lib/generators/katapult/basics/templates/app/views/layouts/_menu_bar.html.haml.tt +12 -0
- data/lib/generators/katapult/basics/templates/app/views/layouts/application.html.haml.tt +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/images/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/index.js +16 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/application.js +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/bootstrap.js +12 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/compilers/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/content_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/modal_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/unpoly.js +9 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_definitions.sass +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_environment.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_mixins.sass +3 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/blocks/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/custom_bootstrap.sass +50 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/bootstrap/navbar.sass +83 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/theme.sass +11 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/unpoly.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/packs/application.js +13 -0
- data/lib/generators/katapult/basics/templates/config/database.sample.yml +1 -1
- data/lib/generators/katapult/basics/templates/config/deploy.rb +3 -4
- data/lib/generators/katapult/basics/templates/config/environments/staging.rb +5 -0
- data/lib/generators/katapult/basics/templates/config/initializers/better_errors.rb +23 -0
- data/lib/generators/katapult/basics/templates/config/initializers/exception_notification.rb.tt +1 -1
- data/lib/generators/katapult/basics/templates/config/initializers/ext.rb +1 -1
- data/lib/generators/katapult/basics/templates/config/webpack/loaders/unpoly.js +4 -0
- data/lib/generators/katapult/basics/templates/features/support/capybara_screenshot.rb +7 -0
- data/lib/generators/katapult/basics/templates/features/support/factory_bot.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/paths.rb +7 -2
- data/lib/generators/katapult/basics/templates/features/support/rspec_doubles.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/selectors.rb +3 -3
- data/lib/generators/katapult/basics/templates/features/support/selenium.rb +13 -0
- data/lib/generators/katapult/basics/templates/features/support/{env-custom.rb → spreewald.rb} +0 -0
- data/lib/generators/katapult/basics/templates/features/support/webpacker.rb +35 -0
- data/lib/generators/katapult/basics/templates/lib/ext/action_view/form_for_with_development_errors.rb +31 -31
- data/lib/generators/katapult/basics/templates/lib/ext/active_record/find_by_anything.rb +4 -3
- data/lib/generators/katapult/basics/templates/public/robots.txt +5 -0
- data/lib/generators/katapult/basics/templates/spec/assets/sample.pdf +0 -0
- data/lib/generators/katapult/basics/templates/spec/factories/factories.rb +1 -1
- data/lib/generators/katapult/basics/templates/spec/support/database_cleaner.rb +20 -0
- data/lib/generators/katapult/basics/templates/spec/support/factory_bot.rb +3 -0
- data/lib/generators/katapult/basics/templates/spec/support/fixture_file.rb +6 -0
- data/lib/generators/katapult/basics/templates/spec/support/postgresql_sequences.rb +15 -0
- data/lib/generators/katapult/basics/templates/spec/support/timecop.rb +3 -0
- data/lib/generators/katapult/clearance/clearance_generator.rb +14 -2
- data/lib/generators/katapult/clearance/templates/app/views/layouts/_current_user.html.haml +11 -0
- data/lib/generators/katapult/clearance/templates/app/views/passwords/create.html.haml +10 -4
- data/lib/generators/katapult/clearance/templates/app/views/passwords/edit.html.haml +12 -12
- data/lib/generators/katapult/clearance/templates/app/views/passwords/new.html.haml +14 -11
- data/lib/generators/katapult/clearance/templates/app/views/sessions/new.html.haml +16 -15
- data/lib/generators/katapult/clearance/templates/features/authentication.feature +3 -3
- data/lib/generators/katapult/cucumber_features/templates/feature.feature +1 -1
- data/lib/generators/katapult/model_specs/templates/model_spec.rb +3 -5
- data/lib/generators/katapult/navigation/navigation_generator.rb +7 -1
- data/lib/generators/katapult/navigation/templates/app/views/layouts/_navigation.html.haml +15 -0
- data/lib/generators/katapult/transform/transform_generator.rb +12 -17
- data/lib/generators/katapult/views/templates/_form.html.haml +48 -0
- data/lib/generators/katapult/views/templates/app/helpers/table_helper.rb +14 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/action_bar.sass +22 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/title.sass +11 -0
- data/lib/generators/katapult/views/templates/custom_action.html.haml +5 -0
- data/lib/generators/katapult/views/templates/edit.html.haml +4 -0
- data/lib/generators/katapult/views/templates/index.html.haml +26 -0
- data/lib/generators/katapult/{haml → views}/templates/new.html.haml +1 -1
- data/lib/generators/katapult/views/templates/show.html.haml +39 -0
- data/lib/generators/katapult/{haml/haml_generator.rb → views/views_generator.rb} +19 -25
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/_route.rb +3 -3
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/controller.rb +21 -23
- data/lib/generators/katapult/{w_u_i/w_u_i_generator.rb → web_ui/web_ui_generator.rb} +7 -12
- data/lib/katapult/action.rb +1 -1
- data/lib/katapult/application_model.rb +8 -8
- data/lib/katapult/binary_util.rb +48 -10
- data/lib/katapult/generator.rb +2 -10
- data/lib/katapult/generator_goodies.rb +23 -0
- data/lib/katapult/navigation.rb +10 -5
- data/lib/katapult/parser.rb +15 -8
- data/lib/katapult/version.rb +5 -1
- data/lib/katapult/{wui.rb → web_ui.rb} +19 -4
- data/lib/katapult.rb +0 -5
- data/script/console +5 -2
- data/script/kta +8 -0
- data/script/update +80 -0
- data/spec/action_spec.rb +0 -1
- data/spec/attribute_spec.rb +0 -1
- data/spec/element_spec.rb +0 -1
- data/spec/model_spec.rb +0 -1
- data/spec/parser_spec.rb +26 -0
- data/spec/util_spec.rb +0 -1
- data/spec/{wui_spec.rb → web_ui_spec.rb} +24 -12
- metadata +86 -124
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_all.sass +0 -4
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_items.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_layout.sass +0 -26
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_navigation.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_tools.sass +0 -12
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application.sass +0 -6
- data/lib/generators/katapult/basics/templates/config/spring.rb +0 -3
- data/lib/generators/katapult/basics/templates/features/support/factory_girl.rb +0 -1
- data/lib/generators/katapult/basics/templates/spec/support/factory_girl.rb +0 -3
- data/lib/generators/katapult/haml/templates/_form.html.haml +0 -38
- data/lib/generators/katapult/haml/templates/app/views/layouts/application.html.haml +0 -33
- data/lib/generators/katapult/haml/templates/custom_action.html.haml +0 -5
- data/lib/generators/katapult/haml/templates/edit.html.haml +0 -4
- data/lib/generators/katapult/haml/templates/index.html.haml +0 -29
- data/lib/generators/katapult/haml/templates/show.html.haml +0 -39
- data/lib/generators/katapult/install/install_generator.rb +0 -14
- data/lib/generators/katapult/install/templates/lib/katapult/application_model.rb +0 -20
- data/lib/generators/katapult/navigation/templates/app/models/navigation.rb +0 -12
@@ -6,8 +6,9 @@ module Katapult
|
|
6
6
|
module Generators
|
7
7
|
class ClearanceGenerator < Katapult::Generator
|
8
8
|
|
9
|
-
|
9
|
+
MENU_BAR = 'app/views/layouts/_menu_bar.html.haml'
|
10
10
|
|
11
|
+
desc 'Generate authentication with Clearance'
|
11
12
|
check_class_collision
|
12
13
|
source_root File.expand_path('../templates', __FILE__)
|
13
14
|
|
@@ -74,6 +75,17 @@ resources :users do
|
|
74
75
|
ROUTES
|
75
76
|
end
|
76
77
|
|
78
|
+
def add_current_user_to_layout
|
79
|
+
template 'app/views/layouts/_current_user.html.haml'
|
80
|
+
inject_into_file MENU_BAR, <<-CONTENT, after: /^\s+#navbar.*\n/
|
81
|
+
= render 'layouts/current_user' if signed_in?
|
82
|
+
CONTENT
|
83
|
+
end
|
84
|
+
|
85
|
+
def hide_navigation_unless_signed_in
|
86
|
+
gsub_file MENU_BAR, /(render.*navigation')/, '\1 if signed_in?'
|
87
|
+
end
|
88
|
+
|
77
89
|
def add_sign_in_background_to_all_features
|
78
90
|
Dir['features/*.feature'].each do |file|
|
79
91
|
inject_into_file file, <<-CONTENT, after: /^Feature: .*$/
|
@@ -110,7 +122,7 @@ resources :users do
|
|
110
122
|
end
|
111
123
|
|
112
124
|
def add_user_factory
|
113
|
-
inject_into_file 'spec/factories/factories.rb', <<-'CONTENT', after: '
|
125
|
+
inject_into_file 'spec/factories/factories.rb', <<-'CONTENT', after: 'FactoryBot.define do'
|
114
126
|
|
115
127
|
factory :user do
|
116
128
|
sequence(:email) { |i| "user-#{ i }@example.com" }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%ul.nav.navbar-nav.navbar-right
|
2
|
+
%li.dropdown
|
3
|
+
= link_to edit_user_path(current_user), data: { toggle: 'dropdown' } do
|
4
|
+
Hello,
|
5
|
+
= current_user
|
6
|
+
%span.caret
|
7
|
+
|
8
|
+
%ul.dropdown-menu
|
9
|
+
%li= link_to 'Edit profile', edit_user_path(current_user)
|
10
|
+
%li.divider
|
11
|
+
%li= link_to 'Sign out', sign_out_path, method: :delete, class: 'navbar-logout'
|
@@ -1,5 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.row
|
2
|
+
.col-md-4.col-md-offset-4
|
3
3
|
|
4
|
-
%
|
5
|
-
|
4
|
+
%h1
|
5
|
+
Password Reset Instructions Sent
|
6
|
+
|
7
|
+
%p
|
8
|
+
We've sent you an email with instructions on how to reset your password.
|
9
|
+
|
10
|
+
%p
|
11
|
+
= link_to 'Back to sign-in form', sign_in_path, class: 'btn btn-primary'
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.row
|
2
|
+
.col-md-4.col-md-offset-4
|
3
3
|
|
4
|
-
%
|
5
|
-
|
4
|
+
%h1
|
5
|
+
Reset Password
|
6
6
|
|
7
|
-
= form_for :password_reset,
|
8
|
-
|
9
|
-
|
7
|
+
= form_for :password_reset,
|
8
|
+
url: user_password_path(@user, token: @user.confirmation_token),
|
9
|
+
html: { method: :put } do |form|
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
.form-group
|
12
|
+
= form.label :password
|
13
|
+
= form.password_field :password, class: 'form-control',
|
14
|
+
placeholder: 'New password'
|
15
15
|
|
16
|
-
|
16
|
+
= form.submit 'Update password', class: 'btn btn-primary'
|
@@ -1,14 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.row
|
2
|
+
.col-md-4.col-md-offset-4
|
3
3
|
|
4
|
-
%
|
5
|
-
|
6
|
-
to reset your password.
|
4
|
+
%h1
|
5
|
+
Password Reset
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
= form.email_field :email, class: 'form-control',
|
12
|
-
placeholder: 'Email Address'
|
7
|
+
%p
|
8
|
+
Please enter your email address. We will send you instructions on how
|
9
|
+
to reset your password.
|
13
10
|
|
14
|
-
|
11
|
+
= form_for :password, url: passwords_path do |form|
|
12
|
+
.form-group
|
13
|
+
= form.label :email
|
14
|
+
= form.email_field :email, class: 'form-control',
|
15
|
+
placeholder: 'Email address'
|
16
|
+
|
17
|
+
= form.submit 'Request instructions', class: 'btn btn-primary'
|
@@ -1,19 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.row
|
2
|
+
.col-md-4.col-md-offset-4
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
= form.label :email
|
7
|
-
= form.email_field :email, class: 'form-control',
|
8
|
-
placeholder: 'Email Address', required: true, autofocus: true
|
4
|
+
%h1
|
5
|
+
Please sign in
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
= form_for :session, url: session_path do |form|
|
8
|
+
.form-group
|
9
|
+
= form.label :email
|
10
|
+
= form.email_field :email, class: 'form-control',
|
11
|
+
placeholder: 'Email Address', required: true, autofocus: true
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
.form-group
|
14
|
+
= form.label :password
|
15
|
+
= form.password_field :password, class: 'form-control', required: true,
|
16
|
+
placeholder: 'Password'
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
%p
|
19
|
+
= form.submit 'Sign in', class: 'btn btn-primary'
|
20
|
+
= link_to 'Forgot password', new_password_path, class: 'btn btn-link'
|
@@ -51,7 +51,7 @@ Feature: Everything about user authentication
|
|
51
51
|
And I sign in as the user above
|
52
52
|
|
53
53
|
When I go to the homepage
|
54
|
-
And I follow "henry@example.com" within the
|
54
|
+
And I follow "henry@example.com" within the navbar
|
55
55
|
Then I should be on the form for the user above
|
56
56
|
|
57
57
|
When I fill in "Password" with "new-password"
|
@@ -74,7 +74,7 @@ Feature: Everything about user authentication
|
|
74
74
|
And I should see "Password Reset"
|
75
75
|
|
76
76
|
When I fill in "Email" with "henry@example.com"
|
77
|
-
And I press "Request
|
77
|
+
And I press "Request instructions"
|
78
78
|
Then an email should have been sent with:
|
79
79
|
"""
|
80
80
|
From: system@example.com
|
@@ -89,6 +89,6 @@ Feature: Everything about user authentication
|
|
89
89
|
And I should see "Reset Password"
|
90
90
|
|
91
91
|
When I fill in "Choose password" with "new-password"
|
92
|
-
And I press "Update
|
92
|
+
And I press "Update password"
|
93
93
|
Then I should see "Password successfully changed" within the flash
|
94
94
|
And I should be on the homepage
|
@@ -59,5 +59,5 @@ Feature: <%= model.name(:humans).titleize %>
|
|
59
59
|
|
60
60
|
When I follow "Destroy <%= model.label_attr.test_value %>"
|
61
61
|
Then I should be on the list of <%= model.name(:variables) %>
|
62
|
-
|
62
|
+
But I should not see "<%= model.label_attr.test_value %>"
|
63
63
|
<% end -%>
|
@@ -1,17 +1,15 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
1
|
describe <%= model.name :class %> do
|
4
2
|
|
5
3
|
describe '#to_s' do
|
6
4
|
<%- if model.label_attr -%>
|
7
5
|
it 'returns the #<%= model.label_attr.name %> attribute' do
|
8
6
|
subject.<%= model.label_attr.name %> = <%= model.label_attr.test_value.inspect %>
|
9
|
-
expect(subject.to_s).to
|
7
|
+
expect(subject.to_s).to eq(<%= model.label_attr.test_value.to_s.inspect %>)
|
10
8
|
end
|
11
9
|
<%- else -%>
|
12
10
|
it 'returns its class name with its id' do
|
13
11
|
subject.id = 17
|
14
|
-
expect(subject.to_s).to
|
12
|
+
expect(subject.to_s).to eq("<%= model.name %>#17")
|
15
13
|
end
|
16
14
|
<%- end -%>
|
17
15
|
end
|
@@ -25,7 +23,7 @@ describe <%= model.name :class %> do
|
|
25
23
|
<%- unless attr.default.nil? -%>
|
26
24
|
|
27
25
|
it 'has a default' do
|
28
|
-
expect(
|
26
|
+
expect(subject.<%= attr.name %>).to eq(<%= attr.default.inspect %>)
|
29
27
|
end
|
30
28
|
<%- end -%>
|
31
29
|
end
|
@@ -6,12 +6,18 @@ module Katapult
|
|
6
6
|
module Generators
|
7
7
|
class NavigationGenerator < Katapult::Generator
|
8
8
|
|
9
|
+
MENU_BAR = 'app/views/layouts/_menu_bar.html.haml'
|
10
|
+
|
9
11
|
desc 'Generate the navigation'
|
10
12
|
source_root File.expand_path('../templates', __FILE__)
|
11
13
|
|
12
14
|
|
13
15
|
def create_navigation
|
14
|
-
template 'app/
|
16
|
+
template 'app/views/layouts/_navigation.html.haml'
|
17
|
+
|
18
|
+
inject_into_file MENU_BAR, <<-CONTENT, after: /^\s+#navbar.*\n/
|
19
|
+
= render 'layouts/navigation'
|
20
|
+
CONTENT
|
15
21
|
end
|
16
22
|
|
17
23
|
private
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%ul.nav.navbar-nav
|
2
|
+
<% navigation.links.each do |label, path| -%>
|
3
|
+
%li(up-expand)
|
4
|
+
= content_link_to <%= label.titleize.inspect %>, <%= path %>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
%li.dropdown
|
8
|
+
= link_to '#', data: { toggle: 'dropdown' } do
|
9
|
+
Dropdown example
|
10
|
+
%span.caret
|
11
|
+
|
12
|
+
%ul.dropdown-menu
|
13
|
+
%li= link_to 'One', '#'
|
14
|
+
%li.divider
|
15
|
+
%li= link_to 'Two', '#'
|
@@ -6,9 +6,12 @@
|
|
6
6
|
# 2) render the parsed model into code
|
7
7
|
|
8
8
|
require 'katapult/parser'
|
9
|
+
require 'katapult/generator_goodies'
|
9
10
|
|
10
11
|
module Katapult
|
11
12
|
class TransformGenerator < Rails::Generators::Base
|
13
|
+
include Katapult::GeneratorGoodies
|
14
|
+
|
12
15
|
desc 'Transform the katapult application model'
|
13
16
|
|
14
17
|
argument :path, required: true, type: :string,
|
@@ -16,34 +19,26 @@ module Katapult
|
|
16
19
|
|
17
20
|
def transform_application_model
|
18
21
|
say_status :parse, path
|
19
|
-
|
22
|
+
application_model = File.read(path)
|
23
|
+
@app_model = Katapult::Parser.new.parse(application_model, path)
|
20
24
|
|
21
|
-
say_status :render, "into #{
|
25
|
+
say_status :render, "into #{app_name}"
|
22
26
|
@app_model.render
|
23
27
|
end
|
24
28
|
|
25
29
|
def write_root_route
|
26
30
|
unless File.read('config/routes.rb').include? ' root'
|
27
|
-
|
28
|
-
route "root '#{
|
31
|
+
root_web_ui = @app_model.web_uis.find { |w| w.find_action :index }
|
32
|
+
route "root '#{ root_web_ui.model_name(:variables) }#index'" if root_web_ui
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
def remigrate_all_databases
|
33
|
-
|
34
|
-
run 'rake db:drop:all db:create:all db:migrate parallel:create parallel:prepare'
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
37
|
+
return if ENV['SKIP_MIGRATIONS'] # Used to speed up tests
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def run(*)
|
44
|
-
Bundler.with_clean_env do
|
45
|
-
super
|
46
|
-
end
|
39
|
+
run 'rake db:drop db:create db:migrate'
|
40
|
+
# See comment to Katapult::BasicsGenerator#create_databases
|
41
|
+
run 'unset RAILS_ENV; rake parallel:drop parallel:create parallel:prepare'
|
47
42
|
end
|
48
43
|
|
49
44
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%- object = model_name(:ivar) -%>
|
2
|
+
= form_for <%= object %> do |form|
|
3
|
+
|
4
|
+
<% web_ui.model.editable_attrs.each do |attribute| -%>
|
5
|
+
.form-group
|
6
|
+
= form.label <%= attribute.name(:symbol) %>
|
7
|
+
<%- if attribute.assignable_values -%>
|
8
|
+
= form.select <%= attribute.name(:symbol) %>, form.object.assignable_<%= attribute.name(:variables) %>
|
9
|
+
<%- else -%>
|
10
|
+
<%- case attribute.type -%>
|
11
|
+
<%- when :string -%>
|
12
|
+
= form.text_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
13
|
+
<%- when :email -%>
|
14
|
+
= form.email_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
15
|
+
<%- when :password -%>
|
16
|
+
= form.password_field <%= attribute.name(:symbol) %>, class: 'form-control',
|
17
|
+
autocomplete: 'new-password'
|
18
|
+
<%- when :url -%>
|
19
|
+
= form.url_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
20
|
+
<%- when :integer -%>
|
21
|
+
= form.number_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
22
|
+
<%- when :money -%>
|
23
|
+
.input-group
|
24
|
+
= form.number_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
25
|
+
.input-group-addon
|
26
|
+
€
|
27
|
+
<%- when :text -%>
|
28
|
+
= form.text_area <%= attribute.name(:symbol) %>, rows: 5, class: 'form-control'
|
29
|
+
<%- when :flag -%>
|
30
|
+
.checkbox
|
31
|
+
= form.label <%= attribute.name(:symbol) %> do
|
32
|
+
= form.check_box <%= attribute.name(:symbol) %>
|
33
|
+
<%- when :datetime -%>
|
34
|
+
= form.date_field <%= attribute.name(:symbol) %>, class: 'form-control'
|
35
|
+
<%- end -%>
|
36
|
+
<%- end -%>
|
37
|
+
<% end -%>
|
38
|
+
|
39
|
+
.action-bar
|
40
|
+
- cancel_path = <%= object %>.new_record? ? <%= web_ui.path(:index) %> : <%= web_ui.path(:show, object) %>
|
41
|
+
|
42
|
+
.pull-right
|
43
|
+
- if <%= object %>.persisted?
|
44
|
+
= link_to "Destroy <%= model_name(:human) %>", <%= web_ui.path(:destroy, object) %>, method: :delete,
|
45
|
+
class: 'btn btn-danger', data: { confirm: 'Really destroy?' }
|
46
|
+
|
47
|
+
= form.submit 'Save', class: 'btn btn-primary'
|
48
|
+
= link_to 'Cancel', cancel_path, class: 'btn btn-link'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module TableHelper
|
2
|
+
|
3
|
+
def table(*headers, &block)
|
4
|
+
thead = content_tag(:thead) do
|
5
|
+
content_tag(:tr) do
|
6
|
+
headers.map{ |h| content_tag :th, h }.xss_aware_join
|
7
|
+
end
|
8
|
+
end
|
9
|
+
rest = capture(&block)
|
10
|
+
|
11
|
+
content_tag :table, thead + rest, class: 'table table-hover'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/action_bar.sass
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
@import ../environment
|
2
|
+
|
3
|
+
.action-bar
|
4
|
+
margin-top: $space-md
|
5
|
+
border-top: 1px solid $panel-default-border
|
6
|
+
padding-top: $space-xs
|
7
|
+
|
8
|
+
&.-main
|
9
|
+
float: right
|
10
|
+
|
11
|
+
margin-top: 3px
|
12
|
+
border: none
|
13
|
+
padding: 0
|
14
|
+
|
15
|
+
+within-modal
|
16
|
+
margin: 30px -40px -30px
|
17
|
+
padding: 15px 40px
|
18
|
+
|
19
|
+
background: $panel-footer-bg
|
20
|
+
border-bottom-left-radius: $border-radius-base
|
21
|
+
border-bottom-right-radius: $border-radius-base
|
22
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.action-bar.-main.btn-group
|
2
|
+
= link_to 'Add <%= model_name(:human) %>', <%= web_ui.path(:new) %>, class: 'btn btn-default'
|
3
|
+
<% web_ui.custom_actions.select(&:collection?).each do |action| -%>
|
4
|
+
= link_to '<%= action.name.humanize.titleize %>', <%= web_ui.path(action) %>, class: 'btn btn-default'
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
%h1.title
|
8
|
+
<%= model_name(:humans).capitalize %>
|
9
|
+
|
10
|
+
- if <%= model_name(:ivars) %>.any?
|
11
|
+
<%- object = model_name(:variable) -%>
|
12
|
+
|
13
|
+
= table '<%= web_ui.model.label_attr.name(:human).titleize %>', 'Actions' do
|
14
|
+
- <%= model_name(:ivars) %>.each do |<%= object %>|
|
15
|
+
%tr(up-expand)
|
16
|
+
%td(width='40%')
|
17
|
+
= link_to <%= object %>, <%= object %>
|
18
|
+
%td
|
19
|
+
= link_to 'Edit', <%= web_ui.path(:edit, object) %>
|
20
|
+
= link_to 'Destroy', <%= web_ui.path(:destroy, object) %>, method: :delete,
|
21
|
+
class: 'text-danger',
|
22
|
+
data: { confirm: 'Really destroy?' }, title: "Destroy #{<%= object %>}"
|
23
|
+
|
24
|
+
- else
|
25
|
+
%p.help-block
|
26
|
+
No <%= model_name(:humans) %> found.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%- object = model_name(:ivar) -%>
|
2
|
+
.action-bar.-main.btn-group
|
3
|
+
= link_to 'All <%= model_name(:humans) %>', <%= web_ui.path(:index) %>, class: 'btn btn-default'
|
4
|
+
= link_to 'Edit', <%= web_ui.path(:edit, object) %>, class: 'btn btn-default'
|
5
|
+
<% web_ui.custom_actions.select(&:member?).each do |action| -%>
|
6
|
+
= link_to '<%= action.name(:human).titleize %>', <%= web_ui.path(action, object) %>, class: 'btn btn-default'<%=
|
7
|
+
", method: :#{action.method}" unless action.get?
|
8
|
+
%>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
%h1.title
|
12
|
+
= <%= model_name(:ivar) %>
|
13
|
+
|
14
|
+
%dl
|
15
|
+
<% web_ui.model.renderable_attrs.each do |attribute| -%>
|
16
|
+
<%- model_attribute = "#{object}.#{attribute.name}" -%>
|
17
|
+
%dt
|
18
|
+
= <%= model_name(:class) %>.human_attribute_name(:<%= attribute.name %>)
|
19
|
+
%dd
|
20
|
+
<%- case attribute.type -%>
|
21
|
+
<%- when :string -%>
|
22
|
+
= <%= model_attribute %>
|
23
|
+
<%- when :email -%>
|
24
|
+
= mail_to <%= model_attribute %>, nil
|
25
|
+
<%- when :url -%>
|
26
|
+
= link_to <%= model_attribute %>, <%= model_attribute %>
|
27
|
+
<%- when :integer -%>
|
28
|
+
= <%= model_attribute %>
|
29
|
+
<%- when :money -%>
|
30
|
+
= <%= model_attribute %>
|
31
|
+
€
|
32
|
+
<%- when :text -%>
|
33
|
+
= simple_format(<%= model_attribute %>)
|
34
|
+
<%- when :flag -%>
|
35
|
+
= <%= model_attribute %> ? 'Yes' : 'No'
|
36
|
+
<%- when :datetime -%>
|
37
|
+
= l(<%= model_attribute %>.to_date) if <%= model_attribute %>
|
38
|
+
<%- end -%>
|
39
|
+
<%- end -%>
|
@@ -1,28 +1,30 @@
|
|
1
|
-
# Generate views for a
|
1
|
+
# Generate views for a WebUI
|
2
2
|
|
3
3
|
require 'katapult/generator'
|
4
4
|
require 'generators/katapult/cucumber_features/cucumber_features_generator'
|
5
5
|
|
6
6
|
module Katapult
|
7
7
|
module Generators
|
8
|
-
class
|
8
|
+
class ViewsGenerator < Katapult::Generator
|
9
9
|
|
10
10
|
desc 'Generate HAML views'
|
11
11
|
source_root File.expand_path('../templates', __FILE__)
|
12
12
|
|
13
13
|
|
14
|
-
def install_application_layout
|
15
|
-
remove_file 'app/views/layouts/application.html.erb'
|
16
|
-
template 'app/views/layouts/application.html.haml'
|
17
|
-
template 'app/views/layouts/_flashes.html.haml'
|
18
|
-
end
|
19
|
-
|
20
14
|
def create_views_directory
|
21
15
|
FileUtils.mkdir_p views_path
|
22
16
|
end
|
23
17
|
|
18
|
+
def install_helpers
|
19
|
+
directory 'app/helpers'
|
20
|
+
end
|
21
|
+
|
22
|
+
def install_styles
|
23
|
+
directory 'app/webpack/assets/stylesheets/blocks'
|
24
|
+
end
|
25
|
+
|
24
26
|
def create_rails_standard_action_views
|
25
|
-
actions.select{ |a| a.get? &&
|
27
|
+
actions.select{ |a| a.get? && WebUI::RAILS_ACTIONS.include?(a.name) }.each do |action|
|
26
28
|
file_name = "#{action.name}.html.haml"
|
27
29
|
|
28
30
|
create_view file_name, File.join(views_path, file_name)
|
@@ -40,54 +42,46 @@ module Katapult
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def create_views_for_custom_actions
|
43
|
-
|
45
|
+
web_ui.custom_actions.select(&:get?).each do |action|
|
44
46
|
@action = action # Make the action object accessible in templates
|
45
47
|
create_view 'custom_action.html.haml', File.join(views_path, "#{action.name}.html.haml")
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
51
|
def generate_integration_tests
|
50
|
-
if
|
51
|
-
Generators::CucumberFeaturesGenerator.new(
|
52
|
+
if web_ui.model.present?
|
53
|
+
Generators::CucumberFeaturesGenerator.new(web_ui.model).invoke_all
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
no_tasks do
|
56
58
|
def model_name(kind = nil)
|
57
|
-
|
59
|
+
web_ui.model_name(kind)
|
58
60
|
end
|
59
61
|
|
60
62
|
def views_path
|
61
63
|
File.join('app', 'views', model_name(:variables))
|
62
64
|
end
|
63
|
-
|
64
|
-
def navigation
|
65
|
-
wui.application_model.navigation
|
66
|
-
end
|
67
|
-
|
68
|
-
def authentication
|
69
|
-
wui.application_model.authentication
|
70
|
-
end
|
71
65
|
end
|
72
66
|
|
73
67
|
private
|
74
68
|
|
75
|
-
# Rails views depend heavily on models. If the
|
69
|
+
# Rails views depend heavily on models. If the WebUI has no model, do not
|
76
70
|
# use the templates but create empty files instead.
|
77
71
|
def create_view(template, destination)
|
78
|
-
if
|
72
|
+
if web_ui.model
|
79
73
|
template template, destination
|
80
74
|
else
|
81
75
|
create_file destination
|
82
76
|
end
|
83
77
|
end
|
84
78
|
|
85
|
-
def
|
79
|
+
def web_ui
|
86
80
|
@element
|
87
81
|
end
|
88
82
|
|
89
83
|
def actions
|
90
|
-
|
84
|
+
web_ui.actions
|
91
85
|
end
|
92
86
|
|
93
87
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
% rails_actions =
|
1
|
+
% rails_actions = web_ui.actions - web_ui.custom_actions
|
2
2
|
resources <%= model_name(:symbols) %>, only: <%= rails_actions.map(&:name).map(&:to_sym) %> do
|
3
3
|
member do
|
4
|
-
%
|
4
|
+
% web_ui.custom_actions.select(&:member?).each do |action|
|
5
5
|
<%= action.method %> '<%= action.name %>'
|
6
6
|
% end
|
7
7
|
end
|
8
8
|
collection do
|
9
|
-
%
|
9
|
+
% web_ui.custom_actions.select(&:collection?).each do |action|
|
10
10
|
<%= action.method %> '<%= action.name %>'
|
11
11
|
% end
|
12
12
|
end
|