diff --git a/.rubocop.yml b/.rubocop.yml index d685aa21..7a816d74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -118,6 +118,8 @@ Rails/SkipsModelValidations: - db/migrate/20140519133201_trash_bin.rb - db/migrate/07_dmsf_1_4_4.rb - db/migrate/20240829093801_rename_dmsf_digest_token.rb + - db/migrate/20251015130601_active_storage_migration.rb + - db/migrate/20251017101001_restore_updated_at.rb Rails/ThreeStateBooleanColumn: Exclude: @@ -130,6 +132,10 @@ Rails/UniqueValidationWithoutIndex: - app/models/dmsf_file.rb - app/models/dmsf_workflow_step.rb # Impossible due to steps sorting +Style/ClassVars: + Exclude: + - lib/redmine_dmsf.rb # @@xapian_available + Style/ExpandPathArguments: Enabled: false diff --git a/README.md b/README.md index df8e37dc..94a389af 100644 --- a/README.md +++ b/README.md @@ -224,26 +224,28 @@ instance is stopped. bundle config set --local without 'xapian' bundle install -5. Initialize/Update database: +5. Install Active Storage => [Active Storage](#active-storage) +6. Enable WebDAV => [WebDAV](#webdav) +7. Initialize/Update database `RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME=redmine_dmsf` -6. Install assets +8. Install assets `RAILS_ENV="production" bundle exec rake assets:precompile` -7. The access rights must be set for web server, e.g.: +9. The access rights must be set for web server, e.g.: `chown -R www-data:www-data plugins/redmine_dmsf` -8. Restart the web server, e.g.: +10. Restart the web server, e.g.: `systemctl restart apache2` -9. You should configure the plugin via Redmine interface: Administration -> Plugins -> DMSF -> Configure. (You should check and then save the plugin's configuration after each upgrade.) -10. Don't forget to grant permissions for DMSF in Administration -> Roles and permissions -11. Assign DMSF permissions to appropriate roles. -12. There are a few rake tasks: +11. You should configure the plugin via Redmine interface: Administration -> Plugins -> DMSF -> Configure. (You should check and then save the plugin's configuration after each upgrade.) +12. Don't forget to grant permissions for DMSF in Administration -> Roles and permissions +13. Assign DMSF permissions to appropriate roles. +14. There are a few handy rake tasks: I) To convert documents from the standard Redmine document module @@ -318,7 +320,6 @@ config.active_storage.service = :local # Store files locally #config.active_storage.service = :amazon # Store files on Amazon S3 config.active_storage.analyzers.append RedmineDmsf::XapianAnalyzer # Index uploaded files for Xapian full-text search ``` - Then install Active Storage with the following commands: ```shell diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 25e7f793..f26da173 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -397,7 +397,7 @@ class DmsfFile < ApplicationRecord results = scope.where(find_options).uniq.to_a results.delete_if { |x| !DmsfFolder.permissions?(x.dmsf_folder) } - if !options[:titles_only] && RedmineDmsf::Plugin.lib_available?('xapian') + if !options[:titles_only] && RedmineDmsf.xapian_available database = nil begin lang = RedmineDmsf.dmsf_stemming_lang diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index bb0dc8b9..c1f95bfe 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -417,7 +417,7 @@ class DmsfFileRevision < ApplicationRecord if derived_revisions.empty? # Remove the file from Xapian index - RemoveFromIndexJob.schedule file.blob.key if RedmineDmsf::Plugin.lib_available?('xapian') + RemoveFromIndexJob.schedule file.blob.key if RedmineDmsf.xapian_available # Remove the file shared_file.purge_later if RedmineDmsf.physical_file_delete? else diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index 47968b35..33943592 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -328,7 +328,7 @@ <%= l(:label_full_text) %> -<% if RedmineDmsf::Plugin.lib_available?('xapian') %> +<% if RedmineDmsf.xapian_available %>

<%= content_tag :label, l(:label_index_database) %> <%= text_field_tag 'settings[dmsf_index_database]', RedmineDmsf.dmsf_index_database, size: 50 %> @@ -373,6 +373,14 @@ <%= l(:label_default)%>: <%= l(:general_text_No) %>

+

+ <%= content_tag :label, l(:label_maximum_xapian_filesize) %> + <%= text_field_tag 'settings[dmsf_max_xapian_filesize]', RedmineDmsf.dmsf_max_xapian_filesize, size: 10 %> + + <%= l(:note_maximum_xapian_filesize) %>
+ <%= l(:label_default) %>: 3 +
+

