tb_core 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzM4ZjU3ZmRjOGE0N2M1MDAzYzdmNjI0MmRkM2FmMWQ3NjQ5YTAzMQ==
4
+ NWQwZjNkMTFiYmZhZGYxOTAzYjFjOGIxMmJmNzFjNjYxMzAyMzNhOA==
5
5
  data.tar.gz: !binary |-
6
- Yzc5M2QwYmMzNDM1ZWU1YWI5NDljNjg4MGE3NzNlZTNiM2M3MzQ5NQ==
6
+ YTY2NzhiNzI3YTI2ZDQ3OWMxMWU2ZDgyMmE3ZWVhZWU2NDgwOTU5Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDMxMzMwZmVlMzg1OTBjMDdiYjNlNGQ2OGYxOWVjYWY1Mzc2ZTRlMjFjN2Y4
10
- MTA5MDkyMDFlYjU2ZGZjNWJhNzBlMDc0OTJlYTA5YmY5MzhjZDliMjQxOGM4
11
- Njk2Y2JjNDEwNWNmYjgzNTg5MjViMDJiNmU3ZjBhN2NiZTViYzk=
9
+ NDFkZjJhMWU2MzdlNzA4YzQyNDE0ZTljNzViZjI2ZDIwYzllNWM2YTA5NWM5
10
+ ZjE1NTEwOGYyNTMyMDg2NDZkYmYyMTAzODcxYTU4MDUzMjJjMjc5NDRjNDMw
11
+ ZDJmOWI3NmNjNzU5OGViNDViMjQ2MzY5ZDViN2I4YjE5OTk3NGE=
12
12
  data.tar.gz: !binary |-
