kablam 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +50 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/app/views/kablam_forms/.DS_Store +0 -0
- data/app/views/kablam_forms/_form_generator.html.erb +39 -0
- data/app/views/kablam_forms/_kablam_form.html.erb +16 -0
- data/app/views/kablam_forms/fields/.DS_Store +0 -0
- data/app/views/kablam_forms/fields/_checkbox_array.html.erb +29 -0
- data/app/views/kablam_forms/fields/_checkbox_boolean.html.erb +18 -0
- data/app/views/kablam_forms/fields/_file_upload.html.erb +8 -0
- data/app/views/kablam_forms/fields/_hidden.html.erb +1 -0
- data/app/views/kablam_forms/fields/_input.html.erb +6 -0
- data/app/views/kablam_forms/fields/_multi_inputs.html.erb +26 -0
- data/app/views/kablam_forms/fields/_pretext.html.erb +3 -0
- data/app/views/kablam_forms/fields/_select.html.erb +11 -0
- data/app/views/kablam_forms/fields/_text.html.erb +6 -0
- data/kablam.gemspec +16 -0
- data/lib/generators/kablam/USAGE +7 -0
- data/lib/generators/kablam/forms_generator.rb +84 -0
- data/lib/generators/kablam/kablam_generator.rb +12 -0
- data/lib/generators/kablam/views_generator.rb +11 -0
- data/lib/kablam/forms.rb +30 -0
- metadata +37 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d242a9e71a738c05fa0e32637d57b88451550034324c3200c4e23fc517b4e5
|
4
|
+
data.tar.gz: 5e2557c968a10bf48675c973409d1e84328facb20bb6c6f8311a5406a70bf816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e78162a9705a7b1c12b1a0c616e39120a58ee65c03bbb3eba77d3a56082ba43f5cc7afb85eb8ca50aaaa5e78440d137939bdd48b454806b5113575b7b05f78
|
7
|
+
data.tar.gz: f48a3c6bd1967dd9e4678643bedd463dd1b98cf53e1a809605d30d99ffa72f6fedf92295d129b83892b8adac1f5446254e80d8c8bc8634e335a4fab3e531206f
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Sergio Rivas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<!-- COMPLEX LOGIC HERE! DON'T TOUCH OR SOMETHING WILL BREAK!! -->
|
2
|
+
<%
|
3
|
+
@model = obj.class
|
4
|
+
@table_name = @model.table_name
|
5
|
+
@method = (obj.id.blank? ? :post : :patch)
|
6
|
+
@form_name = @model.to_s.underscore
|
7
|
+
@form_id = "#{obj.id.blank? ? "new" : "update"}_#{@form_name}_form"
|
8
|
+
@url = (@method == :post ? data_create_path(@table_name) : data_update_path(@table_name, obj.id))
|
9
|
+
%>
|
10
|
+
|
11
|
+
<%= form_with model: obj, url: @url, method: @method, id: @form_id, class: classes[:form_wrapper] do |f| %>
|
12
|
+
<% if target.present? %>
|
13
|
+
<input type="hidden" name="target" value="<%= target %>">
|
14
|
+
<% end %>
|
15
|
+
<% if hidden.present? %>
|
16
|
+
<% hidden.each do |k,v| %>
|
17
|
+
<input type="hidden" name="<%= k.to_s %>" value="<%= v %>">
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% @model.fields.each do |field| %>
|
21
|
+
<% kablam_scope = "kablam_forms.#{@table_name}.#{field}" %>
|
22
|
+
<% classyy = @model.prep_form_field[field] %>
|
23
|
+
<% next if classyy == :exclude %>
|
24
|
+
<% input = {name: "#{@form_name}[#{field}]", value: obj.send(field), label: t(:label, scope: kablam_scope, default: ""), pretext: t(:pretext, scope: kablam_scope, default: ""), placeholder: t(:placeholder, scope: kablam_scope, default: ""), hint: raw(t(:hint, scope: kablam_scope, default: "")), choices: @model.choices(field, I18n.locale)} %>
|
25
|
+
<%= (render "kablam_forms/fields/pretext", classes: classes, input: input) if input[:pretext].present? %>
|
26
|
+
<%= render "kablam_forms/fields/#{classyy.to_s}", classes: classes, input: input, f: f %>
|
27
|
+
<% end %>
|
28
|
+
<%= f.submit(
|
29
|
+
data: { disable_with: 'Submitting' },
|
30
|
+
class: classes[:submit_button]) %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<script>
|
34
|
+
initFileUploads({'class': '<%= classes[:file_upload]%>', 'icon': '<%= classes[:file_upload_icon] %>'});
|
35
|
+
<% if ajax_remove.present? %>
|
36
|
+
submitRemove('<%= @form_id %>')
|
37
|
+
<% end %>
|
38
|
+
submitToTop('<%= @form_id %>')
|
39
|
+
</script>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%
|
2
|
+
# Please Override the Default Classes below with classes used in your theme!
|
3
|
+
default_classes = Kablam::Forms.default_classes
|
4
|
+
#
|
5
|
+
classes = classes || {}
|
6
|
+
classes = default_classes.merge classes.select { |k| default_classes.keys.include? k }
|
7
|
+
target = target || nil
|
8
|
+
hidden = hidden || {}
|
9
|
+
ajax_remove = ajax_remove || false
|
10
|
+
%>
|
11
|
+
|
12
|
+
<%= render "kablam_forms/form_generator", classes: classes, obj: obj, target: target, hidden: hidden, ajax_remove: ajax_remove %>
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="<%= classes[:form_group] %>">
|
2
|
+
<fieldset id="<%= input[:id] %>" class="<%= classes[:checkbox_group_wrapper] %>">
|
3
|
+
<legend class="<%= classes[:field_label] %>"><%= input[:label] %></legend>
|
4
|
+
<small id="<%= input[:id] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
5
|
+
|
6
|
+
<% input[:choices].each_with_index do |choice, i| %>
|
7
|
+
<div class="<%= classes[:checkbox_wrapper] %>">
|
8
|
+
<input id="<%= input[:id] %>_<%= i %>" name="<%= input[:name] %>[]" class="<%= classes[:checkbox] %>" <%= "checked" if input[:value].include?(choice[:value]) %> type="checkbox" value="<%= choice[:value] %>">
|
9
|
+
<label for="<%= input[:id] %>_<%= i %>" class="<%= classes[:checkbox_label] %>"><%= choice[:label] %></label>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
</fieldset>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%
|
16
|
+
# STRUCTURE of Checkbox
|
17
|
+
# <div FORM_GROUP >
|
18
|
+
# <fieldset CHECKBOX_GROUP_WRAPPER >
|
19
|
+
# <legend LABEL ></legend>
|
20
|
+
# <small HINT ></small>
|
21
|
+
# ------CHOICES START------
|
22
|
+
# <div>
|
23
|
+
# <input Checkbox>
|
24
|
+
# <label>checkbox choice text</label>
|
25
|
+
# </div>
|
26
|
+
# ------CHOICES END--------
|
27
|
+
# </fieldset>
|
28
|
+
# </div>
|
29
|
+
%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="<%= classes[:form_group] %>">
|
2
|
+
<fieldset id="<%= input[:id] %>" class="<%= classes[:checkbox_group_wrapper] %>">
|
3
|
+
<legend class="<%= classes[:field_label] %>"><%= input[:label] %></legend>
|
4
|
+
<small id="<%= input[:id] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
5
|
+
<div class="<%= classes[:checkbox_wrapper] %>">
|
6
|
+
<input id="<%= input[:id] %>" name="<%= input[:name] %>" class="<%= classes[:checkbox] %>" <%= "checked" if input[:value].present? %> type="checkbox">
|
7
|
+
<label for="<%= input[:id] %>" class="<%= classes[:checkbox_label] %>"><%= input[:choices].first[:label] %></label>
|
8
|
+
</div>
|
9
|
+
</fieldset>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
<div class="<%= classes[:form_group] %>">
|
3
|
+
<label class="<%= classes[:field_label] %>" for="<%= input[:id] %>"><%= input[:label] %></label>
|
4
|
+
<small id="<%= input[:name] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
5
|
+
<div class="kablam_fileinput_init">
|
6
|
+
<input class="kablam_file <%= classes[:file_upload] %>" name="<%= input[:name] %>" type="file" id="<%= input[:id] %>">
|
7
|
+
</div>
|
8
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<input id="<%= input[:id] %>" type="hidden" value="<%= input[:value] %>" name="<%= input[:name] %>">
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="<%= classes[:form_group] %>">
|
2
|
+
<label for="<%= input[:name] %>" class="<%= classes[:field_label] %>"><%= input[:label] %></label>
|
3
|
+
<small id="<%= input[:name] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
4
|
+
<input id="<%= input[:id] if input[:id].present? %>" name="<%= input[:name] %>" class="<%= classes[:input] %>" type="text" aria-describedby="<%= input[:name] %>-desc" value="<%= input[:value] %>" placeholder="<%= input[:placeholder] %>">
|
5
|
+
</div>
|
6
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% require 'securerandom'
|
2
|
+
unique_id = SecureRandom.hex
|
3
|
+
%>
|
4
|
+
<%#
|
5
|
+
THIS TAKES A HASH for INPUT.
|
6
|
+
EX of FORMAT: input = {label: "choices", name: "assessment[choices]", value: ["value", "from", "existing", "DB_ENTRY"], id: "1" (if input_id is used)}
|
7
|
+
%>
|
8
|
+
<div id="multi_input_<%= unique_id %>" class="<%= classes[:form_group] %>">
|
9
|
+
<label class="<%= classes[:field_label] %>"><%= input[:label] %></label>
|
10
|
+
<small class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
11
|
+
<a href="#!" class="<%= classes[:multi_add_button] %>" onclick='event.preventDefault();addInput("multi_input_<%= unique_id %>", "<%= input[:name] %>[]", { "input": "<%= classes[:input] %>", "btn": "<%= classes[:multi_remove_button] %>", "icon": "<%= classes[:multi_remove_icon] %>", "group": "<%= classes[:multi_input_group] %>"});'><i class="<%= classes[:multi_add_icon] %>"></i></a>
|
12
|
+
<% if input[:value].present? %>
|
13
|
+
<% input[:value].each_with_index do |val, i| %>
|
14
|
+
<div id="<%= unique_id %>_<%= i+1 %>" class="<%= classes[:multi_input_group] %>">
|
15
|
+
<input id="" class="<%= classes[:input] %>" type="text" name="<%= input[:name] %>[]" value="<%= val %>">
|
16
|
+
<a href="#!" class="<%= classes[:multi_remove_button] %>" onclick='event.preventDefault();rmParent(this);'><i class="<%= classes[:multi_remove_icon] %>"></i></a>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% else %>
|
20
|
+
<div id="<%= id = SecureRandom.hex %>" class="<%= classes[:multi_input_group] %>">
|
21
|
+
<input class="<%= classes[:input] %>" type="text" name="<%= input[:name] %>[]" placeholder="<%= input[:placeholder] %>">
|
22
|
+
<a href="#!" class="<%= classes[:multi_remove_button] %>" onclick='event.preventDefault();rmParent(this);'><i class="<%= classes[:multi_remove_icon] %>"></i></a>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="<%= classes[:form_group] %>">
|
2
|
+
<label for="<%= input[:id] %>" class="<%= classes[:field_label] %>"><%= input[:label] %></label>
|
3
|
+
<small id="select_<%= input[:id] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
4
|
+
<select id="<%= input[:id] if input[:id].present? %>" class="select_basic <%= classes[:select] %>" name="<%= input[:name] %>" aria-describedby="select_<%= input[:id] %>-desc">
|
5
|
+
<option value=""><%= input[:placeholder] %></option>
|
6
|
+
<% input[:choices].each do |choice| %>
|
7
|
+
<option label="<%= choice[:label] %>" value="<%= choice[:value] %>"<%= input[:value].present? ? (" selected=\"selected\"" if input[:value] == choice[:value] ) : "" %>></option>
|
8
|
+
<% end %>
|
9
|
+
</select>
|
10
|
+
|
11
|
+
</div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="<%= classes[:form_group] %>">
|
2
|
+
<label for="<%= input[:name] %>" class="<%= classes[:field_label] %>"><%= input[:label] %></label>
|
3
|
+
<small id="<%= input[:name] %>-desc" class="<%= classes[:field_hint] %>"><%= input[:hint] %></small>
|
4
|
+
<textarea id="<%= input[:id] if input[:id].present? %>" name="<%= input[:name] %>" class="<%= classes[:textarea] %>" aria-describedby="<%= input[:name] %>-desc" placeholder="<%= input[:placeholder] %>"><%= input[:value] if input[:value].present? %></textarea>
|
5
|
+
</div>
|
6
|
+
|
data/kablam.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'kablam'
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.date = '2018-09-14'
|
5
|
+
s.summary = "Empty Initialization of Gem"
|
6
|
+
s.description = "Gem to make development of everything in rails even faster."
|
7
|
+
s.authors = ["Sergio Rivas"]
|
8
|
+
s.email = 'sergiorivas@163.com'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.homepage =
|
11
|
+
'http://rubygems.org/gems/kablam'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.add_dependency("activerecord")
|
15
|
+
s.add_dependency('rails-i18n')
|
16
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
rails generate kablam:forms LOCALE
|
2
|
+
|
3
|
+
---> This will generate a template file for use with i18n at '/config/locales/kablam-forms.<LOCALE>.yml'
|
4
|
+
|
5
|
+
rails generate kablam:form_views
|
6
|
+
|
7
|
+
---> This will generate all the form-components used with kablam_forms. You can change them to fit any HTML based template you have!
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Kablam
|
4
|
+
module Generators
|
5
|
+
class FormsGenerator < Rails::Generators::NamedBase
|
6
|
+
include Rails::Generators::ResourceHelpers
|
7
|
+
namespace "kablam:forms"
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
argument :name, :type => :string, :default => "en"
|
10
|
+
|
11
|
+
def generate_yml
|
12
|
+
# Load All Models
|
13
|
+
|
14
|
+
db_index = Hash[ActiveRecord::Base.connection.tables.collect{|c| [c, c.classify]}].except("schema_migrations", "ar_internal_metadata")
|
15
|
+
gen_yaml(db_index)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
# HELPER METHODS TO MAKE DOUBLE_QUOTE YML FILES
|
20
|
+
def ensure_quotes(h)
|
21
|
+
h.each do |k, v|
|
22
|
+
if v.is_a?(Hash)
|
23
|
+
ensure_quotes(v)
|
24
|
+
next
|
25
|
+
end
|
26
|
+
h[k] = v + "__ensure_quotes__\n "
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def dump_yaml_with_double_quotes(yaml_file)
|
31
|
+
yaml = YAML.load_file(yaml_file)
|
32
|
+
File.open(yaml_file, 'w') do |f|
|
33
|
+
YAML.dump(ensure_quotes(yaml), f, line_width: -1)
|
34
|
+
end
|
35
|
+
`sed -i '' "s/__ensure_quotes__[\\]n //g" #{yaml_file}`
|
36
|
+
end
|
37
|
+
|
38
|
+
def clean_columns(model)
|
39
|
+
model_attr = model.attribute_names - ["id", "created_at", "updated_at"]
|
40
|
+
# Remove Devise Hidden Attr. if Devise Model
|
41
|
+
if defined? model.params_authenticatable?
|
42
|
+
model_attr << "password"
|
43
|
+
model_attr = model_attr - ["encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "confirmation_token", "confirmed_at", "confirmation_sent_at", "unconfirmed_email", "failed_attempts", "unlock_token", "locked_at"]
|
44
|
+
end
|
45
|
+
return model_attr
|
46
|
+
end
|
47
|
+
|
48
|
+
def name_cleaner(model, attribute)
|
49
|
+
return attribute.split("_").map{|x|x.capitalize}.join(" ")
|
50
|
+
end
|
51
|
+
|
52
|
+
def db_to_hash(db_index)
|
53
|
+
result_hash = {}
|
54
|
+
db_index.each do |table_name, model_name|
|
55
|
+
model = model_name.constantize
|
56
|
+
model_attr = clean_columns(model)
|
57
|
+
|
58
|
+
# setup table hash
|
59
|
+
table_hash = {}
|
60
|
+
model_attr.each do |attribute|
|
61
|
+
clean_name = name_cleaner(model, attribute)
|
62
|
+
|
63
|
+
table_hash[attribute] = {
|
64
|
+
"label" => clean_name,
|
65
|
+
"placeholder" => "placeholder_text_for_#{attribute}",
|
66
|
+
"hint" => "small_text_long_descirption_hint_for_#{attribute}",
|
67
|
+
"pretext" => "pretext_box_for_#{attribute}"
|
68
|
+
}
|
69
|
+
end
|
70
|
+
result_hash[table_name] = table_hash
|
71
|
+
end
|
72
|
+
return result_hash
|
73
|
+
end
|
74
|
+
|
75
|
+
def gen_yaml(db_index)
|
76
|
+
path = "config/locales/kablam-forms.#{name}.yml"
|
77
|
+
yml_hash = {name => {"kablam_forms" => db_to_hash(db_index)}}
|
78
|
+
|
79
|
+
File.write(path, yml_hash.to_yaml)
|
80
|
+
dump_yaml_with_double_quotes(path)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Kablam
|
4
|
+
module Generators
|
5
|
+
class KablamGenerator < Rails::Generators::NamedBase
|
6
|
+
include Rails::Generators::ResourceHelpers
|
7
|
+
namespace "kablam"
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
# argument :name, :type => :string, :default => "en"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/kablam/forms.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Kablam::Forms
|
2
|
+
|
3
|
+
def default_classes
|
4
|
+
{
|
5
|
+
form_wrapper: "pa4 black-80",
|
6
|
+
submit_button: "relative no-underline mt3 f4 tc db w-75 pv3 mb3 bg-red hover-bg-green white br2 shadow-5 btn-3d bn outline-0",
|
7
|
+
form_group: "measure mb4 relative",
|
8
|
+
field_label: "f6 b db mb2",
|
9
|
+
field_hint: "f6 black-60 db mb2",
|
10
|
+
pretext_wrapper: "measure ph3 pv1 mb3 b ba b--dashed bw1 b--red",
|
11
|
+
pretext: "fw5 i f5",
|
12
|
+
|
13
|
+
# Classes for the acutal from field input/select html items:
|
14
|
+
input: "input-reset ba b--black-20 pa2 db w-100",
|
15
|
+
textarea: "db border-box hover-black w-100 measure ba b--black-20 pa2 br2 mb2",
|
16
|
+
select: "ba bg-white b--black-20 pa2 mb2 db w-100",
|
17
|
+
file_upload: "ba b--black-20 pa5 mb2 db w-100 b--dashed b--red",
|
18
|
+
file_upload_icon: "fa fa-upload absolute left-0 right-0 ml-auto mr-auto top-2 mt3 f1 black-05",
|
19
|
+
checkbox_group_wrapper: "", # Wrapper around all checkboxes
|
20
|
+
checkbox_wrapper: "flex items-center mb2", # Wrapper for individual checkbox
|
21
|
+
checkbox_label: "f6 b db",
|
22
|
+
checkbox: "mr2",
|
23
|
+
multi_input_group: "flex mb2", #wrapper with input + delete button
|
24
|
+
multi_add_button: "absolute bg-green hover-bg-red no-underline pv2 pl3 pr3 right-0 top-0 white btn-3d br2", # For 'multi_inputs'
|
25
|
+
multi_remove_button: "relative no-underline bg-red hover-bg-green white pa2 pl3 pr3 ml1 btn-3d br2", # For 'multi_inputs'
|
26
|
+
multi_add_icon: "fa fa-plus",
|
27
|
+
multi_remove_icon: "fa fa-trash"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kablam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rivas
|
@@ -24,13 +24,49 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails-i18n
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Gem to make development of everything in rails even faster.
|
28
42
|
email: sergiorivas@163.com
|
29
43
|
executables: []
|
30
44
|
extensions: []
|
31
45
|
extra_rdoc_files: []
|
32
46
|
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- app/views/kablam_forms/.DS_Store
|
51
|
+
- app/views/kablam_forms/_form_generator.html.erb
|
52
|
+
- app/views/kablam_forms/_kablam_form.html.erb
|
53
|
+
- app/views/kablam_forms/fields/.DS_Store
|
54
|
+
- app/views/kablam_forms/fields/_checkbox_array.html.erb
|
55
|
+
- app/views/kablam_forms/fields/_checkbox_boolean.html.erb
|
56
|
+
- app/views/kablam_forms/fields/_file_upload.html.erb
|
57
|
+
- app/views/kablam_forms/fields/_hidden.html.erb
|
58
|
+
- app/views/kablam_forms/fields/_input.html.erb
|
59
|
+
- app/views/kablam_forms/fields/_multi_inputs.html.erb
|
60
|
+
- app/views/kablam_forms/fields/_pretext.html.erb
|
61
|
+
- app/views/kablam_forms/fields/_select.html.erb
|
62
|
+
- app/views/kablam_forms/fields/_text.html.erb
|
63
|
+
- kablam.gemspec
|
64
|
+
- lib/generators/kablam/USAGE
|
65
|
+
- lib/generators/kablam/forms_generator.rb
|
66
|
+
- lib/generators/kablam/kablam_generator.rb
|
67
|
+
- lib/generators/kablam/views_generator.rb
|
33
68
|
- lib/kablam.rb
|
69
|
+
- lib/kablam/forms.rb
|
34
70
|
- lib/kablam/kablam_record.rb
|
35
71
|
homepage: http://rubygems.org/gems/kablam
|
36
72
|
licenses:
|