Skip to content

Commit

Permalink
Remove auto preview
Browse files Browse the repository at this point in the history
  • Loading branch information
haru committed Feb 23, 2019
1 parent 9d9b163 commit 0c47d08
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 272 deletions.
10 changes: 7 additions & 3 deletions app/models/wiki_extensions_setting.rb
@@ -1,5 +1,5 @@
# Wiki Extensions plugin for Redmine
# Copyright (C) 2011-2015 Haruyuki Iida
# Copyright (C) 2011-2019 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -24,15 +24,19 @@ def self.find_or_create(pj_id)
unless setting
setting = WikiExtensionsSetting.new
setting.project_id = pj_id
setting.save!
setting.save!
end
5.times do |i|
WikiExtensionsMenu.find_or_create(pj_id, i + 1)
end
return setting
end

def auto_preview_enabled
false
end

def menus
WikiExtensionsMenu.where(:project_id => project_id).order('menu_no')
WikiExtensionsMenu.where(:project_id => project_id).order("menu_no")
end
end
7 changes: 2 additions & 5 deletions app/views/wiki_extensions/_body_bottom.html.erb
@@ -1,5 +1,5 @@
<% # Wiki Extensions plugin for Redmine
# Copyright (C) 2012-2013 Haruyuki Iida
# Copyright (C) 2012-2019 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -22,9 +22,6 @@

context = {:project => project, :controller => controller, :request => request}

return add_messages_auto_preview(context) if controller.class.name == 'MessagesController'
return add_boards_auto_preview(context) if controller.class.name == 'BoardsController'

return unless controller.class.name == 'WikiController'
action_name = controller.action_name

Expand All @@ -39,7 +36,7 @@
<% if action_name == 'edit' or (action_name == 'show' and page_name and page == nil) %>
<%= render :partial => 'wiki_extensions/tags_form', :locals => context %>
<%= raw add_wiki_auto_preview(context) %>
<% else %>

Expand Down
33 changes: 0 additions & 33 deletions app/views/wiki_extensions/_issues_edit_notes_bottom.html.erb

This file was deleted.

