From 05b900d76c503dd9cc8a251ed3f54d53f72d39a3 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 21 Mar 2017 19:26:33 +0800 Subject: [PATCH 1/5] Fix PLUGIN_DEV typo --- PLUGIN_DEV.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PLUGIN_DEV.md b/PLUGIN_DEV.md index 0116edc6ce..f2da8dcb00 100644 --- a/PLUGIN_DEV.md +++ b/PLUGIN_DEV.md @@ -29,7 +29,7 @@ module Homeland initializer 'homeland.foo.init' do |app| # 确定应用 config.modules 启用了 foo,才开启 - return unless Setting.has_module?(:foo) + next unless Setting.has_module?(:foo) # 注册 Homeland Plugin Homeland.register_plugin do |plugin| # 插件名称,应用 Ruby 的变量命名风格,例如 foo_bar From 3ae8d6c58a8f311648397dcc9884925e96a51d35 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 21 Mar 2017 19:32:56 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Fix=20#903=20=E5=89=A5=E7=A6=BB=E8=AE=B0?= =?UTF-8?q?=E4=BA=8B=E6=9C=AC=E6=88=90=E4=B8=BA=E7=8B=AC=E7=AB=8B=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20homeland-note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + Gemfile.lock | 5 +- app/assets/javascripts/app.coffee | 10 +-- app/assets/javascripts/notes.coffee | 28 ------ app/assets/stylesheets/front.scss | 1 - app/assets/stylesheets/notes.scss | 22 ----- app/controllers/notes_controller.rb | 65 -------------- app/controllers/users/user_actions.rb | 7 +- app/helpers/notes_helper.rb | 12 --- app/models/ability.rb | 9 -- app/models/note.rb | 31 ------- app/models/user.rb | 1 - app/views/admin/home/index.html.erb | 12 --- .../devise/menu/_registration_items.html.erb | 3 +- app/views/notes/_form.html.erb | 31 ------- app/views/notes/_sidebar.html.erb | 21 ----- app/views/notes/edit.html.erb | 13 --- app/views/notes/index.html.erb | 44 ---------- app/views/notes/new.html.erb | 13 --- app/views/notes/show.html.erb | 39 --------- app/views/shared/_usernav.html.erb | 2 - app/views/users/_menu.html.erb | 1 - app/views/users/notes.html.erb | 28 ------ config/locales/admin.en.yml | 1 - config/locales/admin.zh-CN.yml | 1 - config/locales/admin.zh-TW.yml | 1 - config/locales/en.yml | 8 -- config/locales/menu.en.yml | 1 - config/locales/menu.zh-CN.yml | 1 - config/locales/menu.zh-TW.yml | 1 - config/locales/notes.en.yml | 10 --- config/locales/notes.zh-CN.yml | 10 --- config/locales/notes.zh-TW.yml | 10 --- config/locales/users.en.yml | 1 - config/locales/users.zh-CN.yml | 1 - config/locales/users.zh-TW.yml | 1 - config/locales/zh-CN.yml | 8 -- config/locales/zh-TW.yml | 8 -- config/routes.rb | 6 -- db/schema.rb | 2 +- spec/controllers/notes_controller_spec.rb | 86 ------------------- spec/controllers/users_controller_spec.rb | 9 -- spec/factories/notes.rb | 7 -- spec/models/ability_spec.rb | 14 --- 44 files changed, 9 insertions(+), 577 deletions(-) delete mode 100644 app/assets/javascripts/notes.coffee delete mode 100644 app/assets/stylesheets/notes.scss delete mode 100644 app/controllers/notes_controller.rb delete mode 100644 app/helpers/notes_helper.rb delete mode 100644 app/models/note.rb delete mode 100644 app/views/notes/_form.html.erb delete mode 100644 app/views/notes/_sidebar.html.erb delete mode 100644 app/views/notes/edit.html.erb delete mode 100644 app/views/notes/index.html.erb delete mode 100644 app/views/notes/new.html.erb delete mode 100644 app/views/notes/show.html.erb delete mode 100644 app/views/users/notes.html.erb delete mode 100644 config/locales/notes.en.yml delete mode 100644 config/locales/notes.zh-CN.yml delete mode 100644 config/locales/notes.zh-TW.yml delete mode 100644 spec/controllers/notes_controller_spec.rb delete mode 100644 spec/factories/notes.rb diff --git a/Gemfile b/Gemfile index 6695b933f9..36784719c8 100644 --- a/Gemfile +++ b/Gemfile @@ -122,6 +122,7 @@ gem 'bundler-audit', require: false gem 'homeland-press' gem 'homeland-jobs' gem 'homeland-wiki' +gem 'homeland-note' gem 'sdoc', '1.0.0.rc1' diff --git a/Gemfile.lock b/Gemfile.lock index aaaa11e59b..5e18004bd4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -164,9 +164,11 @@ GEM hiredis (0.6.1) homeland-jobs (0.1.1) rails (~> 5) + homeland-note (0.1.1) + rails (~> 5) homeland-press (0.3.3) rails (~> 5) - homeland-wiki (0.2.2) + homeland-wiki (0.3.0) rails (~> 5) html-pipeline (2.5.0) activesupport (>= 2) @@ -449,6 +451,7 @@ DEPENDENCIES font-awesome-rails hiredis homeland-jobs + homeland-note homeland-press homeland-wiki html-pipeline diff --git a/app/assets/javascripts/app.coffee b/app/assets/javascripts/app.coffee index a207d8a21c..1321a9dc97 100644 --- a/app/assets/javascripts/app.coffee +++ b/app/assets/javascripts/app.coffee @@ -21,7 +21,6 @@ #= require action_cable #= require form_storage #= require topics -#= require notes #= require editor #= require toc #= require turbolinks @@ -57,14 +56,7 @@ AppView = Backbone.View.extend if $('body').data('controller-name') in ['topics', 'replies'] window._topicView = new TopicView({parentView: @}) - if $('body').data('controller-name') in ['pages'] - window._pageView = new PageView({parentView: @}) - - if $('body').data('controller-name') in ['notes'] - window._noteView = new NoteView({parentView: @}) - - if $('body').data('controller-name') in ['topics', 'pages'] - window._tocView = new TOCView({parentView: @}) + window._tocView = new TOCView({parentView: @}) initComponents: () -> $("abbr.timeago").timeago() diff --git a/app/assets/javascripts/notes.coffee b/app/assets/javascripts/notes.coffee deleted file mode 100644 index ca55f65011..0000000000 --- a/app/assets/javascripts/notes.coffee +++ /dev/null @@ -1,28 +0,0 @@ -window.NoteView = Backbone.View.extend - el: "body" - events: - "click .editor-toolbar .edit a": "toggleEditView" - "click .editor-toolbar .preview a": "togglePreviewView" - - initialize: (opts) -> - @parentView = opts.parentView - $("").insertAfter( $('#note_body') ) - window._editor = new Editor() - - toggleEditView: (e) -> - $(e.target).parent().addClass('active') - $('.preview a').parent().removeClass('active') - $('#preview').hide() - $('#note_body').show() - false - - togglePreviewView: (e) -> - $(e.target).parent().addClass('active') - $('.edit a').parent().removeClass('active') - $('#preview').html('Loading...') - $('#note_body').hide() - $('#preview').show() - $.post '/notes/preview', {body: $('#note_body').val()}, (data)-> - $('#preview').html(data) - false - false diff --git a/app/assets/stylesheets/front.scss b/app/assets/stylesheets/front.scss index 282770c996..7528f5c9df 100644 --- a/app/assets/stylesheets/front.scss +++ b/app/assets/stylesheets/front.scss @@ -5,7 +5,6 @@ *= require notifications *= require home *= require users - *= require notes *= require teams *= require search *= require toc diff --git a/app/assets/stylesheets/notes.scss b/app/assets/stylesheets/notes.scss deleted file mode 100644 index 7e18ad012f..0000000000 --- a/app/assets/stylesheets/notes.scss +++ /dev/null @@ -1,22 +0,0 @@ -#notes { - .info { color: #666; } - .media { - &:last-child { - padding-bottom: 0px; - border-bottom: 0px; - } - border-bottom: 1px solid #f0f0f0; - padding-bottom: 10px; - - .media-heading { - a { font-size: 15px; } - } - .info { color: #AAA; font-size: 12px; } - } - - .markdown { - min-height: 493px; - - h2:first-child { text-align: center; } - } -} diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb deleted file mode 100644 index 9ebafca635..0000000000 --- a/app/controllers/notes_controller.rb +++ /dev/null @@ -1,65 +0,0 @@ -class NotesController < ApplicationController - require_module_enabled! :note - - before_action :authenticate_user! - before_action :set_recent_notes, only: [:index, :show, :edit, :new, :create, :update] - load_and_authorize_resource - - def index - @notes = current_user.notes.recent_updated.page(params[:page]) - end - - def show - @note = Note.find(params[:id]) - @note.hits.incr(1) - end - - def new - @note = current_user.notes.build - end - - def edit - @note = current_user.notes.find(params[:id]) - end - - def create - @note = current_user.notes.new(note_params) - @note.publish = note_params[:publish] == '1' - if @note.save - redirect_to(@note, notice: t('common.create_success')) - else - render action: 'new' - end - end - - def update - @note = current_user.notes.find(params[:id]) - if @note.update(note_params) - redirect_to(@note, notice: t('common.update_success')) - else - render action: 'edit' - end - end - - def preview - out = Homeland::Markdown.call(params[:body]) - render plain: out - end - - def destroy - @note = current_user.notes.find(params[:id]) - @note.destroy - - redirect_to(notes_url) - end - - private - - def set_recent_notes - @recent_notes = current_user.notes.recent.limit(10) - end - - def note_params - params.require(:note).permit(:title, :body, :publish) - end -end diff --git a/app/controllers/users/user_actions.rb b/app/controllers/users/user_actions.rb index d1d5db7ff3..c810ac060d 100644 --- a/app/controllers/users/user_actions.rb +++ b/app/controllers/users/user_actions.rb @@ -4,7 +4,7 @@ module UserActions included do before_action :authenticate_user!, only: [:block, :unblock, :blocked, :follow, :unfollow] - before_action :only_user!, only: [:topics, :replies, :favorites, :notes, + before_action :only_user!, only: [:topics, :replies, :favorites, :block, :unblock, :follow, :unfollow, :followers, :following, :calendar, :reward] end @@ -24,11 +24,6 @@ def favorites @topics = @topics.page(params[:page]) end - def notes - @notes = @user.notes.published.recent - @notes = @notes.page(params[:page]) - end - def block current_user.block_user(@user.id) render json: { code: 0 } diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb deleted file mode 100644 index 9f87454930..0000000000 --- a/app/helpers/notes_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -module NotesHelper - def render_node_name(name, id) - link_to(name, main_app.node_topics_path(id), class: 'node') - end - - def note_title_tag(note, opts = {}) - opts[:limit] ||= 50 - return '' if note.blank? - return '' if note.title.blank? - truncate(note.title.delete('#'), length: opts[:limit]) - end -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 36ec5c7bb3..07b3ba6930 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -22,7 +22,6 @@ def initialize(u) def roles_for_members roles_for_topics roles_for_replies - roles_for_notes roles_for_comments roles_for_photos roles_for_sites @@ -62,12 +61,6 @@ def current_lock_reply? Time.zone.now.hour > 22 || Time.zone.now.hour < 9 end - def roles_for_notes - can :create, Note - can [:update, :destroy, :read], Note, user_id: user.id - can :read, Note, publish: true - end - def roles_for_photos can :tiny_new, Photo can :create, Photo @@ -105,11 +98,9 @@ def roles_for_team_users def basic_read_only can [:read, :feed, :node], Topic can [:read, :reply_to], Reply - can :preview, Note can :read, Photo can :read, Site can :read, Section - can :read, Node can :read, Comment can :read, Team end diff --git a/app/models/note.rb b/app/models/note.rb deleted file mode 100644 index 1840239fc7..0000000000 --- a/app/models/note.rb +++ /dev/null @@ -1,31 +0,0 @@ -# 记事本 -class Note < ApplicationRecord - second_level_cache - - belongs_to :user - - counter :hits, default: 0 - - scope :recent_updated, -> { order(updated_at: :desc) } - scope :published, -> { where(publish: true) } - - validates :body, presence: true - - before_save :auto_set_value - def auto_set_value - unless body.blank? - self.title = body.split("\n").first[0..50] - self.word_count = body.length - end - end - - before_update :update_changes_count - def update_changes_count - self.changes_count = 0 if changes_count.blank? - increment(:changes_count) - end - - def display_title - (title || '').gsub(/^[\#]+/, '') - end -end diff --git a/app/models/user.rb b/app/models/user.rb index 43d3514af1..95c0f3aa6c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,7 +24,6 @@ class User < ApplicationRecord mount_uploader :avatar, AvatarUploader has_many :topics, dependent: :destroy - has_many :notes has_many :replies, dependent: :destroy has_many :authorizations, dependent: :destroy has_many :notifications, dependent: :destroy diff --git a/app/views/admin/home/index.html.erb b/app/views/admin/home/index.html.erb index fb463c37e5..6d304d6f93 100644 --- a/app/views/admin/home/index.html.erb +++ b/app/views/admin/home/index.html.erb @@ -71,18 +71,6 @@ -
-
-
0
-
- 记事本总数 - +0 - +0 -
-
-
- -
diff --git a/app/views/devise/menu/_registration_items.html.erb b/app/views/devise/menu/_registration_items.html.erb index be8460082b..27025c0bac 100644 --- a/app/views/devise/menu/_registration_items.html.erb +++ b/app/views/devise/menu/_registration_items.html.erb @@ -1,10 +1,9 @@ <% if user_signed_in? %> 你好 <%= current_user.login %>, <% if not params[:controller].match(/admin/) %> - 记事本 | <%= link_to('设置', setting_path) %> | <% if admin? current_user %>后台 | <% end %> <% end %> <% else %> - <%= link_to('加入社区', new_user_registration_path) %> + <%= link_to('加入社区', new_user_registration_path) %> <% end %> diff --git a/app/views/notes/_form.html.erb b/app/views/notes/_form.html.erb deleted file mode 100644 index 5f92e003ac..0000000000 --- a/app/views/notes/_form.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<%= simple_form_for(@note, html: { class: "" }) do |f| %> - <%= render "shared/error_messages", target: @note %> - -
- <%= render "/shared/editor_toolbar" %> -
- -
- - <%= f.text_area :body, rows: 20, class: 'form-control topic-editor' %> - -