13
- MmVjNmY5Yjk0NDZhMzFlNDI2MTMyZWYxYjkzZGQ0MDM5ODMzODM3ZmQ2MTI4
14
- NzRkYjY1NWFhYzdkMGI4ZmYzYzk5YWYzNGUyMzZhZjRhZjdiNWI4N2Q4ZTIy
15
- MGY3MDdjM2Y1ZjdhZDY1YzZkZWRhZjcxYjk0YmYyNzZmYzliMTk=
13
+ ZWFkNWFjYzY3ODM1N2E0YjM3NDhjNTNlMDlmMDE3MWQ3Mzc5YTA4NmVhMWQ2
14
+ NzM5NTJlMmYwZmE1MGFmMGQyMTYzZWVlMDU1OTkwNDY3ODEyZGU5ZWEwMmQ3
15
+ YjgyYjgwNWM0OTI2NWJmMTM3ZTY0ZGNjNjQwOWY2MjMwNWZjMjc=
@@ -0,0 +1,52 @@
1
+ require 'rails/generators/migration'
2
+
3
+ class Spud::ModuleGenerator < ::Rails::Generators::Base
4
+ desc "Creates a new model, dashboard module, and frontend route"
5
+ argument :module_name, :type => :string
6
+ argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def create_module
11
+ template "admin_controller.rb.erb", "app/controllers/admin/#{module_name_formatted}_controller.rb"
12
+ template "controller.rb.erb", "app/controllers/#{module_name_formatted}_controller.rb"
13
+ template "views/admin/index.html.erb", "app/views/admin/#{module_name_formatted}/index.html.erb"
14
+ template "views/admin/new.html.erb", "app/views/admin/#{module_name_formatted}/new.html.erb"
15
+ template "views/admin/edit.html.erb", "app/views/admin/#{module_name_formatted}/edit.html.erb"
16
+ template "views/admin/_form.html.erb", "app/views/admin/#{module_name_formatted}/_form.html.erb"
17
+ template "views/frontend/index.html.erb", "app/views/#{module_name_formatted}/index.html.erb"
18
+ template "views/frontend/show.html.erb", "app/views/#{module_name_formatted}/show.html.erb"
19
+ environment("Spud::Core.config.admin_applications += [{:name => '#{module_name_formatted.humanize.titlecase}', :thumbnail => \"/assets/admin/portfolio.png\",:url => \"/admin/#{module_name_formatted}\"}]")
20
+ create_routes
21
+ invoke "model", [module_name_formatted.singularize] + attributes
22
+ end
23
+
24
+ private
25
+
26
+ def module_name_formatted
27
+ module_name.pluralize.downcase.underscore
28
+ end
29
+
30
+ def create_routes
31
+ route <<EOF
32
+ namespace :admin do
33
+ resources :#{module_name_formatted}
34
+ end
35
+ resources :#{module_name_formatted}, :only => [:index, :show]
36
+ EOF
37
+ end
38
+
39
+ def field_for_attribute(type, name)
40
+ case type
41
+ when 'integer'
42
+ "<%= f.number_field :#{name} %>"
43
+ when 'text'
44
+ "<%= f.text_area :#{name}, :rows => 4 %>"
45
+ when 'boolean'
46
+ "<%= f.check_box :#{name} %>"
47
+ else
48
+ "<%= f.text_field :#{name} %>"
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,54 @@
1
+ class Admin::<%= module_name_formatted.camelize%>Controller < Admin::ApplicationController
2
+
3
+ before_filter :load_<%= module_name_formatted.singularize %>, :only => [:show, :edit, :update, :destroy]
4
+ belongs_to_spud_app :<%= module_name_formatted %>
5
+ add_breadcrumb "<%= module_name_formatted.humanize.titlecase %>", :admin_<%= module_name_formatted %>_path
6
+
7
+ def index
8
+ @<%= module_name_formatted %> = <%= module_name_formatted.singularize.camelize %>.paginate(:page => params[:page])
9
+ respond_with @<%= module_name_formatted %>
10
+ end
11
+
12
+ def show
13
+ respond_with @<%= module_name_formatted %>
14
+ end
15
+
16
+ def new
17
+ @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.new
18
+ respond_with @<%= module_name_formatted.singularize %>
19
+ end
20
+
21
+ def create
22
+ @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.new(params[:<%= module_name_formatted.singularize %>])
23
+ flash[:notice] = '<%= module_name_formatted.singularize.camelize %> created successfully' if @<%= module_name_formatted.singularize %>.save
24
+ respond_with @<%= module_name_formatted.singularize %>, :location => admin_<%= module_name_formatted %>_path
25
+ end
26
+
27
+ def edit
28
+ respond_with @<%= module_name_formatted.singularize %>
29
+ end
30
+
31
+ def update
32
+ if @<%= module_name_formatted.singularize%>.update_attributes(params[:<%= module_name_formatted.singularize%>])
33
+ flash[:notice] = '<%= module_name_formatted.singularize.camelize %> updated successfully'
34
+ end
35
+ respond_with @<%= module_name_formatted.singularize %>, :location => admin_<%= module_name_formatted %>_path
36
+ end
37
+
38
+ def destroy
39
+ flash[:notice] = '<%= module_name_formatted.singularize.camelize %> deleted successfully' if @<%= module_name_formatted.singularize %>.destroy
40
+ respond_with @<%= module_name_formatted.singularize %>, :location => admin_<%= module_name_formatted %>_path
41
+ end
42
+
43
+ private
44
+
45
+ def load_<%= module_name_formatted.singularize %>
46
+ @<%= module_name_formatted.singularize %> = <%= module_name_formatted.singularize.camelize %>.where(:id => params[:id]).first
47
+ if @<%= module_name_formatted.singularize %>.blank?
48
+ flash[:error] = "Could not find the requested <%= module_name_formatted.singularize.camelize %>"
49
+ redirect_to admin_<%= module_name_formatted %>_path
50
+ return false
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,25 @@
1
+ class <%=module_name_formatted.camelize%>Controller < ApplicationController
2
+
3
+ respond_to :html
4
+ before_filter :load_<%=module_name_formatted.singularize%>, :only => [:show]
5
+
6
+ def index
7
+ @<%=module_name_formatted%> = <%=module_name_formatted.singularize.camelize%>.paginate(:page => params[:page])
8
+ respond_with @<%=module_name_formatted%>
9
+ end
10
+
11
+ def show
12
+ respond_with @<%=module_name_formatted%>
13
+ end
14
+
15
+ private
16
+
17
+ def load_<%=module_name_formatted.singularize%>
18
+ @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.where(:id => params[:id]).first
19
+ if @<%=module_name_formatted.singularize%>.blank?
20
+ raise Spud::NotFoundError
21
+ return false
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,20 @@
1
+ <%%= form_for [:admin, @<%=module_name_formatted.singularize%>], :html => {:class => 'form-horizontal'} do |f| %>
2
+
3
+ <%%= error_messages_for(f.object) %>
4
+
5
+ <fieldset>
6
+ <legend>Details</legend> <%attributes.each do |attribute|%>
7
+ <%attribute_args = attribute.split(":")%>
8
+ <div class="control-group">
9
+ <%%= f.label :<%=attribute_args[0]%>, :class => "control-label" %>
10
+ <div class="controls">
11
+ <%= field_for_attribute(attribute_args[1], attribute_args[0]) %>
12
+ </div>
13
+ </div> <%end%>
14
+ </fieldset>
15
+
16
+ <div class="form-actions">
17
+ <%%= f.submit "Save <%=module_name_formatted.singularize.humanize.titlecase%>", :class => "btn btn-primary form-btn", "data-loading-text" => "Saving..." %> or <%%= link_to "Cancel", admin_<%= module_name_formatted %>_path, :class => "btn" %>
18
+ </div>
19
+
20
+ <%% end %>
@@ -0,0 +1 @@
1
+ <%%= render 'form' %>
@@ -0,0 +1,30 @@
1
+ <%% content_for :data_controls do %>
2
+ <%%= link_to "New <%=module_name_formatted.singularize.humanize.titlecase%>", new_admin_<%=module_name_formatted.singularize%>_path, :class => "btn btn-primary", :title => "New <%=module_name_formatted.singularize.humanize.titlecase%>" %>
3
+ <%% end %>
4
+
5
+ <%% content_for :detail do %>
6
+ <table class="table table-striped">
7
+ <thead>
8
+ <tr><%attributes.each do |attribute|%>
9
+ <%-attribute_args = attribute.split(":")-%>
10
+ <th><%=attribute_args[0].humanize.titlecase%></th><% end %>
11
+ <th>Actions</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <%% @<%=module_name_formatted%>.each do |<%=module_name_formatted.singularize%>| %>
16
+ <tr>
17
+ <%-attributes.each do |attribute|-%>
18
+ <%-attribute_args = attribute.split(":")-%>
19
+ <td><%%= <%=module_name_formatted.singularize%>.<%=attribute_args[0]%> %></td>
20
+ <%-end-%>
21
+ <td align="right" width="150">
22
+ <%%= link_to 'Edit', edit_admin_<%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>), :class => 'btn btn-mini' %>
23
+ <%%= link_to 'Delete', admin_<%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>), :method => :delete, :confirm => 'Are you sure you want to delete this <%=module_name_formatted.singularize.humanize%>?', :class => 'btn btn-danger btn-mini' %>
24
+ </td>
25
+ </tr>
26
+ <%% end %>
27
+ </tbody>
28
+ </table>
29
+ <%%= will_paginate @<%=module_name_formatted%> %>
30
+ <%% end %>
@@ -0,0 +1 @@
1
+ <%%= render 'form' %>
@@ -0,0 +1,22 @@
1
+ <h1><%= module_name_formatted.pluralize.camelize %></h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr><%attributes.each do |attribute|%>
6
+ <%-attribute_args = attribute.split(":")-%>
7
+ <th><%=attribute_args[0].humanize.titlecase%></th> <%end%>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <%% @<%=module_name_formatted%>.each do |<%=module_name_formatted.singularize%>| %>
12
+ <tr>
13
+ <%-attributes.each do |attribute|-%>
14
+ <%-attribute_args = attribute.split(":")-%>
15
+ <td><%%= <%=module_name_formatted.singularize%>.<%=attribute_args[0]%> %></td>
16
+ <%-end-%>
17
+ <td><%%= link_to 'Details', <%=module_name_formatted.singularize%>_path(<%=module_name_formatted.singularize%>) %></td>
18
+ </tr>
19
+ <%% end %>
20
+ </tbody>
21
+ </table>
22
+ <%%=will_paginate @<%=module_name_formatted%>%>
@@ -0,0 +1,8 @@
1
+ <h1><%= module_name_formatted.singularize.camelize %></h1>
2
+
3
+ <%-attributes.each do |attribute|-%>
4
+ <%-attribute_args = attribute.split(":")-%>
5
+ <p><strong><%=attribute_args[0].humanize.titlecase%></strong> <%%=@<%=module_name_formatted.singularize%>.<%=attribute_args[0]%> %></p>
6
+ <%-end-%>
7
+
8
+ <p><%%= link_to 'Back', <%=module_name_formatted.pluralize%>_path %></p>
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.1.5"
3
+ VERSION = "1.1.6"
4
4
  end
5
5
  end