aor-theme 0.1.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +34 -0
  5. data/lib/aor/theme.rb +9 -0
  6. data/lib/aor/theme/engine.rb +6 -0
  7. data/lib/aor/theme/version.rb +5 -0
  8. data/lib/generators/aor/theme/USAGE +8 -0
  9. data/lib/generators/aor/theme/templates/generator/admin_controller_generator.rb.noautoload +12 -0
  10. data/lib/generators/aor/theme/templates/generator/admin_scaffold_controller_generator.rb.noautoload +13 -0
  11. data/lib/generators/aor/theme/templates/generator/admin_scaffold_generator.rb.noautoload +13 -0
  12. data/lib/generators/aor/theme/templates/generator/erb/controller/view.html.erb +2 -0
  13. data/lib/generators/aor/theme/templates/generator/erb/scaffold/_form.html.erb +36 -0
  14. data/lib/generators/aor/theme/templates/generator/erb/scaffold/edit.html.erb +16 -0
  15. data/lib/generators/aor/theme/templates/generator/erb/scaffold/index.html.erb +59 -0
  16. data/lib/generators/aor/theme/templates/generator/erb/scaffold/new.html.erb +13 -0
  17. data/lib/generators/aor/theme/templates/generator/erb/scaffold/show.html.erb +24 -0
  18. data/lib/generators/aor/theme/templates/generator/rails/controller/controller.rb +13 -0
  19. data/lib/generators/aor/theme/templates/generator/rails/scaffold_controller/api_controller.rb +61 -0
  20. data/lib/generators/aor/theme/templates/generator/rails/scaffold_controller/controller.rb +73 -0
  21. data/lib/generators/aor/theme/templates/theme/admin.css +111 -0
  22. data/lib/generators/aor/theme/templates/theme/admin.js +3 -0
  23. data/lib/generators/aor/theme/templates/theme/admin_base_controller.rb +26 -0
  24. data/lib/generators/aor/theme/templates/theme/admin_base_helper.rb +18 -0
  25. data/lib/generators/aor/theme/templates/theme/admin_common_errors.html.erb +8 -0
  26. data/lib/generators/aor/theme/templates/theme/admin_common_flash_messages.html.erb +6 -0
  27. data/lib/generators/aor/theme/templates/theme/admin_common_headnav.html.erb +23 -0
  28. data/lib/generators/aor/theme/templates/theme/admin_common_sidebar.html.erb +16 -0
  29. data/lib/generators/aor/theme/templates/theme/admin_layout.html.erb +33 -0
  30. data/lib/generators/aor/theme/theme_generator.rb +34 -0
  31. data/lib/tasks/aor/theme_tasks.rake +4 -0
  32. metadata +186 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d528725b10ab44cc04f1b4d784fb7e61f628506
