diff --git a/app/controllers/dmsf_help_controller.rb b/app/controllers/dmsf_help_controller.rb new file mode 100644 index 00000000..22a5167e --- /dev/null +++ b/app/controllers/dmsf_help_controller.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +# Redmine plugin for Document Management System "Features" +# +# Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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. + +class DmsfHelpController < ApplicationController + def show_wiki_syntax + lang = current_language.to_s + template = "dmsf_help/#{lang}/wiki_syntax" + lang = 'en' unless lookup_context.exists?(template) + render template: "dmsf_help/#{lang}/wiki_syntax", layout: nil + end + + def show_dmsf_help + lang = current_language.to_s + template = "dmsf_help/#{lang}/dmsf_help" + lang = 'en' unless lookup_context.exists?(template) + render template: "dmsf_help/#{lang}/dmsf_help", layout: nil + end +end diff --git a/app/views/dmsf_context_menus/_main.html.erb b/app/views/dmsf_context_menus/_main.html.erb index 888d5cb2..6c149f04 100644 --- a/app/views/dmsf_context_menus/_main.html.erb +++ b/app/views/dmsf_context_menus/_main.html.erb @@ -83,9 +83,5 @@ <%= sprite_icon('del', l(:link_trash_bin)) %> <% end %> -<% lang = current_language.to_s.downcase %> -<% path = File.join(File.dirname(__FILE__), '..', '..', '..', 'assets', 'help', lang, 'dmsf_help.html') %> -<% lang = 'en' unless File.exist?(path) %> -<% url = "/plugin_assets/redmine_dmsf/help/#{lang}/dmsf_help.html" %> -<%= link_to sprite_icon('help', l(:label_help)), 'dmsf_help.html', class: 'icon icon-help', - onclick: "window.open('#{url}','_blank', 'width=640,height=960'); return false;" %> +<%= link_to sprite_icon('help', l(:label_help)), dmsf_help_path, class: 'icon icon-help', + onclick: "window.open('#{dmsf_help_url}','_blank', 'width=640,height=960'); return false;" %> diff --git a/assets/help/cs/wiki_syntax.html b/app/views/dmsf_help/cs/wiki_syntax.html similarity index 97% rename from assets/help/cs/wiki_syntax.html rename to app/views/dmsf_help/cs/wiki_syntax.html index f19bc0c7..f7703722 100644 --- a/assets/help/cs/wiki_syntax.html +++ b/app/views/dmsf_help/cs/wiki_syntax.html @@ -7,7 +7,7 @@ -

DMS Syntax Reference

+

Referenční dokumentace syntaxe DMS

DMS přidává následující makra:

diff --git a/assets/help/de/wiki_syntax.html b/app/views/dmsf_help/de/wiki_syntax.html similarity index 100% rename from assets/help/de/wiki_syntax.html rename to app/views/dmsf_help/de/wiki_syntax.html diff --git a/assets/help/en/dmsf_help.html b/app/views/dmsf_help/en/dmsf_help.html.erb similarity index 99% rename from assets/help/en/dmsf_help.html rename to app/views/dmsf_help/en/dmsf_help.html.erb index e5265fba..03b0daac 100644 --- a/assets/help/en/dmsf_help.html +++ b/app/views/dmsf_help/en/dmsf_help.html.erb @@ -3,8 +3,8 @@ Wiki formatting - - + <%= stylesheet_link_tag 'wiki_syntax.css' %> + <%= stylesheet_link_tag 'dmsf_help.css', plugin: :redmine_dmsf %> diff --git a/assets/help/en/wiki_syntax.html b/app/views/dmsf_help/en/wiki_syntax.html.erb similarity index 95% rename from assets/help/en/wiki_syntax.html rename to app/views/dmsf_help/en/wiki_syntax.html.erb index 8e1e7c35..bed35d70 100644 --- a/assets/help/en/wiki_syntax.html +++ b/app/views/dmsf_help/en/wiki_syntax.html.erb @@ -3,7 +3,7 @@ Wiki formatting - + <%= stylesheet_link_tag 'wiki_syntax.css' %> diff --git a/assets/javascripts/dmsf_button.js b/assets/javascripts/dmsf_button.js index 57a3215f..cbc70c5c 100644 --- a/assets/javascripts/dmsf_button.js +++ b/assets/javascripts/dmsf_button.js @@ -57,8 +57,7 @@ jsToolBar.prototype.dmsfMenu = function(fn){ let help = a[1]; let macroItem = $('
').text(help); $('
  • ').html(macroItem).appendTo(menu).mousedown(function () { - window.open('/plugin_assets/redmine_dmsf/help/' + lang + '/wiki_syntax.html', - '_blank', 'width=480,height=480'); + window.open('/dmsf/help/wiki_syntax','_blank', 'width=480,height=480'); }); } } diff --git a/config/routes.rb b/config/routes.rb index 265ea886..fa60f7fc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -177,5 +177,9 @@ if Redmine::Plugin.installed? 'redmine_dmsf' match '/dmsf', to: ->(env) { [405, {}, ["#{env['REQUEST_METHOD']} method is not allowed"]] }, via: %i[propfind options] + + # Help + get '/dmsf/help/wiki_syntax', controller: 'dmsf_help', action: 'show_wiki_syntax', as: 'dmsf_wiki_syntax' + get '/dmsf/help/dmsf_help', controller: 'dmsf_help', action: 'show_dmsf_help', as: 'dmsf_help' end end diff --git a/test/functional/dmsf_help_controller_test.rb b/test/functional/dmsf_help_controller_test.rb new file mode 100644 index 00000000..caf6e2d3 --- /dev/null +++ b/test/functional/dmsf_help_controller_test.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Redmine plugin for Document Management System "Features" +# +# Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 File.expand_path('../../test_helper', __FILE__) + +class HelpControllerTest < RedmineDmsf::Test::TestCase + fixtures :dmsf_folders, :dmsf_files, :dmsf_file_revisions + + def test_wiki_syntax + post '/login', params: { username: 'jsmith', password: 'jsmith' } + get '/dmsf/help/wiki_syntax' + assert_response :success + assert_select 'h1', text: 'DMS Syntax Reference' + end + + def test_wiki_syntax_cs + @jsmith.language = 'cs' + assert @jsmith.save + post '/login', params: { username: 'jsmith', password: 'jsmith' } + get '/dmsf/help/wiki_syntax' + assert_response :success + assert_select 'h1', text: 'Referenční dokumentace syntaxe DMS' + end + + def test_dmsf_help + post '/login', params: { username: 'jsmith', password: 'jsmith' } + get '/dmsf/help/dmsf_help' + assert_response :success + assert_select 'h1', text: "DMSF User's guide" + end +end