homeland-site 0.1.0

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +22 -0
  4. data/Rakefile +36 -0
  5. data/app/assets/config/homeland_site_manifest.js +2 -0
  6. data/app/assets/javascripts/homeland/site/application.js +1 -0
  7. data/app/assets/stylesheets/homeland/site/application.css +4 -0
  8. data/app/controllers/homeland/site/admin/site_nodes_controller.rb +55 -0
  9. data/app/controllers/homeland/site/admin/sites_controller.rb +60 -0
  10. data/app/controllers/homeland/site/application_controller.rb +12 -0
  11. data/app/controllers/homeland/site/sites_controller.rb +27 -0
  12. data/app/helpers/homeland/site/application_helper.rb +6 -0
  13. data/app/models/homeland/site/ability.rb +36 -0
  14. data/app/models/site.rb +30 -0
  15. data/app/models/site_node.rb +15 -0
  16. data/app/views/homeland/site/admin/site_nodes/_base.html.erb +5 -0
  17. data/app/views/homeland/site/admin/site_nodes/_form.html.erb +16 -0
  18. data/app/views/homeland/site/admin/site_nodes/edit.html.erb +3 -0
  19. data/app/views/homeland/site/admin/site_nodes/index.html.erb +27 -0
  20. data/app/views/homeland/site/admin/site_nodes/new.html.erb +2 -0
  21. data/app/views/homeland/site/admin/sites/_base.html.erb +3 -0
  22. data/app/views/homeland/site/admin/sites/_form.html.erb +18 -0
  23. data/app/views/homeland/site/admin/sites/edit.html.erb +3 -0
  24. data/app/views/homeland/site/admin/sites/index.html.erb +51 -0
  25. data/app/views/homeland/site/sites/_form.html.erb +19 -0
  26. data/app/views/homeland/site/sites/index.html.erb +28 -0
  27. data/app/views/homeland/site/sites/new.html.erb +3 -0
  28. data/app/views/layouts/homeland/site/application.html.erb +14 -0
  29. data/config/locales/homeland.site.zh-CN.yml +19 -0
  30. data/config/routes.rb +11 -0
  31. data/db/migrate/20170321125706_create_sites.rb +33 -0
  32. data/lib/homeland/site/engine.rb +24 -0
  33. data/lib/homeland/site/version.rb +7 -0
  34. data/lib/homeland/site.rb +7 -0
  35. data/lib/tasks/homeland/site_tasks.rake +4 -0
  36. metadata +92 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 100a91cbb778fa30cadc54157f58511a8d20b84c
