kablam 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd80585b73d2f561735a42f89a32e543e75ac639000af42a7816c07885b9ece2
4
- data.tar.gz: 89ffc03edd6437375e6bbe16248a54b513957e1251fc3627cb4a9836b46616da
3
+ metadata.gz: ca66e443b91e7d0343983aa56ff183eaa4a9497aeec5aa80f608e23db08060f8
4
+ data.tar.gz: 39c970580855e0063ece5d79f0b794354058f7474685017b9469c079f0301edb
5
5
  SHA512:
6
- metadata.gz: 66e2f1c89e5047ccf06b40ac4c95ee11fa61280139749f5662e728b870ca7dbce0e28c9660ebece8728d89edf0367794e386e1d17de6b181793ad31580690eea
7
- data.tar.gz: 4c16ff0f5651077853d81109f20df9063981d0e29a79fc09362770fa5a8cf23a1488a87c8075131036b16939520b05436d70dbc0031723c310eaa9973ee735d6
6
+ metadata.gz: dced7f9382e138a51dd307ab981bb1fd4d0ca374c2f4f7a38b47664b5cbe9b473daa9492327f33c8005c1fd0414d42b9108f3818d511d75cd3e069e0c54ab0d5
7
+ data.tar.gz: 7380749f0aadb71e1741120cad316aca1d6886d8b0b2691e6129a32113e595e5d310cafe2a2b4c79d01578110775b5557e1bbc83bc3122493162d38faaef1186
@@ -1,6 +1,6 @@
1
1
  require 'rest-client'
2
2
 
3
- class DataController < ApplicationController
3
+ class KablamController < ApplicationController
4
4
  protect_from_forgery with: :exception
5
5
  before_action :set_model, only: [:create, :update, :undo, :destroy, :form]
6
6
  before_action :set_object, only: [:update, :destroy]
@@ -1,4 +1,4 @@
1
- var content = '<%= j render "data/models/#{@object.model_name.singular}", obj: @object %>'
1
+ var content = '<%= j render "kablam/models/#{@object.model_name.singular}", obj: @object %>'
2
2
 
3
3
  document
4
4
  .getElementById('<%= params[:target] || "target_index" %>')
@@ -1,7 +1,7 @@
1
1
  <%= hide @object %>
2
2
  <% if @object.undoable? %>
3
3
  <%= render_flash message: 'Deleted', partial: 'application/flash_undo',
