Easy Document link macro creation #239

This commit is contained in:
Karel Pičman 2023-01-11 14:20:44 +01:00
parent e2408e1344
commit 9b1f61fc9e
12 changed files with 316 additions and 4906 deletions

106
README.md
View File

@ -30,7 +30,7 @@ Features
* Configurable document approval workflow
* Document access auditing
* Integration with Redmine's activity feed
* Wiki macros for quick content linking
* Wiki macros for a quick content linking
* Full read/write WebDAV functionality
* Optional document content full-text search
* Documents and folders' symbolic links
@ -152,109 +152,11 @@ DMSF is designed to act as project module, so it must be checked as an enabled m
Search will now automatically search DMSF content when a Redmine search is performed, additionally a "Documents" and "Folders" check box will be visible, allowing you to search DMSF content exclusively.
Linking DMSF files from Wiki entries (macros)
Linking DMSF object from Wiki entries (macros)
---------------------------------------------
Link to a document with id 17: `{{dmsf(17)}}`
Link to a document with id 17 with link text "File": `{{dmsf(17, File)}}`
Link to the details of a document with id 17: `{{dmsfd(17)}}`
Link to the details of a document with id 17 with link text "Details": `{{dmsfd(17, Details)}}`
Text of the description of a document with id 17: `{{dmsfdesc(17)}}`
Text referring to the version of a document with id 17: `{{dmsfversion(17)}}`
Text referring to the last update date of a document with id 17: `{{dmsflastupdate(17)}}`
Link to the preview of 5 lines from a document with id 17: `{{dmsft(17, 5)}}`
Inline picture of the file with id 8; it must be an image file such as JPEG, PNG,...: `{{dmsf_image(8)}}`
Multiple inline pictures: `{{dmsf_image(8 9 10)}}`
Inline picture with custom size: `{{dmsf_image(8, size=300)}}`
Inline picture with custom size: `{{dmsf_image(8, size=50%)}}`
Inline picture with custom height: `{{dmsf_image(8, height=300)}}`
Inline picture with custom width: `{{dmsf_image(8, width=300)}}`
Inline picture with custom size: `{{dmsf_image(8, size=640x480)}}`
Thumbnail with height of 200px: `{{dmsftn(8)}}`
Multiple thumbnails with height of 200px: `{{dmsftn(8 9 10)}}`
Thumbnail with custom size: `{{dmsftn(8, size=300)}}`
Inline video of the file with id 8; it must be a video file such as MP4: `{{dmsf_video(9)}}`
Inline video with custom size: `{{dmsf_video(9, size=300)}}`
Inline video with custom size: `{{dmsf_video(9, size=50%)}}`
Inline video with custom height: `{{dmsf_video(9, height=300)}}`
Inline video with custom width: `{{dmsf_video(9, width=300)}}`
Inline video with custom size: `{{dmsf_video(9, size=640x480)}}`
Approval workflow status of a document with id 8: `{{dmsfw(8)}}`
The DMSF document/revision id can be found in document details.
Linking DMSF folders from Wiki entries (macros)
-----------------------------------------------
Link to a folder with id 5: `{{dmsff(5)}}`
Link to a folder with id 5 with link text "Folder": `{{dmsff(5, Folder)}}`
The DMSF folder id can be found in the link when opening folders within Redmine.
You can also publish Wiki help description:
In the file <redmine_root>/public/help/<language>/wiki_syntax_detailed.html, after the document link description/definition:
<ul>
<li>
DMSF:
<ul>
<li><strong>{{dmsf(17)}}</strong> (a link to the file with id 17)</li>
<li><strong>{{dmsf(17, File)}}</strong> (a link to the file with id 17 with the link text "File")</li>
<li><strong>{{dmsf(17, File, 10)}}</strong> (a link to the file with id 17 with the link text "File" and the link pointing to the revision 10)</li>
<li><strong>{{dmsfd(17)}}</strong> (a link to the details of the file with id 17)</li>
<li><strong>{{dmsfdesc(17)}}</strong> (a link to the description of the file with id 17)</li>
<li><strong>{{dmsff(5)}}</strong> (a link to the folder with id 5)</li>
<li><strong>{{dmsff(5, Folder)}}</strong> (a link to the folder with id 5 with the link text "Folder")</li>
<li><strong>{{dmsf_image(8)}}</strong> (an inline picture of the file with id 8; it must be an image file such as JPEG, PNG,...)</li>
<li><strong>{{dmsf_image(8, size=300)}}</strong> (an inline picture with custom size)</li>
<li><strong>{{dmsf_image(8, size=640x480)}}</strong> (an inline picture with custom size)</li>
<li><strong>{{dmsf_image(8, size=50%)}}</strong> (an inline picture with custom size)</li>
<li><strong>{{dmsf_image(8, height=300)}}</strong> (an inline picture with custom size)</li>
<li><strong>{{dmsf_image(8, width=300)}}</strong> (an inline picture with custom size)</li>
<li><strong>{{dmsftn(8)}}</strong> (a thumbnail with height of 200px)</li>
<li><strong>{{dmsftn(8, size=300)}}</strong> (a thumbnail with custom size)</li>
<li><strong>{{dmsfw(8)}}</strong> (approval workflow status of a document with id 8)</li>
</ul>
The DMSF file/revision id can be found in the link for file/revision download from within Redmine.<br />
The DMSF folder id can be found in the link when opening folders within Redmine.
</li>
</ul>
In the file <redmine_root>/public/help/<language>/wiki_syntax.html, at the end of the Redmine links section:
<tr><th></th><td>{{dmsf(83)}}</td><td>Document <a href="#">#83</a></td></tr>
There's a patch (tested with Redmine 3.4.2) that helps you to modify all help files at once. In your Redmine folder:
`cd redmine`
`patch -p0 < plugins/redmine_dmsf/extra/help_files_dmsf.diff`
You can link DMSF object from Wikis using a macro tag `{{ }}`. List of available macros with their description is
available from the wiki's toolbar.
Hooks
-----

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="cs">
<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">
</head>
<body>
<h1>DMS Syntax Reference</h1>
<p>DMS přidává následující makra:</p>
<dl>
<dt><b>Dokumenty</b></dt>
<dd>
<p><code>{{dmsf(17)}}</code> - odkaz na dokument #17</p>
<p><code>{{dmsf(17, File)}}</code> - odkaz na dokument #17 s textem "File"</p>
<p><code>{{dmsf(17, File, 10)}}</code> - odkaz na dokument #17 r10 s textem "File"</p>
<p><code>{{dmsfd(17)}}</code> - odkaz na detaily dokument #17</p>
<p><code>{{dmsfdesc(17)}}</code> - odkaz na popis dokumentu #17</p>
</dd>
<dt><b>Složky</b></dt>
<dd>
<p><code>{{dmsff(5)}}</code> - odkaz na složku #5</p>
<p><code>{{dmsff(5, Folder)}}</code> - odkaz na složku #5 s textem "Folder"</p>
</dd>
<dt><b>Obrázky</b></dt>
<dd>
<p><code>{{dmsf_image(8)}}</code> - vložený obrázek dokumentu #8 (dokument musí být obrázek typu JPEG, PNG,...)</p>
<p><code>{{dmsf_image(8, size=300)}}</code></p>
<p><code>{{dmsf_image(8, size=640x480)}}</code></p>
<p><code>{{dmsf_image(8, size=50%)}}</code></p>
<p><code>{{dmsf_image(8, height=300)}}</code></p>
<p><code>{{dmsf_image(8, width=300)}}</code> - obrázek dokumentu #8 s nastavenou velikostí</p>
<p><code>{{dmsftn(8)}}</code> - náhled obrázku dokumentu #8</p>
<p><code>{{dmsftn(8, size=300)}}</code> - náhled obrázku dokumentu #8 s nastavenou velikostí</p>
</dd>
<dt><b>Schvalovací procesy</b></dt>
<dd>
<p><code>{{dmsfw(8)}}</code> - schvalovací proces dokumentu #8</p>
</dd>
</dl>
<em>ID dokumentu nebo složky naleznete v jejích detailech.</em>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="de">
<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">
</head>
<body>
<h1>DMS Syntax Reference</h1>
<p>DMS fügt die folgenden integrierten Makros hinzu:</p>
<dl>
<dt><b>Documente</b></dt>
<dd>
<p><code>{{dmsf(17)}}</code> - Link zum Dokument #17</p>
<p><code>{{dmsf(17, File)}}</code> - Link zum Dokument #17 mit dem Text "File"</p>
<p><code>{{dmsf(17, File, 10)}}</code> - Link zum Dokument #17 r10 mit dem Text "File"</p>
<p><code>{{dmsfd(17)}}</code> - Link zu den Dokumentdetails #17</p>
<p><code>{{dmsfdesc(17)}}</code> - Link zur Beschreibung des Dokuments #17</p>
</dd>
<dt><b>Ordner</b></dt>
<dd>
<p><code>{{dmsff(5)}}</code> - Link zum Ordner #5</p>
<p><code>{{dmsff(5, Folder)}}</code> - Link yum Ordner #5 mit dem Text "Folder"</p>
</dd>
<dt><b>Bilder</b></dt>
<dd>
<p><code>{{dmsf_image(8)}}</code> - Bild des Dokuments #8 (der Dokumnt must eine Bilddatei wie JPEG, PNG,... sein</p>
<p><code>{{dmsf_image(8, size=300)}}</code></p>
<p><code>{{dmsf_image(8, size=640x480)}}</code></p>
<p><code>{{dmsf_image(8, size=50%)}}</code></p>
<p><code>{{dmsf_image(8, height=300)}}</code></p>
<p><code>{{dmsf_image(8, width=300)}}</code> - Bild des Dokuments #8 mit Benutzerdefinierte Größe</p>
<p><code>{{dmsftn(8)}}</code> - Miniaturansicht des Documents #8</p>
<p><code>{{dmsftn(8, size=300)}}</code> - Miniaturansicht des Documents #8 mit Benutzerdefinierte Größe</p>
</dd>
<dt><b>Genehmigungs-Workflows</b></dt>
<dd>
<p><code>{{dmsfw(8)}}</code> - Workflowstatus des Dokuments #8</p>
</dd>
</dl>
<em>ID des Dokuments/Ordners man kann in sein Details finden.</em>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<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">
</head>
<body>
<h1>DMS Syntax Reference</h1>
<p>DMS adds the following builtin macros:</p>
<dl>
<dt><b>Documents</b></dt>
<dd>
<p><code>{{dmsf(17)}}</code> - link to document #17</p>
<p><code>{{dmsf(17, File)}}</code> - link to document #17 with the text "File"</p>
<p><code>{{dmsf(17, File, 10)}}</code> - link to document #17 r10 with the text "File"</p>
<p><code>{{dmsfd(17)}}</code> - link to the details of document #17</p>
<p><code>{{dmsfdesc(17)}}</code> - link to the description of document #17</p>
</dd>
<dt><b>Folders</b></dt>
<dd>
<p><code>{{dmsff(5)}}</code> - link to folder #5</p>
<p><code>{{dmsff(5, Folder)}}</code> - link to folder #5 with the text "Folder"</p>
</dd>
<dt><b>Images</b></dt>
<dd>
<p><code>{{dmsf_image(8)}}</code> - inline picture of document #8; the document must be an image file such as JPEG, PNG,...</p>
<p><code>{{dmsf_image(8, size=300)}}</code></p>
<p><code>{{dmsf_image(8, size=640x480)}}</code></p>
<p><code>{{dmsf_image(8, size=50%)}}</code></p>
<p><code>{{dmsf_image(8, height=300)}}</code></p>
<p><code>{{dmsf_image(8, width=300)}}</code> - inline picture of document 8 with a custom size</p>
<p><code>{{dmsftn(8)}}</code> - thumbnail of document #8</p>
<p><code>{{dmsftn(8, size=300)}}</code> - thumbnail of document #8 with a custom size</p>
</dd>
<dt><b>Approval Workflow</b></dt>
<dd>
<p><code>{{dmsfw(8)}}</code> - approval workflow status of document #8</p>
</dd>
</dl>
<em>The document/folder's ID can be found in it's details.</em>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,77 @@
/* encoding: utf-8
*
* Redmine plugin for Document Management System "Features"
*
* Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
*
* 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.
*/
/* Global jsToolBar */
/* Space */
jsToolBar.prototype.elements.dmsf_space = {
type: 'space'
}
/* DMSF button */
jsToolBar.prototype.elements.dmsf = {
type: 'button',
title: 'DMS',
fn: {
wiki: function() {
let This = this;
this.dmsfMenu(function(macro){
This.encloseLineSelection('{{' + macro + '(', ')}}');
});
}
}
};
/* DMSF button's popup menu */
jsToolBar.prototype.dmsfMenu = function(fn){
let menu = $('<ul style="position:absolute;"></ul>');
for (let i = 0; i < this.dmsfList.length; i++) {
let reg = new RegExp('^dmsf');
let item = this.dmsfList[i];
if(reg.test(item)) {
let macroItem = $('<div></div>').text(item);
$('<li></li>').html(macroItem).appendTo(menu).mousedown(function () {
fn($(this).text());
});
}
else {
$('<li></li>').html('<hr>').appendTo(menu);
const a = item.split(';');
let lang = a[0];
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');
});
}
}
$('body').append(menu);
menu.menu().width(150).position({
my: 'left top',
at: 'left bottom',
of: this.toolNodes['dmsf']
});
$(document).on('mousedown', function() {
menu.remove();
});
return false;
};