4
+ data.tar.gz: 07a77e480da5f4fd2e01e4508f37946fdedf135b
5
+ SHA512:
6
+ metadata.gz: f9989b5528f168c9cd58452f4df42e828490fd4c9b82a0f71950f635406f587c7ecc8fadd2c97ed213303286e2d510e93dbc97faa5d1b8b4a21df0afe95e1e83
7
+ data.tar.gz: a4ba5e639645678e2f30237b044763c05838fb80533a1273004a1f44a8ba9d7372c7a432114cafd2d652f0e139b8623d3f1214380add60d5c2576980219253b2
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Jason Lee
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.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ Homeland::Site Plugin
2
+ ---------------------
3
+
4
+ 酷站插件 for Homeland.
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your Homeland's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'homeland-site'
13
+ ```
14
+
15
+ And then execute:
16
+ ```bash
17
+ $ bundle
18
+ ```
19
+
20
+ ## License
21
+
22
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
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 = 'Homeland::Site'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/homeland/site .js
2
+ //= link_directory ../stylesheets/homeland/site .css
@@ -0,0 +1,4 @@
1
+ #site_nodes .site {
2
+ margin-bottom: 10px;
3
+ a { color: #777; }
4
+ }
@@ -0,0 +1,55 @@
1
+ module Homeland::Site
2
+ module Admin
3
+ class SiteNodesController < ::Admin::ApplicationController
4
+ require_module_enabled! :site
5
+ before_action :set_site_node, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @site_nodes = SiteNode.order(id: :desc).page(params[:page])
9
+ end
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @site_node = SiteNode.new
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @site_node = SiteNode.new(site_node_params)
23
+
24
+ if @site_node.save
25
+ redirect_to(admin_site_nodes_path, notice: 'Site node 创建成功。')
26
+ else
27
+ render action: 'new'
28
+ end
29
+ end
30
+
31
+ def update
32
+ if @site_node.update(site_node_params)
33
+ redirect_to(admin_site_nodes_path, notice: 'Site node 更新成功。')
34
+ else
35
+ render action: 'edit'
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @site_node.destroy
41
+ redirect_to(admin_site_nodes_path, notice: '删除成功。')
42
+ end
43
+
44
+ private
45
+
46
+ def site_node_params
47
+ params[:site_node].permit!
48
+ end
49
+
50
+ def set_site_node
51
+ @site_node = SiteNode.find(params[:id])
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,60 @@
1
+ module Homeland::Site
2
+ module Admin
3
+ class SitesController < ::Admin::ApplicationController
4
+ require_module_enabled! :site
5
+ before_action :set_site, only: [:show, :edit, :update, :destroy, :undestroy]
6
+
7
+ def index
8
+ @sites = ::Site.unscoped.recent.includes(:user, :site_node)
9
+ if params[:q].present?
10
+ @sites = @sites.where('name LIKE ?', "%#{params[:q]}%")
11
+ end
12
+ @sites = @sites.page(params[:page])
13
+ end
14
+
15
+ def show
16
+ end
17
+
18
+ def new
19
+ @site = ::Site.new
20
+ end
21
+
22
+ def edit
23
+ end
24
+
25
+ def create
26
+ @site = ::Site.new(params[:site].permit!)
27
+
28
+ if @site.save
29
+ redirect_to(admin_sites_path, notice: 'Site 创建成功。')
30
+ else
31
+ render action: 'new'
32
+ end
33
+ end
34
+
35
+ def update
36
+ if @site.update(params[:site].permit!)
37
+ redirect_to(admin_sites_path, notice: 'Site 更新成功。')
38
+ else
39
+ render action: 'edit'
40
+ end
41
+ end
42
+
43
+ def destroy
44
+ @site.destroy
45
+ redirect_to(admin_sites_path, notice: "#{@site.name} 删除成功。")
46
+ end
47
+
48
+ def undestroy
49
+ @site.update_attribute(:deleted_at, nil)
50
+ redirect_to(admin_sites_path, notice: "#{@site.name} 已恢复。")
51
+ end
52
+
53
+ private
54
+
55
+ def set_site
56
+ @site = ::Site.unscoped.find(params[:id])
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,12 @@
1
+ module Homeland::Site
2
+ class ApplicationController < ::ApplicationController
3
+ protect_from_forgery with: :exception
4
+ layout "homeland/site/application"
5
+
6
+ helper Homeland::Site::ApplicationHelper
7
+
8
+ def current_ability
9
+ @current_ability ||= Homeland::Site::Ability.new(current_user)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ module Homeland::Site
2
+ class SitesController < Homeland::Site::ApplicationController
3
+ def index
4
+ @site_nodes = SiteNode.all.order(sort: :desc)
5
+ end
6
+
7
+ def new
8
+ @site = ::Site.new
9
+ end
10
+
11
+ def create
12
+ @site = ::Site.new(site_params)
13
+ @site.user_id = current_user.id
14
+ if @site.save
15
+ redirect_to(sites_path, notice: '提交成功。谢谢。')
16
+ else
17
+ render action: 'new'
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def site_params
24
+ params.require(:site).permit(:name, :desc, :url, :favorite, :site_node_id)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ module Homeland
2
+ module Site
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ module Homeland::Site
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ attr_reader :user
6
+
7
+ def initialize(u)
8
+ @user = u
9
+ if @user.blank?
10
+ roles_for_anonymous
11
+ elsif user.roles?(:site_editor)
12
+ can :create, Site
13
+ else
14
+ roles_for_anonymous
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ # 普通会员权限
21
+ def roles_for_site_editors
22
+ can :create, Site
23
+ basic_read_only
24
+ end
25
+
26
+ # 未登录用户权限
27
+ def roles_for_anonymous
28
+ cannot :manage, Site
29
+ basic_read_only
30
+ end
31
+
32
+ def basic_read_only
33
+ can :read, Site
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ class Site < ApplicationRecord
2
+ include SoftDelete
3
+
4
+ belongs_to :site_node
5
+ belongs_to :user
6
+
7
+ validates :url, :name, :site_node_id, presence: true
8
+ validates :url, uniqueness: true
9
+
10
+ after_save :update_cache_version
11
+ after_destroy :update_cache_version
12
+ def update_cache_version
13
+ # 记录节点变更时间,用于清除缓存
14
+ CacheVersion.sites_updated_at = Time.now.to_i
15
+ end
16
+
17
+ before_validation :fix_urls
18
+ def fix_urls
19
+ unless url.blank?
20
+ url = self.url.gsub(%r{http[s]{0,1}://}, '').split('/').join('/')
21
+ self.url = "http://#{url}"
22
+ end
23
+ end
24
+
25
+ def favicon_url
26
+ return '' if url.blank?
27
+ domain = url.gsub('http://', '')
28
+ "https://favicon.b0.upaiyun.com/ip2/#{domain}.ico"
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ class SiteNode < ApplicationRecord
2
+ second_level_cache expires_in: 2.weeks
3
+
4
+ has_many :sites
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+
8
+ after_save :update_cache_version
9
+ after_destroy :update_cache_version
10
+
11
+ def update_cache_version
12
+ # 记录节点变更时间,用于清除缓存
13
+ CacheVersion.sites_updated_at = Time.now.to_i
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ <% content_for :sitemap do %>
2
+ <a href="<%= admin_sites_path %>">酷站</a>
3
+ <i class="fa fa-angle-right"></i>
4
+ <span class="current">酷站分类管理</span>
5
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <div id="admin_site_node" class="form">
2
+
3
+ <%= simple_form_for([:admin, @site_node]) do |f| %>
4
+ <%= render "/shared/error_messages", target: @site_node %>
5
+ <fieldset>
6
+ <legend>编辑</legend>
7
+ <%= f.input :name %>
8
+ <%= f.input :sort %>
9
+ <div class="form-actions">
10
+ <%= f.submit '保存', class: "btn btn-primary", 'data-disable-with' => '保存中...' %>
11
+ or
12
+ <%= link_to '取消', admin_site_nodes_path %>
13
+ </div>
14
+ </fieldset>
15
+ <% end %>
16
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= render 'base' %>
2
+ <%= render 'form' %>
3
+
@@ -0,0 +1,27 @@
1
+ <%= render 'base' %>
2
+
3
+ <div class="toolbar">
4
+ <a href="<%= new_admin_site_node_path %>" class="btn btn-small btn-success">新建</a>
5
+ </div>
6
+
7
+ <div id="admin_site_nodes">
8
+ <table class="table table-bordered table-striped table-condensed">
9
+ <tr class="head">
10
+ <td>#</td>
11
+ <td>名称</td>
12
+ <td>排序</td>
13
+ <td class="opts"></td>
14
+ </tr>
15
+ <% @site_nodes.each do |item| %>
16
+ <tr class="<%= cycle("", "even") %>">
17
+ <td><%= item.id %></td>
18
+ <td><%= item.name %></td>
19
+ <td><%= item.sort %></td>
20
+ <td>
21
+ <%= link_to "", edit_admin_site_node_path(item.id), class: "fa fa-pencil" %>
22
+ <%= link_to "", admin_site_node_path(item.id), method: :delete, 'data-confirm' => '确定要删除吗?', class: "fa fa-trash" %>
23
+ </td>
24
+ </tr>
25
+ <% end %>
26
+ </table>
27
+ </div>
@@ -0,0 +1,2 @@
1
+ <%= render 'base' %>
2
+ <%= render 'form' %>
@@ -0,0 +1,3 @@
1
+ <% content_for :sitemap do %>
2
+ <span class="current"><%= t("admin.menu.sites")%></span>
3
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div id="admin_site" class="form">
2
+
3
+ <%= simple_form_for([:admin,@site]) do |f| %>
4
+ <%= render "/shared/error_messages", target: @site %>
5
+ <fieldset>
6
+ <legend><%= t("common.edit") %></legend>
7
+ <%= f.input :name %>
8
+ <%= f.input :url, input_html: { class: "xxlarge" }, placeholder: "http://" %>
9
+ <%= f.input :desc, as: :text, input_html: { class: "xxlarge", rows: "3" } %>
10
+ <%= f.input :site_node_id, collection: SiteNode.all.collect { |t| [t.name, t.id] }, include_blank: false %>
11
+ <div class="form-actions">
12
+ <%= f.submit '保存', class: "btn btn-primary", 'data-disable-with' => '保存中...' %>
13
+ or
14
+ <%= link_to '取消', admin_sites_path %>
15
+ </div>
16
+ </fieldset>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= render 'base' %>
2
+ <%= render 'form' %>
3
+
@@ -0,0 +1,51 @@
1
+ <%= render 'base' %>
2
+
3
+ <div class="toolbar clearfix">
4
+ <form class="form-inline pull-left" action="<%= admin_sites_path %>">
5
+ <div class="form-group">
6
+ <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="网站名称" />
7
+ </div>
8
+ <button class="btn btn-default">搜索</button>
9
+ </form>
10
+
11
+ <div class="pull-right">
12
+ <a href="<%= admin_site_nodes_path %>" class="btn btn-default">分类管理...</a>
13
+ </div>
14
+ </div>
15
+
16
+ <div id="admin_sites">
17
+ <table class="table table-bordered table-striped table-condensed">
18
+ <tr class="head">
19
+ <td style="width:40px;">编号</td>
20
+ <td style="width:140px;">网站</td>
21
+ <td>信息</td>
22
+ <td>提交人</td>
23
+ <td style="width:100px">节点</td>
24
+ <td style="width:105px">时间</td>
25
+ <td style="width:30px" class="opts"></td>
26
+ </tr>
27
+ <% @sites.each do |item| %>
28
+ <tr class="<%= cycle("","even") %><%= ' deleted' if !item.deleted_at.blank? %>">
29
+ <td><%= item.id %></td>
30
+ <td><%= image_tag(item.favicon_url, style: "width:16px;height:16px;")%> <%= item.name %></td>
31
+ <td>
32
+ <%= link_to item.url,item.url, target: "_blank" %><br />
33
+ <small class="muted"><%= item.desc %></small>
34
+ </td>
35
+ <td><%= user_name_tag(item.user) %></td>
36
+ <td><%= item.site_node.name if !item.site_node.blank? %></td>
37
+ <td><%= l(item.created_at, format: :short) %></td>
38
+ <td>
39
+ <%= link_to "", edit_admin_site_path(item.id), class: "fa fa-pencil" %>
40
+ <% if item.deleted? %>
41
+ <%= link_to "", undestroy_admin_site_path(item.id), method: :post, 'data-confirm' => '确定要恢复么?', class: "fa fa-undo" %>
42
+ <% else %>
43
+ <%= link_to "", admin_site_path(item.id), method: :delete, 'data-confirm' => '确定要删除吗?', class: "fa fa-trash" %>
44
+ <% end %>
45
+ </td>
46
+ </tr>
47
+ <% end %>
48
+ </table>
49
+ <%= paginate @sites %>
50
+ </div>
51
+
@@ -0,0 +1,19 @@
1
+ <div id="site" class="panel panel-default">
2
+ <div class="panel-heading">提交酷站</div>
3
+ <div class="panel-body">
4
+ <%= simple_form_for(@site) do |f| %>
5
+ <%= render "/shared/error_messages", target: @site %>
6
+ <%= f.input :site_node_id, collection: SiteNode.all.collect { |t| [t.name, t.id] }, include_blank: false %>
7
+
8
+ <%= f.input :name %>
9
+ <%= f.input :url, input_html: { class: "xxlarge" }, placeholder: "http://" %>
10
+ <%= f.input :desc, as: :text, input_html: { class: "xxlarge", rows: "3" } %>
11
+
12
+ <div class="form-group">
13
+ <%= f.submit '提交', class: "btn btn-primary", 'data-disable-with' => '提交中...' %>
14
+ or
15
+ <%= link_to '取消', sites_path %>
16
+ </div>
17
+ <% end %>
18
+ </div>
19
+ </div>
@@ -0,0 +1,28 @@
1
+ <% title_tag t('plugin.site') %>
2
+
3
+ <div id="site_nodes">
4
+ <% if can? :create, Site %>
5
+ <div class="panel panel-default">
6
+ <div class="panel-body">
7
+ <%= raw Setting.site_index_html %>
8
+ <%= link_to('创建', new_site_path, class: "btn btn-success")%>
9
+ </div>
10
+ </div>
11
+ <% end %>
12
+
13
+ <% cache(["plugin/sites", t: CacheVersion.sites_updated_at, d: Date.today]) do %>
14
+ <% @site_nodes.each do |node| %>
15
+ <div class="panel panel-default">
16
+ <div class="panel-heading"><%= node.name %></div>
17
+ <div class="panel-body row">
18
+ <% node.sites.each do |item| %>
19
+ <div class="col-md-2 site">
20
+ <%= image_tag(item.favicon_url, class: "favicon", style: "width: 16px; height: 16px;")%>
21
+ <%= link_to item.name, item.url, target: "_blank", rel: "twipsy", title: item.desc %>
22
+ </div>
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+ <% end %>
28
+ </div>
@@ -0,0 +1,3 @@
1
+ <% title_tag t('plugin.site') %>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1,14 @@
1
+ <% content_for :stylesheets do %>
2
+ <%= stylesheet_link_tag "homeland/site/application", media: "all" %>
3
+ <% end %>
4
+
5
+ <% content_for :javascripts do %>
6
+ <% end %>
7
+
8
+ <% content_for :main do %>
9
+ <div id="homeland-site">
10
+ <%= yield %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= render template: "/layouts/application" %>
@@ -0,0 +1,19 @@
1
+ "zh-CN":
2
+ plugin:
3
+ site: 酷站
4
+ simple_form:
5
+ hints:
6
+ site:
7
+ desc: '100字左右的介绍'
8
+ url: "别忘了要写 http:// 哦!"
9
+ favicon: '此网站的 Favicon,不填将会用 Google 来分析此网站的图标.'
10
+ activerecord:
11
+ models:
12
+ site: 酷站
13
+ site_node: 酷站分类
14
+ attributes:
15
+ site:
16
+ name: 网站名称
17
+ url: 地址
18
+ desc: 简单介绍
19
+ site_node_id: 分类
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Homeland::Site::Engine.routes.draw do
2
+ resources :sites
3
+ namespace :admin do
4
+ resources :sites do
5
+ member do
6
+ post :undestroy
7
+ end
8
+ end
9
+ resources :site_nodes
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ class CreateSites < ActiveRecord::Migration[5.0]
2
+ def up
3
+ return if ActiveRecord::Base.connection.table_exists? :sites
4
+
5
+ create_table 'site_nodes', force: :cascade do |t|
6
+ t.string 'name', null: false
7
+ t.integer 'sort', default: 0, null: false
8
+ t.datetime 'created_at'
9
+ t.datetime 'updated_at'
10
+ end
11
+
12
+ add_index 'site_nodes', ['sort'], name: 'index_site_nodes_on_sort', using: :btree
13
+
14
+ create_table 'sites', force: :cascade do |t|
15
+ t.integer 'user_id'
16
+ t.integer 'site_node_id'
17
+ t.string 'name', null: false
18
+ t.string 'url', null: false
19
+ t.string 'desc'
20
+ t.datetime 'deleted_at'
21
+ t.datetime 'created_at'
22
+ t.datetime 'updated_at'
23
+ end
24
+
25
+ add_index 'sites', ['site_node_id'], name: 'index_sites_on_site_node_id', using: :btree
26
+ add_index 'sites', ['url'], name: 'index_sites_on_url', using: :btree
27
+ end
28
+
29
+ def down
30
+ drop_table :sites, if_exists: true
31
+ drop_table :site_nodes, if_exists: true
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ module Homeland::Site
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Homeland::Site
4
+
5
+ initializer 'homeland.site.init' do |app|
6
+ next unless Setting.has_module?(:site)
7
+ Homeland.register_plugin do |plugin|
8
+ plugin.name = Homeland::Site::NAME
9
+ plugin.display_name = '酷站'
10
+ plugin.version = Homeland::Site::VERSION
11
+ plugin.description = Homeland::Site::DESCRIPTION
12
+ plugin.navbar_link = true
13
+ plugin.admin_navbar_link = true
14
+ plugin.root_path = "/sites"
15
+ plugin.admin_path = "/admin/sites"
16
+ end
17
+
18
+ app.routes.prepend do
19
+ mount Homeland::Site::Engine => '/'
20
+ end
21
+ app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module Homeland
2
+ module Site
3
+ VERSION = '0.1.0'
4
+ NAME = 'site'
5
+ DESCRIPTION = 'Site for Homeland.'
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require "homeland/site/version"
2
+ require "homeland/site/engine"
3
+
4
+ module Homeland
5
+ module Site
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :homeland_site do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: homeland-site
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-21 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ description: Site for Homeland.
28
+ email:
29
+ - huacnlee@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/assets/config/homeland_site_manifest.js
38
+ - app/assets/javascripts/homeland/site/application.js
39
+ - app/assets/stylesheets/homeland/site/application.css
40
+ - app/controllers/homeland/site/admin/site_nodes_controller.rb
41
+ - app/controllers/homeland/site/admin/sites_controller.rb
42
+ - app/controllers/homeland/site/application_controller.rb
43
+ - app/controllers/homeland/site/sites_controller.rb
44
+ - app/helpers/homeland/site/application_helper.rb
45
+ - app/models/homeland/site/ability.rb
46
+ - app/models/site.rb
47
+ - app/models/site_node.rb
48
+ - app/views/homeland/site/admin/site_nodes/_base.html.erb
49
+ - app/views/homeland/site/admin/site_nodes/_form.html.erb
50
+ - app/views/homeland/site/admin/site_nodes/edit.html.erb
51
+ - app/views/homeland/site/admin/site_nodes/index.html.erb
52
+ - app/views/homeland/site/admin/site_nodes/new.html.erb
53
+ - app/views/homeland/site/admin/sites/_base.html.erb
54
+ - app/views/homeland/site/admin/sites/_form.html.erb
55
+ - app/views/homeland/site/admin/sites/edit.html.erb
56
+ - app/views/homeland/site/admin/sites/index.html.erb
57
+ - app/views/homeland/site/sites/_form.html.erb
58
+ - app/views/homeland/site/sites/index.html.erb
59
+ - app/views/homeland/site/sites/new.html.erb
60
+ - app/views/layouts/homeland/site/application.html.erb
61
+ - config/locales/homeland.site.zh-CN.yml
62
+ - config/routes.rb
63
+ - db/migrate/20170321125706_create_sites.rb
64
+ - lib/homeland/site.rb
65
+ - lib/homeland/site/engine.rb
66
+ - lib/homeland/site/version.rb
67
+ - lib/tasks/homeland/site_tasks.rake
68
+ homepage: https://github.com/ruby-china/homeland-site
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.6.11
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Site plugin for Homeland
92
+ test_files: []