semanticui-generators 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/semanticui/install/install_generator.rb +1 -5
- data/lib/generators/semanticui/install/templates/lib/rails/generators/erb/scaffold/scaffold_generator.rb +33 -0
- data/lib/generators/semanticui/install/templates/{form_builders/form_builder → lib/templates/erb/scaffold}/_form.html.erb +1 -1
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/create.js.erb +2 -0
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/destroy.js.erb +2 -0
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/edit.html.erb +1 -1
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/index.html.erb +1 -1
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/show.html.erb +1 -1
- data/lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/update.js.erb +2 -0
- data/lib/generators/semanticui/install/templates/lib/templates/rails/scaffold_controller/controller.rb +63 -0
- data/lib/semanticui/generators/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8314897e33c0a932e6ca588d2d915b80e0a515ba
|
4
|
+
data.tar.gz: dfb2423aaed8b94a0378f681a05e0789cd106ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5950a0ea37dbb6f11776954de807e1a89e65bb78690ddbfb913c25e2dbb260537283b5ccb8f1b05591d05d6b48a557aae0222fe0a34b99e9abd705543d9fd4e3
|
7
|
+
data.tar.gz: 5b93b497c511faeba3401c988ed238140058052f4ff41e822ef730da722812771fd41dcf3f0836d74314000e2053c345bae574fa8a59bd62a267e94e8089ad28
|
@@ -7,11 +7,7 @@ module Semanticui
|
|
7
7
|
source_root ::File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
9
|
def copy_lib
|
10
|
-
directory "lib
|
11
|
-
end
|
12
|
-
|
13
|
-
def copy_form_builder
|
14
|
-
copy_file "form_builders/form_builder/_form.html.erb", "lib/templates/erb/scaffold/_form.html.erb"
|
10
|
+
directory "lib"
|
15
11
|
end
|
16
12
|
|
17
13
|
def create_layout
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# lib/generators/all/scaffold/scaffold_generator.rb
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
require 'rails/generators/resource_helpers'
|
4
|
+
|
5
|
+
module Erb # :nodoc:
|
6
|
+
module Generators # :nodoc:
|
7
|
+
class ScaffoldGenerator < Rails::Generators::NamedBase # :nodoc:
|
8
|
+
include Rails::Generators::ResourceHelpers
|
9
|
+
|
10
|
+
source_root File.join(Rails.root, 'lib', 'templates', 'erb', 'scaffold', File::SEPARATOR)
|
11
|
+
|
12
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
13
|
+
|
14
|
+
def create_root_folder
|
15
|
+
empty_directory File.join("app/views", controller_file_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_view_files
|
19
|
+
available_views.each do |view|
|
20
|
+
template view, File.join("app/views", controller_file_path, view)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def available_views
|
26
|
+
# use all template files contained in source_root ie 'lib/templates/scaffold/**/*'
|
27
|
+
base = self.class.source_root
|
28
|
+
base_len = base.length
|
29
|
+
Dir[File.join(base, '**', '*')].select { |f| File.file?(f) }.map{|f| f[base_len..-1]}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%%= form_for(@<%= singular_table_name %>, html: { class: "ui form" }) do |f| %>
|
1
|
+
<%%= form_for(@<%= singular_table_name %>, remote: true, html: { class: "ui form" }) do |f| %>
|
2
2
|
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
3
|
<div class="ui message negative">
|
4
4
|
<div class="header">
|
@@ -8,7 +8,7 @@
|
|
8
8
|
</h2>
|
9
9
|
</div>
|
10
10
|
<div class="right aligned two wide column">
|
11
|
-
<%%= link_to 'Destroy', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui tiny fluid red button' %>
|
11
|
+
<%%= link_to 'Destroy', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, remote: true, data: { confirm: 'Are you sure?' }, class: 'ui tiny fluid red button' %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<div class="one column row">
|
@@ -38,7 +38,7 @@
|
|
38
38
|
<%%= link_to edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'ui button' do %>
|
39
39
|
<i class="icon edit"></i>
|
40
40
|
<%% end %>
|
41
|
-
<%%= link_to <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui button' do %>
|
41
|
+
<%%= link_to <%= singular_table_name %>, method: :delete, remote: true, data: { confirm: 'Are you sure?' }, class: 'ui button' do %>
|
42
42
|
<i class="icon remove"></i>
|
43
43
|
<%% end %>
|
44
44
|
</span>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'ui tiny fluid orange button' %>
|
12
12
|
</div>
|
13
13
|
<div class="right aligned two wide column">
|
14
|
-
<%%= link_to 'Destroy', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, data: { confirm: 'Are you sure?' }, class: 'ui tiny fluid red button' %>
|
14
|
+
<%%= link_to 'Destroy', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, remote: true, data: { confirm: 'Are you sure?' }, class: 'ui tiny fluid red button' %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
<div class="one column row">
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST <%= route_url %>
|
24
|
+
def create
|
25
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
26
|
+
|
27
|
+
if @<%= orm_instance.save %>
|
28
|
+
flash[:notice] = <%= "'#{human_name} was successfully created.'" %>
|
29
|
+
render :create
|
30
|
+
else
|
31
|
+
render :new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
37
|
+
flash[:notice] = <%= "'#{human_name} was successfully updated.'" %>
|
38
|
+
render :update
|
39
|
+
else
|
40
|
+
render :edit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
@<%= orm_instance.destroy %>
|
46
|
+
flash[:notice] = <%= "'#{human_name} was successfully destroyed.'" %>
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def set_<%= singular_table_name %>
|
52
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
53
|
+
end
|
54
|
+
|
55
|
+
def <%= "#{singular_table_name}_params" %>
|
56
|
+
<%- if attributes_names.empty? -%>
|
57
|
+
params.fetch(:<%= singular_table_name %>, {})
|
58
|
+
<%- else -%>
|
59
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
60
|
+
<%- end -%>
|
61
|
+
end
|
62
|
+
end
|
63
|
+
<% end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semanticui-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Lins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,12 +70,17 @@ files:
|
|
70
70
|
- lib/generators/semanticui/install/install_generator.rb
|
71
71
|
- lib/generators/semanticui/install/templates/assets/javascripts/semanticui-scaffold.js.coffee
|
72
72
|
- lib/generators/semanticui/install/templates/assets/stylesheets/semanticui-scaffold.scss
|
73
|
-
- lib/generators/semanticui/install/templates/form_builders/form_builder/_form.html.erb
|
74
73
|
- lib/generators/semanticui/install/templates/layouts/application.html.erb
|
74
|
+
- lib/generators/semanticui/install/templates/lib/rails/generators/erb/scaffold/scaffold_generator.rb
|
75
|
+
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/_form.html.erb
|
76
|
+
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/create.js.erb
|
77
|
+
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/destroy.js.erb
|
75
78
|
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/edit.html.erb
|
76
79
|
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/index.html.erb
|
77
80
|
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/new.html.erb
|
78
81
|
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/show.html.erb
|
82
|
+
- lib/generators/semanticui/install/templates/lib/templates/erb/scaffold/update.js.erb
|
83
|
+
- lib/generators/semanticui/install/templates/lib/templates/rails/scaffold_controller/controller.rb
|
79
84
|
- lib/semanticui-generators.rb
|
80
85
|
- lib/semanticui/generators/version.rb
|
81
86
|
- semanticui-generators.gemspec
|