admin-panel 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +4 -0
  4. data/README.md +7 -3
  5. data/admin-panel.gemspec +2 -1
  6. data/lib/admin-panel/version.rb +1 -1
  7. data/lib/generators/admin_panel/install/install_generator.rb +7 -3
  8. data/lib/generators/admin_panel/install/templates/layouts/{admin → erb/admin}/_messages.html.erb +0 -0
  9. data/lib/generators/admin_panel/install/templates/layouts/{admin → erb/admin}/_navigation.html.erb +0 -0
  10. data/lib/generators/admin_panel/install/templates/layouts/{admin → erb/admin}/application.html.erb +0 -0
  11. data/lib/generators/admin_panel/install/templates/layouts/haml/admin/_messages.html.haml +5 -0
  12. data/lib/generators/admin_panel/install/templates/layouts/haml/admin/_navigation.html.haml +13 -0
  13. data/lib/generators/admin_panel/install/templates/layouts/haml/admin/application.html.haml +16 -0
  14. data/lib/generators/admin_panel/install/templates/views/erb/admin/dashboard/index.html.erb +1 -0
  15. data/lib/generators/admin_panel/install/templates/views/{admin → erb/admin}/passwords/edit.html.erb +0 -0
  16. data/lib/generators/admin_panel/install/templates/views/{admin → erb/admin}/passwords/new.html.erb +0 -0
  17. data/lib/generators/admin_panel/install/templates/views/{admin → erb/admin}/sessions/new.html.erb +1 -1
  18. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_first_page.html.erb +13 -0
  19. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_gap.html.erb +8 -0
  20. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_last_page.html.erb +13 -0
  21. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_next_page.html.erb +14 -0
  22. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_page.html.erb +12 -0
  23. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_paginator.html.erb +23 -0
  24. data/lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_prev_page.html.erb +13 -0
  25. data/lib/generators/admin_panel/install/templates/views/haml/admin/dashboard/index.html.haml +1 -0
  26. data/lib/generators/admin_panel/install/templates/views/haml/admin/passwords/edit.html.haml +13 -0
  27. data/lib/generators/admin_panel/install/templates/views/haml/admin/passwords/new.html.haml +10 -0
  28. data/lib/generators/admin_panel/install/templates/views/haml/admin/sessions/new.html.haml +13 -0
  29. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_first_page.html.haml +11 -0
  30. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_gap.html.haml +9 -0
  31. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_last_page.html.haml +11 -0
  32. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_next_page.html.haml +12 -0
  33. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_page.html.haml +12 -0
  34. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_paginator.html.haml +21 -0
  35. data/lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_prev_page.html.haml +11 -0
  36. data/lib/generators/admin_panel/scaffold/templates/controllers/controller.rb.erb +1 -1
  37. data/lib/generators/admin_panel/scaffold/templates/views/erb/_form.html.erb.erb +1 -1
  38. data/lib/generators/admin_panel/scaffold/templates/views/erb/edit.html.erb.erb +9 -8
  39. data/lib/generators/admin_panel/scaffold/templates/views/erb/index.html.erb.erb +14 -12
  40. data/lib/generators/admin_panel/scaffold/templates/views/erb/new.html.erb.erb +5 -9
  41. data/lib/generators/admin_panel/scaffold/templates/views/erb/show.html.erb.erb +15 -19
  42. data/lib/generators/admin_panel/scaffold/templates/views/haml/_form.html.haml.erb +15 -0
  43. data/lib/generators/admin_panel/scaffold/templates/views/haml/edit.html.haml.erb +12 -0
  44. data/lib/generators/admin_panel/scaffold/templates/views/haml/index.html.haml.erb +33 -0
  45. data/lib/generators/admin_panel/scaffold/templates/views/haml/new.html.haml.erb +10 -0
  46. data/lib/generators/admin_panel/scaffold/templates/views/haml/show.html.haml.erb +19 -0
  47. data/spec/generators/admin_panel/install/install_generator_spec.rb +4 -0
  48. metadata +50 -10
  49. data/lib/generators/admin_panel/install/templates/views/admin/dashboard/index.html.erb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bbe264a8f0f9ce2982096d8dc4b8873c1cdf736