4
- link: button_to('Undo', data_undo_path(@object.class.table_name, @object,
4
+ link: button_to('Undo', kablam_undo_path(@object.class.table_name, @object,
5
5
  @object.model_name.singular.to_sym => { destroyed_at: nil }),
6
6
  {data: { disable_with: 'Restoring…' },
7
7
  class: 'no-underline mt3 f4 tc pv2 ph4 white bg-black hover-bg-green shadow-5',
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  <% if params[:target].present? %>
2
2
 
3
3
  var objRow = byId('<%= @object.html_id %>')
4
- var content = `<%= j render "data/models/#{@object.model_name.singular}", obj: @object %>`
4
+ var content = `<%= j render "kablam/models/#{@object.model_name.singular}", obj: @object %>`
5
5
  var newRow = HTMLElement.From(content);
6
6
 
7
7
  objRow.innerHTML = newRow.innerHTML
@@ -5,7 +5,7 @@
5
5
  @method = (obj.id.blank? ? :post : :patch)
6
6
  @form_name = @model.to_s.underscore
7
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))
8
+ @url = (@method == :post ? kablam.create_path(@table_name) : kablam.update_path(@table_name, obj.id))
9
9
  %>
10
10
 
11
11
  <%= form_with model: obj, url: @url, method: @method, id: @form_id, class: classes[:form_wrapper] do |f| %>
@@ -0,0 +1,7 @@
1
+ Kablam::Engine.routes.draw do
2
+ get '/:name/form' => 'kablam#form', as: 'form'
3
+ post '/:name' => 'kablam#create', as: 'create'
4
+ patch '/:name/:id' => 'kablam#update', as: 'update'
5
+ delete '/:name/:id' => 'kablam#destroy', as: 'destroy'
6
+ put '/:name/:id' => 'kablam#undo', as: 'undo'
7
+ end
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'kablam'
3
- s.version = '0.0.8'
3
+ s.version = '0.1.0'
4
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."
5
+ s.summary = "Kablam! All the things you hate. But Faster."
6
+ s.description = "Gem to make development of everything in rails faster. Form creation & styling, all the resource routes, even actioncable messaging!"
7
7
  s.authors = ["Sergio Rivas"]
8
8
  s.email = 'sergiorivas@163.com'
9
9
  s.files = `git ls-files`.split("\n")
@@ -74,7 +74,9 @@ module Kablam
74
74
 
75
75
  def gen_yaml(db_index)
76
76
  path = "config/locales/kablam-forms.#{name}.yml"
77
+ original = YAML.load_file(path)
77
78
  yml_hash = {name => {"kablam_forms" => db_to_hash(db_index)}}
79
+ yml_hash.merge!(original) if original.present?
78
80
 
79
81
  File.write(path, yml_hash.to_yaml)
80
82
  dump_yaml_with_double_quotes(path)
@@ -13,14 +13,19 @@ module Kablam
13
13
 
14
14
  # Setup Initializer
15
15
  template "kablam.rb", "config/initializers/kablam.rb"
16
+ template "_sample_target_item.html.erb", "app/views/kablam/models/_sample_target_item.html.erb"
16
17
 
17
18
  def setup_routes
18
- route "# form/create/update/destroy/undo for all models"
19
- route "get 'd/:name/form' => 'data#form', as: 'data_form'"
20
- route "post 'd/:name' => 'data#create', as: 'data_create'"
21
- route "patch 'd/:name/:id' => 'data#update', as: 'data_update'"
22
- route "delete 'd/:name/:id' => 'data#destroy', as: 'data_destroy'"
23
- route "put 'd/:name/:id' => 'data#undo', as: 'data_undo'"
19
+ route "# KABLAM! form/create/update/destroy/undo for all models"
20
+ route "# Note: Make sure Kablam engine is at the BOTTOM of routes"
21
+ route "# helpers to use KABLAM! [examples w/ 'posts' model)"
22
+ route "# ---> kablam.form_path('posts')"
23
+ route "# (if edit form, must add '?id=\#\{@post.id\}' at end of path)"
24
+ route "# ---> kablam.create_path('posts')"
25
+ route "# ---> kablam.delete_path('posts', @post)"
26
+ route "# ---> kablam.update_path('posts', @post)"
27
+ route "# ---> kablam.undo_path('posts', @post)"
28
+ route "mount Kablam::Engine => '/kablam', as: 'kablam'"
24
29
  end
25
30
 
26
31
  def setup_assets
@@ -0,0 +1,25 @@
1
+ <!-- If rendering things to a table after form submission,
2
+ create a partial with the model name in this folder.
3
+ example: for User, create a file '_user.html.erb'
4
+ Then follow the following format:
5
+
6
+ note: THE ACTIVERECORD OBJECT muse be called 'obj' in your partial!
7
+ note: obj.html_id is a helper method included in Kablam.
8
+ -->
9
+
10
+ <tr id="<%= obj.html_id %>" class="some_tr_class_you_want">
11
+ <td class="some_td_class"><%= obj.some_column %></td>
12
+ <td class="some_td_class"><%= obj.another_column %></td>
13
+
14
+ <td class="some_td_class">
15
+ <%= raw Kablam::Forms.render_edit(obj, 'form_div_id', 'table_div_id') %>
16
+ <!-- Can also give params in a hash, {class: "class", text: "edit" } -->
17
+ </td>
18
+ <td class="">
19
+ <%= raw Kablam::Forms.render_destroy(obj) %>
20
+ <!-- Can also give params in a hash, {class: "class", text: "edit" } -->
21
+ </td>
22
+ </tr>
23
+
24
+
25
+
@@ -1,5 +1,13 @@
1
1
  module Kablam
2
2
  class Forms
3
+ def self.render_edit(obj, target_id, table_id, opt={})
4
+ "<a class='#{opt[:class]}' onclick='event.preventDefault();load('#{target_id}', '/kablam/#{obj.class.table_name}/form?id=#{obj.id}&target=#{table_id}')' href='#'>#{opt[:text] || "Edit"}</a>"
5
+ end
6
+
7
+ def self.render_destroy(obj, opt={})
8
+ "<a data-disable-with='…' class='#{opt[:class]}' data-remote='true' rel='nofollow' data-method='delete' href='/kablam/#{obj.class.table_name}/#{obj.id}'>#{opt[:text] || "Remove"}</a>"
9
+ end
10
+
3
11
  def self.default_classes
4
12
  {
5
13
  # Generally used classes for everything.
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.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rivas
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Gem to make development of everything in rails even faster.
55
+ description: Gem to make development of everything in rails faster. Form creation
56
+ & styling, all the resource routes, even actioncable messaging!
56
57
  email: sergiorivas@163.com
57
58
  executables: []
58
59
  extensions: []
@@ -69,13 +70,13 @@ files:
69
70
  - app/assets/stylesheets/kablam.scss
70
71
  - app/channels/chat_channel.rb
71
72
  - app/controllers/concerns/api_settings.rb
72
- - app/controllers/data_controller.rb
73
+ - app/controllers/kablam_controller.rb
73
74
  - app/views/.DS_Store
74
- - app/views/data/create.js.erb
75
- - app/views/data/destroy.js.erb
76
- - app/views/data/form.html.erb
77
- - app/views/data/undo.js.erb
78
- - app/views/data/update.js.erb
75
+ - app/views/kablam/create.js.erb
76
+ - app/views/kablam/destroy.js.erb
77
+ - app/views/kablam/form.html.erb
78
+ - app/views/kablam/undo.js.erb
79
+ - app/views/kablam/update.js.erb
79
80
  - app/views/kablam_forms/.DS_Store
80
81
  - app/views/kablam_forms/_form_generator.html.erb
81
82
  - app/views/kablam_forms/_kablam_form.html.erb
@@ -89,11 +90,13 @@ files:
89
90
  - app/views/kablam_forms/fields/_pretext.html.erb
90
91
  - app/views/kablam_forms/fields/_select.html.erb
91
92
  - app/views/kablam_forms/fields/_text.html.erb
93
+ - config/routes.rb
92
94
  - kablam.gemspec
93
95
  - lib/generators/kablam/USAGE
94
96
  - lib/generators/kablam/forms_generator.rb
95
97
  - lib/generators/kablam/install_generator.rb
96
98
  - lib/generators/kablam/messaging_generator.rb
99
+ - lib/generators/kablam/templates/_sample_target_item.html.erb
97
100
  - lib/generators/kablam/templates/chat.rb
98
101
  - lib/generators/kablam/templates/kablam.rb
99
102
  - lib/generators/kablam/templates/message.rb
@@ -125,5 +128,5 @@ rubyforge_project:
125
128
  rubygems_version: 2.7.6
126
129
  signing_key:
127
130
  specification_version: 4
128
- summary: Empty Initialization of Gem
131
+ summary: Kablam! All the things you hate. But Faster.
129
132
  test_files: []