From 734fd7c0fc7ca604adef1f09a26ca7f0cf0e9fba Mon Sep 17 00:00:00 2001 From: Fabian Koller Date: Tue, 23 Feb 2021 08:35:10 +0100 Subject: [PATCH 1/6] Update exposed configuration variables Include the newly added OCR clean and deskew parameters --- ansible/defaults/main.yml | 11 ++++++++--- ansible/tasks/main.yml | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ansible/defaults/main.yml b/ansible/defaults/main.yml index f1cbb8f88..0a5824608 100644 --- a/ansible/defaults/main.yml +++ b/ansible/defaults/main.yml @@ -18,8 +18,9 @@ paperlessng_directory: /opt/paperless-ng paperlessng_consumption_dir: "{{ paperlessng_directory }}/consumption" paperlessng_data_dir: "{{ paperlessng_directory }}/data" paperlessng_media_root: "{{ paperlessng_directory }}/media" -paperlessng_static_dir: "{{ paperlessng_directory }}/static" +paperlessng_staticdir: "{{ paperlessng_directory }}/static" paperlessng_filename_format: +paperlessng_logging_dir: "{{ paperlessng_data_dir }}/log" paperlessng_virtualenv: "{{ paperlessng_directory }}/.venv" # Hosting & Security @@ -36,12 +37,15 @@ paperlessng_enable_http_remote_user: False paperlessng_ocr_languages: - eng paperlessng_ocr_mode: skip +paperlessng_ocr_clean: clean +paperlessng_ocr_deskew: True +paperlessng_ocr_rotate_pages: True +paperlessng_ocr_rotate_pages_threshold: 12 paperlessng_ocr_output_type: pdfa paperlessng_ocr_pages: 0 paperlessng_ocr_image_dpi: # see https://ocrmypdf.readthedocs.io/en/latest/api.html#ocrmypdf.ocr paperlessng_ocr_user_args: - #- "deskew": True # https://github.com/jonaswinkler/paperless-ng/issues/231 - "optimize": 1 paperlessng_use_jbig2enc: True paperlessng_big2enc_lossy: False @@ -57,10 +61,11 @@ paperlessng_consumer_polling: 0 paperlessng_consumer_delete_duplicates: False paperlessng_consumer_recursive: False paperlessng_consumer_subdirs_as_tags: False +paperlessng_convert_memory_limit: 0 +paperlessng_convert_tmpdir: paperlessng_optimize_thumbnails: True paperlessng_post_consume_script: paperlessng_filename_date_order: -paperlessng_filename_parse_transforms: paperlessng_thumbnail_font_name: /usr/share/fonts/liberation/LiberationSerif-Regular.ttf paperlessng_ignore_dates: "" diff --git a/ansible/tasks/main.yml b/ansible/tasks/main.yml index bfaf8df17..ad16e2b0c 100644 --- a/ansible/tasks/main.yml +++ b/ansible/tasks/main.yml @@ -256,7 +256,7 @@ - "{{ paperlessng_consumption_dir }}" - "{{ paperlessng_data_dir }}" - "{{ paperlessng_media_root }}" - - "{{ paperlessng_static_dir }}" + - "{{ paperlessng_staticdir }}" - name: rename initial config command: @@ -280,9 +280,11 @@ - regexp: PAPERLESS_MEDIA_ROOT line: "PAPERLESS_MEDIA_ROOT={{ paperlessng_media_root }}" - regexp: PAPERLESS_STATICDIR - line: "PAPERLESS_STATICDIR={{ paperlessng_static_dir }}" + line: "PAPERLESS_STATICDIR={{ paperlessng_staticdir }}" - regexp: PAPERLESS_FILENAME_FORMAT line: "PAPERLESS_FILENAME_FORMAT={{ paperlessng_filename_format }}" + - regexp: PAPERLESS_LOGGING_DIR + line: "PAPERLESS_LOGGING_DIR={{ paperlessng_logging_dir }}" # Hosting & Security - regexp: PAPERLESS_SECRET_KEY line: "PAPERLESS_SECRET_KEY={{ paperlessng_secret_key }}" @@ -305,6 +307,14 @@ line: "PAPERLESS_OCR_LANGUAGE={{ paperlessng_ocr_languages | join('+') }}" - regexp: PAPERLESS_OCR_MODE line: "PAPERLESS_OCR_MODE={{ paperlessng_ocr_mode }}" + - regexp: PAPERLESS_OCR_CLEAN + line: "PAPERLESS_OCR_CLEAN={{ paperlessng_ocr_clean }}" + - regexp: PAPERLESS_OCR_DESKEW + line: "PAPERLESS_OCR_DESKEW={{ paperlessng_ocr_deskew }}" + - regexp: PAPERLESS_OCR_ROTATE_PAGES + line: "PAPERLESS_OCR_ROTATE_PAGES={{ paperlessng_ocr_rotate_pages }}" + - regexp: PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD + line: "PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD={{ paperlessng_ocr_rotate_pages_threshold }}" - regexp: PAPERLESS_OCR_OUTPUT_TYPE line: "PAPERLESS_OCR_OUTPUT_TYPE={{ paperlessng_ocr_output_type }}" - regexp: PAPERLESS_OCR_PAGES @@ -331,6 +341,10 @@ line: "PAPERLESS_CONSUMER_RECURSIVE={{ paperlessng_consumer_recursive }}" - regexp: PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS line: "PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS={{ paperlessng_consumer_subdirs_as_tags }}" + - regexp: PAPERLESS_CONVERT_MEMORY_LIMIT + line: "PAPERLESS_CONVERT_MEMORY_LIMIT={{ paperlessng_convert_memory_limit }}" + - regexp: PAPERLESS_CONVERT_TMPDIR + line: "PAPERLESS_CONVERT_TMPDIR={{ paperlessng_convert_tmpdir }}" - regexp: PAPERLESS_OPTIMIZE_THUMBNAILS line: "PAPERLESS_OPTIMIZE_THUMBNAILS={{ paperlessng_optimize_thumbnails }}" - regexp: PAPERLESS_POST_CONSUME_SCRIPT From 6273eb006159204b6a3211c6af581a5443d3484d Mon Sep 17 00:00:00 2001 From: Fabian Koller Date: Tue, 23 Feb 2021 08:38:01 +0100 Subject: [PATCH 2/6] Handle OCR languages with hyphens See https://github.com/jonaswinkler/paperless-ng/issues/584#issuecomment-782830878 --- ansible/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/tasks/main.yml b/ansible/tasks/main.yml index ad16e2b0c..92eb92032 100644 --- a/ansible/tasks/main.yml +++ b/ansible/tasks/main.yml @@ -43,7 +43,7 @@ - name: install ocr languages apt: - pkg: "{{ paperlessng_ocr_languages | map('regex_replace', '^(.*)$', 'tesseract-ocr-\\1') | list }}" + pkg: "{{ paperlessng_ocr_languages | map('regex_replace', '^(.*)$', 'tesseract-ocr-\\1') | map('replace', '_', '-') | list }}" - name: set up notesalexp repository key (for jbig2enc) apt_key: @@ -304,7 +304,7 @@ line: "PAPERLESS_ENABLE_HTTP_REMOTE_USER={{ paperlessng_enable_http_remote_user }}" # OCR settings - regexp: PAPERLESS_OCR_LANGUAGE - line: "PAPERLESS_OCR_LANGUAGE={{ paperlessng_ocr_languages | join('+') }}" + line: "PAPERLESS_OCR_LANGUAGE={{ paperlessng_ocr_languages | join('+') | replace('-','_') }}" - regexp: PAPERLESS_OCR_MODE line: "PAPERLESS_OCR_MODE={{ paperlessng_ocr_mode }}" - regexp: PAPERLESS_OCR_CLEAN From 772f5cb1a8e346c10cc6a55ad9860cc6b60c3c7e Mon Sep 17 00:00:00 2001 From: Bolko Schreiber Date: Thu, 25 Feb 2021 13:57:45 +0100 Subject: [PATCH 3/6] Added option to invert thumbnails in dark mode --- .../document-card-large.component.html | 2 +- .../document-card-large.component.scss | 2 +- .../document-card-large.component.ts | 7 ++++++- .../document-card-small.component.html | 2 +- .../document-card-small.component.scss | 2 +- .../document-card-small.component.ts | 7 ++++++- .../manage/settings/settings.component.html | 1 + .../components/manage/settings/settings.component.ts | 2 ++ src-ui/src/app/services/settings.service.ts | 2 ++ src-ui/src/theme_dark.scss | 12 +++++++++++- 10 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index a47f13653..a531dea97 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss index c49de93b5..10454dc73 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss @@ -4,7 +4,7 @@ overflow-wrap: anywhere; } -.doc-img { +.doc-img, .doc-img-inverted { object-fit: cover; object-position: top left; height: 100%; diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts index f8bb9f518..ae68f5b60 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts @@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { PaperlessDocument } from 'src/app/data/paperless-document'; import { DocumentService } from 'src/app/services/rest/document.service'; +import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service'; @Component({ selector: 'app-document-card-large', @@ -10,7 +11,7 @@ import { DocumentService } from 'src/app/services/rest/document.service'; }) export class DocumentCardLargeComponent implements OnInit { - constructor(private documentService: DocumentService, private sanitizer: DomSanitizer) { } + constructor(private documentService: DocumentService, private sanitizer: DomSanitizer, private settingsService: SettingsService) { } @Input() selected = false @@ -53,6 +54,10 @@ export class DocumentCardLargeComponent implements OnInit { ngOnInit(): void { } + getIsThumbInverted() { + return this.settingsService.get(SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED) + } + getDetailsAsString() { if (typeof this.details === 'string') { return this.details.substring(0, 500) diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index 28dc84236..f90239e63 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss index cbe8fa6f6..680198efc 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss @@ -1,6 +1,6 @@ @import "/src/theme"; -.doc-img { +.doc-img, .doc-img-inverted { object-fit: cover; object-position: top left; height: 200px; diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts index 5db0e30c0..95c01dcec 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts @@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { map } from 'rxjs/operators'; import { PaperlessDocument } from 'src/app/data/paperless-document'; import { DocumentService } from 'src/app/services/rest/document.service'; +import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service'; @Component({ selector: 'app-document-card-small', @@ -10,7 +11,7 @@ import { DocumentService } from 'src/app/services/rest/document.service'; }) export class DocumentCardSmallComponent implements OnInit { - constructor(private documentService: DocumentService) { } + constructor(private documentService: DocumentService, private settingsService: SettingsService) { } @Input() selected = false @@ -32,6 +33,10 @@ export class DocumentCardSmallComponent implements OnInit { ngOnInit(): void { } + getIsThumbInverted() { + return this.settingsService.get(SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED) + } + getThumbUrl() { return this.documentService.getThumbUrl(this.document.id) } diff --git a/src-ui/src/app/components/manage/settings/settings.component.html b/src-ui/src/app/components/manage/settings/settings.component.html index 3674bbcb9..5467f6ea2 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.html +++ b/src-ui/src/app/components/manage/settings/settings.component.html @@ -96,6 +96,7 @@
+
diff --git a/src-ui/src/app/components/manage/settings/settings.component.ts b/src-ui/src/app/components/manage/settings/settings.component.ts index 15cfb8a19..fbcef7b70 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.ts +++ b/src-ui/src/app/components/manage/settings/settings.component.ts @@ -21,6 +21,7 @@ export class SettingsComponent implements OnInit { 'documentListItemPerPage': new FormControl(this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE)), 'darkModeUseSystem': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM)), 'darkModeEnabled': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_ENABLED)), + 'darkModeInvertThumbs': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED)), 'useNativePdfViewer': new FormControl(this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)), 'savedViews': this.savedViewGroup, 'displayLanguage': new FormControl(this.settings.getLanguage()), @@ -74,6 +75,7 @@ export class SettingsComponent implements OnInit { this.settings.set(SETTINGS_KEYS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage) this.settings.set(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, this.settingsForm.value.darkModeUseSystem) this.settings.set(SETTINGS_KEYS.DARK_MODE_ENABLED, (this.settingsForm.value.darkModeEnabled == true).toString()) + this.settings.set(SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED, (this.settingsForm.value.darkModeInvertThumbs == true).toString()) this.settings.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, this.settingsForm.value.useNativePdfViewer) this.settings.set(SETTINGS_KEYS.DATE_LOCALE, this.settingsForm.value.dateLocale) this.settings.set(SETTINGS_KEYS.DATE_FORMAT, this.settingsForm.value.dateFormat) diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts index d511fa65f..96db88430 100644 --- a/src-ui/src/app/services/settings.service.ts +++ b/src-ui/src/app/services/settings.service.ts @@ -21,6 +21,7 @@ export const SETTINGS_KEYS = { DOCUMENT_LIST_SIZE: 'general-settings:documentListSize', DARK_MODE_USE_SYSTEM: 'general-settings:dark-mode:use-system', DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled', + DARK_MODE_THUMB_INVERTED: 'general-settings:dark-mode:thumb-inverted', USE_NATIVE_PDF_VIEWER: 'general-settings:document-details:native-pdf-viewer', DATE_LOCALE: 'general-settings:date-display:date-locale', DATE_FORMAT: 'general-settings:date-display:date-format', @@ -36,6 +37,7 @@ const SETTINGS: PaperlessSettings[] = [ {key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE, type: "number", default: 50}, {key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, type: "boolean", default: true}, {key: SETTINGS_KEYS.DARK_MODE_ENABLED, type: "boolean", default: false}, + {key: SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED, type: "boolean", default: false}, {key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, type: "boolean", default: false}, {key: SETTINGS_KEYS.DATE_LOCALE, type: "string", default: ""}, {key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"}, diff --git a/src-ui/src/theme_dark.scss b/src-ui/src/theme_dark.scss index 4e850f017..89a7bea34 100644 --- a/src-ui/src/theme_dark.scss +++ b/src-ui/src/theme_dark.scss @@ -138,6 +138,16 @@ $border-color-dark-mode: #47494f; } .doc-img { + mix-blend-mode: normal; + border-radius: 0; + border-color: $bg-dark-mode; + + &.border-right { + border-right: none !important; + } + } + + .doc-img-inverted { mix-blend-mode: normal; filter: invert(95%) hue-rotate(180deg); border-radius: 0; @@ -148,7 +158,7 @@ $border-color-dark-mode: #47494f; } } - .card-selected .doc-img { + .card-selected .doc-img .doc-img-inverted { mix-blend-mode: luminosity; } From a331e4b49c4e7bedb8db56e555e26a23db31069e Mon Sep 17 00:00:00 2001 From: Bolko Schreiber Date: Thu, 25 Feb 2021 14:52:55 +0100 Subject: [PATCH 4/6] Set default value of DARK_MODE_THUMB_INVERTED to true --- src-ui/src/app/services/settings.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts index 96db88430..a89c791c6 100644 --- a/src-ui/src/app/services/settings.service.ts +++ b/src-ui/src/app/services/settings.service.ts @@ -37,7 +37,7 @@ const SETTINGS: PaperlessSettings[] = [ {key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE, type: "number", default: 50}, {key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, type: "boolean", default: true}, {key: SETTINGS_KEYS.DARK_MODE_ENABLED, type: "boolean", default: false}, - {key: SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED, type: "boolean", default: false}, + {key: SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED, type: "boolean", default: true}, {key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, type: "boolean", default: false}, {key: SETTINGS_KEYS.DATE_LOCALE, type: "string", default: ""}, {key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"}, From 6a1f5fb4cd19e640dc92cfbfb9d1a37551e2df67 Mon Sep 17 00:00:00 2001 From: Bolko Schreiber Date: Thu, 25 Feb 2021 15:35:15 +0100 Subject: [PATCH 5/6] cleanup css --- .../document-card-large.component.html | 2 +- .../document-card-large.component.scss | 2 +- .../document-card-small.component.html | 2 +- .../document-card-small.component.scss | 2 +- src-ui/src/theme_dark.scss | 11 ++--------- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index a531dea97..e1ad87bcc 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss index 10454dc73..c49de93b5 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss @@ -4,7 +4,7 @@ overflow-wrap: anywhere; } -.doc-img, .doc-img-inverted { +.doc-img { object-fit: cover; object-position: top left; height: 100%; diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index f90239e63..862b0ad22 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -1,7 +1,7 @@
- +
diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss index 680198efc..cbe8fa6f6 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss @@ -1,6 +1,6 @@ @import "/src/theme"; -.doc-img, .doc-img-inverted { +.doc-img { object-fit: cover; object-position: top left; height: 200px; diff --git a/src-ui/src/theme_dark.scss b/src-ui/src/theme_dark.scss index 89a7bea34..1b26680fe 100644 --- a/src-ui/src/theme_dark.scss +++ b/src-ui/src/theme_dark.scss @@ -147,18 +147,11 @@ $border-color-dark-mode: #47494f; } } - .doc-img-inverted { - mix-blend-mode: normal; + .doc-img.inverted { filter: invert(95%) hue-rotate(180deg); - border-radius: 0; - border-color: $bg-dark-mode; - - &.border-right { - border-right: none !important; - } } - .card-selected .doc-img .doc-img-inverted { + .card-selected .doc-img { mix-blend-mode: luminosity; } From 420feb3a523cc272187940b8aa292d27d531a507 Mon Sep 17 00:00:00 2001 From: Bolko Schreiber Date: Fri, 26 Feb 2021 12:26:23 +0100 Subject: [PATCH 6/6] lowered thumb brightness in non-inverted mode --- src-ui/src/theme_dark.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/src/theme_dark.scss b/src-ui/src/theme_dark.scss index 1b26680fe..aa3822661 100644 --- a/src-ui/src/theme_dark.scss +++ b/src-ui/src/theme_dark.scss @@ -141,7 +141,7 @@ $border-color-dark-mode: #47494f; mix-blend-mode: normal; border-radius: 0; border-color: $bg-dark-mode; - + filter: invert(10%); &.border-right { border-right: none !important; }