Skip to content

Commit

Permalink
#1563 help
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Nov 21, 2024
1 parent de02696 commit 347fed7
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 12 deletions.
35 changes: 35 additions & 0 deletions app/controllers/dmsf_help_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

# Redmine plugin for Document Management System "Features"
#
# Karel Pičman <[email protected]>
#
# 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
8 changes: 2 additions & 6 deletions app/views/dmsf_context_menus/_main.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,5 @@
<%= sprite_icon('del', l(:link_trash_bin)) %>
</span>
<% 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;" %>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>
<body>

<h1>DMS Syntax Reference</h1>
<h1>Referenční dokumentace syntaxe DMS</h1>

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

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wiki formatting</title>
<link rel="stylesheet" type="text/css" href="/help/wiki_syntax_detailed.css">
<link rel="stylesheet" type="text/css" href="../../stylesheets/dmsf_help.css">
<%= stylesheet_link_tag 'wiki_syntax.css' %>
<%= stylesheet_link_tag 'dmsf_help.css', plugin: :redmine_dmsf %>
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wiki formatting</title>
<link rel="stylesheet" type="text/css" href="../../../../help/wiki_syntax.css">
<%= stylesheet_link_tag 'wiki_syntax.css' %>
</head>
<body>

Expand Down
3 changes: 1 addition & 2 deletions assets/javascripts/dmsf_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ jsToolBar.prototype.dmsfMenu = function(fn){
let help = a[1];
let macroItem = $('<div></div>').text(help);
$('<li></li>').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');
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,9 @@
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
48 changes: 48 additions & 0 deletions test/functional/dmsf_help_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

# Redmine plugin for Document Management System "Features"
#
# Karel Pičman <[email protected]>
#
# 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

0 comments on commit 347fed7

Please sign in to comment.