customize_admin 0.0.1

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.
Files changed (76) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/customize_admin/admin/application.js +2 -0
  5. data/app/assets/javascripts/customize_admin/admin/base.js +2 -0
  6. data/app/assets/javascripts/customize_admin/application.js +11 -0
  7. data/app/assets/javascripts/customize_admin/bootstrap.js.coffee +19 -0
  8. data/app/assets/stylesheets/customize_admin/application.css +17 -0
  9. data/app/assets/stylesheets/customize_admin/bootstrap.css.less +5 -0
  10. data/app/controllers/customize_admin/application_controller.rb +5 -0
  11. data/app/controllers/customize_admin/base_controller.rb +41 -0
  12. data/app/helpers/customize_admin/application_helper.rb +18 -0
  13. data/app/helpers/customize_admin/base_helper.rb +4 -0
  14. data/app/views/customize_admin/application/_admin_menu.html.erb +1 -0
  15. data/app/views/customize_admin/base/_form (kopia).html.erb +13 -0
  16. data/app/views/customize_admin/base/_form.html.erb +8 -0
  17. data/app/views/customize_admin/base/_index_action.html.erb +4 -0
  18. data/app/views/customize_admin/base/_more_form_inputs.html.erb +0 -0
  19. data/app/views/customize_admin/base/_more_index_action.html.erb +1 -0
  20. data/app/views/customize_admin/base/_more_show_action.html.erb +0 -0
  21. data/app/views/customize_admin/base/edit.html.erb +9 -0
  22. data/app/views/customize_admin/base/index.html.erb +49 -0
  23. data/app/views/customize_admin/base/new.html.erb +6 -0
  24. data/app/views/customize_admin/base/show.html.erb +12 -0
  25. data/app/views/layouts/customize_admin/application.html.erb +37 -0
  26. data/config/initializers/ckeditor.rb +18 -0
  27. data/config/initializers/formtastic.rb +82 -0
  28. data/config/routes.rb +7 -0
  29. data/lib/customize_admin.rb +4 -0
  30. data/lib/customize_admin/engine.rb +5 -0
  31. data/lib/customize_admin/version.rb +3 -0
  32. data/lib/generators/customize_admin/install/USAGE +8 -0
  33. data/lib/generators/customize_admin/install/install_generator.rb +51 -0
  34. data/lib/generators/customize_admin/install/templates/dashboard_controller.rb +5 -0
  35. data/lib/generators/customize_admin/install/templates/index.html.erb +1 -0
  36. data/lib/generators/customize_admin/scaffold/USAGE +8 -0
  37. data/lib/generators/customize_admin/scaffold/scaffold_generator.rb +46 -0
  38. data/lib/generators/customize_admin/scaffold/templates/controller_template.rb +2 -0
  39. data/lib/tasks/customize_admin_tasks.rake +13 -0
  40. data/lib/templates/erb/scaffold/_form.html.erb +11 -0
  41. data/test/customize_admin_test.rb +7 -0
  42. data/test/dummy/Rakefile +7 -0
  43. data/test/dummy/app/assets/javascripts/application.js +9 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  45. data/test/dummy/app/controllers/application_controller.rb +3 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  48. data/test/dummy/config.ru +4 -0
  49. data/test/dummy/config/application.rb +45 -0
  50. data/test/dummy/config/boot.rb +10 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +30 -0
  54. data/test/dummy/config/environments/production.rb +60 -0
  55. data/test/dummy/config/environments/test.rb +39 -0
  56. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  57. data/test/dummy/config/initializers/inflections.rb +10 -0
  58. data/test/dummy/config/initializers/mime_types.rb +5 -0
  59. data/test/dummy/config/initializers/secret_token.rb +7 -0
  60. data/test/dummy/config/initializers/session_store.rb +8 -0
  61. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/test/dummy/config/locales/en.yml +5 -0
  63. data/test/dummy/config/routes.rb +4 -0
  64. data/test/dummy/log/development.log +0 -0
  65. data/test/dummy/public/404.html +26 -0
  66. data/test/dummy/public/422.html +26 -0
  67. data/test/dummy/public/500.html +26 -0
  68. data/test/dummy/public/favicon.ico +0 -0
  69. data/test/dummy/script/rails +6 -0
  70. data/test/functional/customize_admin/admin/application_controller_test.rb +9 -0
  71. data/test/functional/customize_admin/admin/base_controller_test.rb +9 -0
  72. data/test/integration/navigation_test.rb +10 -0
  73. data/test/test_helper.rb +10 -0
  74. data/test/unit/helpers/customize_admin/admin/application_helper_test.rb +6 -0
  75. data/test/unit/helpers/customize_admin/admin/base_helper_test.rb +6 -0
  76. metadata +184 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = CustomizeAdmin
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
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 = 'CustomizeAdmin'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,11 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require twitter/bootstrap
10
+ //= require ckeditor/ckeditor
11
+ //= require_tree .
@@ -0,0 +1,19 @@
1
+ $ ->
2
+ $("body > .topbar").scrollSpy()
3
+ $ ->
4
+ $(".tabs").tabs()
5
+ $ ->
6
+ $("a[rel=twipsy]").twipsy live: true
7
+ $ ->
8
+ $("a[rel=popover]").popover offset: 10
9
+ $ ->
10
+ $(".topbar-wrapper").dropdown()
11
+ $ ->
12
+ $(".alert-message").alert()
13
+ $ ->
14
+ domModal = $(".modal").modal(
15
+ backdrop: true
16
+ closeOnEscape: true
17
+ )
18
+ $(".open-modal").click ->
19
+ domModal.toggle()
@@ -0,0 +1,17 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require formtastic
7
+ *= require twitter/bootstrap
8
+ */
9
+ .page{
10
+ margin-top: 50px;
11
+ }
12
+ .link_white, a{
13
+ color: #ffffff;
14
+ }
15
+ .link_white, a:hover, a:active, a:focus{
16
+ color: #ffffff;
17
+ }
@@ -0,0 +1,5 @@
1
+ @import "twitter/bootstrap";
2
+
3
+ // Baseline grid
4
+ @basefont: 13px;
5
+ @baseline: 18px;
@@ -0,0 +1,5 @@
1
+ module CustomizeAdmin
2
+ class ApplicationController < ActionController::Base
3
+
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ module CustomizeAdmin
2
+ class BaseController < ApplicationController
3
+ inherit_resources
4
+ helper_method :sort_column, :sort_direction, :string_filter
5
+ before_filter :authenticate_admin_user!
6
+ # defaults :route_prefix => 'admin'
7
+
8
+ protected
9
+ def collection
10
+ collection = search(params[:search]).order( sort_column + " " + sort_direction ).paginate(:per_page => 10, :page => params[:page])
11
+ end
12
+
13
+ def sort_column
14
+ sort_params = params[:sort].to_s.downcase
15
+ end_of_association_chain.column_names.include?(sort_params) ? sort_params : "id"
16
+ end
17
+
18
+ def sort_direction
19
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
20
+ end
21
+
22
+ def string_filter
23
+ t=[]
24
+ end_of_association_chain.columns.each do |m|
25
+ m.type == :string ? t << m.name : ""
26
+ end
27
+ t
28
+ end
29
+
30
+ def search( s )
31
+
32
+ if s
33
+ end_of_association_chain.where( 'name LIKE ?', "%#{s}%" )
34
+ else
35
+ end_of_association_chain
36
+ end
37
+ end
38
+
39
+
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ module CustomizeAdmin
2
+ module ApplicationHelper
3
+ def sortable( column, title = nil )
4
+ title ||= column.titleize
5
+ column = column.to_s.downcase
6
+ direction = ( column == sort_column && sort_direction == "asc" ) ? "desc" : "asc"
7
+ link_to title, { :sort => column, :direction => direction }
8
+ end
9
+
10
+ def test
11
+ string_filter.each do |n|
12
+
13
+ end
14
+ end
15
+
16
+
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module CustomizeAdmin
2
+ module BaseHelper
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ <%= form_for([:admin, resource]) do |f| %>
2
+
3
+ <% resource_class.attribute_names.each do |attr| %>
4
+ <div class="field">
5
+ <%= f.label attr %><br />
6
+ <%= f.text_field attr %>
7
+ </div>
8
+
9
+ <% end %>
10
+ <%= f.submit %>
11
+ <% end %>
12
+
13
+
@@ -0,0 +1,8 @@
1
+ <%= semantic_form_for([:admin, resource]) do |f| %>
2
+ <%= f.inputs %>
3
+ <%= render :partial => "more_form_inputs", :locals => { :f => f } %>
4
+ <%= f.buttons %>
5
+
6
+ <% end %>
7
+
8
+
@@ -0,0 +1,4 @@
1
+ <td><%= link_to 'Show', resource_path(admin_resource) %></td>
2
+ <td><%= link_to 'Edit', edit_resource_path(admin_resource) %></td>
3
+ <td><%= link_to 'Destroy', resource_path(admin_resource), confirm: 'Are you sure?', method: :delete %></td>
4
+
@@ -0,0 +1,9 @@
1
+ <h1>Edit <%=resource_class.model_name.human%></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', resource_path(resource) %> |
6
+ <%= link_to 'Back', collection_url %>
7
+
8
+
9
+
@@ -0,0 +1,49 @@
1
+
2
+ <div class="page-header">
3
+ <h1>
4
+ Listing <%=resource_class.model_name.human%>
5
+ a a a Base
6
+ <div class="pull-right">
7
+ <%= button_to 'New', new_resource_path, :method => :get, :class => "btn primary" %>
8
+ </div>
9
+ </h1>
10
+
11
+ </div>
12
+
13
+ <%= form_tag collection_path, :method => 'get' do %>
14
+ <p>
15
+ <%= text_field_tag :search, params[:search] %>
16
+ <%= submit_tag "Search", :name => nil %>
17
+ </p>
18
+
19
+ <% end %>
20
+ <%= test %>
21
+ </br>
22
+ <table class="zebra-striped">
23
+ <tr>
24
+ <% resource_class.attribute_names.each do |attr| %>
25
+ <th> <%= sortable attr, resource_class.human_attribute_name(attr) %> </th>
26
+ <% end %>
27
+ <th></th>
28
+ <th></th>
29
+ <th></th>
30
+ </tr>
31
+
32
+ <% collection.each do |admin_resource| %>
33
+ <tr>
34
+
35
+ <% resource_class.attribute_names.each do |attr| %>
36
+ <td><%= admin_resource.public_send(attr).to_s.truncate(20) %> </td>
37
+
38
+
39
+ <% end %>
40
+
41
+ <%= render :partial => "index_action", :locals => { :admin_resource => admin_resource } %>
42
+ <%= render :partial => "more_index_action", :locals => { :admin_resource => admin_resource } %>
43
+
44
+ </tr>
45
+ <% end %>
46
+ </table>
47
+ <%= will_paginate collection %>
48
+ <br />
49
+
@@ -0,0 +1,6 @@
1
+ <h1>New <%=resource_class.model_name.human%></h1>
2
+
3
+ <%= render 'form' %>
4
+ <%#= resource_class.attribute_names %>
5
+
6
+ <%= link_to 'Back', collection_url %>
@@ -0,0 +1,12 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <% resource_class.attribute_names.each do |attr| %>
4
+ <div class="field">
5
+ <b><%= attr %>:</b> <%= resource.public_send(attr).to_s.truncate(20) %> </br>
6
+ </div>
7
+ </br>
8
+ <%end%>
9
+
10
+ <%= render :partial => "more_show_action" %>
11
+ <%= link_to 'Edit', edit_resource_path(resource) %> |
12
+ <%= link_to 'Back', collection_url %>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CustomizeAdmin</title>
5
+ <%= stylesheet_link_tag "customize_admin/application" %>
6
+ <%= javascript_include_tag "customize_admin/application" %>
7
+ <%= yield( :head ) %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+ <div class="topbar">
12
+ <div class="fill">
13
+ <div class="container">
14
+ <%= render "admin_menu" %>
15
+ <div class="pull-right">
16
+ <%= link_to('Logout', destroy_admin_user_session_path, :method => :delete) %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+
23
+
24
+ <%#= CustomizeAdmin::BaseController.subclasses.collect { |type| type.name.split("::").last.split("Controller").last } %>
25
+ <%#= Dir.new(Rails.root.to_s + "/app/controllers/admin/").entries.collect{ |t| t.split("_controller").first} %>
26
+ <%#= Dir.new("/app/controllers/admin").entries %>
27
+ <%#= link_to "pr", "products" %>
28
+ <%#= %>
29
+ <div class="page">
30
+ <div class="container" >
31
+ <div class="content">
32
+ <%= yield %>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,18 @@
1
+ # Use this hook to configure ckeditor
2
+ if Object.const_defined?("Ckeditor")
3
+ Ckeditor.setup do |config|
4
+ # ==> ORM configuration
5
+ # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
6
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
7
+ # available as additional gems.
8
+ require "ckeditor/orm/active_record"
9
+
10
+ # Allowed image file types for upload.
11
+ # Set to nil or [] (empty array) for all file types
12
+ # config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
13
+
14
+ # Allowed attachment file types for upload.
15
+ # Set to nil or [] (empty array) for all file types
16
+ # config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]
17
+ end
18
+ end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+
3
+ # --------------------------------------------------------------------------------------------------
4
+ # Please note: If you're subclassing Formtastic::FormBuilder, Formtastic uses
5
+ # class_attribute for these configuration attributes instead of the deprecated
6
+ # class_inheritable_attribute. The behaviour is slightly different with subclasses (especially
7
+ # around attributes with Hash or Array) values, so make sure you understand what's happening.
8
+ # See the documentation for class_attribute in ActiveSupport for more information.
9
+ # --------------------------------------------------------------------------------------------------
10
+
11
+ # Set the default text field size when input is a string. Default is nil.
12
+ # Formtastic::FormBuilder.default_text_field_size = 50
13
+
14
+ # Set the default text area height when input is a text. Default is 20.
15
+ # Formtastic::FormBuilder.default_text_area_height = 5
16
+
17
+ # Set the default text area width when input is a text. Default is nil.
18
+ # Formtastic::FormBuilder.default_text_area_width = 50
19
+
20
+ # Should all fields be considered "required" by default?
21
+ # Defaults to true.
22
+ # Formtastic::FormBuilder.all_fields_required_by_default = true
23
+
24
+ # Should select fields have a blank option/prompt by default?
25
+ # Defaults to true.
26
+ # Formtastic::FormBuilder.include_blank_for_select_by_default = true
27
+
28
+ # Set the string that will be appended to the labels/fieldsets which are required
29
+ # It accepts string or procs and the default is a localized version of
30
+ # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
31
+ # in your locale, it will replace the abbr title properly. But if you don't want to use
32
+ # abbr tag, you can simply give a string as below
33
+ # Formtastic::FormBuilder.required_string = "(required)"
34
+
35
+ # Set the string that will be appended to the labels/fieldsets which are optional
36
+ # Defaults to an empty string ("") and also accepts procs (see required_string above)
37
+ # Formtastic::FormBuilder.optional_string = "(optional)"
38
+
39
+ # Set the way inline errors will be displayed.
40
+ # Defaults to :sentence, valid options are :sentence, :list, :first and :none
41
+ # Formtastic::FormBuilder.inline_errors = :sentence
42
+ # Formtastic uses the following classes as default for hints, inline_errors and error list
43
+
44
+ # If you override the class here, please ensure to override it in your stylesheets as well
45
+ # Formtastic::FormBuilder.default_hint_class = "inline-hints"
46
+ # Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
47
+ # Formtastic::FormBuilder.default_error_list_class = "errors"
48
+
49
+ # Set the method to call on label text to transform or format it for human-friendly
50
+ # reading when formtastic is used without object. Defaults to :humanize.
51
+ # Formtastic::FormBuilder.label_str_method = :humanize
52
+
53
+ # Set the array of methods to try calling on parent objects in :select and :radio inputs
54
+ # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
55
+ # that is found on the object will be used.
56
+ # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
57
+ # Formtastic::FormBuilder.collection_label_methods = [
58
+ # "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
59
+
60
+ # Additionally, you can customize the order for specific types of inputs.
61
+ # This is configured on a type basis and if a type is not found it will
62
+ # fall back to the default order as defined by #inline_order
63
+ # Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
64
+ # Formtastic::FormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
65
+
66
+ # Specifies if labels/hints for input fields automatically be looked up using I18n.
67
+ # Default value: true. Overridden for specific fields by setting value to true,
68
+ # i.e. :label => true, or :hint => true (or opposite depending on initialized value)
69
+ # Formtastic::FormBuilder.i18n_lookups_by_default = false
70
+
71
+ # You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
72
+ # specifying that class here. Defaults to Formtastic::FormBuilder.
73
+ # Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
74
+
75
+ # You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
76
+ # and `<textarea>` tags by setting this to false (defaults to true).
77
+ # Formtastic::FormBuilder.use_required_attribute = true
78
+
79
+ # You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
80
+ # this to false. Doing so will add a `novalidate` attribute to the `<form>` tag.
81
+ # See http://diveintohtml5.org/forms.html#validation for more info.
82
+ # Formtastic::FormBuilder.perform_browser_validations = true