Merge branch 'devel'

This commit is contained in:
Karel Pičman 2025-07-10 16:01:43 +02:00
commit b32f19900a
24 changed files with 80 additions and 68 deletions

View File

@ -1,6 +1,17 @@
Changelog for Redmine DMSF
==========================
4.2.1 *2025-07-10*
------------------
Searching in multiple revisions
IMPORTANT: Issue tracking numbering has been restarted after the movement to the new repository
* Bug: #1 - Can't install 3.2.4 on redmine 5.0
* Bug: #3 - Download CSV file leads to 404
* New: #4 - Searching in multiple revisions
4.2.0 *2025-07-04*
------------------
@ -92,15 +103,10 @@ NOTE: These issues are still from the original danmunn's repository
------------------
Multiple file upload fix
Uploaded file size fix
* Bug: #1559 - Multiple files upload
* Bug: #1558 - Deleting of uploaded files
3.2.3 *2024-10-18*
------------------
Uploaded file size fix
* Bug: 1556 - Wrong file size when uploading documents
3.2.2 *2024-10-09*

View File

@ -1,4 +1,4 @@
# Redmine DMSF Plugin 4.2.0
# Redmine DMSF Plugin 4.2.1
[![GitHub CI](https://github.com/picman/redmine_dmsf/actions/workflows/rubyonrails.yml/badge.svg?branch=master)](https://github.com/picman/redmine_dmsf/actions/workflows/rubyonrails.yml)
[![Support Ukraine Badge](https://bit.ly/support-ukraine-now)](https://github.com/support-ukraine/support-ukraine)

View File

@ -81,7 +81,7 @@ class DmsfFilesController < ApplicationController
send_file pdf_preview, filename: "#{basename}.pdf", type: 'application/pdf', disposition: 'inline'
# Text preview
elsif !api_request? && params[:download].blank? && (@file.size <= Setting.file_max_size_displayed.to_i.kilobyte) &&
(@file.text? || @file.markdown? || @file.textile?) && !@file.html?
(@file.text? || @file.markdown? || @file.textile?) && !@file.html? && formats.include?(:html)
@content = File.read(@revision.disk_file, mode: 'rb')
render action: 'document'
# Offer the file for download

View File

@ -51,22 +51,56 @@ class DmsfFile < ApplicationRecord
case_sensitive: true
}
acts_as_event title: proc { |o| o.name },
description: proc { |o|
desc = Redmine::Search.cache_store.fetch("DmsfFile-#{o.id}")
if desc
Redmine::Search.cache_store.delete("DmsfFile-#{o.id}")
else
# Set desc to an empty string if o.description is nil
desc = o.description.nil? ? +'' : +o.description
desc += ' / ' if o.description.present? && o.last_revision.comment.present?
desc += o.last_revision.comment if o.last_revision.comment.present?
acts_as_event(
title: proc { |o|
@searched_revision = nil
o.dmsf_file_revisions.visible.each do |r|
key = "DmsfFile-#{o.id}-#{r.id}"
@desc = Redmine::Search.cache_store.fetch(key)
next unless @desc
Redmine::Search.cache_store.delete key
@searched_revision = r
break
end
if @searched_revision && (@searched_revision != o.last_revision)
"#{o.name} (r#{@searched_revision.id})"
else
o.name
end
desc
},
url: proc { |o| { controller: 'dmsf_files', action: 'view', id: o } },
datetime: proc { |o| o.updated_at },
author: proc { |o| o.last_revision.user }
description: proc { |o|
unless @desc
# Set desc to an empty string if o.description is nil
@desc = o.description.nil? ? +'' : +o.description
@desc += ' / ' if o.description.present? && o.last_revision.comment.present?
@desc += o.last_revision.comment if o.last_revision.comment.present?
end
@desc
},
url: proc { |o|
if @searched_revision
{ controller: 'dmsf_files', action: 'view', id: o.id, download: @searched_revision.id,
filename: o.name }
else
{ controller: 'dmsf_files', action: 'view', id: o.id, filename: o.name }
end
},
datetime: proc { |o|
if @searched_revision
@searched_revision.updated_at
else
o.updated_at
end
},
author: proc { |o|
if @searched_revision
@searched_revision.user
else
o.last_revision.user
end
}
)
acts_as_watchable
acts_as_searchable(
columns: [
@ -415,20 +449,21 @@ class DmsfFile < ApplicationRecord
filename = dochash['url']
next unless filename
dmsf_attrs = filename.scan(%r{^([^/]+/[^_]+)_(\d+)_(.*)$})
dmsf_attrs = filename.scan(%r{^\d{4}/\d{2}/(\d{12}_(\d+)_.*)$})
id_attribute = 0
id_attribute = dmsf_attrs[0][1] if dmsf_attrs.length.positive?
next if dmsf_attrs.empty? || id_attribute.to_i.zero?
next unless results.none? { |f| f.id.to_s == id_attribute }
dmsf_file = DmsfFile.visible.where(limit_options).find_by(id: id_attribute)
next unless dmsf_file && DmsfFolder.permissions?(dmsf_file.dmsf_folder) &&
user.allowed_to?(:view_dmsf_files, dmsf_file.project) &&
(project_ids.blank? || project_ids.include?(dmsf_file.project_id))
rev_id = DmsfFileRevision.where(dmsf_file_id: dmsf_file.id, disk_filename: dmsf_attrs[0][0])
.pick(:id)
if dochash['sample']
Redmine::Search.cache_store.write("DmsfFile-#{dmsf_file.id}", dochash['sample'].force_encoding('UTF-8'))
Redmine::Search.cache_store.write("DmsfFile-#{dmsf_file.id}-#{rev_id}",
dochash['sample'].force_encoding('UTF-8'))
end
break if options[:limit].present? && results.count >= options[:limit]

View File

@ -324,12 +324,10 @@
</div>
<hr>
<p>
<em class="info">
<%= l(:text_fulltext_search, cmd1: 'libreoffice', cmd2: 'pdftotext') %>
<%= l(:label_full_text) %>
</em>
</p>
<% if RedmineDmsf::Plugin.lib_available?('xapian') %>
<p>
<%= content_tag :label, l(:label_index_database) %>

View File

@ -470,8 +470,6 @@ cs:
label_remove_original_documents_module: Odstranit původní modul Dokumenty
text_fulltext_search: 'Full-textové vyhledávání v dokumentech vyžaduje přítomnost %{cmd1} and %{cmd2} na serveru.'
notice_entries_copied: Kopírování se podařilo
notice_entries_moved: Přesun se podařil
label_dmsf_file_revision: DMS Dokument rev.

View File

@ -465,8 +465,6 @@ de:
label_remove_original_documents_module: Original Projektmodule Dokumente entfernen
text_fulltext_search: 'Full-text Suche in Dokumente fordert die Existenz %{cmd1} and %{cmd2} auf dem Server.'
notice_entries_copied: Kopieren ist gelungen
notice_entries_moved: Verschieben ist gelungen
label_dmsf_file_revision: DMS Dokument Rev.

View File

@ -469,8 +469,6 @@ en:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ es:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -448,8 +448,6 @@ fa:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ fr:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -468,8 +468,6 @@ hu:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ it: # Italian strings thx 2 Matteo Arceci!
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -470,8 +470,6 @@ ja:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ ko:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ nl:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ pl:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ pt-BR:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ sl:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -471,8 +471,6 @@ uk:
label_remove_original_documents_module: Видалити модуль оригінальних документів
text_fulltext_search: 'Повнотекстовий пошук вимагає наявності %{cmd1} та %{cmd2} команд на сервері.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -468,8 +468,6 @@ zh-TW:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -469,8 +469,6 @@ zh:
label_remove_original_documents_module: Remove the original Documents module
text_fulltext_search: 'Full-text search in documents requires presence of %{cmd1} and %{cmd2} commands on the server.'
notice_entries_copied: Copying has succeeded
notice_entries_moved: Moving has succeeded
label_dmsf_file_revision: DMS Document rev.

View File

@ -27,7 +27,7 @@ Redmine::Plugin.register :redmine_dmsf do
author_url 'https://github.com/picman/redmine_dmsf/graphs/contributors'
author 'Vít Jonáš / Daniel Munn / Karel Pičman'
description 'Document Management System Features'
version '4.2.0'
version '4.2.1'
requires_redmine version_or_higher: '6.0.0'

View File

@ -61,13 +61,20 @@ class DmsfFilesControllerTest < RedmineDmsf::Test::TestCase
assert_response :forbidden
end
def test_view_file_ok
def test_view_file_standard_url
# Permissions OK
post '/login', params: { username: 'jsmith', password: 'jsmith' }
get "/dmsf/files/#{@file1.id}/view", params: { id: @file1.id }
assert_response :success
end
def test_view_file_pretty_url
# Permissions OK
post '/login', params: { username: 'jsmith', password: 'jsmith' }
get "/dmsf/files/#{@file1.id}/test.txt", params: { id: @file1.id }
assert_response :success
end
def test_view_file_forbidden
# Missing permissions
post '/login', params: { username: 'jsmith', password: 'jsmith' }