4
- data.tar.gz: 3bb81974a0670450b6530da533311a6325dd5edb
3
+ metadata.gz: d576adba9f3f426390beb98ce565a2dd3f9cad6c
4
+ data.tar.gz: b0b7c5cbabace377af3932220d4b8b259b5bc64d
5
5
  SHA512:
6
- metadata.gz: bf8e131f97cc7c676133a242eff4c57a49627f8ad229f2d783fbe86ce5429d4b48bb8444d818127c56307ef6b6e827216b5a788dfdc5eaa5d56bd9562a2e8b7b
7
- data.tar.gz: 4ad86baa443f5c7c2e6cbf594f3dc11270cc833b316fae60c34b1aabc43fb6b5d3432fa285ba95bb439138d99ea37464c6de032e4c0e695f628dde3929bba142
6
+ metadata.gz: 7767e7da9205c126aa2b6a90595f7d65fb0c2445009e948dd6ced8c64d4390695a51932487be12d255d13e1e313126e7c9e5162d844fd8cdfaaa4e207f4487c3
7
+ data.tar.gz: c67f7de6a57171029cf9b55db6140691629254c6ac261a001cc55ffc9ec77556d70ec8ad89398b9d51f9f6920ddf8fdb6144e0e1d9c1c1b397723d49f73e235c
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .idea
2
2
  tmp/
3
+ .DS_Store
4
+ */.DS_Store
@@ -4,6 +4,7 @@ PATH
4
4
  admin-panel (0.1.2)
5
5
  bootstrap-sass (~> 3.1)
6
6
  devise (~> 3.2)
7
+ kaminari (~> 0.16)
7
8
  railties (>= 4.0.0)
8
9
  sass-rails (>= 4.0.0)
9
10
  simple_form (>= 3.1.0.rc1)
@@ -48,6 +49,9 @@ GEM
48
49
  hike (1.2.3)
49
50
  i18n (0.6.9)
50
51
  json (1.8.1)
52
+ kaminari (0.16.1)
53
+ actionpack (>= 3.0.0)
54
+ activesupport (>= 3.0.0)
51
55
  minitest (5.3.4)
52
56
  multi_json (1.10.1)
53
57
  orm_adapter (0.5.0)
data/README.md CHANGED
@@ -9,10 +9,11 @@ Installation
9
9
  Start with adding these gems to your Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'admin-panel', '~> 0.1.1'
12
+ gem 'admin-panel', '~> 0.1.3'
13
13
  gem 'devise', '~> 3.2'
14
14
  gem 'simple_form', '3.1.0.rc1'
15
15
  gem 'bootstrap-sass', '~> 3.1'