4
+ data.tar.gz: 4cb64ff75759cccece96c873d18410b47054b9fb
5
+ SHA512:
6
+ metadata.gz: 6db83adc81d91694507a18aaca5e07ab1e61f6c03d25d2848b120278e0a82276217cc2d8e9301d487f893f7c55e0b11ba668eb216bde1250a03d088332b8cda5
7
+ data.tar.gz: 1637323d89812dd7b27f4f5800c3e375d9032feb4a42038ba168c5ccc80b419293f39132097725a7fc8ecef04fe02ee8b8e81ed1608e628d5fc98d9f17b91615
@@ -0,0 +1,20 @@
1
+ Copyright 2016 ciro9527
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.
@@ -0,0 +1,28 @@
1
+ # Aor::Theme
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'aor-theme'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install aor-theme
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Aor::Theme'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,9 @@
1
+ require 'aor/bootstrap'
2
+ require 'aor/authentication'
3
+ require 'aor/authorization'
4
+
5
+ module Aor
6
+ module Theme
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module Aor
2
+ module Theme
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Aor
2
+ module Theme
3
+ VERSION = '0.1.0.alpha1'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate theme Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,12 @@
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+ require 'rails/generators/rails/controller/controller_generator'
3
+
4
+ module Admin
5
+ class ControllerGenerator < Rails::Generators::NamedBase
6
+ def invoke_default
7
+ Erb::Generators::ControllerGenerator.source_paths.insert(0, File.expand_path('../../templates/erb/controller', __FILE__))
8
+ Rails::Generators::ControllerGenerator.source_paths.insert(0, File.expand_path('../../templates/rails/controller', __FILE__))
9
+ invoke 'controller', ARGV
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
3
+
4
+ module Admin
5
+ class ScaffoldControllerGenerator < Rails::Generators::NamedBase
6
+ def invoke_default
7
+ Erb::Generators::ScaffoldGenerator.source_paths.insert(0, File.expand_path('../../templates/erb/scaffold', __FILE__))
8
+ Rails::Generators::ScaffoldControllerGenerator.source_paths.insert(0, File.expand_path('../../templates/rails/scaffold_controller', __FILE__))
9
+ Rails::Generators::ScaffoldControllerGenerator.remove_hook_for(:jbuilder) if defined?(Jbuilder)
10
+ invoke 'scaffold_controller', ARGV
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
3
+
4
+ module Admin
5
+ class ScaffoldGenerator < Rails::Generators::NamedBase
6
+ def invoke_default
7
+ Erb::Generators::ScaffoldGenerator.source_paths.insert(0, File.expand_path('../../templates/erb/scaffold', __FILE__))
8
+ Rails::Generators::ScaffoldControllerGenerator.source_paths.insert(0, File.expand_path('../../templates/rails/scaffold_controller', __FILE__))
9
+ Rails::Generators::ScaffoldControllerGenerator.remove_hook_for(:jbuilder) if defined?(Jbuilder)
10
+ invoke 'scaffold', ARGV
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ <h1 class="page-header"><%= class_name %>#<%= @action %></h1>
2
+ <p>Find me in <%= @path %></p>
@@ -0,0 +1,36 @@
1
+ <%%= form_for([:admin, <%= singular_name %>], html: {class: 'form-horizontal'}) do |f| %>
2
+ <%% if <%= singular_name %>.errors.any? %>
3
+ <%%= render 'admin/common/errors', errors: <%= singular_name %>.errors %>
4
+ <%% end %>
5
+
6
+ <% attributes.each do |attribute| -%>
7
+ <div class="form-group">
8
+ <% if attribute.password_digest? -%>
9
+ <%%= f.label :password, class: 'col-sm-3 control-label' %>
10
+ <div class="col-sm-9">
11
+ <%%= f.password_field :password, class: 'form-control' %>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="form-group">
16
+ <%%= f.label :password_confirmation, class: 'col-sm-3 control-label' %>
17
+ <div class="col-sm-9">
18
+ <%%= f.password_field :password_confirmation, class: 'form-control' %>
19
+ </div>
20
+ <% else -%>
21
+ <%%= f.label :<%= attribute.column_name %>, class: 'col-sm-3 control-label' %>
22
+ <div class="col-sm-9">
23
+ <%%= f.<%= attribute.field_type %> :<%= attribute.column_name %>, class: 'form-control' %>
24
+ </div>
25
+ <% end -%>
26
+ </div>
27
+
28
+ <% end -%>
29
+ <div class="form-group">
30
+ <div class="col-sm-offset-3 col-sm-9">
31
+ <%% if((f.object.new_record? && can?(:create, :<%= singular_name %>)) || (f.object.persisted? && can?(:update, :<%= singular_name %>))) %>
32
+ <%%= f.submit nil, class: 'btn btn-primary' %>
33
+ <%% end %>
34
+ </div>
35
+ </div>
36
+ <%% end %>
@@ -0,0 +1,16 @@
1
+ <h1 class="page-header">Editing <%= singular_name.titleize %></h1>
2
+
3
+ <div class="panel panel-default">
4
+ <div class="panel-heading">
5
+ <%% if can? :show, :<%= singular_name %> %>
6
+ <%%= link_to 'Show', [:admin, @<%= singular_name %>], class: 'btn btn-default' %>
7
+ <%% end %>
8
+ <%% if can? :index, :<%= singular_name %> %>
9
+ <%%= link_to 'Back', <%= index_helper %>_path, class: 'btn btn-default' %>
10
+ <%% end %>
11
+ </div>
12
+
13
+ <div class="panel-body">
14
+ <%%= render 'form', <%= singular_name %>: @<%= singular_name %> %>
15
+ </div>
16
+ </div>
@@ -0,0 +1,59 @@
1
+ <h1 class="page-header"><%= plural_name.titleize %></h1>
2
+
3
+ <div class="panel panel-default">
4
+ <div class="panel-heading">
5
+ <%% if can? :new, :<%= singular_name %> %>
6
+ <%%= link_to 'New <%= singular_name.titleize %>', new_<%= singular_table_name %>_path, class: 'btn btn-default' %>
7
+ <%% end %>
8
+ </div>
9
+
10
+ <div class="panel-body">
11
+ <%%= search_form_for [:admin, @q], class: 'form-inline admin-search-form' do |f| %>
12
+ <div class="form-group">
13
+ <%%= f.label :id_eq %>
14
+ <%%= f.text_field :id_eq, class: 'form-control' %>
15
+ </div>
16
+ <%%= f.submit class: 'btn btn-default' %>
17
+ <%% end %>
18
+ </div>
19
+
20
+ <div class="table-responsive">
21
+ <table class="table table-bordered">
22
+ <thead>
23
+ <tr>
24
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
25
+ <th><%= attribute.human_name %></th>
26
+ <% end -%>
27
+ <th>Actions</th>
28
+ </tr>
29
+ </thead>
30
+
31
+ <tbody>
32
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
33
+ <tr>
34
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
35
+ <td><%%= <%= singular_name %>.<%= attribute.name %> %></td>
36
+ <% end -%>
37
+ <td>
38
+ <%% if can? :show, :<%= singular_name %> %>
39
+ <%%= link_to 'Show', [:admin, <%= singular_name %>], class: 'btn btn-default' %>
40
+ <%% end %>
41
+ <%% if can? :edit, :<%= singular_name %> %>
42
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_name %>), class: 'btn btn-default' %>
43
+ <%% end %>
44
+ <%% if can? :destroy, :<%= singular_name %> %>
45
+ <%%= link_to 'Destroy', [:admin, <%= singular_name %>], class: 'btn btn-danger', method: :delete, data: { confirm: 'Are you sure?' } %>
46
+ <%% end %>
47
+ </td>
48
+ </tr>
49
+ <%% end %>
50
+ </tbody>
51
+ </table>
52
+ </div>
53
+ <div class="panel-footer">
54
+ <p>
55
+ <%%= page_entries_info @<%= plural_name %> %>
56
+ </p>
57
+ <%%= paginate @<%= plural_name %> %>
58
+ </div>
59
+ </div>
@@ -0,0 +1,13 @@
1
+ <h1 class="page-header">New <%= singular_name.titleize %></h1>
2
+
3
+ <div class="panel panel-default">
4
+ <div class="panel-heading">
5
+ <%% if can? :index, :<%= singular_name %> %>
6
+ <%%= link_to 'Back', <%= index_helper %>_path, class: 'btn btn-default' %>
7
+ <%% end %>
8
+ </div>
9
+
10
+ <div class="panel-body">
11
+ <%%= render 'form', <%= singular_name %>: @<%= singular_name %> %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,24 @@
1
+ <h1 class="page-header">Show <%= singular_name.titleize %></h1>
2
+
3
+ <div class="panel panel-default">
4
+ <div class="panel-heading">
5
+ <%% if can? :edit, :<%= singular_name %> %>
6
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_name %>), class: 'btn btn-default' %>
7
+ <%% end %>
8
+ <%% if can? :index, :<%= singular_name %> %>
9
+ <%%= link_to 'Back', <%= index_helper %>_path, class: 'btn btn-default' %>
10
+ <%% end %>
11
+ </div>
12
+
13
+ <table class="table table-bordered">
14
+ <tbody>
15
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
16
+ <tr>
17
+ <th class="col-sm-3 text-right"><%= attribute.human_name %></th>
18
+ <td class="col-sm-9"><%%= @<%= singular_name %>.<%= attribute.name %> %></td>
19
+ </tr>
20
+ <% end -%>
21
+ </tbody>
22
+ </table>
23
+
24
+ </div>
@@ -0,0 +1,13 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_path %>/application_controller"
3
+
4
+ <% end -%>
5
+ <% module_namespacing do -%>
6
+ class <%= class_name %>Controller < Admin::BaseController
7
+ <% actions.each do |action| -%>
8
+ def <%= action %>
9
+ end
10
+ <%= "\n" unless action == actions.last -%>
11
+ <% end -%>
12
+ end
13
+ <% end -%>
@@ -0,0 +1,61 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_path %>/application_controller"
3
+
4
+ <% end -%>
5
+ <% module_namespacing do -%>
6
+ class <%= controller_class_name %>Controller < Admin::BaseController
7
+ before_action :set_<%= singular_name %>, only: [:show, :update, :destroy]
8
+
9
+ # GET <%= route_url %>
10
+ def index
11
+ @<%= plural_name %> = <%= orm_class.all(singular_name.camelize) %>
12
+
13
+ render json: <%= "@#{plural_name}" %>
14
+ end
15
+
16
+ # GET <%= route_url %>/1
17
+ def show
18
+ render json: <%= "@#{singular_name}" %>
19
+ end
20
+
21
+ # POST <%= route_url %>
22
+ def create
23
+ @<%= singular_name %> = <%= orm_class.build(singular_name.camelize, "#{singular_name}_params") %>
24
+
25
+ if @<%= orm_instance(singular_name).save %>
26
+ render json: <%= "@#{singular_name}" %>, status: :created, location: <%= "@#{singular_name}" %>
27
+ else
28
+ render json: <%= "@#{orm_instance(singular_name).errors}" %>, status: :unprocessable_entity
29
+ end
30
+ end
31
+
32
+ # PATCH/PUT <%= route_url %>/1
33
+ def update
34
+ if @<%= orm_instance(singular_name).update("#{singular_name}_params") %>
35
+ render json: <%= "@#{singular_name}" %>
36
+ else
37
+ render json: <%= "@#{orm_instance(singular_name).errors}" %>, status: :unprocessable_entity
38
+ end
39
+ end
40
+
41
+ # DELETE <%= route_url %>/1
42
+ def destroy
43
+ @<%= orm_instance(singular_name).destroy %>
44
+ end
45
+
46
+ private
47
+ # Use callbacks to share common setup or constraints between actions.
48
+ def set_<%= singular_name %>
49
+ @<%= singular_name %> = <%= orm_class.find(singular_name.camelize, "params[:id]") %>
50
+ end
51
+
52
+ # Only allow a trusted parameter "white list" through.
53
+ def <%= "#{singular_name}_params" %>
54
+ <%- if attributes_names.empty? -%>
55
+ params.fetch(:<%= singular_name %>, {})
56
+ <%- else -%>
57
+ params.require(:<%= singular_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
58
+ <%- end -%>
59
+ end
60
+ end
61
+ <% end -%>
@@ -0,0 +1,73 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_path %>/application_controller"
3
+
4
+ <% end -%>
5
+ <% module_namespacing do -%>
6
+ class <%= controller_class_name %>Controller < Admin::BaseController
7
+ before_action :set_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
8
+
9
+ # GET <%= route_url %>
10
+ def index
11
+ @q = <%= singular_name.camelize %>.ransack(search_params)
12
+ @<%= plural_name %> = @q.result.page(params[:page])
13
+ end
14
+
15
+ # GET <%= route_url %>/1
16
+ def show
17
+ end
18
+
19
+ # GET <%= route_url %>/new
20
+ def new
21
+ @<%= singular_name %> = <%= orm_class.build(singular_name.camelize) %>
22
+ end
23
+
24
+ # GET <%= route_url %>/1/edit
25
+ def edit
26
+ end
27
+
28
+ # POST <%= route_url %>
29
+ def create
30
+ @<%= singular_name %> = <%= orm_class.build(singular_name.camelize, "#{singular_name}_params") %>
31
+
32
+ if @<%= orm_instance(singular_name).save %>
33
+ redirect_to [:admin, @<%= singular_name %>], notice: <%= "'#{human_name} was successfully created.'" %>
34
+ else
35
+ render :new
36
+ end
37
+ end
38
+
39
+ # PATCH/PUT <%= route_url %>/1
40
+ def update
41
+ if @<%= orm_instance(singular_name).update("#{singular_name}_params") %>
42
+ redirect_to [:admin, @<%= singular_name %>], notice: <%= "'#{human_name} was successfully updated.'" %>
43
+ else
44
+ render :edit
45
+ end
46
+ end
47
+
48
+ # DELETE <%= route_url %>/1
49
+ def destroy
50
+ @<%= orm_instance(singular_name).destroy %>
51
+ redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
52
+ end
53
+
54
+ private
55
+ # Use callbacks to share common setup or constraints between actions.
56
+ def set_<%= singular_name %>
57
+ @<%= singular_name %> = <%= orm_class.find(singular_name.camelize, "params[:id]") %>
58
+ end
59
+
60
+ # Only allow a trusted parameter "white list" through.
61
+ def <%= "#{singular_name}_params" %>
62
+ <%- if attributes_names.empty? -%>
63
+ params.fetch(:<%= singular_name %>, {})
64
+ <%- else -%>
65
+ params.require(:<%= singular_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
66
+ <%- end -%>
67
+ end
68
+
69
+ def search_params
70
+ params.fetch(:q, {}).permit(:id_eq)
71
+ end
72
+ end
73
+ <% end -%>
@@ -0,0 +1,111 @@
1
+ /*
2
+ *= require bootstrap
3
+ *= require_self
4
+ */
5
+
6
+
7
+ /*
8
+ * Base structure
9
+ */
10
+
11
+ /* Move down content because we have a fixed navbar that is 50px tall */
12
+ body {
13
+ padding-top: 50px;
14
+ }
15
+
16
+
17
+ /*
18
+ * Global add-ons
19
+ */
20
+
21
+ .sub-header {
22
+ padding-bottom: 10px;
23
+ border-bottom: 1px solid #eee;
24
+ }
25
+
26
+ /*
27
+ * Top navigation
28
+ * Hide default border to remove 1px line.
29
+ */
30
+ .navbar-fixed-top {
31
+ border: 0;
32
+ }
33
+
34
+ /*
35
+ * Sidebar
36
+ */
37
+
38
+ /* Hide for mobile, show later */
39
+ .sidebar {
40
+ display: none;
41
+ }
42
+ @media (min-width: 768px) {
43
+ .sidebar {
44
+ position: fixed;
45
+ top: 51px;
46
+ bottom: 0;
47
+ left: 0;
48
+ z-index: 1000;
49
+ display: block;
50
+ padding: 20px;
51
+ overflow-x: hidden;
52
+ overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
53
+ background-color: #f5f5f5;
54
+ border-right: 1px solid #eee;
55
+ }
56
+ }
57
+
58
+ /* Sidebar navigation */
59
+ .nav-sidebar {
60
+ margin-right: -21px; /* 20px padding + 1px border */
61
+ margin-bottom: 20px;
62
+ margin-left: -20px;
63
+ }
64
+ .nav-sidebar > li > a {
65
+ padding-right: 20px;
66
+ padding-left: 20px;
67
+ }
68
+ .nav-sidebar > .active > a,
69
+ .nav-sidebar > .active > a:hover,
70
+ .nav-sidebar > .active > a:focus {
71
+ color: #fff;
72
+ background-color: #428bca;
73
+ }
74
+
75
+
76
+ /*
77
+ * Main content
78
+ */
79
+
80
+ .main {
81
+ padding: 20px;
82
+ }
83
+ @media (min-width: 768px) {
84
+ .main {
85
+ padding-right: 40px;
86
+ padding-left: 40px;
87
+ }
88
+ }
89
+ .main .page-header {
90
+ margin-top: 0;
91
+ }
92
+
93
+
94
+ /*
95
+ * Placeholder dashboard ideas
96
+ */
97
+
98
+ .placeholders {
99
+ margin-bottom: 30px;
100
+ text-align: center;
101
+ }
102
+ .placeholders h4 {
103
+ margin-bottom: 0;
104
+ }
105
+ .placeholder {
106
+ margin-bottom: 20px;
107
+ }
108
+ .placeholder img {
109
+ display: inline-block;
110
+ border-radius: 50%;
111
+ }
@@ -0,0 +1,3 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require bootstrap
@@ -0,0 +1,26 @@
1
+ class Admin::BaseController < ApplicationController
2
+ include Aor::Authentication
3
+ include Aor::Authorization
4
+
5
+ before_action :login_required
6
+ before_action :authorize_admin
7
+
8
+ helper Admin::BaseHelper
9
+ layout 'admin'
10
+
11
+ protected
12
+ def current_user
13
+ @current_user ||= (login_from_session || :false)
14
+ end
15
+
16
+ def login_from_session
17
+ if session[:user_id]
18
+ new_user = AdmUser.find_by(id: session[:user_id])
19
+ self.current_user_form_session = new_user
20
+ end
21
+ end
22
+
23
+ def current_ability
24
+ @current_ability ||= AdmAbility.new(current_user)
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module Admin::BaseHelper
2
+
3
+ def bootstrap_class_for(flash_type)
4
+ case flash_type.to_sym
5
+ when :success
6
+ "alert-success"
7
+ when :error
8
+ "alert-danger"
9
+ when :alert
10
+ "alert-warning"
11
+ when :notice
12
+ "alert-info"
13
+ else
14
+ "alert-warning"
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,8 @@
1
+ <div class="panel panel-danger">
2
+ <div class="panel-heading"><%= pluralize(errors.count, "error") %>:</div>
3
+ <ul class="list-group">
4
+ <% errors.full_messages.each do |message| %>
5
+ <li class="list-group-item"><%= message %></li>
6
+ <% end %>
7
+ </ul>
8
+ </div>
@@ -0,0 +1,6 @@
1
+ <% flash.each do |type, message| %>
2
+ <div class="alert <%= bootstrap_class_for(type) %> alert-dismissible fade in" role="alert">
3
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
4
+ <%= message %>
5
+ </div>
6
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid">
2
+ <div class="navbar-header">
3
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
4
+ <span class="sr-only">Toggle navigation</span>
5
+ <span class="icon-bar"></span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ </button>
9
+ <a class="navbar-brand" href="#">Project name</a>
10
+ </div>
11
+ <div id="navbar" class="navbar-collapse collapse">
12
+ <ul class="nav navbar-nav navbar-right">
13
+ <li><a href="#">Dashboard</a></li>
14
+ <li><a href="#">Settings</a></li>
15
+ <li><a href="#">Profile</a></li>
16
+ <li><a href="#">Help</a></li>
17
+ </ul>
18
+ <form class="navbar-form navbar-right">
19
+ <input type="text" class="form-control" placeholder="Search...">
20
+ </form>
21
+ </div>
22
+ </div>
23
+ </nav>
@@ -0,0 +1,16 @@
1
+ <ul class="nav nav-sidebar">
2
+ <li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>
3
+ <%# if can?(:index, :article) %>
4
+ <li><a href="#">Articles</a></li>
5
+ <%# end %>
6
+ <li><a href="#">Reports</a></li>
7
+ <li><a href="#">Analytics</a></li>
8
+ <li><a href="#">Export</a></li>
9
+ </ul>
10
+ <ul class="nav nav-sidebar">
11
+ <li><a href="">Nav item</a></li>
12
+ <li><a href="">Nav item again</a></li>
13
+ <li><a href="">One more nav</a></li>
14
+ <li><a href="">Another nav item</a></li>
15
+ <li><a href="">More navigation</a></li>
16
+ </ul>
@@ -0,0 +1,33 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ <title>Admin</title>
9
+
10
+ <%= stylesheet_link_tag 'admin', media: 'all' %>
11
+
12
+ <%= csrf_meta_tags %>
13
+ </head>
14
+
15
+ <body>
16
+
17
+ <%= render 'admin/common/headnav' %>
18
+
19
+ <div class="container-fluid">
20
+ <div class="row">
21
+ <div class="col-sm-3 col-md-2 sidebar">
22
+ <%= render 'admin/common/sidebar' %>
23
+ </div>
24
+ <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
25
+ <%= render 'admin/common/flash_messages' %>
26
+ <%= yield %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+
31
+ <%= javascript_include_tag 'admin' %>
32
+ </body>
33
+ </html>
@@ -0,0 +1,34 @@
1
+ class Aor::ThemeGenerator < Rails::Generators::Base
2
+ source_paths.insert(0, File.expand_path('../templates', __FILE__))
3
+
4
+ def create_admin_layout
5
+ copy_file 'theme/admin.js', 'app/assets/javascripts/admin.js'
6
+ copy_file 'theme/admin.css', 'app/assets/stylesheets/admin.css'
7
+
8
+ copy_file 'theme/admin_common_headnav.html.erb', 'app/views/admin/common/_headnav.html.erb'
9
+ copy_file 'theme/admin_common_sidebar.html.erb', 'app/views/admin/common/_sidebar.html.erb'
10
+ copy_file 'theme/admin_common_errors.html.erb', 'app/views/admin/common/_errors.html.erb'
11
+ copy_file 'theme/admin_common_flash_messages.html.erb', 'app/views/admin/common/_flash_messages.html.erb'
12
+ copy_file 'theme/admin_layout.html.erb', 'app/views/layouts/admin.html.erb'
13
+
14
+ copy_file 'theme/admin_base_controller.rb', 'app/controllers/admin/base_controller.rb'
15
+ copy_file 'theme/admin_base_helper.rb', 'app/helpers/admin/base_helper.rb'
16
+
17
+ initializer 'admin_assets.rb' do
18
+ "Rails.application.config.assets.precompile += %w( admin.js admin.css )"
19
+ end
20
+
21
+ initializer 'bootstrap_field_error.rb' do
22
+ 'Rails.application.config.action_view.field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"has-error\">#{html_tag}</div>".html_safe }'
23
+ end
24
+ end
25
+
26
+ def create_admin_generator
27
+ directory 'generator/erb', 'lib/generators/admin/templates/erb'
28
+ copy_file 'generator/admin_controller_generator.rb.noautoload', 'lib/generators/admin/controller/controller_generator.rb'
29
+ copy_file 'generator/admin_scaffold_controller_generator.rb.noautoload', 'lib/generators/admin/scaffold_controller/scaffold_controller_generator.rb'
30
+ copy_file 'generator/admin_scaffold_generator.rb.noautoload', 'lib/generators/admin/scaffold/scaffold_generator.rb'
31
+
32
+ directory 'generator/rails', 'lib/generators/admin/templates/rails'
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :aor_theme do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aor-theme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.alpha1
5
+ platform: ruby
6
+ authors:
7
+ - ciro9527
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aor-bootstrap
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aor-authentication
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aor-authorization
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jquery-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ransack
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: kaminari
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: theme
126
+ email:
127
+ - ciro9527@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - MIT-LICENSE
133
+ - README.md
134
+ - Rakefile
135
+ - lib/aor/theme.rb
136
+ - lib/aor/theme/engine.rb
137
+ - lib/aor/theme/version.rb
138
+ - lib/generators/aor/theme/USAGE
139
+ - lib/generators/aor/theme/templates/generator/admin_controller_generator.rb.noautoload
140
+ - lib/generators/aor/theme/templates/generator/admin_scaffold_controller_generator.rb.noautoload
141
+ - lib/generators/aor/theme/templates/generator/admin_scaffold_generator.rb.noautoload
142
+ - lib/generators/aor/theme/templates/generator/erb/controller/view.html.erb
143
+ - lib/generators/aor/theme/templates/generator/erb/scaffold/_form.html.erb
144
+ - lib/generators/aor/theme/templates/generator/erb/scaffold/edit.html.erb
145
+ - lib/generators/aor/theme/templates/generator/erb/scaffold/index.html.erb
146
+ - lib/generators/aor/theme/templates/generator/erb/scaffold/new.html.erb
147
+ - lib/generators/aor/theme/templates/generator/erb/scaffold/show.html.erb
148
+ - lib/generators/aor/theme/templates/generator/rails/controller/controller.rb
149
+ - lib/generators/aor/theme/templates/generator/rails/scaffold_controller/api_controller.rb
150
+ - lib/generators/aor/theme/templates/generator/rails/scaffold_controller/controller.rb
151
+ - lib/generators/aor/theme/templates/theme/admin.css
152
+ - lib/generators/aor/theme/templates/theme/admin.js
153
+ - lib/generators/aor/theme/templates/theme/admin_base_controller.rb
154
+ - lib/generators/aor/theme/templates/theme/admin_base_helper.rb
155
+ - lib/generators/aor/theme/templates/theme/admin_common_errors.html.erb
156
+ - lib/generators/aor/theme/templates/theme/admin_common_flash_messages.html.erb
157
+ - lib/generators/aor/theme/templates/theme/admin_common_headnav.html.erb
158
+ - lib/generators/aor/theme/templates/theme/admin_common_sidebar.html.erb
159
+ - lib/generators/aor/theme/templates/theme/admin_layout.html.erb
160
+ - lib/generators/aor/theme/theme_generator.rb
161
+ - lib/tasks/aor/theme_tasks.rake
162
+ homepage: https://adminonrails.github.io
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">"
178
+ - !ruby/object:Gem::Version
179
+ version: 1.3.1
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.5.1
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: theme
186
+ test_files: []