loyal_core 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module LoyalCore
6
6
 
7
7
  # self.acts_as_tiny_cached
8
8
 
9
- self.loyal_passport_acts_as_creator_able
9
+ self.loyal_core_acts_as_creator_able
10
10
 
11
11
  belongs_to :target, :polymorphic => true, :counter_cache => :liked_count
12
12
 
@@ -5,7 +5,7 @@ module LoyalCore
5
5
 
6
6
  # self.acts_as_tiny_cached
7
7
 
8
- self.loyal_passport_acts_as_creator_able
8
+ self.loyal_core_acts_as_creator_able
9
9
 
10
10
  # TODO: counter_cache 是否需要?
11
11
  belongs_to :target, :polymorphic => true, :counter_cache => true
@@ -20,7 +20,7 @@ module LoyalCore
20
20
  validates_presence_of :name
21
21
 
22
22
  # 用于作者
23
- self.loyal_passport_acts_as_creator_able
23
+ self.loyal_core_acts_as_creator_able
24
24
 
25
25
  self.loyal_core_acts_as_has_avatar
26
26
 
@@ -1,12 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  LoyalCore::Engine.routes.draw do
3
3
 
4
- scope :admin, :module => :admin, :as => :admin, :path => :loyal_core do
5
- namespace :skin do
6
- resources :folders
7
- resources :recipes
8
- end
9
- end
10
4
 
11
5
  namespace :ajax do
12
6
  scope :core, :as => :core, :path => :core do
@@ -15,6 +15,8 @@ module LoyalCore
15
15
  autoload :ActsAsNamedFilterAble, "#{File.dirname(__FILE__)}/acts/named_filter_able"
16
16
 
17
17
  autoload :ActsAsSkinDishAble, "#{File.dirname(__FILE__)}/acts/skin_dish_able"
18
+
19
+ autoload :ActsAsCreatorAble, "#{File.dirname(__FILE__)}/acts/creator_able"
18
20
  end
19
21
 
20
22
  if defined?(ActiveRecord::Base)
@@ -32,4 +34,6 @@ if defined?(ActiveRecord::Base)
32
34
 
33
35
  ::ActiveRecord::Base.send :include, ::LoyalCore::ActsAsNamedFilterAble
34
36
  ::ActiveRecord::Base.send :include, ::LoyalCore::ActsAsSkinDishAble
37
+
38
+ ::ActiveRecord::Base.send :include, ::LoyalCore::ActsAsCreatorAble
35
39
  end
@@ -0,0 +1,25 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module LoyalCore
3
+ module ActsAsCreatorAble
4
+ def self.included base
5
+ base.class_eval do
6
+ extend ClassMethods
7
+ end
8
+ end
9
+
10
+ module ClassMethods
11
+ def loyal_core_acts_as_creator_able *args
12
+ belongs_to :creator, :class_name => "User", :foreign_key => :created_by
13
+
14
+ scope :filter_by_creator, ->(user_or_user_id) do
15
+ where :created_by => (user_or_user_id.is_a?(::User) ? user_or_user_id.id : user_or_user_id)
16
+ end
17
+
18
+ define_method :creator_is? do |__user|
19
+ self.created_by == __user.id
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require "protected_attributes"
2
3
  require "tiny_cache"
3
4
  # rails config
4
5
  require "rails_config"
@@ -1,8 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module LoyalCore
3
- autoload :ArrayUtil, "#{File.dirname(__FILE__)}/utils/array_util"
4
- autoload :DataUtil, "#{File.dirname(__FILE__)}/utils/data_util"
5
- autoload :ConfigUtil, "#{File.dirname(__FILE__)}/utils/config_util"
6
- autoload :TextUtil, "#{File.dirname(__FILE__)}/utils/text_util"
3
+ autoload :ArrayUtil, "#{File.dirname(__FILE__)}/utils/array_util"
4
+ autoload :DataUtil, "#{File.dirname(__FILE__)}/utils/data_util"
5
+ autoload :ConfigUtil, "#{File.dirname(__FILE__)}/utils/config_util"
6
+ autoload :TextUtil, "#{File.dirname(__FILE__)}/utils/text_util"
7
+ autoload :PlatformUtil, "#{File.dirname(__FILE__)}/utils/platform_util"
7
8
  end
8
9
 
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module LoyalCore
3
+ class PlatformUtil
4
+
5
+ end
6
+ end
7
+
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module LoyalCore
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loyal_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,6 +11,22 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: protected_attributes
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rails_config
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -247,8 +263,6 @@ files:
247
263
  - app/controllers/loyal_core/jumps_controller.rb
248
264
  - app/controllers/loyal_core/ajax_controller.rb
249
265
  - app/controllers/loyal_core/application_controller.rb