View File

@ -0,0 +1,23 @@
/* encoding: utf-8
*
* Redmine plugin for Document Management System "Features"
*
* Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
*
* 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.
*/
jsToolBar.strings = {};
jsToolBar.strings['DMS'] = 'DMS';

View File

@ -391,3 +391,8 @@ div.dmsf-scroll {
width: 90%;
max-width: 90%;
}
/* Wiki toolbar */
.jstb_dmsf {
background-image: url('../images/jstoolbar/bt_dmsf.png');
}

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@ require File.dirname(__FILE__) + '/../app/validators/dmsf_url_validator'
require File.dirname(__FILE__) + '/../app/validators/dmsf_folder_parent_validator'
# Plugin's patches
require File.dirname(__FILE__) + '/redmine_dmsf/patches/formatting_helper_patch'
require File.dirname(__FILE__) + '/redmine_dmsf/patches/projects_helper_patch'
require File.dirname(__FILE__) + '/redmine_dmsf/patches/project_patch'
require File.dirname(__FILE__) + '/redmine_dmsf/patches/user_preference_patch'

View File

@ -25,7 +25,7 @@ module RedmineDmsf
class BaseViewHooks < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return unless /^(Dmsf|Projects|Issues|Queries|EasyCrmCases|MyController|SettingsController)/.match?(
return unless /^(Dmsf|Projects|Issues|Queries|EasyCrmCases|MyController|SettingsController|WikiController)/.match?(
context[:controller].class.name)
meta = "\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', plugin: :redmine_dmsf) +
"\n".html_safe + stylesheet_link_tag('select2.min.css', plugin: :redmine_dmsf) +

View File

@ -0,0 +1,61 @@
# encoding: utf-8
# frozen_string_literal: true
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-23 Karel Pičman <karel.picman@kontron.com>
#
# 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.
module RedmineDmsf
module Patches
module FormattingHelperPatch
def heads_for_wiki_formatter
super
return if @dmsf_macro_list
@dmsf_macro_list = []
Redmine::WikiFormatting::Macros.available_macros.each do |key, value|
if key.to_s =~ /^dmsf/
@dmsf_macro_list << key.to_s
end
end
# If localized files for the current language are not available, switch to English
lang = current_language.to_s.downcase
path = File.join(File.dirname(__FILE__),
'..', '..', '..', 'assets', 'help', lang, 'wiki_syntax.html')
if File.exist?(path)
@dmsf_macro_list << "#{lang};#{l(:label_help)}"
else
@dmsf_macro_list << "en;#{l(:label_help)}"
end
path = File.join(File.dirname(__FILE__),
'..', '..', '..', 'assets', 'javascripts', 'lang', "dmsf_button-#{lang}.js")
unless File.exist?(path)
lang = 'en'
end
content_for :header_tags do
javascript_include_tag("lang/dmsf_button-#{lang}", plugin: 'redmine_dmsf') +
javascript_include_tag('dmsf_button', plugin: 'redmine_dmsf') +
javascript_tag("jsToolBar.prototype.dmsfList = #{@dmsf_macro_list.to_json};")
end
end
end
end
end
# Apply the patch
Redmine::WikiFormatting::Textile::Helper.prepend RedmineDmsf::Patches::FormattingHelperPatch