simplify-admin-rails 0.3.1 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -4
- data/README.md +2 -1
- data/lib/generators/simplify_admin/USAGE +24 -0
- data/lib/generators/simplify_admin/simplify_admin_generator.rb +219 -0
- data/lib/simplify/admin/rails/version.rb +1 -1
- data/simplify-admin-rails.gemspec +0 -3
- data/vendor/assets/theme/simplify_admin.js +1 -0
- data/vendor/assets/theme/simplify_admin/js/common.js +49 -0
- metadata +5 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a6a0ac7d2da59a68804c2cfd82d2c67eac71dd4
|
4
|
+
data.tar.gz: b71272a166fa3c52cb933c76641f76bab6be69ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2486cf3a5bceea0dc47ba2c42d0775de83574dbee41fead764cd7ba6d2ad7f9de91ae2a8eca969e7be72ccc2a7364af66432df39a72e9fa31a7dc1b0fd50504e
|
7
|
+
data.tar.gz: 8b235ae98be34551a46166600df35c8117bdd0f60a154e5d0f32f4894dbd7f69d86f8020e861ab5be7981307b95160a4ce8aba90b9674590f0a0faa687eac15a
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,9 +6,10 @@
|
|
6
6
|
|
7
7
|
- Add this line to your application's Gemfile:
|
8
8
|
```ruby
|
9
|
-
gem 'simplify-admin-rails'
|
10
9
|
gem 'jquery-rails'
|
10
|
+
gem 'bootstrap-sass'
|
11
11
|
gem 'font-awesome-rails'
|
12
|
+
gem 'simplify-admin-rails'
|
12
13
|
```
|
13
14
|
- Then run: `bundle install`
|
14
15
|
- Or install it yourself as: `gem install simplify-admin-rails`
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Description:
|
2
|
+
Generate basic templates of simplify_admin
|
3
|
+
|
4
|
+
Usage:
|
5
|
+
rails generate simplify_admin layout [layout_name] [options]
|
6
|
+
|
7
|
+
Required Options:
|
8
|
+
title: string
|
9
|
+
|
10
|
+
Example:
|
11
|
+
rails generate simplify_admin layout --layout_name admin --options title:test
|
12
|
+
|
13
|
+
This will create
|
14
|
+
app/views/shared/_header.html.slim
|
15
|
+
app/views/shared/_sidebar.html.slim
|
16
|
+
app/controller/dashboard_controller.rb
|
17
|
+
|
18
|
+
This will add those lines in #{layout_name}.css.scss file
|
19
|
+
@import "bootstrap";
|
20
|
+
@import "font-awesome";
|
21
|
+
@import "simplify_admin";
|
22
|
+
|
23
|
+
This will add this line in #{layout_name}.js file
|
24
|
+
//= require simplify_admin
|
@@ -0,0 +1,219 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SimplifyAdminGenerator < Rails::Generators::NamedBase
|
4
|
+
include Rails::Generators::Actions
|
5
|
+
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
class_option :layout_name, type: :string, default: 'application'
|
8
|
+
class_option :options, type: :string, default: []
|
9
|
+
|
10
|
+
def import_assets
|
11
|
+
css_file_path = "#{Rails.root}/app/assets/stylesheets/#{layout_name}.css"
|
12
|
+
File.rename(css_file_path, "#{layout_name}.css.scss") if File.exist?(css_file_path)
|
13
|
+
|
14
|
+
css_file_names = %w(bootstrap-sprockets bootstrap font-awesome simplify_admin)
|
15
|
+
File.open("#{css_file_path}.scss", 'a') do |f|
|
16
|
+
css_file_names.each do |n|
|
17
|
+
next if File.read(f).match(/@import "#{n}";/)
|
18
|
+
f.puts <<~css
|
19
|
+
@import "#{n}";
|
20
|
+
css
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
js_file_path = "#{Rails.root}/app/assets/javascripts/#{layout_name}.js"
|
25
|
+
File.open(js_file_path, 'a') do |f|
|
26
|
+
f.puts("//= require simplify_admin") unless File.read(f).match(/simplify_admin/)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_layout
|
31
|
+
layout_html_path = "#{Rails.root}/app/views/layouts/#{layout_name}.html.erb"
|
32
|
+
File.rename(layout_html_path, "#{options["layout_name"]}.html.slim") if File.exist?(layout_html_path)
|
33
|
+
layout_path = "#{Rails.root}/app/views/layouts/#{layout_name}.html.slim"
|
34
|
+
|
35
|
+
helper_methods_exist?(%w(body_id body_class))
|
36
|
+
|
37
|
+
File.truncate(layout_path, 0) if File.exist?(layout_path)
|
38
|
+
File.open(layout_path, 'w') do |f|
|
39
|
+
f.puts <<~slim
|
40
|
+
doctype html
|
41
|
+
html
|
42
|
+
head
|
43
|
+
meta content=("text/html; charset=UTF-8") http-equiv="Content-Type" /
|
44
|
+
= yield :tb_before_cache
|
45
|
+
title
|
46
|
+
| #{title}
|
47
|
+
= csrf_meta_tags
|
48
|
+
= action_cable_meta_tag
|
49
|
+
= stylesheet_link_tag "#{layout_name}", media: 'all', 'data-turbolinks-track': 'reload'
|
50
|
+
= javascript_include_tag "#{layout_name}", 'data-turbolinks-track': 'reload'
|
51
|
+
= javascript_pack_tag "#{layout_name}"
|
52
|
+
|
53
|
+
body id=body_id class=body_class
|
54
|
+
.wrapper
|
55
|
+
= render 'shared/header'
|
56
|
+
= render 'shared/sidebar'
|
57
|
+
.main-container
|
58
|
+
.padding-md
|
59
|
+
= yield :breadcrumb
|
60
|
+
= yield
|
61
|
+
a.scroll-to-top.hidden-print href='#'
|
62
|
+
i.fa.fa-chevron-up.fa-lg
|
63
|
+
slim
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def create_simplify_admin_header
|
68
|
+
return if file_name != 'layout'
|
69
|
+
|
70
|
+
create_file 'app/views/shared/_header.html.slim' do
|
71
|
+
<<~header_partial
|
72
|
+
header.top-nav
|
73
|
+
.top-nav-inner
|
74
|
+
.nav-header
|
75
|
+
button#sidebarToggleSM.navbar-toggle.pull-left.sidebar-toggle type="button"
|
76
|
+
span.icon-bar
|
77
|
+
span.icon-bar
|
78
|
+
span.icon-bar
|
79
|
+
a.brand href='#'
|
80
|
+
i.fa.fa-database
|
81
|
+
span.brand-name
|
82
|
+
| #{title}
|
83
|
+
|
84
|
+
.nav-container
|
85
|
+
button#sidebarToggleLG.navbar-toggle.pull-left.sidebar-toggle type='button'
|
86
|
+
span.icon-bar
|
87
|
+
span.icon-bar
|
88
|
+
span.icon-bar
|
89
|
+
.pull-right.m-right-sm
|
90
|
+
.user-block.hidden-xs
|
91
|
+
a#userToggle data-toggle='dropdown' href='#'
|
92
|
+
#user-detail.user-detail.inline-block
|
93
|
+
#user-avatar
|
94
|
+
/ - if current_user.avatar.blank?
|
95
|
+
/ = image_tag 'avatar-default.png'
|
96
|
+
/ - else
|
97
|
+
/ = image_tag current_user.avatar.url
|
98
|
+
/ span.ml5 = current_user&.name
|
99
|
+
i.fa.fa-angle-down.m-left-xs
|
100
|
+
|
101
|
+
.panel.border.dropdown-menu.user-panel style="left: -20px;"
|
102
|
+
.panel-body.paddingTB-sm
|
103
|
+
ul
|
104
|
+
li
|
105
|
+
= link_to nil do
|
106
|
+
i.fa.fa-cog.fa-lg
|
107
|
+
span.m-left-xs 个人设置
|
108
|
+
li
|
109
|
+
= link_to nil, method: 'delete' do
|
110
|
+
i.fa.fa-power-off.fa-lg
|
111
|
+
span.m-left-xs 登出
|
112
|
+
header_partial
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def create_simplify_admin_sidebar
|
117
|
+
return if file_name != 'layout'
|
118
|
+
|
119
|
+
helper_methods_exist?(%w(render_active render_open display_block))
|
120
|
+
|
121
|
+
create_file 'app/views/shared/_sidebar.html.slim' do
|
122
|
+
<<~sidebar_partial
|
123
|
+
aside.sidebar-menu.fixed
|
124
|
+
.sidebar-inner.scrollable-sidebar
|
125
|
+
.main-menu
|
126
|
+
ul#test.accordion
|
127
|
+
li.menu-header
|
128
|
+
| Main Menu
|
129
|
+
|
130
|
+
li.bg-palette1 class=render_active(['dashboard'])
|
131
|
+
= link_to nil do
|
132
|
+
span.menu-content.block
|
133
|
+
span.menu-icon
|
134
|
+
i.block.fa.fa-home.fa-lg
|
135
|
+
span.text.m-left-sm 主页
|
136
|
+
span.menu-content-hover.block
|
137
|
+
| 主页
|
138
|
+
|
139
|
+
li.openable.bg-palette2 class=render_active(['foo'])
|
140
|
+
= link_to nil do
|
141
|
+
span.menu-content.block
|
142
|
+
span.menu-icon
|
143
|
+
i.block.fa.fa-list.fa-lg
|
144
|
+
span.text.m-left-sm Lorem Ipsum
|
145
|
+
span.submenu-icon
|
146
|
+
span.menu-content-hover.block
|
147
|
+
| Lorem Ipsum
|
148
|
+
ul.submenu.bg-palette2 style=display_block(['foo'])
|
149
|
+
li class=render_active(['foo'], 'index', 'new', 'edit')
|
150
|
+
= link_to nil do
|
151
|
+
span.submenu-label Lorem Ipsum
|
152
|
+
sidebar_partial
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def create_dashboard_controller
|
157
|
+
create_file "#{prefix('c')}/dashboard_controller.rb" do
|
158
|
+
<<~dashboard_controller
|
159
|
+
# frozen_string_literal: true
|
160
|
+
|
161
|
+
class DashboardController < ApplicationController
|
162
|
+
def index
|
163
|
+
end
|
164
|
+
end
|
165
|
+
dashboard_controller
|
166
|
+
end
|
167
|
+
|
168
|
+
route "root 'dashboard#index'"
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_dashboard_view
|
172
|
+
create_file "#{prefix('v')}/dashboard/index.html.slim" do
|
173
|
+
<<~dashboard_page
|
174
|
+
.row.m-bottom-md
|
175
|
+
.col-sm-6
|
176
|
+
.page-title
|
177
|
+
| Dashboard
|
178
|
+
.page-sub-header
|
179
|
+
| Welcome come back🙂
|
180
|
+
dashboard_page
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
private
|
185
|
+
|
186
|
+
def helper_methods_exist?(methods)
|
187
|
+
methods.each do |m|
|
188
|
+
raise "Missing #{ m } method, please init KTemplate first!" unless app_helper_code.match(/def #{ m }/)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def app_helper_code
|
193
|
+
if !File.exist?("#{ Rails.root }/app/helpers/application_helper.rb")
|
194
|
+
raise 'Missing application_helper.rb, please generate KTemplate first!'
|
195
|
+
end
|
196
|
+
File.read("#{ Rails.root }/app/helpers/application_helper.rb")
|
197
|
+
end
|
198
|
+
|
199
|
+
def layout_name
|
200
|
+
options["layout_name"]
|
201
|
+
end
|
202
|
+
|
203
|
+
def prefix(t)
|
204
|
+
t = case t
|
205
|
+
when 'm' then 'models'
|
206
|
+
when 'v' then 'views'
|
207
|
+
when 'c' then 'controllers'
|
208
|
+
end
|
209
|
+
layout_name == 'application' ? "app/#{t}/" : "app/#{t}/#{ layout_name }"
|
210
|
+
end
|
211
|
+
|
212
|
+
def title
|
213
|
+
attrs.fetch(:title)
|
214
|
+
end
|
215
|
+
|
216
|
+
def attrs
|
217
|
+
options["options"].split(' ').map { |ele| ele.split(':') }.to_h.symbolize_keys
|
218
|
+
end
|
219
|
+
end
|
@@ -24,7 +24,4 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.14"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
spec.add_development_dependency "jquery-rails", "~> 4"
|
28
|
-
spec.add_development_dependency "bootstrap-sass", '~> 3.3.7', '>= 3.3.7'
|
29
|
-
spec.add_development_dependency "font-awesome-rails", "~> 4"
|
30
27
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
$(document).on('turbolinks:load', function () {
|
4
|
+
$('#sidebarToggleLG').click(function () {
|
5
|
+
if ($('.wrapper').hasClass('display-right')) {
|
6
|
+
$('.wrapper').removeClass('display-right');
|
7
|
+
$('.sidebar-right').removeClass('active');
|
8
|
+
} else {
|
9
|
+
$('.top-nav').toggleClass('sidebar-mini');
|
10
|
+
$('aside').toggleClass('sidebar-mini');
|
11
|
+
$('footer').toggleClass('sidebar-mini');
|
12
|
+
$('.main-container').toggleClass('sidebar-mini');
|
13
|
+
$('.main-menu').find('.openable').removeClass('open');
|
14
|
+
$('.main-menu').find('.submenu').removeAttr('style');
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
$('#sidebarToggleSM').click(function () {
|
19
|
+
$('aside').toggleClass('active');
|
20
|
+
$('.wrapper').toggleClass('display-left');
|
21
|
+
});
|
22
|
+
|
23
|
+
$('.sidebarRight-toggle').click(function () {
|
24
|
+
$('.sidebar-right').toggleClass('active');
|
25
|
+
$('.wrapper').toggleClass('display-right');
|
26
|
+
$('footer').toggleClass('display-right');
|
27
|
+
return false;
|
28
|
+
});
|
29
|
+
|
30
|
+
$('.sidebar-menu .openable > a').click(function () {
|
31
|
+
if (!$('aside').hasClass('sidebar-mini') || Modernizr.mq('(max-width: 991px)')) {
|
32
|
+
if ($(this).parent().children('.submenu').is(':hidden')) {
|
33
|
+
$(this).parent().siblings().removeClass('open').children('.submenu').slideUp(200);
|
34
|
+
$(this).parent().addClass('open').children('.submenu').slideDown(200);
|
35
|
+
} else {
|
36
|
+
$(this).parent().removeClass('open').children('.submenu').slideUp(200);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return false;
|
40
|
+
});
|
41
|
+
|
42
|
+
if (!$('.sidebar-menu').hasClass('sidebar-mini') || Modernizr.mq('(max-width: 767px)')) {
|
43
|
+
$('.openable.open').children('.submenu').slideDown(200);
|
44
|
+
}
|
45
|
+
|
46
|
+
return $('#btn-collapse').click(function () {
|
47
|
+
$('.sidebar-header').toggleClass('active');
|
48
|
+
});
|
49
|
+
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplify-admin-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naive CAI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,54 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: jquery-rails
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '4'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bootstrap-sass
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 3.3.7
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 3.3.7
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - "~>"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 3.3.7
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 3.3.7
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: font-awesome-rails
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '4'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '4'
|
103
55
|
description: " Quickly start admin page using SimplifyAdmin theme. "
|
104
56
|
email:
|
105
57
|
- 835010809@qq.com
|
@@ -117,6 +69,8 @@ files:
|
|
117
69
|
- Rakefile
|
118
70
|
- bin/console
|
119
71
|
- bin/setup
|
72
|
+
- lib/generators/simplify_admin/USAGE
|
73
|
+
- lib/generators/simplify_admin/simplify_admin_generator.rb
|
120
74
|
- lib/simplify/admin/rails.rb
|
121
75
|
- lib/simplify/admin/rails/version.rb
|
122
76
|
- simplify-admin-rails.gemspec
|
@@ -132,6 +86,7 @@ files:
|
|
132
86
|
- vendor/assets/theme/simplify_admin/css/owl.carousel.min.css
|
133
87
|
- vendor/assets/theme/simplify_admin/css/owl.theme.default.min.css
|
134
88
|
- vendor/assets/theme/simplify_admin/css/simplify.css
|
89
|
+
- vendor/assets/theme/simplify_admin/js/common.js
|
135
90
|
- vendor/assets/theme/simplify_admin/js/modernizr-2.6.2.min.js
|
136
91
|
homepage: https://github.com/NaiveCAI/simplify_admin_template
|
137
92
|
licenses:
|