250
- - app/controllers/loyal_core/admin/skin/recipes_controller.rb
251
- - app/controllers/loyal_core/admin/skin/folders_controller.rb
252
266
  - app/controllers/loyal_core/ajax/rating_tracks_controller.rb
253
267
  - app/controllers/loyal_core/ajax/users/sessions_controller.rb
254
268
  - app/controllers/loyal_core/ajax/captchas_controller.rb
@@ -273,16 +287,6 @@ files:
273
287
  - app/models/kindeditor/image.rb
274
288
  - app/models/kindeditor/flash.rb
275
289
  - app/views/layouts/loyal_core/application.html.erb
276
- - app/views/loyal_core/admin/skin/recipes/new.html.erb
277
- - app/views/loyal_core/admin/skin/recipes/_form.html.erb
278
- - app/views/loyal_core/admin/skin/recipes/index.html.erb
279
- - app/views/loyal_core/admin/skin/recipes/edit.html.erb
280
- - app/views/loyal_core/admin/skin/recipes/show.html.erb
281
- - app/views/loyal_core/admin/skin/folders/new.html.erb
282
- - app/views/loyal_core/admin/skin/folders/_form.html.erb
283
- - app/views/loyal_core/admin/skin/folders/index.html.erb
284
- - app/views/loyal_core/admin/skin/folders/edit.html.erb
285
- - app/views/loyal_core/admin/skin/folders/show.html.erb
286
290
  - app/views/loyal_core/jumps/show.html.erb
287
291
  - app/views/loyal_core/ajax/captchas/new.html.erb
288
292
  - app/views/loyal_core/ajax/captchas/_new.html.erb
@@ -351,6 +355,7 @@ files:
351
355
  - lib/loyal_core/memoist.rb
352
356
  - lib/loyal_core/action_view.rb
353
357
  - lib/loyal_core/utils/config_util.rb
358
+ - lib/loyal_core/utils/platform_util.rb
354
359
  - lib/loyal_core/utils/data_util.rb
355
360
  - lib/loyal_core/utils/array_util.rb
356
361
  - lib/loyal_core/utils/text_util.rb
@@ -359,6 +364,7 @@ files:
359
364
  - lib/loyal_core/utils.rb
360
365
  - lib/loyal_core/acts/content_mode_able.rb
361
366
  - lib/loyal_core/acts/content_depart_able.rb
367
+ - lib/loyal_core/acts/creator_able.rb
362
368
  - lib/loyal_core/acts/bit_able.rb
363
369
  - lib/loyal_core/acts/uuid_ful.rb
364
370
  - lib/loyal_core/acts/skin_dish_able.rb
@@ -394,7 +400,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
394
400
  version: '0'
395
401
  segments:
396
402
  - 0
397
- hash: 550503749273658230
403
+ hash: -1509056482027656799
398
404
  required_rubygems_version: !ruby/object:Gem::Requirement
399
405
  none: false
400
406
  requirements:
@@ -403,7 +409,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
409
  version: '0'
404
410
  segments:
405
411
  - 0
406
- hash: 550503749273658230
412
+ hash: -1509056482027656799
407
413
  requirements: []
408
414
  rubyforge_project:
409
415
  rubygems_version: 1.8.25