<% else %>

<%= l(:warning_xapian_not_available) %>

<% end %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 783e3410..16210446 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -70,7 +70,7 @@ cs: link_modified: Změněno link_ver: Ver. link_author: Autor - title_check_for_zip_download_or_email: Vybrat pro stažení jako zip nebo emailem + title_check_for_zip_download_or_email: Vybrat pro stažení jako zip nebo e-mailem title_check_for_restore_or_delete: Vybrat pro obnovení nebo smazání title_notifications_active_deactivate: "Notifikace aktivní: Deaktivovat" @@ -82,9 +82,9 @@ cs: title_unlock_file: Odemknout a umožnit změny ostatním uživatelům title_lock_file: Zamknout a zabránit změnám ostatních uživatelů title_download_checked: Stáhnout vybrané jako Zip - title_send_checked_by_email: Zaslat vybrané emailem + title_send_checked_by_email: Zaslat vybrané e-mailem link_user_preferences: Vaše nastavení - heading_send_documents_by_email: Odeslat dokumenty emailem + heading_send_documents_by_email: Odeslat dokumenty e-mailem label_email_from: Od label_email_to: Komu label_email_cc: Kopie @@ -125,7 +125,7 @@ cs: option_version_custom: Vlastní label_new_content: Nový obsah label_maximum_files_download: Maximální počet najednou stažených souborů - note_maximum_number_of_files_downloaded: Maximální počet najednou stažených souborů jako Zip nebo odeslaných emailem. + note_maximum_number_of_files_downloaded: Maximální počet najednou stažených souborů jako Zip nebo odeslaných e-mailem. 0 znamená bez omezení. label_file_storage_directory: Složka pro uložení souborů label_index_database: Index databáze @@ -144,8 +144,8 @@ cs: label_default_notifications: Výchozí notifikace pro soubory heading_uploaded_files: Nahrané soubory link_documents: Dokumenty - permission_view_dmsf_file_revision_accesses: View downloads in Activity stream - permission_view_dmsf_file_revisions: View revisions in Activity stream + permission_view_dmsf_file_revision_accesses: Zobrazit stažení v aktivitách + permission_view_dmsf_file_revisions: Zobrazit revize v aktivitách permission_view_dmsf_folders: Procházet dokumenty permission_user_preferences: Nastavení uživatele permission_view_dmsf_files: Zobrazit dokumenty @@ -155,8 +155,8 @@ cs: permission_manage_workflows: Spravovat schvalovací procesy permission_file_delete: Mazat dokumenty permission_display_system_folders: Zobrazit systémové složky - permission_file_approval: File approval - permission_email_documents: Email documents + permission_file_approval: Schvalovat dokumenty + permission_email_documents: Posílat dokumenty e-mailem label_file: Soubor field_folder: Složka error_file_commit_require_uploaded_file: Potvrzení vyžaduje nahraný soubor @@ -182,7 +182,7 @@ cs: menu_dmsf: DMS # Project tab title label_physical_file_delete: Fyzické smazání souboru user_is_not_project_member: Nejste členem projektu - heading_access_downloads_emails: Stažené/Emaily + heading_access_downloads_emails: Stažené/E-maily heading_access_first: První heading_access_last: Poslední label_dmsf_updated: Změněno @@ -199,11 +199,11 @@ cs: error_target_folder_same: Cílový složka a projekt jsou stejné jako aktuální title_copy: Kopírovat - error_max_email_filesize_exceeded: "Přesáhli jste maximální velikost souboru, který lze poslat emailem. + error_max_email_filesize_exceeded: "Přesáhli jste maximální velikost souboru, který lze poslat e-mailem. (%{number} MB)" - note_maximum_email_filesize: Omezí se maximální velikost souboru, který může být poslán emailem. 0 znamená neomezený. + note_maximum_email_filesize: Omezí se maximální velikost souboru, který může být poslán e-mailem. 0 znamená neomezený. Číslo je v MB. - label_maximum_email_filesize: Maximální velikost souboru emailu + label_maximum_email_filesize: Maximální velikost souboru e-mailu header_minimum_filesize: Chyba souboru. error_minimum_filesize: "Soubor %{file} má nulovou velikost a nebude přiložen." parent_directory: Nadřazená složka @@ -317,9 +317,9 @@ cs: label_links_only: pouze odkazy label_display_notified_recipients: Zobrazit příjemce notifikací - note_display_notified_recipients: Uživatel bude informován o příjemcích právě odeslané emailové notifikace. + note_display_notified_recipients: Uživatel bude informován o příjemcích právě odeslané e-mailové notifikace. - warning_email_notifications: "Notifikační email poslán na uživatele %{to}" + warning_email_notifications: "Notifikační e-mail poslán na uživatele %{to}" link_trash_bin: Koš title_restore: Obnovit @@ -384,8 +384,7 @@ cs: label_enable_cjk_ngrams: Povolit generování n-gramů pro CJK texty text_enable_cjk_ngrams: "Pokud je povoleno, sekvence čínských nebo japonských znaků jsou rozděleny do jednotlivých znaků nebo skupin znaků. Znaky si nesou informaci o své pozici. Znaky psané latinkou jsou rozděleny normálně do - slov. Odpovídající proměná prostředí musí být použita při indexaci. - např.: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + slov." label_dmsf_fast_links: Rychlé odkazy text_dmsf_fast_links_info: Při vytváření odkazů budete moci zadat přímo ID cílové složky za účelem zrychlení @@ -493,6 +492,10 @@ cs: warning_folder_unlockable: Složku nelze odemknout redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximální velikost souboru pro indexaci + note_maximum_xapian_filesize: Omezuje maximální velikost souboru pro indexaci. Větší soubory nebudou indexovány. + Velikost je v MB. + activerecord: errors: messages: diff --git a/config/locales/de.yml b/config/locales/de.yml index 90c13c14..3186396d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -378,9 +378,7 @@ de: label_enable_cjk_ngrams: Aktiviere die Erstellung von n-grams aus Koreanischen Texten text_enable_cjk_ngrams: "Mit dieser Aktivierung werden Koreanische Zeichenfolgen in Monograms and Bigrams zerlegt. - Monograms enthalten Informationen zur Position. Nicht-Koreanische Zeichenfolgen werden in Wörter zerlegt. Die entsprechende - Option muss beim Indexieren verwendet werden, - z.B. XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + Monograms enthalten Informationen zur Position. Nicht-Koreanische Zeichenfolgen werden in Wörter zerlegt." label_dmsf_fast_links: Schnelle Verknüpfung text_dmsf_fast_links_info: Ermöglicht durch Eingabe der Ordner-ID auf einfache Art und Weise eine Verknüpfung @@ -489,6 +487,10 @@ de: warning_folder_unlockable: Der Ordner kann nicht entsperrt werden redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximale Dateigröße für den Index + note_maximum_xapian_filesize: Begrenzt die maximale Dateigröße für die Indizierung. Größere Dateien werden nicht + indiziert. Angabe in MB. + activerecord: errors: messages: diff --git a/config/locales/en.yml b/config/locales/en.yml index b8032cab..a4f66258 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -382,9 +382,7 @@ en: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ en: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/es.yml b/config/locales/es.yml index 850d6109..2317ae9c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -382,9 +382,7 @@ es: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ es: label_dmsf_commit: Commit label_dmsf_upload_commit: Upload and commit + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 9298d77b..34e666ce 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -471,6 +471,9 @@ fa: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d0a46667..9e26cc91 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -382,9 +382,7 @@ fr: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal" label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ fr: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 29a3edda..8f19937b 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -381,9 +381,7 @@ hu: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -491,6 +489,9 @@ hu: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/it.yml b/config/locales/it.yml index 43cc1f6c..83992e7d 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -382,9 +382,7 @@ it: # Italian strings thx 2 Matteo Arceci! label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ it: # Italian strings thx 2 Matteo Arceci! warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 79a2ff00..66b11453 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -382,9 +382,7 @@ ja: label_enable_cjk_ngrams: CJKテキストから n-grams の生成を有効にする text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: 高速リンク text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -493,6 +491,9 @@ ja: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 941a64b9..83dfb2bd 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -381,10 +381,8 @@ ko: label_email_reply_to: 회신 label_enable_cjk_ngrams: CJK 텍스트로부터 n-gram 생성을 활성화 - text_enable_cjk_ngrams: "이 기능을 사용하면 CJK 문자 범위가 유니그램과 바이그램으로 분할되고, 유니그램은 위치 정보를 전달합니다. CJK 범위 외의 문자는 일반적인 단어로 분할됩니다. 해당 옵션은 색인 시점에 사용됩니다. 예: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" - - - + text_enable_cjk_ngrams: "이 기능을 사용하면 CJK 문자 범위가 유니그램과 바이그램으로 분할되고, 유니그램은 위치 정보를 전달합니다. + CJK 범위 외의 문자는 일반적인 단어로 분할됩니다." label_dmsf_fast_links: 빠른 링크 text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ ko: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index b9dd3eb7..9ed9a34a 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -492,6 +492,9 @@ nl: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index b8dd78cf..42582c59 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -382,9 +382,7 @@ pl: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ pl: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index f6dcb30c..dd75c706 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -382,9 +382,7 @@ pt-BR: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ pt-BR: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/sl.yml b/config/locales/sl.yml index f4b76e58..ad2b6933 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -382,9 +382,7 @@ sl: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ sl: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/uk.yml b/config/locales/uk.yml index dec75710..1ef670b9 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -383,10 +383,7 @@ uk: label_enable_cjk_ngrams: Дозводити генерацію n-грам з тексту CJK text_enable_cjk_ngrams: "Якщо ввімкнено цю функцію, діапазони символів CJK розбиваються на уніграми і біграми, при - цьому уніграми містять позиційну інформацію. Символи, відмінні від CJK, розбиваються на слова як зазвичай. - Відповідна опція повинна бути використана під час індексування - Приклад: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" - + цьому уніграми містять позиційну інформацію. Символи, відмінні від CJK, розбиваються на слова як зазвичай." label_dmsf_fast_links: Швидкі посилання text_dmsf_fast_links_info: Ви зможете вручну ввести ідентифікатор кінцевої папки під час створення посилань або переміщення файлів чи папок, щоб пришвидшити процес створення посилань. @@ -494,6 +491,9 @@ uk: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 6ec983a7..3048c0e9 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -381,9 +381,8 @@ zh-TW: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." + label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -491,6 +490,9 @@ zh-TW: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 82f65f53..746a1fe4 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -382,9 +382,7 @@ zh: label_enable_cjk_ngrams: Enable generation of n-grams from CJK text text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the - unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding - option needs to have been used at index time. - e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" + unigrams carrying positional information. Non-CJK characters are split into words as normal." label_dmsf_fast_links: Fast links text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files @@ -492,6 +490,9 @@ zh: warning_folder_unlockable: The folder can't be unlocked redmine_dmsf: Redmine DMSF + label_maximum_xapian_filesize: Maximum Xapian file size + note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB. + activerecord: errors: messages: diff --git a/db/migrate/20251015130601_active_storage_migration.rb b/db/migrate/20251015130601_active_storage_migration.rb index 277fdc30..5adc060d 100644 --- a/db/migrate/20251015130601_active_storage_migration.rb +++ b/db/migrate/20251015130601_active_storage_migration.rb @@ -24,8 +24,8 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0] $stdout.puts 'It could be a very long process. Be patient...' # We need to keep updated_at column unchanged and due to the asynchronous file analysis there is probably no better # way how to achieve that. - add_column :dmsf_file_revisions, :temp_updated_at, :datetime, default: nil, - null: true, if_not_exists: true + add_column :dmsf_file_revisions, :temp_updated_at, :datetime, + default: nil, null: true, if_not_exists: true DmsfFileRevision.update_all 'temp_updated_at = updated_at' # Remove the Xapian database as it will be rebuilt from scratch during the migration if xapian_database_removed? @@ -93,7 +93,7 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0] # Delete Xapian database def xapian_database_removed? - if RedmineDmsf::Plugin.lib_available?('xapian') + if RedmineDmsf::Plugin.xapian_available FileUtils.rm_rf File.join(RedmineDmsf.dmsf_index_database, RedmineDmsf.dmsf_stemming_lang) true else diff --git a/init.rb b/init.rb index abed9a52..c47c91b4 100644 --- a/init.rb +++ b/init.rb @@ -62,7 +62,8 @@ Redmine::Plugin.register :redmine_dmsf do 'empty_minor_version_by_default' => '0', 'remove_original_documents_module' => '0', 'dmsf_webdav_authentication' => 'Digest', - 'dmsf_really_delete_files' => '0' + 'dmsf_really_delete_files' => '0', + 'dmsf_max_xapian_filesize' => 3 } end diff --git a/lib/redmine_dmsf.rb b/lib/redmine_dmsf.rb index 07e91390..597f241f 100644 --- a/lib/redmine_dmsf.rb +++ b/lib/redmine_dmsf.rb @@ -19,6 +19,18 @@ # Main module module RedmineDmsf + # Return true if the given gem is installed + def self.lib_available?(path) + require path + true + rescue LoadError => e + Rails.logger.debug e.message + false + end + + mattr_accessor :xapian_available, instance_writer: false + @@xapian_available = RedmineDmsf.lib_available?('xapian') + # Settings class << self def dmsf_max_file_download @@ -211,6 +223,14 @@ module RedmineDmsf value = Setting.plugin_redmine_dmsf['dmsf_default_notifications'] value.to_i.positive? || value == 'true' end + + def dmsf_max_xapian_filesize + if Setting.plugin_redmine_dmsf['dmsf_max_xapian_filesize'].present? + Setting.plugin_redmine_dmsf['dmsf_max_xapian_filesize'].to_i + else + 3 + end + end end end diff --git a/lib/redmine_dmsf/patches/puma_patch.rb b/lib/redmine_dmsf/patches/puma_patch.rb index 46966d56..532d809f 100644 --- a/lib/redmine_dmsf/patches/puma_patch.rb +++ b/lib/redmine_dmsf/patches/puma_patch.rb @@ -39,4 +39,4 @@ module RedmineDmsf end # Apply the patch -Puma::Const.include RedmineDmsf::Patches::PumaPatch if RedmineDmsf::Plugin.lib_available?('puma/const') +Puma::Const.include RedmineDmsf::Patches::PumaPatch if RedmineDmsf.lib_available?('puma/const') diff --git a/lib/redmine_dmsf/plugin.rb b/lib/redmine_dmsf/plugin.rb index ffe5f2d9..15622b52 100644 --- a/lib/redmine_dmsf/plugin.rb +++ b/lib/redmine_dmsf/plugin.rb @@ -36,14 +36,5 @@ module RedmineDmsf end false end - - # Return true if the given gem is installed - def self.lib_available?(path) - require path - true - rescue LoadError => e - Rails.logger.debug e.message - false - end end end diff --git a/lib/redmine_dmsf/xapian_analyzer.rb b/lib/redmine_dmsf/xapian_analyzer.rb index 04dea1bd..a5d874e6 100644 --- a/lib/redmine_dmsf/xapian_analyzer.rb +++ b/lib/redmine_dmsf/xapian_analyzer.rb @@ -21,7 +21,8 @@ module RedmineDmsf # ActiveRecord Analyzer for Xapian class XapianAnalyzer < ActiveStorage::Analyzer def self.accept?(blob) - return false unless RedmineDmsf::Plugin.lib_available?('xapian') && blob.byte_size < 1_024 * 1_024 * 3 # 3MB + return false unless RedmineDmsf.xapian_available && + blob.byte_size < 1_024 * 1_024 * RedmineDmsf.dmsf_max_xapian_filesize # MB @blob = blob true @@ -38,10 +39,11 @@ module RedmineDmsf db_path = File.join RedmineDmsf.dmsf_index_database, stem_lang url = File.join(@blob.key[0..1], @blob.key[2..3]) dir = File.join(Dir.tmpdir, @blob.key) + env = 'XAPIAN_CJK_NGRAM=true ' if RedmineDmsf.dmsf_enable_cjk_ngrams? FileUtils.mkdir dir @blob.open do |file| FileUtils.mv file.path, File.join(dir, @blob.key) - system "omindex -s \"#{stem_lang}\" -D \"#{db_path}\" --url=/#{url} \"#{dir}\" -p", exception: true + system "#{env}omindex -s \"#{stem_lang}\" -D \"#{db_path}\" --url=/#{url} \"#{dir}\" -p", exception: true end true rescue StandardError => e diff --git a/test/unit/lib/redmine_dmsf/dmsf_plugin_test.rb b/test/unit/lib/redmine_dmsf/dmsf_plugin_test.rb index 55ce667f..2fcce477 100644 --- a/test/unit/lib/redmine_dmsf/dmsf_plugin_test.rb +++ b/test/unit/lib/redmine_dmsf/dmsf_plugin_test.rb @@ -43,8 +43,9 @@ class DmsfPluginTest < RedmineDmsf::Test::HelperTest FileUtils.rm_rf path end + # TODO: move it elswhere def test_lib_available? - assert RedmineDmsf::Plugin.lib_available?('zip') - assert_not RedmineDmsf::Plugin.lib_available?('not_existing_gem') + assert RedmineDmsf.lib_available?('zip') + assert_not RedmineDmsf.lib_available?('not_existing_gem') end end