active_leonardo 0.0.2
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.
- data/CHANGELOG +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +157 -0
- data/active_template.rb +88 -0
- data/lib/generators/active_leonardo.rb +334 -0
- data/lib/generators/erb/leosca/leosca_generator.rb +122 -0
- data/lib/generators/leolay/USAGE +21 -0
- data/lib/generators/leolay/install_generator.rb +16 -0
- data/lib/generators/leolay/leolay_generator.rb +368 -0
- data/lib/generators/leolay/templates/app/admin/users.rb +63 -0
- data/lib/generators/leolay/templates/app/assets/javascripts/custom.js +10 -0
- data/lib/generators/leolay/templates/app/helpers/layout_helper.rb +27 -0
- data/lib/generators/leolay/templates/app/views/admin/users/_form.html.erb +21 -0
- data/lib/generators/leolay/templates/config.rb +11 -0
- data/lib/generators/leolay/templates/config/locales/en.yml +271 -0
- data/lib/generators/leolay/templates/config/locales/it.yml +298 -0
- data/lib/generators/leolay/templates/lib/development_mail_interceptor.rb +6 -0
- data/lib/generators/leolay/templates/lib/upd_activeadmin.rb +65 -0
- data/lib/generators/leolay/templates/lib/upd_array.rb +25 -0
- data/lib/generators/leolay/templates/styles/active/images/logo.png +0 -0
- data/lib/generators/leolay/templates/styles/active/images/style/Thumbs.db +0 -0
- data/lib/generators/leolay/templates/styles/active/images/style/ico_v.png +0 -0
- data/lib/generators/leolay/templates/styles/active/images/style/ico_x.png +0 -0
- data/lib/generators/leolay/templates/styles/active/stylesheets/app/_enviroment.css.scss +25 -0
- data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss +23 -0
- data/lib/generators/leolay/templates/styles/active/stylesheets/app/stylesheet.css.scss +51 -0
- data/lib/generators/leolay/templates/styles/active/views/layout/_message.html.erb +3 -0
- data/lib/generators/leolay/templates/styles/active/views/layout/_session.html.erb +10 -0
- data/lib/generators/leolay/templates/styles/active/views/layout/application.html.erb +45 -0
- data/lib/generators/leosca/USAGE +23 -0
- data/lib/generators/leosca/install_generator.rb +16 -0
- data/lib/generators/rails/leosca/USAGE +40 -0
- data/lib/generators/rails/leosca/leosca_generator.rb +56 -0
- data/lib/generators/rails/leosca/templates/leosca.css +56 -0
- data/lib/generators/rails/leosca_controller/USAGE +23 -0
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +197 -0
- data/lib/generators/rails/leosca_controller/templates/controller.rb +3 -0
- metadata +117 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
module ActiveAdmin
|
3
|
+
module Views
|
4
|
+
module Pages
|
5
|
+
|
6
|
+
#Custom footer
|
7
|
+
#\lib\active_admin\views\pages\base.rb
|
8
|
+
class Base < Arbre::HTML::Document
|
9
|
+
private
|
10
|
+
def build_footer
|
11
|
+
div :id => "footer" do
|
12
|
+
para "#{CONFIG[:application][:name]} #{Rails.env} #{CONFIG[:application][:version]} <%= Time.now.year %>.".html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#Avoid xml and json from download
|
20
|
+
#\lib\active_admin\views\components\paginated_collection.rb
|
21
|
+
#class PaginatedCollection
|
22
|
+
# def build_download_format_links(formats = [:csv])
|
23
|
+
# links = formats.collect do |format|
|
24
|
+
# link_to format.to_s.upcase, { :format => format}.merge(request.query_parameters.except(:commit, :format))
|
25
|
+
# end
|
26
|
+
# div :class => "download_links" do
|
27
|
+
# text_node [I18n.t('active_admin.download'), links].flatten.join(" ").html_safe
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
#class Resource
|
35
|
+
# module ActionItems
|
36
|
+
# private
|
37
|
+
#
|
38
|
+
# # Adds the default action items to each resource
|
39
|
+
# def add_default_action_items
|
40
|
+
# # New Link on all actions except :new and :show
|
41
|
+
# add_action_item :except => [:new, :show] do
|
42
|
+
# if controller.action_methods.include?('new') && can?(:create, eval(active_admin_config.resource_name.classify))
|
43
|
+
# link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_name), new_resource_path)
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# # Edit link on show
|
48
|
+
# add_action_item :only => :show do
|
49
|
+
# if controller.action_methods.include?('edit') && can?(:edit, resource)
|
50
|
+
# link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_name), edit_resource_path(resource))
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# # Destroy link on show
|
55
|
+
# add_action_item :only => :show do
|
56
|
+
# if controller.action_methods.include?("destroy") && can?(:destroy, resource)
|
57
|
+
# link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_name),
|
58
|
+
# resource_path(resource),
|
59
|
+
# :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'))
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
#end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Array
|
2
|
+
#Find in collection where :search condition is matched and return a fields if param :get is passed
|
3
|
+
#otherwise it return the item
|
4
|
+
#Example1 Articles.quickly :search => {:id => 1}, :get => :title
|
5
|
+
#Example2 People.quickly :search => {:fiscal_code => ABCDFG01H02I100J}
|
6
|
+
def item(options={})
|
7
|
+
#:search => {:id => 3}
|
8
|
+
#:get => :name
|
9
|
+
options = {
|
10
|
+
:search => nil,
|
11
|
+
:get => nil
|
12
|
+
}.merge(options)
|
13
|
+
raise "Array.trova: specify required parameters!" unless options[:search]
|
14
|
+
self.each do |item|
|
15
|
+
condition = nil
|
16
|
+
options[:search].each do |label, value|
|
17
|
+
condition = (item[label] == value)
|
18
|
+
break unless condition
|
19
|
+
end
|
20
|
+
next unless condition
|
21
|
+
return (options[:get] ? item[options[:get]] : item)
|
22
|
+
end
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//Uncomment these lines in production to have a different color
|
2
|
+
//$env-color: rgb(250,50,50);
|
3
|
+
//
|
4
|
+
//@mixin primary-gradient {
|
5
|
+
// @include gradient(darken($env-color, 20%), darken($env-color, 33%));
|
6
|
+
// border-bottom: 1px solid darken($env-color, 38%);
|
7
|
+
//}
|
8
|
+
//
|
9
|
+
//#header {
|
10
|
+
// @include primary-gradient;
|
11
|
+
// ul#tabs > li.current > a {
|
12
|
+
// background-color: darken($env-color, 15%);
|
13
|
+
// }
|
14
|
+
// ul#tabs > li:hover > a {
|
15
|
+
// background-color: darken($env-color, 10%);
|
16
|
+
// }
|
17
|
+
//}
|
18
|
+
//.table_tools_segmented_control li.selected {
|
19
|
+
// a {
|
20
|
+
// color: $env-color;
|
21
|
+
// }
|
22
|
+
// a:hover {
|
23
|
+
// color: darken($env-color, 20%);
|
24
|
+
// }
|
25
|
+
//}
|
data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
@import "enviroment";
|
2
|
+
|
3
|
+
#active_admin_content {
|
4
|
+
padding: 10px 10px;
|
5
|
+
}
|
6
|
+
.price {
|
7
|
+
text-align: right;
|
8
|
+
}
|
9
|
+
table.index_table tr.odd.selected td {
|
10
|
+
background: none repeat scroll 0 0 #FFFFBD;
|
11
|
+
}
|
12
|
+
table.index_table tr.even.selected td {
|
13
|
+
background: none repeat scroll 0 0 #FFFFAC;
|
14
|
+
}
|
15
|
+
.table_tools_segmented_control li.selected {
|
16
|
+
a {
|
17
|
+
background-color: #E6E6E6;
|
18
|
+
cursor: pointer;
|
19
|
+
}
|
20
|
+
a:hover {
|
21
|
+
color: inherit;
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
@import "active_admin/mixins";
|
2
|
+
@import "active_admin/base";
|
3
|
+
@import "enviroment";
|
4
|
+
@import "active_admin/pages/logged_out";
|
5
|
+
|
6
|
+
#header {
|
7
|
+
#session {
|
8
|
+
display: inline-block;
|
9
|
+
color: #cdcdcd;
|
10
|
+
float: right;
|
11
|
+
margin-right: 20px;
|
12
|
+
margin-bottom: 0px;
|
13
|
+
padding-top: 3px;
|
14
|
+
font-size: 1em;
|
15
|
+
font-weight: normal;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
body.logged_out #content_wrapper {
|
19
|
+
width: 600px;
|
20
|
+
}
|
21
|
+
ul li {
|
22
|
+
list-style-type: circle;
|
23
|
+
}
|
24
|
+
|
25
|
+
#login {
|
26
|
+
form {
|
27
|
+
input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], textarea {
|
28
|
+
//width: 76%;
|
29
|
+
//border: 1px solid #c9d0d6;
|
30
|
+
//@include rounded;
|
31
|
+
//font-size: 0.95em;
|
32
|
+
//@include sans-family;
|
33
|
+
//outline: none;
|
34
|
+
padding: 8px 7px;
|
35
|
+
|
36
|
+
//&:focus {
|
37
|
+
// border: 1px solid #99a2aa;
|
38
|
+
// @include shadow(0,0,4px,#99a2aa);
|
39
|
+
//}
|
40
|
+
}
|
41
|
+
input[type=submit] {
|
42
|
+
@include dark-button;
|
43
|
+
margin-left: 20px;
|
44
|
+
//padding: 4px 8px;
|
45
|
+
}
|
46
|
+
//.buttons {
|
47
|
+
// margin-top: 15px;
|
48
|
+
// //input[type=submit] { margin-right: 10px; }
|
49
|
+
//}
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div id="session">
|
2
|
+
<%- if user_signed_in? -%>
|
3
|
+
<%= t("authentication.signed_in_as") %> <strong><%= current_user.email || "Guest" %></strong>. <%= t("authentication.not_you") %>
|
4
|
+
<%= link_to t("authentication.sign_out"), destroy_user_session_path, :method => :delete %>
|
5
|
+
<%- else -%>
|
6
|
+
<%= link_to t("authentication.sign_up"), new_user_registration_path %> -
|
7
|
+
<%= link_to t("authentication.sign_in"), new_user_session_path %>
|
8
|
+
<%- end -%>
|
9
|
+
</div>
|
10
|
+
<div class="clear"></div>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= "#{CONFIG[:application][:name]} #{controller.controller_name.capitalize}: #{controller.action_name}" %></title>
|
5
|
+
<%= stylesheet_link_tag "application" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
<%= yield(:head) %>
|
9
|
+
</head>
|
10
|
+
<body class="<%= user_signed_in? ? "logged_out" : "logged_out" -%>">
|
11
|
+
<div id="wrapper">
|
12
|
+
<div id="header">
|
13
|
+
<div id="site_title">
|
14
|
+
<h1><%= link_to CONFIG[:application][:name], root_url %> <span class="subtitle"><%= Rails.env %> <%= CONFIG[:application][:version] %></span></h1>
|
15
|
+
</div>
|
16
|
+
<div class="clear"></div>
|
17
|
+
<%= render 'session' %>
|
18
|
+
<div class="clear"></div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<% if show_title? -%>
|
22
|
+
<div id="title_bar">
|
23
|
+
<div id="titlebar_left">
|
24
|
+
<span class="breadcrumb">
|
25
|
+
<a href="/">Home</a>
|
26
|
+
<span class="breadcrumb_sep">/</span>
|
27
|
+
</span>
|
28
|
+
<h2 id="page_title"><%= yield(:title) %></h2>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<% end -%>
|
32
|
+
<div id="content_wrapper">
|
33
|
+
<%= render 'message' %>
|
34
|
+
<div id="active_admin_content">
|
35
|
+
<%= yield %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="footer" style="text-align: center">
|
40
|
+
<p><%= image_tag("logo.png") %><br />
|
41
|
+
<%= "#{CONFIG[:application][:name]} #{Rails.env} #{CONFIG[:application][:version]} 2012." %> </p>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</body>
|
45
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Description:
|
2
|
+
en: Copy all templates in the project directory lib \ generators to allow customization.
|
3
|
+
it: Copia tutti i template nella directory del progetto lib\generators per consentire la personalizzazione.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
rails generate leosca:install
|
7
|
+
|
8
|
+
This will create:
|
9
|
+
lib/generators/erb/leosca/USAGE
|
10
|
+
lib/generators/erb/leosca/leosca_generator.rb
|
11
|
+
lib/generators/erb/leosca/templates/_form.html.erb
|
12
|
+
lib/generators/erb/leosca/templates/_list.erb
|
13
|
+
lib/generators/erb/leosca/templates/edit.html.erb
|
14
|
+
lib/generators/erb/leosca/templates/index.html.erb
|
15
|
+
lib/generators/erb/leosca/templates/index.js.erb
|
16
|
+
lib/generators/erb/leosca/templates/new.html.erb
|
17
|
+
lib/generators/erb/leosca/templates/show.html.erb
|
18
|
+
lib/generators/rails/leosca/USAGE
|
19
|
+
lib/generators/rails/leosca/leosca_generator.rb
|
20
|
+
lib/generators/rails/leosca/templates/leosca.css
|
21
|
+
lib/generators/rails/leosca_controller/USAGE
|
22
|
+
lib/generators/rails/leosca_controller/leosca_controller_generator.rb
|
23
|
+
lib/generators/rails/leosca_controller/templates/controller.rb
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Leosca
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../../', __FILE__)
|
5
|
+
class_option :erb, :type => :boolean, :default => true, :description => "Copy erb files"
|
6
|
+
|
7
|
+
def copy_templates_to_local
|
8
|
+
#directory "erb/leosca", "lib/generators/erb/leosca" if options.erb?
|
9
|
+
directory "rails/leosca", "lib/generators/rails/leosca"
|
10
|
+
directory "rails/leosca_controller", "lib/generators/rails/leosca_controller"
|
11
|
+
copy_file "active_leonardo.rb", "lib/generators/active_leonardo.rb"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Description:
|
2
|
+
en: Customized version of rails's scaffold, to be used after leolay.
|
3
|
+
it: Versione personalizzata dello scaffold di rails, da usare dopo leolay.
|
4
|
+
|
5
|
+
Scaffolds an entire resource, from model and migration to controller and
|
6
|
+
views, along with a full test suite. The resource is ready to use as a
|
7
|
+
starting point for your RESTful, resource-oriented application.
|
8
|
+
|
9
|
+
Pass the name of the model (in singular form), either CamelCased or
|
10
|
+
under_scored, as the first argument, and an optional list of attribute
|
11
|
+
pairs.
|
12
|
+
|
13
|
+
Attribute pairs are field:type arguments specifying the
|
14
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
15
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
16
|
+
|
17
|
+
You don't have to think up every attribute up front, but it helps to
|
18
|
+
sketch out a few so you can start working with the resource immediately.
|
19
|
+
|
20
|
+
For example, 'scaffold post title:string body:text published:boolean'
|
21
|
+
gives you a model with those three attributes, a controller that handles
|
22
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
23
|
+
an index that lists them all, as well as a resources :posts
|
24
|
+
declaration in config/routes.rb.
|
25
|
+
|
26
|
+
If you want to remove all the generated files, run
|
27
|
+
'rails destroy scaffold ModelName'.
|
28
|
+
|
29
|
+
Use after leolay:
|
30
|
+
1. rails generate leolay
|
31
|
+
2. rails generate leosca
|
32
|
+
|
33
|
+
Usage example:
|
34
|
+
rails generate leosca product name:string description:text active:boolean items:integer price:decimal
|
35
|
+
|
36
|
+
Available options:
|
37
|
+
rails generate leosca product name:string --skip-seeds
|
38
|
+
rails generate leosca product name:string --seeds=60 => if you need more records
|
39
|
+
|
40
|
+
Of course, these options are in addition to those provided by the original scaffold
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rails/generators/rails/scaffold/scaffold_generator'
|
2
|
+
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
module Generators
|
6
|
+
class LeoscaGenerator < ::Rails::Generators::ScaffoldGenerator
|
7
|
+
include ::ActiveLeonardo::Base
|
8
|
+
#include ::Leonardo::Nested
|
9
|
+
#puts 'rails:leosca'
|
10
|
+
|
11
|
+
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
12
|
+
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
13
|
+
|
14
|
+
remove_hook_for :scaffold_controller
|
15
|
+
hook_for :leosca_controller, :required => true
|
16
|
+
|
17
|
+
#Override
|
18
|
+
#def add_resource_route
|
19
|
+
# return if options[:actions].present?
|
20
|
+
#
|
21
|
+
# route_config = ""
|
22
|
+
# iparent = 0
|
23
|
+
#
|
24
|
+
# if nested?
|
25
|
+
# plural_parent_resources.each do |m|
|
26
|
+
# iparent += 2
|
27
|
+
# indent = eval "/^\s{#{16 - iparent}}/"
|
28
|
+
# route_config << <<-FILE.gsub(indent, '')
|
29
|
+
# resources :#{m} do
|
30
|
+
# get :with_#{file_name.pluralize}
|
31
|
+
# post :select, :on => :collection
|
32
|
+
# post :edit_multiple, :on => :collection
|
33
|
+
# put :update_multiple, :on => :collection
|
34
|
+
# put :create_multiple, :on => :collection
|
35
|
+
# FILE
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# route_config << base_namespaces.map{|m| "namespace :#{m} do " }.join(" ") if leospaced?
|
39
|
+
# route_config << regular_class_path.map{|m| "namespace :#{m} do " }.join(" ")
|
40
|
+
# indent = eval "/^\s{#{8 - iparent}}/"
|
41
|
+
# route_config << <<-FILE.gsub(indent, '')
|
42
|
+
#
|
43
|
+
# resources :#{file_name.pluralize} do
|
44
|
+
# post :select, :on => :collection
|
45
|
+
# post :edit_multiple, :on => :collection
|
46
|
+
# put :update_multiple, :on => :collection
|
47
|
+
# put :create_multiple, :on => :collection
|
48
|
+
# end
|
49
|
+
# FILE
|
50
|
+
# route_config << " end" * (regular_class_path.size + plural_parent_resources.size + base_namespaces.size)
|
51
|
+
# route route_config
|
52
|
+
#end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|