crud 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1 -0
- data/LICENSE.md +674 -0
- data/README.md +136 -0
- data/Rakefile +72 -0
- data/app/assets/images/crud/search-icon.png +0 -0
- data/app/assets/javascripts/crud/application.js +17 -0
- data/app/assets/javascripts/crud/dashboard.js +7 -0
- data/app/assets/javascripts/crud/pagination.js +41 -0
- data/app/assets/stylesheets/crud/application.css +27 -0
- data/app/assets/stylesheets/crud/dashboard.css +4 -0
- data/app/assets/stylesheets/crud/flash_notices.css +19 -0
- data/app/assets/stylesheets/crud/pagination.css +104 -0
- data/app/assets/stylesheets/dataTables/jquery.dataTables-override.css +20 -0
- data/app/controllers/crud/crud_base_controller.rb +28 -0
- data/app/controllers/crud/crud_controller.rb +149 -0
- data/app/controllers/crud/dashboard_controller.rb +17 -0
- data/app/helpers/crud/crud_helper.rb +104 -0
- data/app/helpers/crud/dashboard_helper.rb +4 -0
- data/app/models/crud/klass_info.rb +166 -0
- data/app/models/crud/klass_list.rb +51 -0
- data/app/models/crud/menus/development_menu.rb +63 -0
- data/app/views/crud/crud/_attribute_value.html.erb +5 -0
- data/app/views/crud/crud/_error_messages.html.erb +10 -0
- data/app/views/crud/crud/_flash_messages.html.erb +10 -0
- data/app/views/crud/crud/_form.html.erb +22 -0
- data/app/views/crud/crud/_klass_data.html.erb +117 -0
- data/app/views/crud/crud/edit.html.erb +17 -0
- data/app/views/crud/crud/index.html.erb +6 -0
- data/app/views/crud/crud/index.js.erb +1 -0
- data/app/views/crud/crud/new.html.erb +13 -0
- data/app/views/crud/crud/show.html.erb +69 -0
- data/app/views/crud/dashboard/index.html.erb +15 -0
- data/app/views/layouts/crud/application.html.erb +13 -0
- data/config/cucumber.yml +8 -0
- data/config/initializers/inflections.rb +5 -0
- data/config/initializers/rails_engine.rb +8 -0
- data/config/initializers/will_paginate.rb +1 -0
- data/config/locales/de.yml +3 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/es.yml +3 -0
- data/config/locales/fr.yml +3 -0
- data/config/routes.rb +16 -0
- data/crud.gemspec +29 -0
- data/lib/crud.rb +144 -0
- data/lib/crud/engine.rb +23 -0
- data/lib/crud/version.rb +3 -0
- data/lib/tasks/crud_tasks.rake +4 -0
- metadata +157 -0
data/README.md
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# CRUD
|
2
|
+
|
3
|
+
This gem is a simple mechanism to allow you to develop your rails applications using models and custom views alone (no need to generate and throw away scaffolding anymore).
|
4
|
+
|
5
|
+
It provides all of the basic CRUD functionality of the standard controllers/views generated by the scaffolding operations.
|
6
|
+
|
7
|
+
There are some small extensions which will allow you to extend the functionality for your own purpose.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
To 'Gemfile', add:
|
12
|
+
|
13
|
+
gem 'crud'
|
14
|
+
|
15
|
+
To 'config/routes.rb', add:
|
16
|
+
|
17
|
+
mount Crud::Engine => "/crud", :as => :crud
|
18
|
+
|
19
|
+
|
20
|
+
Create 'config/iniializers/crud.rb', containing:
|
21
|
+
|
22
|
+
# Initialisation
|
23
|
+
Crud.setup do |config|
|
24
|
+
# Set model path
|
25
|
+
# Allow clients to register paths containing models. The backend determines
|
26
|
+
# acceptable model sources.
|
27
|
+
#
|
28
|
+
# Clients may register additional paths like this:
|
29
|
+
# model_path << 'path/to/model/directory'
|
30
|
+
config.model_path << File.join(Rails.root, 'app', 'models')
|
31
|
+
|
32
|
+
|
33
|
+
# Allow clients to customise the appearance of fields when rendering model data.
|
34
|
+
#
|
35
|
+
# :class
|
36
|
+
# The fully qualified name of the model to which this definition applies
|
37
|
+
#
|
38
|
+
# NOTE: If :class is set to :all, the definition will apply to all models.
|
39
|
+
#
|
40
|
+
# :hidden_fields
|
41
|
+
# If :hidden_fields contains an existing column, the column will not be displayed
|
42
|
+
#
|
43
|
+
# :only
|
44
|
+
# Filter to define in which views this definition applies.
|
45
|
+
# Valid values: :index, :show, :new, :edit
|
46
|
+
#
|
47
|
+
# Clients may register column settings like this:
|
48
|
+
# column_settings << { :class => 'Model',
|
49
|
+
# :hidden_fields => [:id, :created_at, :updated_at],
|
50
|
+
# :only => [:index, :show ]
|
51
|
+
# }
|
52
|
+
#
|
53
|
+
# column_settings << { :class => :all,
|
54
|
+
# :hidden_fields => [:id, :created_at, :updated_at],
|
55
|
+
# :only => [:index, :show],
|
56
|
+
# }
|
57
|
+
#
|
58
|
+
|
59
|
+
# Allow clients to register additional customisation to fields when rendering
|
60
|
+
# model data.
|
61
|
+
#
|
62
|
+
# :global
|
63
|
+
# If :global is specified and set to 'true', the partial will be at the end
|
64
|
+
# as an extension of the active view.
|
65
|
+
#
|
66
|
+
# :column_name
|
67
|
+
# If :column_name is an existing column, the partial will be rendered alongside
|
68
|
+
# the default, unless :column_replacement is set to true
|
69
|
+
#
|
70
|
+
# NOTE: The functionality of :column_name and :global are mutually exclusive.
|
71
|
+
# As such, if both are specified, :global will take presedence
|
72
|
+
#
|
73
|
+
# :column_replacement
|
74
|
+
# Flag to indicate whether this customisation should replace the default or
|
75
|
+
# appear alongside the default.
|
76
|
+
#
|
77
|
+
# :record_data_parameter
|
78
|
+
# :record_data_parameter is the name of the symbol used for passing the record
|
79
|
+
# data to the partial.
|
80
|
+
#
|
81
|
+
# :additional_partial_parameters
|
82
|
+
# A hash containing any additional partial parameters
|
83
|
+
#
|
84
|
+
# :only
|
85
|
+
# Filter to define in which views the extension applies.
|
86
|
+
# Valid values: :index, :show, :new, :edit
|
87
|
+
#
|
88
|
+
# Clients may register custom fields like this:
|
89
|
+
# custom_fields << { :class => 'Model',
|
90
|
+
# :only => [:index, :show ],
|
91
|
+
# :global => false,
|
92
|
+
# :column_name => 'id',
|
93
|
+
# :column_replacement => true,
|
94
|
+
# :partial => 'partial_path', :record_data_parameter => 'data',
|
95
|
+
# :additional_partial_parameters => {:size => 20, :contract => true}
|
96
|
+
# }
|
97
|
+
#
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
Start and browse to your application url '/crud'
|
102
|
+
|
103
|
+
http://localhost:3000/crud
|
104
|
+
|
105
|
+
## Examples
|
106
|
+
|
107
|
+
See the test application under spec/dummy
|
108
|
+
|
109
|
+
## Links
|
110
|
+
|
111
|
+
* Homepage: <https://github.com/htcl/crud>
|
112
|
+
* Source code: <https://github.com/htcl/crud>
|
113
|
+
* RubyGem: <https://rubygems.org/gems/crud>
|
114
|
+
* Travis CI: <https://travis-ci.org/htcl/crud>
|
115
|
+
|
116
|
+
## Authors
|
117
|
+
|
118
|
+
* Everard Brown <mailto:everard.brown@htcl.eu>
|
119
|
+
|
120
|
+
## Licence
|
121
|
+
|
122
|
+
Copyright (c) 2013-2014 Everard Brown
|
123
|
+
|
124
|
+
This program is free software: you can redistribute it and/or modify
|
125
|
+
it under the terms of the GNU General Public License as published by
|
126
|
+
the Free Software Foundation, either version 3 of the License, or
|
127
|
+
(at your option) any later version.
|
128
|
+
|
129
|
+
Level is distributed in the hope that it will be useful,
|
130
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
131
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
132
|
+
GNU General Public License for more details.
|
133
|
+
|
134
|
+
You should have received a copy of the GNU General Public License
|
135
|
+
along with Level. If not, see <http://www.gnu.org/licenses/>
|
136
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Crud'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Encourage the visibilty of application-bourne rake tasks
|
24
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
25
|
+
load 'rails/tasks/engine.rake'
|
26
|
+
|
27
|
+
# Test::Unit tasks
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# RSpec 1.x tasks
|
39
|
+
#require 'spec/version'
|
40
|
+
#require 'spec/rake/spectask'
|
41
|
+
|
42
|
+
# RSpec 2.x tasks
|
43
|
+
if Rails.version.to_i < 3
|
44
|
+
require 'spec/rake/spectask'
|
45
|
+
rspec_task_class = 'Spec::Rake::SpecTask'
|
46
|
+
else
|
47
|
+
require 'rspec/core/rake_task'
|
48
|
+
rspec_task_class = 'RSpec::Core::RakeTask'
|
49
|
+
end
|
50
|
+
rspec_task_class.constantize.new(:spec)
|
51
|
+
|
52
|
+
# Alias for cucumber task
|
53
|
+
task :cucumber => 'app:cucumber'
|
54
|
+
|
55
|
+
# ci_reporter tasks
|
56
|
+
require 'rubygems'
|
57
|
+
require 'ci/reporter/rake/test_unit' # use this if you’re using Test::Unit
|
58
|
+
require 'ci/reporter/rake/rspec' # use this if you’re using RSpec
|
59
|
+
require 'ci/reporter/rake/cucumber' # use this if you're using Cucumber
|
60
|
+
|
61
|
+
# Aliases for CI tasks
|
62
|
+
task 'ci:all' => 'app:ci:all'
|
63
|
+
task 'ci:install_vendor_migrations' => 'app:ci:install_vendor_migrations'
|
64
|
+
task 'ci:all_tests' => 'app:ci:all_tests'
|
65
|
+
|
66
|
+
task :default => [:spec, :cucumber]
|
67
|
+
|
68
|
+
# Other useful aliases
|
69
|
+
task :routes => 'app:routes'
|
70
|
+
task :guard => 'app:guard'
|
71
|
+
|
72
|
+
Bundler::GemHelper.install_tasks
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= #require dataTables/jquery.dataTables
|
16
|
+
//= require_self
|
17
|
+
//= require_tree .
|
@@ -0,0 +1,41 @@
|
|
1
|
+
$(function() {
|
2
|
+
$(document).on("click", ".pagination a", function() {
|
3
|
+
$(".pagination_overlay").html("Page is loading...");
|
4
|
+
$.get(this.href, pagination_parameters(), null, "script");
|
5
|
+
return false;
|
6
|
+
});
|
7
|
+
|
8
|
+
$(document).on("change", "select#per_page", function() {
|
9
|
+
$(".pagination_overlay").html("Page is loading...");
|
10
|
+
$.get(this.href, pagination_parameters(), null, "script");
|
11
|
+
return false;
|
12
|
+
});
|
13
|
+
|
14
|
+
$(document).on("submit", "form#search_form", function() {
|
15
|
+
$(".pagination_overlay").html("Page is loading...");
|
16
|
+
$.get(this.href, pagination_parameters(), null, "script");
|
17
|
+
return false;
|
18
|
+
});
|
19
|
+
|
20
|
+
//$(document).on("change", "input#search", function() {
|
21
|
+
// $(".pagination_overlay").html("Page is loading...");
|
22
|
+
// $.get(this.href, pagination_parameters(), null, "script");
|
23
|
+
// return false;
|
24
|
+
//});
|
25
|
+
|
26
|
+
$(document).on("change", "input#advanced_search", function() {
|
27
|
+
$(".pagination_overlay").html("Page is loading...");
|
28
|
+
$.get(this.href, pagination_parameters(), null, "script");
|
29
|
+
return false;
|
30
|
+
});
|
31
|
+
|
32
|
+
function pagination_parameters()
|
33
|
+
{
|
34
|
+
return {
|
35
|
+
page: $("#crud_pagination input#page").val(),
|
36
|
+
per_page: $("#crud_pagination select#per_page").val(),
|
37
|
+
search: $("#crud_search input#search").val(),
|
38
|
+
advanced_search: $("#crud_search input#advanced_search").is(':checked')
|
39
|
+
};
|
40
|
+
}
|
41
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= #require dataTables/jquery.dataTables
|
12
|
+
*= #require dataTables/jquery.dataTables-override
|
13
|
+
*= require_self
|
14
|
+
*= require_tree .
|
15
|
+
*/
|
16
|
+
|
17
|
+
table#klass_table {
|
18
|
+
/* font-family: Fixed, monospace; */
|
19
|
+
}
|
20
|
+
|
21
|
+
table#klass_table thead {
|
22
|
+
/* font-size: 1em; */
|
23
|
+
}
|
24
|
+
|
25
|
+
table#klass_table tbody {
|
26
|
+
/* font-size: 0.99em; */
|
27
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
.digg_pagination {
|
2
|
+
background: white;
|
3
|
+
cursor: default;
|
4
|
+
/* self-clearing method: */ }
|
5
|
+
.digg_pagination a, .digg_pagination span, .digg_pagination em {
|
6
|
+
padding: 0.2em 0.5em;
|
7
|
+
display: block;
|
8
|
+
float: left;
|
9
|
+
margin-right: 1px; }
|
10
|
+
.digg_pagination .disabled {
|
11
|
+
color: #999999;
|
12
|
+
border: 1px solid #dddddd; }
|
13
|
+
.digg_pagination .current {
|
14
|
+
font-style: normal;
|
15
|
+
font-weight: bold;
|
16
|
+
background: #2e6ab1;
|
17
|
+
color: white;
|
18
|
+
border: 1px solid #2e6ab1; }
|
19
|
+
.digg_pagination a {
|
20
|
+
text-decoration: none;
|
21
|
+
color: #105cb6;
|
22
|
+
border: 1px solid #9aafe5; }
|
23
|
+
.digg_pagination a:hover, .digg_pagination a:focus {
|
24
|
+
color: #000033;
|
25
|
+
border-color: #000033; }
|
26
|
+
.digg_pagination .page_info {
|
27
|
+
background: #2e6ab1;
|
28
|
+
color: white;
|
29
|
+
padding: 0.4em 0.6em;
|
30
|
+
width: 22em;
|
31
|
+
margin-bottom: 0.3em;
|
32
|
+
text-align: center; }
|
33
|
+
.digg_pagination .page_info b {
|
34
|
+
color: #000033;
|
35
|
+
background: #6aa6ed;
|
36
|
+
padding: 0.1em 0.25em; }
|
37
|
+
.digg_pagination:after {
|
38
|
+
content: ".";
|
39
|
+
display: block;
|
40
|
+
height: 0;
|
41
|
+
clear: both;
|
42
|
+
visibility: hidden; }
|
43
|
+
* html .digg_pagination {
|
44
|
+
height: 1%; }
|
45
|
+
*:first-child + html .digg_pagination {
|
46
|
+
overflow: hidden; }
|
47
|
+
|
48
|
+
.apple_pagination {
|
49
|
+
background: #f1f1f1;
|
50
|
+
border: 1px solid #e5e5e5;
|
51
|
+
text-align: center;
|
52
|
+
padding: 1em;
|
53
|
+
cursor: default; }
|
54
|
+
.apple_pagination a, .apple_pagination span {
|
55
|
+
padding: 0.2em 0.3em; }
|
56
|
+
.apple_pagination .disabled {
|
57
|
+
color: #aaaaaa; }
|
58
|
+
.apple_pagination .current {
|
59
|
+
font-style: normal;
|
60
|
+
font-weight: bold;
|
61
|
+
background-color: #bebebe;
|
62
|
+
display: inline-block;
|
63
|
+
width: 1.4em;
|
64
|
+
height: 1.4em;
|
65
|
+
line-height: 1.5;
|
66
|
+
-moz-border-radius: 1em;
|
67
|
+
-webkit-border-radius: 1em;
|
68
|
+
border-radius: 1em;
|
69
|
+
text-shadow: rgba(255, 255, 255, 0.8) 1px 1px 1px; }
|
70
|
+
.apple_pagination a {
|
71
|
+
text-decoration: none;
|
72
|
+
color: black; }
|
73
|
+
.apple_pagination a:hover, .apple_pagination a:focus {
|
74
|
+
text-decoration: underline; }
|
75
|
+
|
76
|
+
.flickr_pagination {
|
77
|
+
text-align: center;
|
78
|
+
padding: 0.3em;
|
79
|
+
cursor: default; }
|
80
|
+
.flickr_pagination a, .flickr_pagination span, .flickr_pagination em {
|
81
|
+
padding: 0.2em 0.5em; }
|
82
|
+
.flickr_pagination .disabled {
|
83
|
+
color: #aaaaaa; }
|
84
|
+
.flickr_pagination .current {
|
85
|
+
font-style: normal;
|
86
|
+
font-weight: bold;
|
87
|
+
color: #ff0084; }
|
88
|
+
.flickr_pagination a {
|
89
|
+
border: 1px solid #dddddd;
|
90
|
+
color: #0063dc;
|
91
|
+
text-decoration: none; }
|
92
|
+
.flickr_pagination a:hover, .flickr_pagination a:focus {
|
93
|
+
border-color: #003366;
|
94
|
+
background: #0063dc;
|
95
|
+
color: white; }
|
96
|
+
.flickr_pagination .page_info {
|
97
|
+
color: #aaaaaa;
|
98
|
+
padding-top: 0.8em; }
|
99
|
+
.flickr_pagination .previous_page, .flickr_pagination .next_page {
|
100
|
+
border-width: 2px; }
|
101
|
+
.flickr_pagination .previous_page {
|
102
|
+
margin-right: 1em; }
|
103
|
+
.flickr_pagination .next_page {
|
104
|
+
margin-left: 1em; }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
* Pagination
|
3
|
+
*/
|
4
|
+
.paginate_enabled_previous { background: url('/assets/dataTables/back_enabled.png') no-repeat top left; }
|
5
|
+
.paginate_enabled_previous:hover { background: url('/assets/dataTables/back_enabled_hover.png') no-repeat top left; }
|
6
|
+
.paginate_disabled_previous { background: url('/assets/dataTables/back_disabled.png') no-repeat top left; }
|
7
|
+
|
8
|
+
.paginate_enabled_next { background: url('/assets/dataTables/forward_enabled.png') no-repeat top right; }
|
9
|
+
.paginate_enabled_next:hover { background: url('/assets/dataTables/forward_enabled_hover.png') no-repeat top right; }
|
10
|
+
.paginate_disabled_next { background: url('/assets/dataTables/forward_disabled.png') no-repeat top right; }
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Sorting
|
14
|
+
*/
|
15
|
+
.sorting { background: url('/assets/dataTables/sort_both.png') no-repeat center right; }
|
16
|
+
.sorting_asc { background: url('/assets/dataTables/sort_asc.png') no-repeat center right; }
|
17
|
+
.sorting_desc { background: url('/assets/dataTables/sort_desc.png') no-repeat center right; }
|
18
|
+
|
19
|
+
.sorting_asc_disabled { background: url('/assets/dataTables/sort_asc_disabled.png') no-repeat center right; }
|
20
|
+
.sorting_desc_disabled { background: url('/assets/dataTables/sort_desc_disabled.png') no-repeat center right; }
|