39 changes: 0 additions & 39 deletions app/views/wiki_extensions/_issues_form_details_bottom.html.erb

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/wiki_extensions_settings/_show.html.erb
Expand Up @@ -45,12 +45,7 @@ function click_wiki_menu_tab(num) {
<div class="box">
<p>

<%= f.check_box 'auto_preview_enabled' %>
</p>

<p>
<%= f.check_box 'tag_disabled' %>
</p>

<hr/>
<b><%=h l(:wiki_extensions_add_tab)%></b>
Expand Down
33 changes: 1 addition & 32 deletions assets/javascripts/wiki_extensions.js
@@ -1,6 +1,6 @@
/*
# Wiki Extensions plugin for Redmine
# Copyright (C) 2009-2017 Haruyuki Iida
# Copyright (C) 2009-2019 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -17,7 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

var auto_preview_interval = 2000;

function add_wiki_extensions_tags_form() {
var tags_form = $('#wiki_extensions_tag_form');
Expand All @@ -34,37 +33,7 @@ function set_tag_atuto_complete(taglist) {
})
}

function setAutPreviewCallback(url, preview_id, form_id, content_id) {
var content_org = $(content_id).val();

setInterval(function(){
var content_new = $(content_id).val();
if (content_new != content_org) {
$(preview_id).load(url, $(form_id).we_serialize2json());
content_org = content_new;
}
},auto_preview_interval);
}

function setWikiAutoPreview(url) {
setAutPreviewCallback(url, '#preview', '#wiki_form', '#content_text');
}

function setMessagesAutoPreview(url) {
setAutPreviewCallback(url, '#preview', '#message-form', '#message_content');
}

function setBoardsAutoPreview(url) {
setAutPreviewCallback(url, '#preview', '#message-form', '#message_content');
}

function setIssueAutoPreview(url) {
setAutPreviewCallback(url, '#preview', '#issue-form', '#issue_description');
}

function setIssueNotesAutoPreview(url) {
setAutPreviewCallback(url, '#preview', '#issue-form', '#notes');
}

function is_table_for_sort(tbody) {
var trs = tbody.getElementsByTagName('tr');
Expand Down
33 changes: 16 additions & 17 deletions init.rb
Expand Up @@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine'
begin
require 'config/initializers/session_store.rb'
require 'config/initializers/session_store.rb'
rescue LoadError
end
require 'redmine/wiki_formatting/textile/redcloth3'
Expand All @@ -30,39 +30,38 @@
include ActionView::Helpers::WikiExtensionsHelper
end


Redmine::Plugin.register :redmine_wiki_extensions do
name 'Redmine Wiki Extensions plugin'
author 'Haruyuki Iida'
author_url 'http://twitter.com/haru_iida'
description 'This is a Wiki Extensions plugin for Redmine'
url "http://www.r-labs.org/projects/r-labs/wiki/Wiki_Extensions_en"
url 'http://www.r-labs.org/projects/r-labs/wiki/Wiki_Extensions_en'
version '0.9.0'
requires_redmine :version_or_higher => '4.0.0'

project_module :wiki_extensions do
permission :wiki_extensions_vote, {:wiki_extensions => [:vote, :show_vote]}, :public => true
permission :add_wiki_comment, {:wiki_extensions => [:add_comment, :reply_comment]}
permission :delete_wiki_comments, {:wiki_extensions => [:destroy_comment]}
permission :edit_wiki_comments, {:wiki_extensions => [:update_comment]}
permission :show_wiki_extension_tabs, {:wiki_extensions => [:forward_wiki_page]}, :public => true
permission :view_wiki_comment, {:wiki_extensions => [:show_comments]}, :public => true
permission :show_wiki_tags, {:wiki_extensions => [:tag]}, :public => true
permission :wiki_extensions_settings, {:wiki_extensions_settings => [:show, :update]}
permission :wiki_extensions_vote, { :wiki_extensions => [:vote, :show_vote] }, :public => true
permission :add_wiki_comment, { :wiki_extensions => [:add_comment, :reply_comment] }
permission :delete_wiki_comments, { :wiki_extensions => [:destroy_comment] }
permission :edit_wiki_comments, { :wiki_extensions => [:update_comment] }
permission :show_wiki_extension_tabs, { :wiki_extensions => [:forward_wiki_page] }, :public => true
permission :view_wiki_comment, { :wiki_extensions => [:show_comments] }, :public => true
permission :show_wiki_tags, { :wiki_extensions => [:tag] }, :public => true
permission :wiki_extensions_settings, { :wiki_extensions_settings => [:show, :update] }
end

menulist = [:wiki_extensions1,:wiki_extensions2,:wiki_extensions3,:wiki_extensions4,:wiki_extensions5]
menulist.length.times{|i|
menulist = [:wiki_extensions1, :wiki_extensions2, :wiki_extensions3, :wiki_extensions4, :wiki_extensions5]
menulist.length.times { |i|
no = i + 1
before = :wiki
before = menulist[i - 1] if i > 0

menu :project_menu, menulist[i], { :controller => 'wiki_extensions', :action => 'forward_wiki_page', :menu_id => no },:after => before,
:caption => Proc.new{|proj| WikiExtensionsMenu.title(proj.id, no)},
:if => Proc.new{|proj| WikiExtensionsMenu.enabled?(proj.id, no)}
menu :project_menu, menulist[i], { :controller => 'wiki_extensions', :action => 'forward_wiki_page', :menu_id => no }, :after => before,
:caption => Proc.new { |proj| WikiExtensionsMenu.title(proj.id, no) },
:if => Proc.new { |proj| WikiExtensionsMenu.enabled?(proj.id, no) }
}

RedCloth3::ALLOWED_TAGS << "div"
RedCloth3::ALLOWED_TAGS << 'div'

activity_provider :wiki_comment, :class_name => 'WikiExtensionsComment', :default => false
end
50 changes: 6 additions & 44 deletions lib/wiki_extensions_application_hooks.rb
@@ -1,5 +1,5 @@
# Wiki Extensions plugin for Redmine
# Copyright (C) 2009-2013 Haruyuki Iida
# Copyright (C) 2009-2019 Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -14,50 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine'
require 'application_helper'
require "redmine"
require "application_helper"

class WikiExtensionsApplicationHooks < Redmine::Hook::ViewListener
include ApplicationHelper

render_on :view_layouts_base_html_head, :partial => 'wiki_extensions/html_header'
render_on :view_layouts_base_body_bottom, :partial => 'wiki_extensions/body_bottom'

end

def add_wiki_auto_preview(context)
project = context[:project]
setting = WikiExtensionsSetting.find_or_create(project.id)
return '' unless setting.auto_preview_enabled
request = context[:request]
params = request.parameters if request
page_name = params[:id] if params
url = url_for(:controller => 'wiki', :action => 'preview', :id => page_name, :project_id => project)
o = ''
o << javascript_tag("setWikiAutoPreview('#{url}');")
return o
render_on :view_layouts_base_html_head, :partial => "wiki_extensions/html_header"
render_on :view_layouts_base_body_bottom, :partial => "wiki_extensions/body_bottom"
end

def add_messages_auto_preview(context)
project = context[:project]
setting = WikiExtensionsSetting.find_or_create(project.id)
return '' unless setting.auto_preview_enabled
request = context[:request]
params = request.parameters if request
board = params[:board_id] if params
url = url_for :controller => 'messages', :action => 'preview', :board_id => board
o = ''
o << javascript_tag("setMessagesAutoPreview('#{url}');")
return o
end

def add_boards_auto_preview(context)
project = context[:project]
setting = WikiExtensionsSetting.find_or_create(project.id)
return '' unless setting.auto_preview_enabled
return '' unless @board
return '' unless @board.id
url = url_for :controller => 'messages', :action => 'preview', :board_id => @board
o = ''
o << javascript_tag("setBoardsAutoPreview('#{url}');")
return o
end
21 changes: 0 additions & 21 deletions lib/wiki_extensions_issue_hooks.rb

This file was deleted.

0 comments on commit 0c47d08

Please sign in to comment.