16
+ gem 'kaminari', '~> 0.16.1'
16
17
  ```
17
18
 
18
19
  Then do `bundle install` and run the installer:
@@ -40,6 +41,8 @@ Thanks
40
41
 
41
42
  This gem was based mostly on two different pieces of software: [bootstrap-generators](https://github.com/decioferreira/bootstrap-generators) and [rails-admin-scaffold](https://github.com/dhampik/rails-admin-scaffold)
42
43
 
44
+ I also took the liberty of copying kaminari bootstrap templates from [kaminari-bootstrap](https://github.com/mcasimir/kaminari-bootstrap)
45
+
43
46
  TODO
44
47
  ----
45
48
 
@@ -48,8 +51,9 @@ Currently this gem is pretty much one-evening project, I'm not sure if I'll cont
48
51
  Things that'd be nice to have:
49
52
 
50
53
  - support for anything more than Active Record
51
- - support for anything more than Erb (haml, slim)
54
+ - ~~support for anything more than Erb (haml)~~
55
+ - support for slim
52
56
  - namespace change support and more configuration options
53
- - kaminari/will_paginate support
57
+ - ~~kaminari/will_paginate support~~
54
58
  - I liked the idea of copying the files to your project during install at first but now it just seems silly; I should probably rewrite everything from scratch to work more similarly to Devise, including the ability to extend default controllers where necessary
55
59
  - I was also supposed to add Carrierwave support too but ran out of time
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Michał Matyas']
9
9
  spec.email = ['michal@higher.lv']
10
10
  spec.summary = 'Generates Twitter Bootstrap based admin panel with scaffolder'
11
- spec.description = 'Generates Twitter Bootstrap based admin panel with scaffolder. Project is quite opinionated, requires Rails 4, SASS, SimpleForm and Devise.'
11
+ spec.description = 'Generates Twitter Bootstrap based admin panel with scaffolder. Project is quite opinionated, requires Rails 4, SASS, SimpleForm, Kaminari and Devise.'
12
12
  spec.homepage = 'https://github.com/d4rky-pl/admin-panel'
13
13
  spec.license = 'MIT'
14
14
 
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'bootstrap-sass', '~> 3.1'
27
27
  spec.add_runtime_dependency 'simple_form', '>= 3.1.0.rc1'
28
28
  spec.add_runtime_dependency 'devise', '~> 3.2'
29
+ spec.add_runtime_dependency 'kaminari', '~> 0.16'
29
30
  end
@@ -1,3 +1,3 @@
1
1
  module AdminPanel
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -16,16 +16,20 @@ module AdminPanel
16
16
  invoke 'simple_form:install', [], ['--bootstrap']
17
17
  end
18
18
 
19
+ def generate_kaminari_config
20
+ invoke 'kaminari:config'
21
+ end
22
+
19
23
  attr_reader :app_name
20
24
 
21
25
  def copy_layout
22
26
  @app_name = ::Rails.application.class.to_s.split("::").first.humanize
23
27
  extension = "html.#{options[:template_engine]}"
24
28
 
25
- template "layouts/admin/application.#{extension}", "app/views/layouts/admin/application.#{extension}"
29
+ template "layouts/#{options[:template_engine]}/admin/application.html.#{options[:template_engine]}", "app/views/layouts/admin/application.html.#{options[:template_engine]}"
26
30
  ['_messages', '_navigation'].each do |file|
27
31
  filename = "#{file}.#{extension}"
28
- copy_file "layouts/admin/#{filename}", "app/views/layouts/admin/#{filename}"
32
+ copy_file "layouts/#{options[:template_engine]}/admin/#{filename}", "app/views/layouts/admin/#{filename}"
29
33
  end
30
34
  end
31
35
 
@@ -39,7 +43,7 @@ module AdminPanel
39
43
 
40
44
  def copy_scaffold
41
45
  directory 'controllers', 'app/controllers'
42
- directory 'views', 'app/views'
46
+ directory "views/#{options[:template_engine]}", 'app/views'
43
47
  end
44
48
 
45
49
  def create_admin_model
@@ -0,0 +1,5 @@
1
+ - flash.each do |name, msg|
2
+ - if msg.is_a?(String)
3
+ %div{class: "alert alert-#{name.to_s == 'notice' ? 'success' : 'danger'}"}
4
+ %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
5
+ = content_tag :div, msg, :id => "flash_#{name}"
@@ -0,0 +1,13 @@
1
+ %nav.navbar.navbar-default{role: "navigation"}
2
+ .container-fluid
3
+ .navbar-header
4
+ %a.navbar-brand{href: admin_dashboard_path} App name
5
+
6
+ - if admin_signed_in?
7
+ %ul.nav.navbar-nav
8
+ - admin_pages.each do |page|
9
+ %li{class: controller_name == page[:controller] ? 'active' : ''}
10
+ %a{href: page[:url]}= page[:name]
11
+
12
+ %ul.nav.navbar-nav.navbar-right
13
+ %li= link_to 'Sign out', destroy_admin_session_path, method: :delete
@@ -0,0 +1,16 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{ content: "width=device-width, initial-scale=1.0", name: "viewport" }/
5
+ %title= content_for?(:title) ? yield(:title) : "<%= app_name.underscore.titleize %>"
6
+ %meta{ name: 'description', content: content_for?(:description) ? yield(:description) : "<%= app_name.underscore.titleize %>" }
7
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
8
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
9
+ = csrf_meta_tags
10
+ %body
11
+ %header
12
+ = render partial: 'layouts/admin/navigation'
13
+ %main{ role: 'main' }
14
+ .container
15
+ = render partial: 'layouts/admin/messages'
16
+ = yield
@@ -13,5 +13,5 @@
13
13
  <% end %>
14
14
 
15
15
  <%- if devise_mapping.recoverable? %>
16
- <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
16
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
17
17
  <% end -%>
@@ -0,0 +1,13 @@
1
+ <%# Link to the "First" page
2
+ - available local variables
3
+ url: url to the first page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <% unless current_page.first? -%>
10
+ <li class="first">
11
+ <%= link_to raw(t 'views.pagination.first'), url, {:remote => remote} %>
12
+ </li>
13
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ <%# Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ total_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ -%>
8
+ <li class="page gap disabled"><a><%= raw(t 'views.pagination.truncate') %></a></li>
@@ -0,0 +1,13 @@
1
+ <%# Link to the "Last" page
2
+ - available local variables
3
+ url: url to the last page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <% unless current_page.last? -%>
10
+ <li class="last">
11
+ <%= link_to raw(t 'views.pagination.last'), url, {:remote => remote} %>
12
+ </li>
13
+ <% end -%>
@@ -0,0 +1,14 @@
1
+ <%# Link to the "Next" page
2
+ - available local variables
3
+ url: url to the next page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+
10
+ <% unless current_page.last? -%>
11
+ <li class="next">
12
+ <%= link_to raw(t 'views.pagination.next'), url, :remote => remote, :rel => 'next' %>
13
+ </li>
14
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <%# Link showing page number
2
+ - available local variables
3
+ page: a page object for "this" page
4
+ url: url to this page
5
+ current_page: a page object for the currently displayed page
6
+ total_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
9
+ -%>
10
+ <li class="page<%= ' active' if page.current? %>">
11
+ <%= link_to page, (page.current? ? 'javascript:void(0)' : url), opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
12
+ </li>
@@ -0,0 +1,23 @@
1
+ <%# The container tag
2
+ - available local variables
3
+ current_page: a page object for the currently displayed page
4
+ total_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
7
+ paginator: the paginator that renders the pagination tags inside
8
+ -%>
9
+ <%= paginator.render do -%>
10
+ <ul class="pagination">
11
+ <%= first_page_tag unless current_page.first? %>
12
+ <%= prev_page_tag unless current_page.first? %>
13
+ <% each_page do |page| -%>
14
+ <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
15
+ <%= page_tag page %>
16
+ <% elsif !page.was_truncated? -%>
17
+ <%= gap_tag %>
18
+ <% end -%>
19
+ <% end -%>
20
+ <%= next_page_tag unless current_page.last? %>
21
+ <%= last_page_tag unless current_page.last? %>
22
+ </ul>
23
+ <% end -%>
@@ -0,0 +1,13 @@
1
+ <%# Link to the "Previous" page
2
+ - available local variables
3
+ url: url to the previous page
4
+ current_page: a page object for the currently displayed page
5
+ total_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
+ -%>
9
+ <% unless current_page.first? -%>
10
+ <li class="prev">
11
+ <%= link_to raw(t 'views.pagination.previous'), url, :remote => remote, :rel => 'prev' %>
12
+ </li>
13
+ <% end -%>
@@ -0,0 +1,13 @@
1
+ %h2 Change your password
2
+ = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
3
+ = f.error_notification
4
+
5
+ = f.input :reset_password_token, as: :hidden
6
+ = f.full_error :reset_password_token
7
+
8
+ .form-inputs
9
+ = f.input :password, label: "New password", required: true, autofocus: true
10
+ = f.input :password_confirmation, label: "Confirm your new password", required: true
11
+
12
+ .form-actions
13
+ = f.button :submit, "Change my password"
@@ -0,0 +1,10 @@
1
+ %h2 Forgot your password?
2
+
3
+ = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
4
+ = f.error_notification
5
+
6
+ .form-inputs
7
+ = f.input :email, required: true, autofocus: true
8
+
9
+ .form-actions
10
+ = f.button :submit, "Send me reset password instructions"
@@ -0,0 +1,13 @@
1
+ %h2 Sign in
2
+
3
+ = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
4
+ .form-inputs
5
+ = f.input :email, required: false, autofocus: true
6
+ = f.input :password, required: false
7
+ = f.input :remember_me, as: :boolean if devise_mapping.rememberable?
8
+
9
+ .form-actions
10
+ = f.button :submit, "Sign in"
11
+
12
+ - if devise_mapping.recoverable?
13
+ = link_to "Forgot your password?", new_password_path(resource_name)
@@ -0,0 +1,11 @@
1
+ -# Link to the "First" page
2
+ -# - available local variables
3
+ -# url: url to the first page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ -#
9
+ - unless current_page.first?
10
+ %li.first
11
+ = link_to raw(t 'views.pagination.first'), url, {:remote => remote}
@@ -0,0 +1,9 @@
1
+ -# Non-link tag that stands for skipped pages...
2
+ -# - available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ -#
8
+ %li.page.gap.disabled
9
+ %a= raw(t 'views.pagination.truncate')
@@ -0,0 +1,11 @@
1
+ -# Link to the "Last" page
2
+ -# - available local variables
3
+ -# url: url to the last page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+
9
+ - unless current_page.last?
10
+ %li.last
11
+ = link_to raw(t 'views.pagination.last'), url, {:remote => remote}
@@ -0,0 +1,12 @@
1
+ -# Link to the "Next" page
2
+ -# - available local variables
3
+ -# url: url to the next page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ -#
9
+
10
+ - unless current_page.last?
11
+ %li.next
12
+ = link_to raw(t 'views.pagination.next'), url, :remote => remote, :rel => 'next'
@@ -0,0 +1,12 @@
1
+ -# Link showing page number
2
+ -# - available local variables
3
+ -# page: a page object for "this" page
4
+ -# url: url to this page
5
+ -# current_page: a page object for the currently displayed page
6
+ -# total_pages: total number of pages
7
+ -# per_page: number of items to fetch per page
8
+ -# remote: data-remote
9
+ -#
10
+
11
+ %li.page{ class: "#{'active' if page.current?}"}
12
+ = link_to page, (page.current? ? 'javascript:void(0)' : url), opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
@@ -0,0 +1,21 @@
1
+ -# The container tag
2
+ -# - available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ -# paginator: the paginator that renders the pagination tags inside
8
+ -#
9
+
10
+ = paginator.render do
11
+ %ul.pagination
12
+ = first_page_tag unless current_page.first?
13
+ = prev_page_tag unless current_page.first?
14
+ - each_page do |page|
15
+ - if page.left_outer? || page.right_outer? || page.inside_window?
16
+ = page_tag page
17
+ - elsif !page.was_truncated?
18
+ = gap_tag
19
+
20
+ = next_page_tag unless current_page.last?
21
+ = last_page_tag unless current_page.last?
@@ -0,0 +1,11 @@
1
+ -# Link to the "Previous" page
2
+ -# - available local variables
3
+ -# url: url to the previous page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+
9
+ - unless current_page.first?
10
+ %li.prev
11
+ = link_to raw(t 'views.pagination.previous'), url, :remote => remote, :rel => 'prev'
@@ -9,7 +9,7 @@ class <%= prefixed_controller_class_name %>Controller < <%= parent_controller_cl
9
9
 
10
10
  # GET <%= prefixed_route_url %>
11
11
  def index
12
- @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
12
+ @<%= plural_table_name %> = <%= class_name %>.page params[:page]
13
13
  end
14
14
 
15
15
  # GET <%= prefixed_route_url %>/1
@@ -15,6 +15,6 @@
15
15
  </div>
16
16
 
17
17
  <div class="form-actions">
18
- <%%= f.button :submit %>
18
+ <%%= f.button :submit, :class => 'btn btn-primary' %>
19
19
  </div>
20
20
  <%% end %>
@@ -1,12 +1,13 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>Editing <%= singular_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
- </div>
9
- </div>
2
+ <%%= link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do %>
3
+ <i class="glyphicon glyphicon-list-alt"></i>
4
+ Back
5
+ <%% end %>
6
+ <%%= link_to <%= "[:#{prefix}, @#{singular_table_name}]" %>, class: 'btn btn-primary pull-right' do %>
7
+ <i class="glyphicon glyphicon-info-sign"></i>
8
+ Show
9
+ <%% end %>
10
+ <h1>Editing <%= human_name %></h1>
10
11
  </div>
11
12
 
12
13
  <%%= render 'form' %>
@@ -1,21 +1,19 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>Listing <%= plural_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'New <%= human_name %>', new_<%= prefixed_plain_model_url %>_path, class: 'btn btn-success'%>
8
- </div>
9
- </div>
2
+ <%%= link_to new_<%= prefixed_plain_model_url %>_path, class: 'btn btn-success pull-right' do %>
3
+ <i class="glyphicon glyphicon-plus"></i>
4
+ New <%= human_name %>
5
+ <%% end %>
6
+ <h1><%= plural_table_name.humanize %></h1>
10
7
  </div>
11
8
 
12
- <table class="table table-striped">
9
+ <table class="table table-striped table-hover table-bordered">
13
10
  <thead>
14
11
  <tr>
15
12
  <% attributes.reject(&:password_digest?).each do |attribute| -%>
16
13
  <th><%= attribute.human_name %></th>
17
14
  <% end -%>
18
- <th class="text-right">Actions</th>
15
+ <th></th>
16
+ <th></th>
19
17
  </tr>
20
18
  </thead>
21
19
 
@@ -26,12 +24,16 @@
26
24
  <td><%%= link_to <%= singular_table_name %>.<%= attribute.name %>, <%= "[:#{prefix}, #{singular_table_name}]" %> %></td>
27
25
  <% end -%>
28
26
  <td class="text-right">
29
- <%%= link_to 'Show', <%= "[:#{prefix}, #{singular_table_name}]" %>, class: 'btn btn-default' %>
30
27
  <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(<%= singular_table_name %>), class: 'btn btn-primary' %>
28
+ </td>
29
+ <td class="text-right">
31
30
  <%%= link_to 'Destroy', <%= "[:#{prefix}, #{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
32
- </td>
31
+ </td>
33
32
  </tr>
34
33
  <%% end %>
35
34
  </tbody>
36
35
  </table>
37
36
 
37
+ <div class="text-center">
38
+ <%%= paginate @<%= plural_table_name %>, theme: 'admin-bootstrap' %>
39
+ </div>
@@ -1,14 +1,10 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>New <%= singular_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
- </div>
9
- </div>
2
+ <%%= link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do %>
3
+ <i class="glyphicon glyphicon-list-alt"></i>
4
+ Back
5
+ <%% end %>
6
+ <h1>New <%= human_name %></h1>
10
7
  </div>
11
8
 
12
-
13
9
  <%%= render 'form' %>
14
10
 
@@ -1,22 +1,18 @@
1
- <p id="notice"><%%= notice %></p>
1
+ <div class="page-header">
2
+ <%%= link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do %>
3
+ <i class="glyphicon glyphicon-list-alt"></i>
4
+ Back
5
+ <%% end %>
6
+ <%%= link_to edit_<%= prefixed_plain_model_url %>_path(@<%= singular_table_name %>), class: 'btn btn-primary pull-right' do %>
7
+ <i class="glyphicon glyphicon-pencil"></i>
8
+ Edit
9
+ <%% end %>
10
+ <h1>Show <%= human_name %></h1>
11
+ </div>
2
12
 
3
- <table class="table table-striped">
4
- <tbody>
13
+ <dl class="dl-horizontal">
5
14
  <% attributes.reject(&:password_digest?).each do |attribute| -%>
6
- <tr>
7
- <td><strong><%= attribute.human_name %>:</strong></td>
8
- <td><%%= @<%= singular_table_name %>.<%= attribute.name %> %></td>
9
- </tr>
15
+ <dt><%= attribute.human_name %>:</dt>
16
+ <dd><%%= @<%= singular_table_name %>.<%= attribute.name %> %></dd>
10
17
  <% end -%>
11
- </tbody>
12
- </table>
13
-
14
- <div class="row">
15
- <div class="col-md-6">
16
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
17
- </div
18
- <div class="col-md-6 text-right">
19
- <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(@<%= singular_table_name %>), class: 'btn btn-primary' %>
20
- <%%= link_to 'Destroy', <%= "[:#{prefix}, @#{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
21
- </div>
22
- </div>
18
+ </dl>
@@ -0,0 +1,15 @@
1
+ = simple_form_for(<%= "[:#{prefix}, @#{singular_table_name}]" %>, html: { class: 'form-horizontal' },
2
+ wrapper: :horizontal_form,
3
+ wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes,
4
+ radio_buttons: :horizontal_radio_and_checkboxes,
5
+ file: :horizontal_file_input,
6
+ boolean: :horizontal_boolean }) do |f|
7
+
8
+ = f.error_notification
9
+
10
+ .form-inputs
11
+ <%- attributes.each do |attribute| -%>
12
+ = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
13
+ <%- end -%>
14
+ .form-actions
15
+ = f.button :submit, :class => 'btn btn-primary'
@@ -0,0 +1,12 @@
1
+ .page-header
2
+ = link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do
3
+ %i.glyphicon.glyphicon-list-alt
4
+ Back
5
+
6
+ = link_to <%= "[:#{prefix}, @#{singular_table_name}]" %>, class: 'btn btn-primary pull-right' do
7
+ %i.glyphicon.glyphicon-info-sign
8
+ Show
9
+ %h1
10
+ Editing <%= human_name %>
11
+
12
+ = render 'form'
@@ -0,0 +1,33 @@
1
+ .page-header
2
+ = link_to new_<%= prefixed_plain_model_url %>_path, class: 'btn btn-success pull-right' do
3
+ %i.glyphicon.glyphicon-plus
4
+ New <%= human_name %>
5
+
6
+ %h1
7
+ <%= plural_table_name.humanize %></h1>
8
+
9
+ %table.table.table-striped.table-hover.table-bordered
10
+ %thead
11
+ %tr
12
+ <%- attributes.reject(&:password_digest?).each do |attribute| -%>
13
+ %th
14
+ <%= attribute.human_name %>
15
+ <%- end -%>
16
+ %th
17
+ %th
18
+
19
+ %tbody
20
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
21
+ %tr
22
+ <%- attributes.reject(&:password_digest?).each do |attribute| -%>
23
+ %td
24
+ = link_to <%= singular_table_name %>.<%= attribute.name %>, <%= "[:#{prefix}, #{singular_table_name}]" %>
25
+ <%- end -%>
26
+ %td.text-right
27
+ = link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(<%= singular_table_name %>), class: 'btn btn-primary'
28
+
29
+ %td.text-right
30
+ = link_to 'Destroy', <%= "[:#{prefix}, #{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
31
+
32
+ .text-center
33
+ = paginate @<%= plural_table_name %>, theme: 'admin-bootstrap'
@@ -0,0 +1,10 @@
1
+ .page-header
2
+ = link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do
3
+ %i.glyphicon.glyphicon-list-alt
4
+ Back
5
+
6
+ %h1
7
+ New <%= human_name %>
8
+
9
+ = render 'form'
10
+
@@ -0,0 +1,19 @@
1
+ .page-header
2
+ = link_to <%= prefixed_index_helper %>_path, class: 'btn btn-default pull-right' do
3
+ %i.glyphicon.glyphicon-list-alt
4
+ Back
5
+
6
+ = link_to edit_<%= prefixed_plain_model_url %>_path(@<%= singular_table_name %>), class: 'btn btn-primary pull-right' do
7
+ %i.glyphicon.glyphicon-pencil
8
+ Edit
9
+
10
+ %h1
11
+ Show <%= human_name %>
12
+
13
+ %dl.dl-horizontal
14
+ <%- attributes.reject(&:password_digest?).each do |attribute| -%>
15
+ %dt
16
+ <%= attribute.human_name %>:
17
+ %dd
18
+ = @<%= singular_table_name %>.<%= attribute.name %>
19
+ <%- end -%>
@@ -19,6 +19,10 @@ describe AdminPanel::Generators::InstallGenerator do
19
19
  it_should_exist 'config/initializers/simple_form.rb'
20
20
  end
21
21
 
22
+ describe 'kaminari:config' do
23
+ it_should_exist 'config/initializers/kaminari_config.rb'
24
+ end
25
+
22
26
  describe 'copying layout' do
23
27
  it_should_exist 'app/views/layouts/admin/application.html.erb'
24
28
  it_should_exist 'app/views/layouts/admin/_messages.html.erb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin-panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Matyas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,8 +136,22 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: kaminari
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.16'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.16'
139
153
  description: Generates Twitter Bootstrap based admin panel with scaffolder. Project
140
- is quite opinionated, requires Rails 4, SASS, SimpleForm and Devise.
154
+ is quite opinionated, requires Rails 4, SASS, SimpleForm, Kaminari and Devise.
141
155
  email:
142
156
  - michal@higher.lv
143
157
  executables: []
@@ -161,13 +175,34 @@ files:
161
175
  - lib/generators/admin_panel/install/templates/controllers/admin/sessions_controller.rb
162
176
  - lib/generators/admin_panel/install/templates/controllers/concerns/administrable.rb
163
177
  - lib/generators/admin_panel/install/templates/helpers/admin_helper.rb
164
- - lib/generators/admin_panel/install/templates/layouts/admin/_messages.html.erb
165
- - lib/generators/admin_panel/install/templates/layouts/admin/_navigation.html.erb
166
- - lib/generators/admin_panel/install/templates/layouts/admin/application.html.erb
167
- - lib/generators/admin_panel/install/templates/views/admin/dashboard/index.html.erb
168
- - lib/generators/admin_panel/install/templates/views/admin/passwords/edit.html.erb
169
- - lib/generators/admin_panel/install/templates/views/admin/passwords/new.html.erb
170
- - lib/generators/admin_panel/install/templates/views/admin/sessions/new.html.erb
178
+ - lib/generators/admin_panel/install/templates/layouts/erb/admin/_messages.html.erb
179
+ - lib/generators/admin_panel/install/templates/layouts/erb/admin/_navigation.html.erb
180
+ - lib/generators/admin_panel/install/templates/layouts/erb/admin/application.html.erb
181
+ - lib/generators/admin_panel/install/templates/layouts/haml/admin/_messages.html.haml
182
+ - lib/generators/admin_panel/install/templates/layouts/haml/admin/_navigation.html.haml
183
+ - lib/generators/admin_panel/install/templates/layouts/haml/admin/application.html.haml
184
+ - lib/generators/admin_panel/install/templates/views/erb/admin/dashboard/index.html.erb
185
+ - lib/generators/admin_panel/install/templates/views/erb/admin/passwords/edit.html.erb
186
+ - lib/generators/admin_panel/install/templates/views/erb/admin/passwords/new.html.erb
187
+ - lib/generators/admin_panel/install/templates/views/erb/admin/sessions/new.html.erb
188
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_first_page.html.erb
189
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_gap.html.erb
190
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_last_page.html.erb
191
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_next_page.html.erb
192
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_page.html.erb
193
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_paginator.html.erb
194
+ - lib/generators/admin_panel/install/templates/views/erb/kaminari/admin-bootstrap/_prev_page.html.erb
195
+ - lib/generators/admin_panel/install/templates/views/haml/admin/dashboard/index.html.haml
196
+ - lib/generators/admin_panel/install/templates/views/haml/admin/passwords/edit.html.haml
197
+ - lib/generators/admin_panel/install/templates/views/haml/admin/passwords/new.html.haml
198
+ - lib/generators/admin_panel/install/templates/views/haml/admin/sessions/new.html.haml
199
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_first_page.html.haml
200
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_gap.html.haml
201
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_last_page.html.haml
202
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_next_page.html.haml
203
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_page.html.haml
204
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_paginator.html.haml
205
+ - lib/generators/admin_panel/install/templates/views/haml/kaminari/admin-bootstrap/_prev_page.html.haml
171
206
  - lib/generators/admin_panel/scaffold/scaffold_generator.rb
172
207
  - lib/generators/admin_panel/scaffold/templates/controllers/controller.rb.erb
173
208
  - lib/generators/admin_panel/scaffold/templates/views/erb/_form.html.erb.erb
@@ -175,6 +210,11 @@ files:
175
210
  - lib/generators/admin_panel/scaffold/templates/views/erb/index.html.erb.erb
176
211
  - lib/generators/admin_panel/scaffold/templates/views/erb/new.html.erb.erb
177
212
  - lib/generators/admin_panel/scaffold/templates/views/erb/show.html.erb.erb
213
+ - lib/generators/admin_panel/scaffold/templates/views/haml/_form.html.haml.erb
214
+ - lib/generators/admin_panel/scaffold/templates/views/haml/edit.html.haml.erb
215
+ - lib/generators/admin_panel/scaffold/templates/views/haml/index.html.haml.erb
216
+ - lib/generators/admin_panel/scaffold/templates/views/haml/new.html.haml.erb
217
+ - lib/generators/admin_panel/scaffold/templates/views/haml/show.html.haml.erb
178
218
  - spec/dummy/Rakefile
179
219
  - spec/dummy/app/assets/javascripts/application.js
180
220
  - spec/dummy/app/assets/stylesheets/application.css