@@ -1,54 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module LoyalCore
3
- class Admin::Skin::FoldersController < ::LoyalAdmin::ApplicationController
4
- def index
5
-
6
- end
7
-
8
- def show
9
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
10
-
11
- @loyal_core_skin_recipes = @loyal_core_skin_folder.recipes.page(params[:page])
12
- end
13
-
14
- def new
15
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.new
16
- end
17
-
18
- def create
19
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.new(params[:loyal_core_skin_folder])
20
-
21
- @loyal_core_skin_folder.created_by = current_user.id
22
- @loyal_core_skin_folder.created_ip = request.remote_ip
23
-
24
- if @loyal_core_skin_folder.save
25
- redirect_to loyal_core_app.admin_skin_folder_url(:id => @loyal_core_skin_folder.id)
26
- else
27
- render :new
28
- end
29
- end
30
-
31
- def edit
32
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
33
- end
34
-
35
- def update
36
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
37
-
38
- if @loyal_core_skin_folder.update_attributes(params[:loyal_core_skin_folder])
39
- redirect_to loyal_core_app.admin_skin_folder_url(:id => @loyal_core_skin_folder.id)
40
- else
41
- render :edit
42
- end
43
- end
44
-
45
- def destroy
46
- @loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
47
-
48
- @loyal_core_skin_folder.destroy
49
-
50
- redirect_to params[:return_to] || loyal_core_app.admin_skin_folders_url
51
- end
52
-
53
- end
54
- end
@@ -1,52 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module LoyalCore
3
- class Admin::Skin::RecipesController < ::LoyalAdmin::ApplicationController
4
- def index
5
- @loyal_core_skin_recipes = ::LoyalCore::Skin::Recipe.page(params[:page])
6
- end
7
-
8
- def show
9
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
10
- end
11
-
12
- def new
13
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.new
14
- end
15
-
16
- def create
17
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.new(params[:loyal_core_skin_recipe])
18
-
19
- @loyal_core_skin_recipe.created_by = current_user.id
20
- @loyal_core_skin_recipe.created_ip = request.remote_ip
21
-
22
- if @loyal_core_skin_recipe.save
23
- redirect_to loyal_core_app.admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id)
24
- else
25
- render :new
26
- end
27
- end
28
-
29
- def edit
30
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
31
- end
32
-
33
- def update
34
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
35
-
36
- if @loyal_core_skin_recipe.update_attributes(params[:loyal_core_skin_recipe])
37
- redirect_to loyal_core_app.admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id)
38
- else
39
- render :edit
40
- end
41
- end
42
-
43
- def destroy
44
- @loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
45
-
46
- @loyal_core_skin_recipe.destroy
47
-
48
- redirect_to params[:return_to] || loyal_core_app.admin_skin_recipes_url
49
- end
50
-
51
- end
52
- end
@@ -1,9 +0,0 @@
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
- <%= f.text_area :instroduction, :style => "height: 50px;" %>
7
- <%= f.text_area :description, :style => "height: 100px;" %>
8
- <%= f.submit %>
9
-
@@ -1,11 +0,0 @@
1
- <%= form_for(
2
- @loyal_core_skin_folder,
3
- :url => loyal_core_app.admin_skin_folder_url(:id => @loyal_core_skin_folder.id),
4
- :builder => ::LoyalCore::ActionView::LabeledBuilder,
5
- :as => :loyal_core_skin_folder
6
- ) do |f| %>
7
- <%= render :partial => 'form', :locals => { :f => f } %>
8
- <% end %>
9
-
10
- <%= link_to "新建", loyal_core_app.new_admin_skin_folder_url %>
11
-
@@ -1,25 +0,0 @@
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
- <% ::LoyalCore::Skin::Folder.nested_set_options do |folder| %>
12
- <tr>
13
- <td><%= folder.id %></td>
14
- <td><%= link_to "#{'- ' * folder.level} #{folder.name}", loyal_core_app.admin_skin_folder_url(
15
- :id => folder.id
16
- ) %></td>
17
- <td>
18
- <%= link_to "编辑", loyal_core_app.edit_admin_skin_folder_url(:id => folder.id) %>
19
- <%= link_to "删除", loyal_core_app.admin_skin_folder_url(:id => folder.id), :method => :delete, :confirm => '确定要删除吗?' %>
20
- </td>
21
- </tr>
22
- <% end %>
23
- </table>
24
-
25
- <%= link_to "新建", loyal_core_app.new_admin_skin_folder_url %>
@@ -1,11 +0,0 @@
1
- <h1>新建新分区</h1>
2
-
3
- <%= form_for(
4
- @loyal_core_skin_folder,
5
- :url => loyal_core_app.admin_skin_folders_url,
6
- :builder => ::LoyalCore::ActionView::LabeledBuilder,
7
- :as => :loyal_core_skin_folder
8
- ) do |f| %>
9
- <%= render :partial => 'form', :locals => { :f => f } %>
10
- <% end %>
11
-
@@ -1,32 +0,0 @@
1
- <h1>【皮肤分类】 <%= @loyal_core_skin_folder.name %></h1>
2
-
3
- <div>
4
- <b>短标题</b><%= @loyal_core_skin_folder.short_name %><br/>
5
- <b>简介</b><%= @loyal_core_skin_folder.instroduction %><br/>
6
- <b>描述</b><%= @loyal_core_skin_folder.description %><br/>
7
- </div>
8
-
9
-
10
- <%= link_to "编辑", loyal_core_app.edit_admin_skin_folder_url(:id => @loyal_core_skin_folder.id) %>
11
- <%= link_to "返回列表", loyal_core_app.admin_skin_folders_url %>
12
-
13
- <div>
14
- <h3>皮肤</h3>
15
- <%= paginate @loyal_core_skin_recipes %>
16
-
17
- <ul>
18
- <% @loyal_core_skin_recipes.each do |recipe| %>
19
- <li>
20
- <%= link_to "#{recipe.name}", loyal_core_app.admin_skin_recipe_url(
21
- :id => recipe.id
22
- ) %>
23
- </li>
24
- <% end %>
25
- </ul>
26
-
27
- <% if @loyal_core_skin_recipes.empty? %>
28
- 为空
29
- <% end %>
30
-
31
- <%= paginate @loyal_core_skin_recipes %>
32
- </div>
@@ -1,25 +0,0 @@
1
- <%= f.text_field :name %>
2
- <%= f.text_field :short_name %>
3
- <%= f.text_field :stored_tags %>
4
-
5
- <p>
6
- <%= f.label :avatar %>
7
- <%= image_tag(f.object.avatar_url :small) if f.object.avatar? %>
8
- <%= f.file_field :avatar %>
9
- <%= f.hidden_field :avatar_cache %>
10
- </p>
11
-
12
- <%= f.nested_belongs_to_select :folder_id,
13
- ::LoyalCore::Skin::Folder,
14
- ::LoyalCore::Skin::Folder
15
- %>
16
-
17
- <%= f.text_field :assets_path %>
18
-
19
- <%= f.text_area :stylesheet_text, :style => 'height: 500px;' %>
20
-
21
- <%= f.text_area :instroduction, :style => 'height: 100px;' %>
22
- <%= f.text_area :description, :style => 'height: 100px;' %>
23
-
24
- <%= f.submit %>
25
-
@@ -1,11 +0,0 @@
1
- <%= form_for(
2
- @loyal_core_skin_recipe,
3
- :url => loyal_core_app.admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id),
4
- :builder => ::LoyalCore::ActionView::LabeledBuilder,
5
- :as => :loyal_core_skin_recipe
6
- ) do |f| %>
7
- <%= render :partial => 'form', :locals => { :f => f } %>
8
- <% end %>
9
-
10
- <%= link_to "新建", loyal_core_app.new_admin_skin_recipe_url %>
11
-
@@ -1,37 +0,0 @@
1
- <h1>皮肤列表</h1>
2
-
3
- <%= paginate @loyal_core_skin_recipes %>
4
-
5
- <table>
6
- <tr>
7
- <th>ID</th>
8
- <th>文章标题</th>
9
- <th>作者</th>
10
- <th>操作</th>
11
- </tr>
12
- <% if @loyal_core_skin_recipes.to_a.any? %>
13
- <% @loyal_core_skin_recipes.each do |recipe| %>
14
- <tr>
15
- <td><%= recipe.id %></td>
16
- <td><%= link_to "#{recipe.name}", loyal_core_app.admin_skin_recipe_url(:id => recipe.id) %></td>
17
- <td>
18
- <% if recipe.creator %>
19
- <%= link_to "#{recipe.creator.nick_name}", loyal_passport_app.admin_user_url(:id => recipe.creator.id) %>
20
- <% else %>
21
- 未知
22
- <% end %>
23
- </td>
24
- <td>
25
- <%= link_to "编辑", loyal_core_app.edit_admin_skin_recipe_url(:id => recipe.id) %>
26
- <%= link_to "删除", loyal_core_app.admin_skin_recipe_url(:id => recipe.id), :method => :delete, :confirm => '确定要删除吗?' %>
27
- </td>
28
- </tr>
29
- <% end %>
30
- <% else %>
31
- 列表为空
32
- <% end %>
33
- </table>
34
-
35
- <%= paginate @loyal_core_skin_recipes %>
36
-
37
- <%= link_to "new", loyal_core_app.new_admin_skin_recipe_url %>
@@ -1,11 +0,0 @@
1
- <h1>新建新皮肤</h1>
2
-
3
- <%= form_for(
4
- @loyal_core_skin_recipe,
5
- :url => loyal_core_app.admin_skin_recipes_url,
6
- :builder => ::LoyalCore::ActionView::LabeledBuilder,
7
- :as => :loyal_core_skin_recipe
8
- ) do |f| %>
9
- <%= render :partial => 'form', :locals => { :f => f } %>
10
- <% end %>
11
-
@@ -1,16 +0,0 @@
1
- <h1>【皮肤】 <%= @loyal_core_skin_recipe.name %></h1>
2
-
3
- <div>
4
- <b>短标题</b><%= @loyal_core_skin_recipe.short_name %><br/>
5
- <b>路径</b><%= @loyal_core_skin_recipe.assets_path %><br/>
6
- <b>样式表</b><%= @loyal_core_skin_recipe.stylesheet_text %><br/>
7
- <b>简介</b><%= @loyal_core_skin_recipe.instroduction %><br/>
8
- <b>描述</b><%= @loyal_core_skin_recipe.description %><br/>
9
-
10
- <b>描述</b>
11
- <%= image_tag @loyal_core_skin_recipe.avatar.url(:small) %>
12
- </div>
13
-
14
-
15
- <%= link_to "编辑", loyal_core_app.edit_admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id) %>
16
- <%= link_to "返回列表", loyal_core_app.admin_skin_recipes_url %>