- <%= t("notes.please_use") %> Markdown <%= t("notes.document_format_to_write") %> -

-
- -
- -
- -
-
-
- <%= f.submit t("common.save"), class: "btn btn-primary btn-lg btn-block", 'data-disable-with' => t("common.saving") %> -
-
- <%= link_to t("common.cancel"), notes_path, class: "btn btn-default btn-lg btn-block" %> -
-
-
-<% end %> diff --git a/app/views/notes/_sidebar.html.erb b/app/views/notes/_sidebar.html.erb deleted file mode 100644 index a1d8af810f..0000000000 --- a/app/views/notes/_sidebar.html.erb +++ /dev/null @@ -1,21 +0,0 @@ - diff --git a/app/views/notes/edit.html.erb b/app/views/notes/edit.html.erb deleted file mode 100644 index fd479ef1cb..0000000000 --- a/app/views/notes/edit.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% title_tag t('notes.edit_note') %> - -
-
-
-
- <%= render 'form' %> -
-
-
- - <%= render "sidebar" %> -
diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb deleted file mode 100644 index 30eb7fc56b..0000000000 --- a/app/views/notes/index.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<% title_tag t('menu.notes') %> -
-
-
-
- <%= t('menu.notes') %> - - 已有 <%= current_user.notes.count %> 条 Note - -
- -
- <% if @notes.blank? %> -
你还没有创建过一个文件。
- <% else %> - <% @notes.each do |note| %> -
-
-
- <%= link_to note.display_title, note %> - <% if note.publish %> - 公开 - <% end %> - - - -
-
- <%= note.word_count %> <%= t("notes.chars") %>, <%= sanitize t("notes.created_at", time: timeago(note.created_at)) %>, <%= note.changes_count %> <%= t("notes.times_edit") %> -
-
-
- <% end %> - <% end %> -
- - -
-
- - <%= render "sidebar" %> -
diff --git a/app/views/notes/new.html.erb b/app/views/notes/new.html.erb deleted file mode 100644 index 25f9798c1d..0000000000 --- a/app/views/notes/new.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% title_tag t('notes.new_note') %> - -
-
-
-
- <%= render 'form' %> -
-
-
- - <%= render "sidebar" %> -
diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb deleted file mode 100644 index f17ae63c70..0000000000 --- a/app/views/notes/show.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<% title_tag [@note.title, t('menu.notes')].join(' · ') %> - -
-
-
-
-
- 共 <%= @note.word_count %> <%= t("notes.chars") %> - • <%= user_name_tag(@note.user) if !owner? @note %> - <%= l @note.created_at, format: :long %> - • <%= @note.hits %> <%= t("common.read_times")%> - • <%= @note.changes_count %> <%= t("notes.times_edit") %> - <% if owner? @note %> - - <%= link_to icon_tag("pencil"), edit_note_path(@note), title: t("common.edit") %> - <%= link_to icon_tag("trash"), note_path(@note), 'data-confirm' => t("common.confirm_delete"), method: :delete, title: t("common.confirm_delete") %> - - <% end %> -
- <% if @note.publish %> - - <% end %> -
-
- <% if !@note.publish %> - - <% end %> -
- <%= markdown(@note.body) %> -
-
-
-
- - <%= render "sidebar" %> -
diff --git a/app/views/shared/_usernav.html.erb b/app/views/shared/_usernav.html.erb index 3e5d74afa5..e9f03b74c8 100644 --- a/app/views/shared/_usernav.html.erb +++ b/app/views/shared/_usernav.html.erb @@ -12,7 +12,6 @@ li << link_to(current_user.login, main_app.user_path(current_user) ) li << "
" li << link_to(t("menu.edit_account_path"), main_app.setting_path) - li << link_to(t("menu.notes"), main_app.notes_path ) li << link_to(t("menu.likes"), main_app.favorites_topics_path) Homeland.user_menu_plugins.each do |plugin| @@ -62,7 +61,6 @@ <%= render_list class: "dropdown-menu", role: "menu" do |li| li << link_to(t("topics.new_topic"), main_app.new_topic_path) - li << link_to(t("notes.new_note"), main_app.new_note_path) if Setting.has_module?(:note) if can? :create, Team li << "
" li << link_to(t("teams.new_team"), main_app.new_team_path) diff --git a/app/views/users/_menu.html.erb b/app/views/users/_menu.html.erb index 895d3b4e79..3d92bc637b 100644 --- a/app/views/users/_menu.html.erb +++ b/app/views/users/_menu.html.erb @@ -3,7 +3,6 @@ li << link_to(t("users.menu.topics"), topics_user_path(@user)) li << link_to(t("users.menu.replies"), replies_user_path(@user)) li << link_to(t("users.menu.favorites"), favorites_user_path(@user), class: 'hide-ios') - li << link_to(t("users.menu.notes"), notes_user_path(@user), class: 'hide-ios') if Setting.has_module?(:note) li << link_to(t("users.menu.following"), following_user_path(@user)) li << link_to(t("users.menu.followers"), followers_user_path(@user)) if owner?(@user) && current_user.block_users? diff --git a/app/views/users/notes.html.erb b/app/views/users/notes.html.erb deleted file mode 100644 index 1759dea297..0000000000 --- a/app/views/users/notes.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<% title_tag [@user.fullname, t('users.menu.notes')].join(' · ') %> - -
- <%= render "sidebar", user: @user %> -
- <%= render "menu" %> -
-
- - - - - - <% @notes.each do |note| %> - "> - - - - <% end %> -
<%= t("common.title") %><%=t("common.statics")%>
<%= note_title_tag(note) %> <%= raw '公开' if note.publish %><%= note.word_count %> <%= t("notes.chars") %>, <%= sanitize t("notes.created_at", time: timeago(note.created_at)) %>
-
- -
-
- -
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index c1336216d2..88b3582fd1 100644 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -10,7 +10,6 @@ topics: "Topics" replies: "Replies" photos: "Photos" - notes: "Notes" comments: "Comments" site_nodes: "Site Nodes" sites: "Sites" diff --git a/config/locales/admin.zh-CN.yml b/config/locales/admin.zh-CN.yml index 4f6367874e..5408cf9158 100644 --- a/config/locales/admin.zh-CN.yml +++ b/config/locales/admin.zh-CN.yml @@ -10,7 +10,6 @@ topics: "话题" replies: "回复" photos: "图片" - notes: "记事本" comments: "评论" site_nodes: "酷站类别" sites: "酷站" diff --git a/config/locales/admin.zh-TW.yml b/config/locales/admin.zh-TW.yml index 3d70acb3fe..0ee284d364 100644 --- a/config/locales/admin.zh-TW.yml +++ b/config/locales/admin.zh-TW.yml @@ -10,7 +10,6 @@ topics: "帖子" replies: "回覆" photos: "圖片" - notes: "記事本" comments: "評論" site_nodes: "酷站類別" sites: "酷站" diff --git a/config/locales/en.yml b/config/locales/en.yml index fd168490d9..317418a7ec 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -76,14 +76,6 @@ en: body: "Content" reply: body: "Reply Content" - note: - title: "Title" - post: - title: "Title" - body: "Content" - tag_list: "Tags" - source: "Source" - source_url: "Source Url" page: slug: Slug title: "Title" diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index e576a01106..a51fba3d6a 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -83,7 +83,6 @@ gems: "Gems" users: "Users" admin: "Control Panel" - notes: "Notes" nodes: "Nodes" sites: "Sites" my_home_page: "My home page" diff --git a/config/locales/menu.zh-CN.yml b/config/locales/menu.zh-CN.yml index 2d2dbb4363..e9bd1a1596 100644 --- a/config/locales/menu.zh-CN.yml +++ b/config/locales/menu.zh-CN.yml @@ -86,7 +86,6 @@ gems: "Gems" users: "会员" admin: "后台" - notes: "记事本" nodes: "节点" sites: "酷站" my_home_page: "我的主页" diff --git a/config/locales/menu.zh-TW.yml b/config/locales/menu.zh-TW.yml index 3308b2f028..9b01315d43 100644 --- a/config/locales/menu.zh-TW.yml +++ b/config/locales/menu.zh-TW.yml @@ -86,7 +86,6 @@ gems: "Gems" users: "會員" admin: "後臺" - notes: "記事本" nodes: "節點" sites: "酷站" my_home_page: "我的主頁" diff --git a/config/locales/notes.en.yml b/config/locales/notes.en.yml deleted file mode 100644 index 967f17f55b..0000000000 --- a/config/locales/notes.en.yml +++ /dev/null @@ -1,10 +0,0 @@ -"en": - notes: - new_note: "Create Note" - edit_note: "Edit Note" - page_link: "Link" - created_at: "Created at %{time}" - times_edit: "times edited" - chars: "characters" - please_use: "Please use" - document_format_to_write: " Document format" \ No newline at end of file diff --git a/config/locales/notes.zh-CN.yml b/config/locales/notes.zh-CN.yml deleted file mode 100644 index b628536419..0000000000 --- a/config/locales/notes.zh-CN.yml +++ /dev/null @@ -1,10 +0,0 @@ -"zh-CN": - notes: - new_note: "新建 Note" - edit_note: "修改 Note" - page_link: "本页地址" - created_at: "于 %{time}创建" - times_edit: "次修改" - chars: "个字符" - please_use: "请用" - document_format_to_write: " 文档格式编写" diff --git a/config/locales/notes.zh-TW.yml b/config/locales/notes.zh-TW.yml deleted file mode 100644 index a52f9c1ca1..0000000000 --- a/config/locales/notes.zh-TW.yml +++ /dev/null @@ -1,10 +0,0 @@ -"zh-TW": - notes: - new_note: "新建 Note" - edit_note: "修改 Note" - page_link: "本頁地址" - created_at: "於 %{time}創建" - times_edit: "次修改" - chars: "個字符" - please_use: "請用" - document_format_to_write: " 文檔格式編寫" diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 72c46a6164..a91ef88496 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -44,7 +44,6 @@ like: "Likes" profile: "Profile" favorites: "Favorites" - notes: "Notes" replies: "Replies" following: "Following" followers: "Followers" diff --git a/config/locales/users.zh-CN.yml b/config/locales/users.zh-CN.yml index ad5b463aef..c452605ada 100644 --- a/config/locales/users.zh-CN.yml +++ b/config/locales/users.zh-CN.yml @@ -44,7 +44,6 @@ like: "赞" profile: "个人信息" favorites: "收藏" - notes: "记事本" replies: "回帖" following: "正在关注" followers: "关注者" diff --git a/config/locales/users.zh-TW.yml b/config/locales/users.zh-TW.yml index fcf206708c..3db3a5368e 100644 --- a/config/locales/users.zh-TW.yml +++ b/config/locales/users.zh-TW.yml @@ -44,7 +44,6 @@ like: "贊" profile: "個人信息" favorites: "收藏" - notes: "記事本" replies: "回帖" following: "正在關注" followers: "關注者" diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index a13fa98500..9e75a57899 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -69,14 +69,6 @@ body: "正文" reply: body: "回复内容" - note: - title: "标题" - post: - title: 标题 - body: 正文 - tag_list: 标签 - source: 来源 - source_url: 来源地址 page: slug: Slug title: 页面标题 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index ad989f2f66..67f01f384b 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -55,14 +55,6 @@ body: "正文" reply: body: "回覆內容" - note: - title: "標題" - post: - title: 標題 - body: 正文 - tag_list: 標籤 - source: 來源 - source_url: 來源地址 page: slug: Slug title: 頁面標題 diff --git a/config/routes.rb b/config/routes.rb index 3c7fcae3ac..8d7d6eb6c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,11 +8,6 @@ resources :sites resources :comments - resources :notes do - collection do - post :preview - end - end resources :devices resources :teams @@ -204,7 +199,6 @@ get :topics get :replies get :favorites - get :notes get :blocked post :block post :unblock diff --git a/db/schema.rb b/db/schema.rb index 4bc1d5ded0..e06ac954b0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170305220755) do +ActiveRecord::Schema.define(version: 20170321074447) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/controllers/notes_controller_spec.rb b/spec/controllers/notes_controller_spec.rb deleted file mode 100644 index 8a23c729f8..0000000000 --- a/spec/controllers/notes_controller_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'rails_helper' - -describe NotesController, type: :controller do - describe 'unauthenticated' do - it 'should not allow anonymous access' do - get :index - expect(response).not_to be_success - end - end - - describe 'authenticated' do - let(:user) { create :user } - let(:note) { create :note, user: user } - - before(:each) { sign_in user } - - describe ':index' do - it 'should have an index action' do - get :index - expect(response).to be_success - end - end - - describe ':new' do - it 'should have a new action' do - get :new - expect(response).to be_success - end - end - - describe ':edit' do - it 'should have an edit action' do - get :edit, params: { id: note.id } - expect(response).to be_success - end - end - - describe ':create' do - it 'should have an create action' do - post :create, params: { note: { title: 'new note', body: 'new body', publish: 1 } } - expect(response).to redirect_to(note_path(Note.find_by_title('new body'))) - end - - it 'should render new when save failure' do - allow_any_instance_of(Note).to receive(:save).and_return(false) - post :create, params: { note: { title: 'new note', body: 'new body', publish: 1 } } - expect(response).to be_success - end - end - - describe ':update' do - it 'should have an update action' do - post :update, params: { id: note, note: { title: 'new note', body: 'new body', publish: 1 } } - expect(response).to redirect_to(note_path(note)) - end - - it 'should render new when save failure' do - allow_any_instance_of(Note).to receive(:update).and_return(false) - post :update, params: { id: note, note: { title: 'new note', body: 'new body', publish: 1 } } - expect(response).to be_success - end - end - - describe ':destroy' do - it 'should have an update action' do - post :destroy, params: { id: note } - expect(response).to redirect_to(notes_path) - end - end - - describe ':show' do - it 'should have a show action' do - get :show, params: { id: note.id } - expect(response).to be_success - end - end - - describe ':preview' do - it 'should have a preview action' do - get :preview, params: { body: '# markdown' } - expect(response).to be_success - expect(response.body).to eq('

markdown

') - end - end - end -end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index b57f50bd3f..08556635ba 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -10,8 +10,6 @@ expect(response.status).to eq(404) get :topics, params: { id: deleted_user.login } expect(response.status).to eq(404) - get :notes, params: { id: deleted_user.login } - expect(response.status).to eq(404) end end @@ -61,13 +59,6 @@ end end - describe ':notes' do - it 'should show user notes' do - get :notes, params: { id: user.login } - expect(response).to be_success - end - end - describe ':block' do it 'should work' do sign_in user diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb deleted file mode 100644 index 9e27f628cc..0000000000 --- a/spec/factories/notes.rb +++ /dev/null @@ -1,7 +0,0 @@ -FactoryGirl.define do - factory :note do - sequence(:title) { |n| "title#{n}" } - sequence(:body) { |n| "body#{n}" } - association :user - end -end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 42798eb514..2890f40f5e 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -13,7 +13,6 @@ it { is_expected.to be_able_to(:manage, Section) } it { is_expected.to be_able_to(:manage, Node) } it { is_expected.to be_able_to(:manage, Site) } - it { is_expected.to be_able_to(:manage, Note) } it { is_expected.to be_able_to(:manage, Photo) } it { is_expected.to be_able_to(:manage, Comment) } it { is_expected.to be_able_to(:manage, Team) } @@ -97,24 +96,11 @@ it { is_expected.to be_able_to(:read, Node) } end - context 'Note' do - it { is_expected.to be_able_to(:read, Note.new(publish: true)) } - it { is_expected.not_to be_able_to(:read, Note.new(publish: false)) } - end - context 'Site' do it { is_expected.to be_able_to(:read, Site) } it { is_expected.not_to be_able_to(:create, Site) } end - context 'Note' do - it { is_expected.to be_able_to(:create, Note) } - it { is_expected.to be_able_to(:read, note) } - it { is_expected.to be_able_to(:update, note) } - it { is_expected.to be_able_to(:destroy, note) } - it { is_expected.to be_able_to(:read, note_publish) } - end - context 'Photo' do it { is_expected.to be_able_to(:create, Photo) } it { is_expected.to be_able_to(:read, Photo) } From 36549696efc45cfe8346dbc1e291cb52feb5daa4 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 21 Mar 2017 19:44:27 +0800 Subject: [PATCH 3/5] homeland-note 0.1.2 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5e18004bd4..95b018efcb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -164,7 +164,7 @@ GEM hiredis (0.6.1) homeland-jobs (0.1.1) rails (~> 5) - homeland-note (0.1.1) + homeland-note (0.1.2) rails (~> 5) homeland-press (0.3.3) rails (~> 5) From 6b4a089039c4db23dc800711d7660269a2c635e4 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 21 Mar 2017 20:16:35 +0800 Subject: [PATCH 4/5] Fix test --- app/helpers/topics_helper.rb | 4 ++++ lib/homeland.rb | 2 +- spec/models/ability_spec.rb | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index c611e0a49b..d1cd755be1 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -52,4 +52,8 @@ def topic_close_tag(topic) return '' unless topic.closed? content_tag(:i, '', title: '问题已解决/话题已结束讨论', class: 'fa fa-check', data: { toggle: 'tooltip' }) end + + def render_node_name(name, id) + link_to(name, node_topics_path(id), class: 'node') + end end diff --git a/lib/homeland.rb b/lib/homeland.rb index 03bd273824..45714fcd2d 100644 --- a/lib/homeland.rb +++ b/lib/homeland.rb @@ -14,7 +14,7 @@ def plugins # Plugin list sorted by `config.modules` order def sorted_plugins @sorted_plugins ||= plugins.sort do |a, b| - Setting.module_list.index(a.name) <=> Setting.module_list.index(b.name) + Setting.module_list.index(a.name) <=> Setting.module_list.index(b.name) end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 2890f40f5e..9c0c2013a6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -92,10 +92,6 @@ it { is_expected.to be_able_to(:read, Section) } end - context 'Node' do - it { is_expected.to be_able_to(:read, Node) } - end - context 'Site' do it { is_expected.to be_able_to(:read, Site) } it { is_expected.not_to be_able_to(:create, Site) } From 29f9474298ad63094fb9138bcbebbed47fc970fa Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 21 Mar 2017 20:32:48 +0800 Subject: [PATCH 5/5] Fix test --- lib/homeland.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/homeland.rb b/lib/homeland.rb index 45714fcd2d..6cc150d8f1 100644 --- a/lib/homeland.rb +++ b/lib/homeland.rb @@ -55,6 +55,7 @@ def register_plugin plugin = Homeland::Plugin.new yield plugin @plugins << plugin + @sorted_plugins = nil plugin end end