loyal_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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/javascripts/loyal_admin/application.js +5 -0
- data/app/assets/javascripts/loyal_admin/display/boards.js +2 -0
- data/app/assets/javascripts/loyal_admin/display/recipes.js +2 -0
- data/app/assets/stylesheets/loyal_admin/application.css.scss +312 -0
- data/app/assets/stylesheets/loyal_admin/display/boards.css +4 -0
- data/app/assets/stylesheets/loyal_admin/display/recipes.css +4 -0
- data/app/controllers/loyal_admin/application_controller.rb +9 -0
- data/app/controllers/loyal_admin/display/boards_controller.rb +49 -0
- data/app/controllers/loyal_admin/display/recipes_controller.rb +49 -0
- data/app/controllers/loyal_admin/welcome_controller.rb +9 -0
- data/app/helpers/loyal_admin/application_helper.rb +5 -0
- data/app/helpers/loyal_admin/display/boards_helper.rb +5 -0
- data/app/helpers/loyal_admin/display/recipes_helper.rb +5 -0
- data/app/models/loyal_admin/display/board.rb +30 -0
- data/app/models/loyal_admin/display/item.rb +16 -0
- data/app/models/loyal_admin/display/recipe.rb +35 -0
- data/app/views/layouts/loyal_admin/application.html.erb +75 -0
- data/app/views/loyal_admin/display/boards/_form.html.erb +11 -0
- data/app/views/loyal_admin/display/boards/_links.html.erb +3 -0
- data/app/views/loyal_admin/display/boards/edit.html.erb +12 -0
- data/app/views/loyal_admin/display/boards/index.html.erb +23 -0
- data/app/views/loyal_admin/display/boards/new.html.erb +11 -0
- data/app/views/loyal_admin/display/boards/show.html.erb +30 -0
- data/app/views/loyal_admin/display/recipes/_form.html.erb +11 -0
- data/app/views/loyal_admin/display/recipes/edit.html.erb +12 -0
- data/app/views/loyal_admin/display/recipes/index.html.erb +25 -0
- data/app/views/loyal_admin/display/recipes/new.html.erb +11 -0
- data/app/views/loyal_admin/display/recipes/show.html.erb +23 -0
- data/app/views/loyal_admin/shared/_side_panel.html.erb +0 -0
- data/app/views/loyal_admin/welcome/index.html.erb +0 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20130325145548_create_loyal_admin_display_items.rb +18 -0
- data/db/migrate/20130503053259_create_loyal_admin_display_recipes.rb +22 -0
- data/db/migrate/20130612063348_create_loyal_admin_display_boards.rb +43 -0
- data/lib/loyal_admin/config.rb +71 -0
- data/lib/loyal_admin/controllers/controller_extends.rb +28 -0
- data/lib/loyal_admin/engine.rb +11 -0
- data/lib/loyal_admin/version.rb +4 -0
- data/lib/loyal_admin.rb +9 -0
- data/lib/tasks/loyal_admin_tasks.rake +4 -0
- data/spec/controllers/loyal_admin/display/boards_controller_spec.rb +8 -0
- data/spec/controllers/loyal_admin/display/recipes_controller_spec.rb +8 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +6 -0
- data/spec/dummy/app/helpers/application_helper.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +24 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +6 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +81 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +5 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/secret_token.rb +13 -0
- data/spec/dummy/config/initializers/session_store.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +15 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +57 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/loyal_admin/display/boards_helper_spec.rb +18 -0
- data/spec/helpers/loyal_admin/display/recipes_helper_spec.rb +18 -0
- data/spec/models/loyal_admin/display/board_spec.rb +8 -0
- data/spec/models/loyal_admin/display/item_spec.rb +8 -0
- data/spec/models/loyal_admin/display/recipe_spec.rb +8 -0
- data/spec/spec_helper.rb +39 -0
- metadata +214 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
5
|
+
<title><%= LoyalAdmin.config.info_config[:title] %> - 管理后台</title>
|
|
6
|
+
<%= stylesheet_link_tag "loyal_admin/application", :media => "all" %>
|
|
7
|
+
<%= javascript_include_tag "loyal_admin/application" %>
|
|
8
|
+
<%= csrf_meta_tags %>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id='nav' class='clearfix'>
|
|
12
|
+
<div class='nav-inner wrapper'>
|
|
13
|
+
<div class='status'>
|
|
14
|
+
<%= render :partial => 'loyal_passport/users/shared/status' %>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<%= link_to '管理后台', loyal_admin_app.root_url %>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div id='container' class='clearfix'>
|
|
22
|
+
<div class='content-block wrapper clearfix'>
|
|
23
|
+
<div class='main-content clearfix'>
|
|
24
|
+
<%= yield %>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div class='side-content clearfix'>
|
|
28
|
+
<ul>
|
|
29
|
+
<h3>
|
|
30
|
+
<%= link_to "用户管理", loyal_passport_app.admin_users_url(
|
|
31
|
+
:subdomain => ::LoyalAdmin.config.subdomain) %>
|
|
32
|
+
</h3>
|
|
33
|
+
<li>
|
|
34
|
+
<%= link_to "角色管理", loyal_passport_app.admin_loyal_passport_roles_url(
|
|
35
|
+
:subdomain => ::LoyalAdmin.config.subdomain) %>
|
|
36
|
+
</li>
|
|
37
|
+
<li>
|
|
38
|
+
<%= link_to "用户列表", loyal_passport_app.admin_users_url(
|
|
39
|
+
:subdomain => ::LoyalAdmin.config.subdomain) %>
|
|
40
|
+
</li>
|
|
41
|
+
</ul>
|
|
42
|
+
|
|
43
|
+
<ul>
|
|
44
|
+
<h3>
|
|
45
|
+
<%= link_to '区域定制管理', loyal_admin_app.display_boards_url %>
|
|
46
|
+
</h3>
|
|
47
|
+
|
|
48
|
+
<li><%= link_to "区域列表", loyal_admin_app.display_boards_url %></li>
|
|
49
|
+
<li><%= link_to "新建区域", loyal_admin_app.new_display_board_url %></li>
|
|
50
|
+
<li><%= link_to "显示块列表", loyal_admin_app.display_recipes_url %></li>
|
|
51
|
+
<li><%= link_to "新建显示块", loyal_admin_app.new_display_recipe_url %></li>
|
|
52
|
+
</ul>
|
|
53
|
+
|
|
54
|
+
<%= render :partial => 'loyal_admin/shared/side_panel' %>
|
|
55
|
+
|
|
56
|
+
<ul>
|
|
57
|
+
<h3>
|
|
58
|
+
公共管理
|
|
59
|
+
</h3>
|
|
60
|
+
|
|
61
|
+
<li><%= link_to "皮肤分类管理", loyal_core_app.admin_skin_folders_url %></li>
|
|
62
|
+
<li><%= link_to "皮肤管理", loyal_core_app.admin_skin_recipes_url %></li>
|
|
63
|
+
</ul>
|
|
64
|
+
|
|
65
|
+
<%= yield :side %>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div id='footer'>
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
</body>
|
|
75
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%= f.nested_parent_select :parent_id, nil %>
|
|
2
|
+
<%= f.text_field :name %>
|
|
3
|
+
<%= f.text_field :short_name %>
|
|
4
|
+
<%= f.text_field :space %>
|
|
5
|
+
<%= f.text_field :permalink %>
|
|
6
|
+
|
|
7
|
+
<%= f.text_area :instroduction, :style => "height: 50px;" %>
|
|
8
|
+
<%= f.kindeditor :description %>
|
|
9
|
+
|
|
10
|
+
<%= f.submit %>
|
|
11
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<h1>编辑显示</h1>
|
|
2
|
+
|
|
3
|
+
<%= form_for(
|
|
4
|
+
@board,
|
|
5
|
+
:url => loyal_admin_app.display_board_url(:id => @board.id),
|
|
6
|
+
:builder => ::LoyalCore::ActionView::LabeledBuilder,
|
|
7
|
+
:as => :board
|
|
8
|
+
) do |f| %>
|
|
9
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<%= link_to "新建", loyal_admin_app.new_display_board_url %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<h1>显示区域列表</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>
|
|
6
|
+
ID
|
|
7
|
+
</th>
|
|
8
|
+
<th>名称</th>
|
|
9
|
+
<th col='3'>操作</th>
|
|
10
|
+
</tr>
|
|
11
|
+
<% ::LoyalAdmin::Display::Board.nested_set_options do |board| %>
|
|
12
|
+
<tr>
|
|
13
|
+
<td><%= board.id %></td>
|
|
14
|
+
<td><%= link_to "#{'- ' * board.level} #{board.name}", loyal_admin_app.display_board_url(:id => board.id) %></td>
|
|
15
|
+
<td>
|
|
16
|
+
<%= link_to "编辑", loyal_admin_app.edit_display_board_url(:id => board.id) %>
|
|
17
|
+
<%= link_to "删除", loyal_admin_app.display_board_url(:id => board.id), :method => :delete, :confirm => '确定要删除吗?' %>
|
|
18
|
+
</td>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</table>
|
|
22
|
+
|
|
23
|
+
<%= link_to "新建", loyal_admin_app.new_display_board_url %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<h1>【分区】 <%= @board.name %></h1>
|
|
2
|
+
|
|
3
|
+
<div>
|
|
4
|
+
<b>名称:</b><%= @board.name %><br/>
|
|
5
|
+
<b>简称:</b><%= @board.short_name %><br/>
|
|
6
|
+
<b>命名空间:</b><%= @board.space %><br/>
|
|
7
|
+
<b>永久链接</b><%= @board.permalink %><br/>
|
|
8
|
+
<% if @board.parent %>
|
|
9
|
+
<b>上一级</b><%= link_to "#{@board.parent.name}", loyal_admin_app.display_board_url(:id => @board.parent_id) %><br/>
|
|
10
|
+
<% end %>
|
|
11
|
+
<b>简介</b><%= @board.instroduction %><br/>
|
|
12
|
+
<b>描述</b>
|
|
13
|
+
<br/><%= raw @board.description %><br/>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<%= link_to "新建", loyal_admin_app.new_display_board_url %>
|
|
17
|
+
<%= link_to "编辑", loyal_admin_app.edit_display_board_url(:id => @board.id) %>
|
|
18
|
+
<%= link_to "返回列表", loyal_admin_app.display_boards_url %>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<h3>项目列表</h3>
|
|
22
|
+
<% @board.items.each do |item| %>
|
|
23
|
+
<% case item.target
|
|
24
|
+
when ::Ruby800::Category %>
|
|
25
|
+
分类:<%= link_to "#{item.target.short_name}" %><br/>
|
|
26
|
+
<% end %>
|
|
27
|
+
|
|
28
|
+
<% end %>
|
|
29
|
+
|
|
30
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<h1>编辑显示块</h1>
|
|
2
|
+
|
|
3
|
+
<%= form_for(
|
|
4
|
+
@display_recipe,
|
|
5
|
+
:url => loyal_admin_app.display_recipe_url(:id => @display_recipe.id),
|
|
6
|
+
:builder => ::LoyalCore::ActionView::LabeledBuilder,
|
|
7
|
+
:as => :display_recipe
|
|
8
|
+
) do |f| %>
|
|
9
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<%= link_to "新建", loyal_admin_app.new_display_recipe_url %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<h1>显示域列表</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>
|
|
6
|
+
ID
|
|
7
|
+
</th>
|
|
8
|
+
<th>名称</th>
|
|
9
|
+
<th col='3'>操作</th>
|
|
10
|
+
</tr>
|
|
11
|
+
<% @display_recipes.each do |recipe| %>
|
|
12
|
+
<tr>
|
|
13
|
+
<td><%= recipe.id %></td>
|
|
14
|
+
<td><%= link_to "#{recipe.text}", loyal_admin_app.display_recipe_url(:id => recipe.id) %></td>
|
|
15
|
+
<td>
|
|
16
|
+
<%= link_to "编辑", loyal_admin_app.edit_display_recipe_url(:id => recipe.id) %>
|
|
17
|
+
<%= link_to "删除", loyal_admin_app.display_recipe_url(:id => recipe.id), :method => :delete, :confirm => '确定要删除吗?' %>
|
|
18
|
+
</td>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</table>
|
|
22
|
+
|
|
23
|
+
<%= paginate @display_recipes %>
|
|
24
|
+
|
|
25
|
+
<%= link_to "新建", loyal_admin_app.new_display_recipe_url %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<h1>新建显示块</h1>
|
|
2
|
+
|
|
3
|
+
<%= form_for(
|
|
4
|
+
@display_recipe,
|
|
5
|
+
:url => loyal_admin_app.display_recipes_url,
|
|
6
|
+
:builder => ::LoyalCore::ActionView::LabeledBuilder,
|
|
7
|
+
:as => :display_recipe
|
|
8
|
+
) do |f| %>
|
|
9
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<h1>【显示块】 <%= @display_recipe.text %></h1>
|
|
2
|
+
|
|
3
|
+
<div>
|
|
4
|
+
<h3>预览</h3>
|
|
5
|
+
|
|
6
|
+
default: <%= raw @display_recipe.generate_html :default %>
|
|
7
|
+
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div>
|
|
11
|
+
<b>URL:</b><%= @display_recipe.url %><br/>
|
|
12
|
+
<b>文本:</b><%= @display_recipe.text %><br/>
|
|
13
|
+
<b>style:</b><%= @display_recipe.style %><br/>
|
|
14
|
+
<b>Title:</b><%= @display_recipe.title %><br/>
|
|
15
|
+
<b>Open Style:</b><%= @display_recipe.filter_named_open_style.desc %><br/>
|
|
16
|
+
<b>Content</b><%= @display_recipe.content %><br/>
|
|
17
|
+
<b>Content预览</b><%= raw @display_recipe.content %><br/>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<%= link_to "新建", loyal_admin_app.new_display_recipe_url %>
|
|
21
|
+
<%= link_to "编辑", loyal_admin_app.edit_display_recipe_url(:id => @display_recipe.id) %>
|
|
22
|
+
<%= link_to "返回列表", loyal_admin_app.display_recipes_url %>
|
|
23
|
+
|
|
File without changes
|
|
File without changes
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
LoyalAdmin::Engine.routes.draw do
|
|
3
|
+
constraints lambda {|request| LoyalAdmin.config.request_routes_constraints?(request) } do
|
|
4
|
+
root :to => 'welcome#index'
|
|
5
|
+
|
|
6
|
+
scope :loyal_admin, :path => :loyal_admin do
|
|
7
|
+
namespace :display do
|
|
8
|
+
resources :recipes
|
|
9
|
+
resources :boards
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
class CreateLoyalAdminDisplayItems < ActiveRecord::Migration
|
|
3
|
+
def change
|
|
4
|
+
create_table :loyal_admin_display_items do |t|
|
|
5
|
+
t.integer :board_id
|
|
6
|
+
t.integer :position, :default => 0, :null => false # 置顶排序
|
|
7
|
+
t.references :target, :polymorphic => true
|
|
8
|
+
|
|
9
|
+
t.datetime :start_at
|
|
10
|
+
t.datetime :end_at
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
add_index :loyal_admin_display_items, [:board_id]
|
|
16
|
+
add_index :loyal_admin_display_items, [:target_id, :target_type], :name => :loyal_admin_display_items_target
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
class CreateLoyalAdminDisplayRecipes < ActiveRecord::Migration
|
|
3
|
+
def change
|
|
4
|
+
create_table :loyal_admin_display_recipes do |t|
|
|
5
|
+
t.string :url # url链接
|
|
6
|
+
t.string :text
|
|
7
|
+
t.string :title
|
|
8
|
+
t.text :content
|
|
9
|
+
|
|
10
|
+
t.string :style # 样式表
|
|
11
|
+
|
|
12
|
+
t.integer :publish_status
|
|
13
|
+
|
|
14
|
+
t.integer :open_style
|
|
15
|
+
|
|
16
|
+
t.datetime :start_at
|
|
17
|
+
t.datetime :end_at
|
|
18
|
+
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
class CreateLoyalAdminDisplayBoards < ActiveRecord::Migration
|
|
3
|
+
def change
|
|
4
|
+
create_table :loyal_admin_display_boards do |t|
|
|
5
|
+
t.string :name #名称
|
|
6
|
+
t.string :short_name #简称
|
|
7
|
+
|
|
8
|
+
# 简介
|
|
9
|
+
t.string :instroduction
|
|
10
|
+
|
|
11
|
+
# 描述
|
|
12
|
+
t.text :description
|
|
13
|
+
|
|
14
|
+
t.integer :lang, default: 0, :null => false #语言
|
|
15
|
+
|
|
16
|
+
t.string :uuid
|
|
17
|
+
|
|
18
|
+
t.string :space #命名空间
|
|
19
|
+
t.string :permalink
|
|
20
|
+
|
|
21
|
+
###### avatar #############################
|
|
22
|
+
t.string :avatar
|
|
23
|
+
|
|
24
|
+
###### for nested_ful #####################
|
|
25
|
+
t.integer :parent_id
|
|
26
|
+
t.integer :left_id
|
|
27
|
+
t.integer :right_id
|
|
28
|
+
t.integer :depth
|
|
29
|
+
t.integer :children_count, default: 0
|
|
30
|
+
|
|
31
|
+
##### soft deleted #######################
|
|
32
|
+
t.datetime :deleted_at
|
|
33
|
+
|
|
34
|
+
t.timestamps
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
add_index :loyal_admin_display_boards, [:uuid]
|
|
38
|
+
add_index :loyal_admin_display_boards, [:space, :permalink]
|
|
39
|
+
add_index :loyal_admin_display_boards, [:parent_id]
|
|
40
|
+
add_index :loyal_admin_display_boards, [:left_id]
|
|
41
|
+
add_index :loyal_admin_display_boards, [:right_id]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
module LoyalAdmin
|
|
3
|
+
class << self
|
|
4
|
+
attr_accessor :config
|
|
5
|
+
|
|
6
|
+
def configure
|
|
7
|
+
yield self.config ||= Config.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
DEFAULT_SUBDOMAIN = 'admin'.freeze
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
DEFAULT_WHITE_HOSTS = {}.freeze
|
|
16
|
+
|
|
17
|
+
DEFAULT_INFO_CONFIGS = {
|
|
18
|
+
:title => 'Loyal Admin'
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
class Config
|
|
22
|
+
def info_config
|
|
23
|
+
@info_config ||= DEFAULT_INFO_CONFIGS
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def info_config= info=DEFAULT_INFO_CONFIGS
|
|
27
|
+
@info_config ||= (
|
|
28
|
+
DEFAULT_INFO_CONFIGS.merge(info)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def white_hosts= hosts=DEFAULT_WHITE_HOSTS
|
|
33
|
+
@white_hosts ||= (
|
|
34
|
+
DEFAULT_WHITE_HOSTS.merge(hosts)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def white_hosts
|
|
39
|
+
@white_hosts ||= DEFAULT_WHITE_HOSTS
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def prepend_view_paths
|
|
43
|
+
@prepend_view_paths ||= (
|
|
44
|
+
self.white_hosts.inject({}) do |result, pair|
|
|
45
|
+
host, config = pair
|
|
46
|
+
|
|
47
|
+
if config[:view_paths]
|
|
48
|
+
result[host] = ::LoyalCore::ArrayUtil.init(config[:view_paths])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
result
|
|
52
|
+
end
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def subdomain= subdomain=DEFAULT_SUBDOMAIN
|
|
57
|
+
@subdomain ||= subdomain
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def subdomain
|
|
61
|
+
@subdomain ||= DEFAULT_SUBDOMAIN
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# 判断请求是否可以路由到passport中来
|
|
65
|
+
def request_routes_constraints?(request)
|
|
66
|
+
request.subdomain == self.subdomain
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
module LoyalAdmin
|
|
3
|
+
module ControllerExtends
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.class_eval do
|
|
6
|
+
include InstanceMethods
|
|
7
|
+
|
|
8
|
+
before_filter :impl_prepend_loyal_admin_view_paths
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module InstanceMethods
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
def impl_prepend_loyal_admin_view_paths
|
|
17
|
+
(::LoyalAdmin.config.prepend_view_paths[request.host] || []).each do |view_path|
|
|
18
|
+
self.prepend_view_path view_path
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if defined?(ActionController::Base)
|
|
26
|
+
ActionController::Base.send :include, ::LoyalAdmin::ControllerExtends
|
|
27
|
+
end
|
|
28
|
+
|
data/lib/loyal_admin.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require File.expand_path('../boot', __FILE__)
|
|
3
|
+
|
|
4
|
+
require 'rails/all'
|
|
5
|
+
|
|
6
|
+
Bundler.require(*Rails.groups)
|
|
7
|
+
require "loyal_admin"
|
|
8
|
+
|
|
9
|
+
module Dummy
|
|
10
|
+
class Application < Rails::Application
|
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
12
|
+
# Application configuration should go into files in config/initializers
|
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
14
|
+
|
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
18
|
+
|
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
21
|
+
# config.i18n.default_locale = :de
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|