├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── stale.yml └── workflows │ ├── backport.yml │ ├── build.yml │ ├── build_release.yml │ ├── dependabot-approve.yml │ ├── lint-fix.yml │ ├── lint.yml │ ├── phpunit-integration.yml │ ├── phpunit.yml │ ├── psalm.yml │ └── sonarqube.yml ├── .gitignore ├── .l10nignore ├── .php-cs-fixer.dist.php ├── .tx └── config ├── .vscode └── launch.json ├── COPYING ├── Makefile ├── README.md ├── appinfo ├── info.xml └── routes.php ├── babel.config.js ├── composer.json ├── composer.lock ├── composer └── autoload.php ├── doc ├── diagramms │ └── general.png └── img │ ├── assign_tag_1.png │ ├── assign_tag_2.png │ ├── debug.jpg │ ├── file_versions.jpg │ ├── global_settings.png │ ├── notifications.png │ ├── per_workflow_settings.jpg │ ├── setup_checks.jpg │ ├── tag_assigned_config.png │ ├── usage_1.jpg │ ├── usual_config_1.jpg │ └── workflowengine_delimitation.jpg ├── img ├── app-dark.svg └── app.svg ├── jest.config.js ├── l10n ├── .gitkeep ├── ar.js ├── ar.json ├── ast.js ├── ast.json ├── bg.js ├── bg.json ├── cs.js ├── cs.json ├── da.js ├── da.json ├── de.js ├── de.json ├── de_DE.js ├── de_DE.json ├── el.js ├── el.json ├── en_GB.js ├── en_GB.json ├── es.js ├── es.json ├── es_EC.js ├── es_EC.json ├── es_MX.js ├── es_MX.json ├── eu.js ├── eu.json ├── fa.js ├── fa.json ├── fi.js ├── fi.json ├── fr.js ├── fr.json ├── ga.js ├── ga.json ├── gl.js ├── gl.json ├── hu.js ├── hu.json ├── it.js ├── it.json ├── ja.js ├── ja.json ├── lt_LT.js ├── lt_LT.json ├── nb.js ├── nb.json ├── pl.js ├── pl.json ├── pt_BR.js ├── pt_BR.json ├── ru.js ├── ru.json ├── sk.js ├── sk.json ├── sl.js ├── sl.json ├── sr.js ├── sr.json ├── sv.js ├── sv.json ├── tr.js ├── tr.json ├── ug.js ├── ug.json ├── uk.js ├── uk.json ├── uz.js ├── uz.json ├── zh_CN.js ├── zh_CN.json ├── zh_HK.js ├── zh_HK.json ├── zh_TW.js └── zh_TW.json ├── lib ├── AppInfo │ └── Application.php ├── BackgroundJobs │ └── ProcessFileJob.php ├── Controller │ ├── ControllerBase.php │ ├── GlobalSettingsController.php │ └── OcrBackendInfoController.php ├── Events │ └── TextRecognizedEvent.php ├── Exception │ ├── CommandException.php │ ├── OcrAlreadyDoneException.php │ ├── OcrNotPossibleException.php │ ├── OcrProcessorNotFoundException.php │ └── OcrResultEmptyException.php ├── Helper │ ├── IProcessingFileAccessor.php │ ├── ISidecarFileAccessor.php │ ├── ProcessingFileAccessor.php │ └── SidecarFileAccessor.php ├── Listener │ └── RegisterFlowOperationsListener.php ├── Migration │ ├── Version2404Date20220903071748.php │ └── Version2702Date20230908170345.php ├── Model │ ├── GlobalSettings.php │ └── WorkflowSettings.php ├── Notification │ └── Notifier.php ├── OcrProcessors │ ├── CommandLineUtils.php │ ├── ICommandLineUtils.php │ ├── IOcrProcessor.php │ ├── IOcrProcessorFactory.php │ ├── Local │ │ ├── ImageOcrProcessor.php │ │ ├── OcrMyPdfBasedProcessor.php │ │ └── PdfOcrProcessor.php │ ├── OcrProcessorFactory.php │ ├── OcrProcessorResult.php │ └── Remote │ │ ├── Client │ │ ├── .openapi-generator-ignore │ │ ├── .openapi-generator │ │ │ ├── FILES │ │ │ └── VERSION │ │ ├── ApiClient.php │ │ ├── Configuration.php │ │ ├── IApiClient.php │ │ ├── Model │ │ │ ├── ErrorResult.php │ │ │ ├── ModelInterface.php │ │ │ └── OcrResult.php │ │ ├── ObjectSerializer.php │ │ ├── generate-client.sh │ │ ├── openapi-spec.json │ │ ├── openapitools.json │ │ └── templates │ │ │ ├── model.mustache │ │ │ ├── model_generic.mustache │ │ │ └── partial_header.mustache │ │ └── WorkflowOcrRemoteProcessor.php ├── Operation.php ├── Service │ ├── EventService.php │ ├── GlobalSettingsService.php │ ├── IEventService.php │ ├── IGlobalSettingsService.php │ ├── INotificationService.php │ ├── IOcrBackendInfoService.php │ ├── IOcrService.php │ ├── NotificationService.php │ ├── OcrBackendInfoService.php │ └── OcrService.php ├── Settings │ └── GlobalSettings.php ├── SetupChecks │ └── OcrMyPdfCheck.php └── Wrapper │ ├── AppApiWrapper.php │ ├── CommandWrapper.php │ ├── Filesystem.php │ ├── IAppApiWrapper.php │ ├── ICommand.php │ ├── IFilesystem.php │ ├── IView.php │ ├── IViewFactory.php │ ├── ViewFactory.php │ └── ViewWrapper.php ├── package-lock.json ├── package.json ├── phpunit.integration.xml ├── phpunit.xml ├── psalm.xml ├── sonar-project.properties ├── src ├── components │ ├── GlobalSettings.vue │ ├── SettingsItem.vue │ └── WorkflowOcr.vue ├── constants.js ├── globalSettings.js ├── main.js ├── service │ ├── globalSettingsService.js │ └── ocrBackendInfoService.js └── test │ ├── OC.js │ ├── components │ ├── GlobalSettings.spec.js │ ├── SettingsItem.spec.js │ └── WorkflowOcr.spec.js │ ├── gobalSettings.spec.js │ ├── main.spec.js │ ├── service │ ├── globalSettingsService.spec.js │ └── ocrBackendInfoService.spec.js │ └── setup-jest.js ├── stylelint.config.js ├── templates └── globalSettings.php ├── tests ├── Integration │ ├── AppTest.php │ ├── BackendTestBase.php │ ├── Composer │ │ └── AutoloaderTest.php │ ├── FileSystemTest.php │ ├── IntegrationTestApiClient.php │ ├── LocalBackendTest.php │ ├── Migration │ │ └── Version2404Date20220903071748Test.php │ ├── Notification │ │ ├── AppFake.php │ │ └── NotificationTest.php │ ├── OcrBackendServiceTest.php │ ├── ViewWrapperTest.php │ └── testdata │ │ ├── document-has-ocr.pdf │ │ └── document-ready-for-ocr.pdf ├── TestUtils.php ├── Unit │ ├── AppInfo │ │ └── ApplicationTest.php │ ├── BackgroundJobs │ │ └── ProcessFileJobTest.php │ ├── Controller │ │ ├── GlobalSettingsControllerTest.php │ │ └── OcrBackendInfoControllerTest.php │ ├── Helper │ │ ├── ProcessingFIleAccessorTest.php │ │ └── SidecarFileAccessorTest.php │ ├── Listener │ │ └── RegisterFlowOperationsListenerTest.php │ ├── Model │ │ └── WorkflowSettingsTest.php │ ├── Notification │ │ └── NotifierTest.php │ ├── OcrProcessors │ │ ├── Local │ │ │ ├── ImageOcrProcessorTest.php │ │ │ └── PdfOcrProcessorTest.php │ │ ├── OcrProcessorFactoryTest.php │ │ └── Remote │ │ │ ├── Client │ │ │ └── ApiClientTest.php │ │ │ └── WorkflowOcrRemoteProcessorTest.php │ ├── OperationTest.php │ ├── Service │ │ ├── EventServiceTest.php │ │ ├── GlobalSettingsServiceTest.php │ │ ├── IMetadataVersionWithBackend.php │ │ ├── NotificationServiceTest.php │ │ ├── OcrBackendInfoServiceTest.php │ │ └── OcrServiceTest.php │ ├── Settings │ │ └── GlobalSettingsTest.php │ ├── SetupChecks │ │ └── OcrMyPdfCheckTest.php │ ├── Wrapper │ │ ├── AppApiWrapperTest.php │ │ ├── CommandWrapperTest.php │ │ └── ViewFactoryTest.php │ └── composer │ │ └── AutoloadTest.php ├── bootstrap.php └── psalm-baseline.xml └── webpack.js /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // no object literal shorthand syntax 4 | 'object-shorthand': ['warn', 'never'], 5 | }, 6 | extends: [ 7 | '@nextcloud', 8 | ], 9 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us to improve the Nextcloud Workflow OCR app 4 | title: '' 5 | labels: bug 6 | assignees: R0Wi 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | **System** 15 | 16 | - App version: [VERSION] 17 | - Nextcloud version: [VERSION] 18 | - PHP version: [VERSION] 19 | - Environment: [Docker/native Apache/native PHP FPM/...] 20 | - `ocrmypdf` version: [VERSION] 21 | 22 | 23 | **How to reproduce** 24 | 25 | Steps to reproduce the behavior: 26 | 1. Go to '...' 27 | 2. Click on '....' 28 | 3. Scroll down to '....' 29 | 4. See error 30 | 31 | **Screenshots** 32 | 33 | If applicable, add screenshots to help explain your problem. 34 | 35 | **Server log** 36 | 37 | Please paste relevant content of your [ `nextcloud.log`](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/logging_configuration.html#logging) file here. It might make sense to first decrease the [Loglevel](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/logging_configuration.html#log-level). Also, since the OCR process runs asynchronously, run your [cron.php](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron) before copying the logs here. 38 | 39 | ``` 40 | Paste relevant server log lines here. Make sure to trim sensitive information. 41 | ``` 42 | 43 | **Browser log** 44 | 45 | If you're observing Browser errors, please paste your developer tools logs here. 46 | 47 | Help for Chrome: https://developer.chrome.com/docs/devtools/console/#view 48 | Help for Firefox: https://firefox-source-docs.mozilla.org/devtools-user/browser_console/index.html 49 | 50 | ``` 51 | Paste your developer tools logs here. 52 | ``` 53 | 54 | **Additional context** 55 | 56 | Add any other context about the problem here. 57 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 40 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: auto-closed 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity within the last 40 days. It will be closed in 7 days if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /.github/workflows/backport.yml: -------------------------------------------------------------------------------- 1 | name: Backport 2 | on: 3 | pull_request: 4 | types: 5 | - closed 6 | - labeled 7 | 8 | jobs: 9 | backport: 10 | runs-on: ubuntu-22.04 11 | name: Backport 12 | steps: 13 | - name: Backport 14 | uses: tibdex/backport@v1.1.0 15 | with: 16 | github_token: ${{ secrets.PERSONAL_TOKEN }} 17 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build artifact 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | 7 | env: 8 | APP_NAME: workflow_ocr 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | with: 17 | path: ${{ env.APP_NAME }} 18 | 19 | - name: Read package.json node and npm engines version 20 | uses: skjnldsv/read-package-engines-version-actions@v2 21 | id: versions 22 | continue-on-error: false 23 | with: 24 | path: ${{ env.APP_NAME }} 25 | 26 | - name: Set up node ${{ steps.versions.outputs.nodeVersion }} 27 | uses: actions/setup-node@v3 28 | with: 29 | node-version: ${{ steps.versions.outputs.nodeVersion }} 30 | 31 | - name: Set up npm ${{ steps.versions.outputs.npmVersion }} 32 | run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" 33 | 34 | - name: Run build 35 | run: cd ${{ env.APP_NAME }} && make appstore 36 | 37 | - name: Upload artifacts 38 | uses: actions/upload-artifact@v4 39 | with: 40 | name: ${{ env.APP_NAME }}.tar.gz 41 | path: ${{ env.APP_NAME }}/build/artifacts/appstore/${{ env.APP_NAME }}.tar.gz 42 | -------------------------------------------------------------------------------- /.github/workflows/build_release.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish app release 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | env: 8 | APP_NAME: workflow_ocr 9 | 10 | jobs: 11 | build_and_publish: 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | with: 17 | path: ${{ env.APP_NAME }} 18 | 19 | - name: Read package.json node and npm engines version 20 | uses: skjnldsv/read-package-engines-version-actions@v2 21 | id: versions 22 | continue-on-error: false 23 | with: 24 | path: ${{ env.APP_NAME }} 25 | 26 | - name: Set up node ${{ steps.versions.outputs.nodeVersion }} 27 | uses: actions/setup-node@v3 28 | with: 29 | node-version: ${{ steps.versions.outputs.nodeVersion }} 30 | 31 | - name: Set up npm ${{ steps.versions.outputs.npmVersion }} 32 | run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" 33 | 34 | - name: Run build 35 | run: cd ${{ env.APP_NAME }} && make appstore 36 | 37 | - name: Upload app tarball to release 38 | uses: svenstaro/upload-release-action@v2 39 | id: attach_to_release 40 | with: 41 | repo_token: ${{ secrets.GITHUB_TOKEN }} 42 | file: ${{ env.APP_NAME }}/build/artifacts/appstore/${{ env.APP_NAME }}.tar.gz 43 | asset_name: ${{ env.APP_NAME }}.tar.gz 44 | tag: ${{ github.ref }} 45 | overwrite: true 46 | 47 | - name: Upload app to Nextcloud appstore 48 | uses: R0Wi/nextcloud-appstore-push-action@v1 49 | with: 50 | app_name: ${{ env.APP_NAME }} 51 | appstore_token: ${{ secrets.APPSTORE_TOKEN }} 52 | download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} 53 | app_private_key: ${{ secrets.APP_PRIVATE_KEY }} 54 | nightly: ${{ github.event.release.prerelease }} 55 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-approve.yml: -------------------------------------------------------------------------------- 1 | name: Dependabot auto approve 2 | on: pull_request 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-22.04 7 | steps: 8 | - uses: hmarr/auto-approve-action@v2.0.0 9 | if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' 10 | with: 11 | github-token: "${{ secrets.GITHUB_TOKEN }}" 12 | -------------------------------------------------------------------------------- /.github/workflows/lint-fix.yml: -------------------------------------------------------------------------------- 1 | name: CS-Fix 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | php-cs-fixer: 8 | name: php-cs-fixer 9 | runs-on: ubuntu-22.04 10 | 11 | strategy: 12 | matrix: 13 | php-versions: ['8.3'] 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | with: 19 | ref: ${{ github.head_ref }} 20 | 21 | - name: Set up php 22 | uses: shivammathur/setup-php@v2 23 | with: 24 | php-version: ${{ matrix.php-versions }} 25 | coverage: none 26 | 27 | - name: Install dependencies 28 | run: composer i 29 | 30 | - name: Run coding standard formatter 31 | run: composer run cs:fix 32 | 33 | - uses: stefanzweifel/git-auto-commit-action@v4 34 | with: 35 | commit_message: Apply php-cs-fixer changes 36 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | - stable* 9 | 10 | env: 11 | APP_NAME: workflow_ocr 12 | 13 | jobs: 14 | php: 15 | runs-on: ubuntu-22.04 16 | 17 | strategy: 18 | matrix: 19 | php-versions: ['8.3', '8.4'] 20 | 21 | name: php${{ matrix.php-versions }}-LINT 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Set up php ${{ matrix.php-versions }} 26 | uses: shivammathur/setup-php@v2 27 | with: 28 | php-version: ${{ matrix.php-versions }} 29 | coverage: none 30 | 31 | - name: Lint 32 | run: composer run lint 33 | -------------------------------------------------------------------------------- /.github/workflows/psalm.yml: -------------------------------------------------------------------------------- 1 | name: Static analysis (PSALM) 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | - stable* 9 | 10 | jobs: 11 | static-psalm-analysis: 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | ocp-version: [ 'dev-master' ] 17 | php-version: [ '8.2', '8.3', '8.4' ] 18 | 19 | name: Nextcloud ${{ matrix.ocp-version }} PHP${{ matrix.php-version }} 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@master 23 | 24 | - name: Set up php 25 | uses: shivammathur/setup-php@v2 26 | with: 27 | php-version: ${{ matrix.php-version }} 28 | coverage: none 29 | 30 | - name: Install dependencies 31 | run: composer i 32 | 33 | - name: Install dependencies 34 | run: composer require --dev nextcloud/ocp:${{ matrix.ocp-version }} 35 | 36 | - name: Run coding standards check 37 | run: composer run psalm -- --php-version=${{ matrix.php-version }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .php_cs.cache 3 | coverage*.xml 4 | coverage*.html 5 | coverage_html 6 | build 7 | .phpunit.result.cache 8 | *.cov 9 | node_modules 10 | js 11 | coverage 12 | .php-cs-fixer.cache 13 | .vscode/settings.json 14 | -------------------------------------------------------------------------------- /.l10nignore: -------------------------------------------------------------------------------- 1 | # compiled vue templates 2 | js/ 3 | # php libs 4 | vendor/ 5 | -------------------------------------------------------------------------------- /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | getFinder() 12 | ->notPath('build') 13 | ->notPath('l10n') 14 | ->notPath('src') 15 | ->notPath('vendor') 16 | ->notPath('node_modules') 17 | ->in(__DIR__); 18 | return $config; -------------------------------------------------------------------------------- /.tx/config: -------------------------------------------------------------------------------- 1 | [main] 2 | host = https://www.transifex.com 3 | lang_map = th_TH: th, ja_JP: ja, bg_BG: bg, cs_CZ: cs, fi_FI: fi, hu_HU: hu, nb_NO: nb, sk_SK: sk 4 | 5 | [o:nextcloud:p:nextcloud:r:workflow_ocr] 6 | file_filter = translationfiles//workflow_ocr.po 7 | source_file = translationfiles/templates/workflow_ocr.pot 8 | source_lang = en 9 | type = PO -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Listen for XDebug", 9 | "type": "php", 10 | "request": "launch", 11 | "port": 9003 12 | }, 13 | { 14 | "name": "Run cron.php", 15 | "type": "php", 16 | "request": "launch", 17 | "program": "${workspaceRoot}/../../cron.php", 18 | "port": 9003 19 | }, 20 | { 21 | "name": "Debug Unittests", 22 | "type": "php", 23 | "request": "launch", 24 | "program": "${workspaceRoot}/vendor/phpunit/phpunit/phpunit", 25 | "args": ["-c", "phpunit.xml"], 26 | "cwd": "${workspaceRoot}", 27 | "port": 9003 28 | }, 29 | { 30 | "name": "Debug Integrationtests", 31 | "type": "php", 32 | "request": "launch", 33 | "program": "${workspaceRoot}/vendor/phpunit/phpunit/phpunit", 34 | "args": ["-c", "phpunit.integration.xml"], 35 | "cwd": "${workspaceRoot}", 36 | "port": 9003 37 | }, 38 | { 39 | "type": "node", 40 | "request": "launch", 41 | "name": "Debug VUE Unit Test (current file)", 42 | "runtimeExecutable": "npm", 43 | "runtimeArgs": [ 44 | "run-script", 45 | "test:debug", 46 | "${file}" 47 | ], 48 | "port": 9229 49 | }, 50 | { 51 | "type": "chrome", 52 | "request": "launch", 53 | "name": "vuejs: chrome", 54 | "url": "http://localhost/nextcloud/index.php/settings/admin/workflow", 55 | "webRoot": "${workspaceFolder}/src", 56 | "sourceMapPathOverrides": { 57 | "webpack:///workflow_ocr/src/*": "${webRoot}/*" 58 | } 59 | }, 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /appinfo/info.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | workflow_ocr 5 | Workflow OCR 6 | Server side OCR processing via workflow engine 7 | This app makes it possible to process various files via OCR algorithms. 8 | The processing is done via workflow-engine and can therefore easily be customized. 9 | Please note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to 10 | process PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md. 11 | 1.32.0 12 | agpl 13 | Robin Windey 14 | WorkflowOcr 15 | 16 | 17 | 18 | files 19 | tools 20 | organization 21 | workflow 22 | 23 | OCA\WorkflowOcr\Settings\GlobalSettings 24 | 25 | https://github.com/R0Wi/workflow_ocr 26 | https://github.com/R0Wi/workflow_ocr/issues 27 | https://github.com/R0Wi/workflow_ocr.git 28 | https://github.com/R0Wi/workflow_ocr/blob/eb2d65e9610406bbab22c4c8dda1cea015b5c791/doc/img/usage_1.jpg?raw=true 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /appinfo/routes.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | 28 | return [ 29 | 'routes' => [ 30 | ['name' => 'GlobalSettings#getGlobalSettings', 'url' => '/globalSettings', 'verb' => 'GET'], 31 | ['name' => 'GlobalSettings#setGlobalSettings', 'url' => '/globalSettings', 'verb' => 'PUT'], 32 | ['name' => 'OcrBackendInfo#getInstalledLanguages', 'url' => '/ocrBackendInfo/installedLangs', 'verb' => 'GET'] 33 | ] 34 | ]; 35 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | const babelConfig = require('@nextcloud/babel-config') 2 | 3 | module.exports = babelConfig -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "mikehaertl/php-shellcommand": "^1.6" 4 | }, 5 | "require-dev": { 6 | "phpunit/phpunit": "^11.0", 7 | "phpunit/php-code-coverage": "^11.0", 8 | "phpunit/phpcov": "^10.0", 9 | "nextcloud/coding-standard": "^1.3", 10 | "vimeo/psalm": "6.4.*", 11 | "nextcloud/ocp": "dev-master" 12 | }, 13 | "config": { 14 | "optimize-autoloader": true, 15 | "platform": { 16 | "php": "8.3" 17 | }, 18 | "autoloader-suffix": "WorkflowOcr" 19 | }, 20 | "autoload": { 21 | "psr-4": { 22 | "OCA\\WorkflowOcr\\": "lib/" 23 | } 24 | }, 25 | "autoload-dev": { 26 | "psr-4": { 27 | "OCP\\": "vendor/nextcloud/ocp/OCP" 28 | } 29 | }, 30 | "scripts": { 31 | "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './node_modules/*' -exec php -l \"{}\" \\;", 32 | "cs:check": "php-cs-fixer fix --dry-run --diff", 33 | "cs:fix": "php-cs-fixer fix", 34 | "psalm": "psalm --threads=1", 35 | "psalm:update-baseline": "psalm --threads=1 --update-baseline", 36 | "psalm:clear": "psalm --clear-cache && psalm --clear-global-cache", 37 | "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType", 38 | "psalm:write-baseline": "psalm --threads=1 --set-baseline=./tests/psalm-baseline.xml" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /composer/autoload.php: -------------------------------------------------------------------------------- 1 | /src/test/setup-jest.js'], 63 | 64 | testEnvironment: 'jest-environment-jsdom', 65 | 66 | moduleFileExtensions: [ 67 | 'js', 68 | 'vue', 69 | ], 70 | 71 | moduleNameMapper: { 72 | '\\.(css|scss)$': 'jest-transform-stub', 73 | }, 74 | 75 | transform: { 76 | '\\.js$': 'babel-jest', 77 | '\\.vue$': '@vue/vue2-jest', 78 | }, 79 | } 80 | -------------------------------------------------------------------------------- /l10n/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/R0Wi-DEV/workflow_ocr/79b364b1c0f889f1408ef360580bb272e48f2bc2/l10n/.gitkeep -------------------------------------------------------------------------------- /l10n/ast.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Fluxu de trabayu d'OCR", 5 | "Workflow OCR error" : "Error del fluxu de trabayu d'OCR", 6 | "OCR file" : "Ficheru OCR", 7 | "OCR processing via workflow" : "Procesamientu d'OCR per un fluxu de trabayu", 8 | "Server side OCR processing via workflow engine" : "Procesamientu d'OCR del sirvidor pel motor de fluxos de trabayu", 9 | "Other settings" : "Otra configuración" 10 | }, 11 | "nplurals=2; plural=(n != 1);"); 12 | -------------------------------------------------------------------------------- /l10n/ast.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Fluxu de trabayu d'OCR", 3 | "Workflow OCR error" : "Error del fluxu de trabayu d'OCR", 4 | "OCR file" : "Ficheru OCR", 5 | "OCR processing via workflow" : "Procesamientu d'OCR per un fluxu de trabayu", 6 | "Server side OCR processing via workflow engine" : "Procesamientu d'OCR del sirvidor pel motor de fluxos de trabayu", 7 | "Other settings" : "Otra configuración" 8 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 9 | } -------------------------------------------------------------------------------- /l10n/bg.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Работен поток OCR", 5 | "Workflow settings JSON value cannot be parsed" : "Стойност JSON на настройките на работния поток не може да бъде анализирана", 6 | "OCR file" : "OCR файл", 7 | "OCR processing via workflow" : "Обработка на OCR чрез работния поток", 8 | "Server side OCR processing via workflow engine" : "Обработка на OCR от страна на сървъра, чрез механизъм на работния поток", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Това приложение дава възможност за обработка на различни файлове чрез OCR алгоритми.\n\tОбработката се извършва чрез механизъм на работния поток и следователно може лесно да бъде персонализирана.\n\tМоля, имайте предвид, че ще трябва да инсталирате OcrMyPDF CLI на вашия Nextcloud сървър, за да\n\tобработвате PDF файлове. Повече инструкции за инсталиране можете да намерите в документите на https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Other settings" : "Други настройки", 11 | "Remove background" : "Премахване на фона" 12 | }, 13 | "nplurals=2; plural=(n != 1);"); 14 | -------------------------------------------------------------------------------- /l10n/bg.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Работен поток OCR", 3 | "Workflow settings JSON value cannot be parsed" : "Стойност JSON на настройките на работния поток не може да бъде анализирана", 4 | "OCR file" : "OCR файл", 5 | "OCR processing via workflow" : "Обработка на OCR чрез работния поток", 6 | "Server side OCR processing via workflow engine" : "Обработка на OCR от страна на сървъра, чрез механизъм на работния поток", 7 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Това приложение дава възможност за обработка на различни файлове чрез OCR алгоритми.\n\tОбработката се извършва чрез механизъм на работния поток и следователно може лесно да бъде персонализирана.\n\tМоля, имайте предвид, че ще трябва да инсталирате OcrMyPDF CLI на вашия Nextcloud сървър, за да\n\tобработвате PDF файлове. Повече инструкции за инсталиране можете да намерите в документите на https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 8 | "Other settings" : "Други настройки", 9 | "Remove background" : "Премахване на фона" 10 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 11 | } -------------------------------------------------------------------------------- /l10n/es_EC.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Workflow OCR.", 5 | "Workflow settings JSON value cannot be parsed" : "Workflow settings JSON value cannot be parsed.", 6 | "OCR file" : "OCR file.", 7 | "OCR processing via workflow" : "OCR processing via workflow.", 8 | "Server side OCR processing via workflow engine" : "Server-side OCR processing via the workflow engine.\n ", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "The OCR Workflow app enables the processing of various files using OCR algorithms. The processing is facilitated through the workflow engine, allowing easy customization according to specific requirements.\n\nIt's important to note that in order to process PDF files, you'll need to install the OcrMyPDF Command-Line Interface on your Nextcloud server. You can find detailed installation instructions in the documentation, which can be accessed at https://github.com/R0Wi/workflow_ocr/blob/master/README.md. Make sure to follow the provided instructions to set up the necessary components for seamless OCR processing of PDF documents within Nextcloud.", 10 | "Other settings" : "Otras configuraciones" 11 | }, 12 | "nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); 13 | -------------------------------------------------------------------------------- /l10n/es_EC.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Workflow OCR.", 3 | "Workflow settings JSON value cannot be parsed" : "Workflow settings JSON value cannot be parsed.", 4 | "OCR file" : "OCR file.", 5 | "OCR processing via workflow" : "OCR processing via workflow.", 6 | "Server side OCR processing via workflow engine" : "Server-side OCR processing via the workflow engine.\n ", 7 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "The OCR Workflow app enables the processing of various files using OCR algorithms. The processing is facilitated through the workflow engine, allowing easy customization according to specific requirements.\n\nIt's important to note that in order to process PDF files, you'll need to install the OcrMyPDF Command-Line Interface on your Nextcloud server. You can find detailed installation instructions in the documentation, which can be accessed at https://github.com/R0Wi/workflow_ocr/blob/master/README.md. Make sure to follow the provided instructions to set up the necessary components for seamless OCR processing of PDF documents within Nextcloud.", 8 | "Other settings" : "Otras configuraciones" 9 | },"pluralForm" :"nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" 10 | } -------------------------------------------------------------------------------- /l10n/es_MX.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Flujo de trabajo OCR", 5 | "Workflow OCR error" : "Error en Flujo de trabajo OCR", 6 | "Workflow OCR error for file {file}" : "Flujo de trabajo OCR, error en archivo {file}", 7 | "Workflow settings JSON value cannot be parsed" : "El valor JSON de configuración del flujo de trabajo no se puede analizar", 8 | "OCR file" : "Archivo OCR", 9 | "OCR processing via workflow" : "Procesamiento de OCR a través del flujo de trabajo", 10 | "Server side OCR processing via workflow engine" : "Procesamiento OCR del lado del servidor a través del motor de flujo de trabajo", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Esta aplicación hace posible el procesamiento de varios archivos a través de algoritmos OCR.\n\tEl procesamiento se realiza a través del motor de flujos de trabajo y se puede personalizar fácilmente.\n\tPor favor tome en cuenta que deberá instalar la línea de comandos OcrMyPDF en su servidor Nextcloud para\n\tprocesar archivos PDF. Puede hallar más instrucciones para la instalación en los siguientes documentos https://github.com/R0Wi/workflow_ocr/blob/master/README.md." 12 | }, 13 | "nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); 14 | -------------------------------------------------------------------------------- /l10n/es_MX.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Flujo de trabajo OCR", 3 | "Workflow OCR error" : "Error en Flujo de trabajo OCR", 4 | "Workflow OCR error for file {file}" : "Flujo de trabajo OCR, error en archivo {file}", 5 | "Workflow settings JSON value cannot be parsed" : "El valor JSON de configuración del flujo de trabajo no se puede analizar", 6 | "OCR file" : "Archivo OCR", 7 | "OCR processing via workflow" : "Procesamiento de OCR a través del flujo de trabajo", 8 | "Server side OCR processing via workflow engine" : "Procesamiento OCR del lado del servidor a través del motor de flujo de trabajo", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Esta aplicación hace posible el procesamiento de varios archivos a través de algoritmos OCR.\n\tEl procesamiento se realiza a través del motor de flujos de trabajo y se puede personalizar fácilmente.\n\tPor favor tome en cuenta que deberá instalar la línea de comandos OcrMyPDF en su servidor Nextcloud para\n\tprocesar archivos PDF. Puede hallar más instrucciones para la instalación en los siguientes documentos https://github.com/R0Wi/workflow_ocr/blob/master/README.md." 10 | },"pluralForm" :"nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" 11 | } -------------------------------------------------------------------------------- /l10n/eu.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Lan-fluxua OCR", 5 | "Workflow settings JSON value cannot be parsed" : "Lan-fluxuaren ezarpenen JSON balioa ezin da analizatu", 6 | "OCR file" : "OCR fitxategia", 7 | "OCR processing via workflow" : "OCR prozesatzea lan-fluxuaren bidez", 8 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Aplikazio honek OCR algoritmoen bidez hainbat fitxategi prozesatzeko aukera ematen du.\nProzesatzea workflow-motor bidez egiten da eta, beraz, erraz pertsonaliza daiteke.\nKontuan izan OcrMyPDF CLI zure Nextcloud zerbitzarian instalatu beharko duzula\nPDF fitxategiak prozesatu. Instalatzeko argibide gehiago https://github.com/R0Wi/workflow_ocr/blob/master/README.md dokumentuetan aurki daitezke.", 9 | "Other settings" : "Beste ezarpen batzuk" 10 | }, 11 | "nplurals=2; plural=(n != 1);"); 12 | -------------------------------------------------------------------------------- /l10n/eu.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Lan-fluxua OCR", 3 | "Workflow settings JSON value cannot be parsed" : "Lan-fluxuaren ezarpenen JSON balioa ezin da analizatu", 4 | "OCR file" : "OCR fitxategia", 5 | "OCR processing via workflow" : "OCR prozesatzea lan-fluxuaren bidez", 6 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Aplikazio honek OCR algoritmoen bidez hainbat fitxategi prozesatzeko aukera ematen du.\nProzesatzea workflow-motor bidez egiten da eta, beraz, erraz pertsonaliza daiteke.\nKontuan izan OcrMyPDF CLI zure Nextcloud zerbitzarian instalatu beharko duzula\nPDF fitxategiak prozesatu. Instalatzeko argibide gehiago https://github.com/R0Wi/workflow_ocr/blob/master/README.md dokumentuetan aurki daitezke.", 7 | "Other settings" : "Beste ezarpen batzuk" 8 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 9 | } -------------------------------------------------------------------------------- /l10n/fa.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Workflow OCR", 5 | "Workflow OCR error" : "Workflow OCR error", 6 | "Workflow OCR error for file {file}" : "Workflow OCR error for file {file}", 7 | "Workflow settings JSON value cannot be parsed" : "Workflow settings JSON value cannot be parsed", 8 | "OCR file" : "OCR file", 9 | "OCR processing via workflow" : "OCR processing via workflow", 10 | "Server side OCR processing via workflow engine" : "Server side OCR processing via workflow engine", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 12 | "Other settings" : "Other settings" 13 | }, 14 | "nplurals=2; plural=(n > 1);"); 15 | -------------------------------------------------------------------------------- /l10n/fa.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Workflow OCR", 3 | "Workflow OCR error" : "Workflow OCR error", 4 | "Workflow OCR error for file {file}" : "Workflow OCR error for file {file}", 5 | "Workflow settings JSON value cannot be parsed" : "Workflow settings JSON value cannot be parsed", 6 | "OCR file" : "OCR file", 7 | "OCR processing via workflow" : "OCR processing via workflow", 8 | "Server side OCR processing via workflow engine" : "Server side OCR processing via workflow engine", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Other settings" : "Other settings" 11 | },"pluralForm" :"nplurals=2; plural=(n > 1);" 12 | } -------------------------------------------------------------------------------- /l10n/fi.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Other settings" : "Muut asetukset", 5 | "Remove background" : "Poista taustakuva" 6 | }, 7 | "nplurals=2; plural=(n != 1);"); 8 | -------------------------------------------------------------------------------- /l10n/fi.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Other settings" : "Muut asetukset", 3 | "Remove background" : "Poista taustakuva" 4 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 5 | } -------------------------------------------------------------------------------- /l10n/fr.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Flux de travail ROC", 5 | "Workflow OCR error" : "Erreur de flux de travail ROC", 6 | "Workflow OCR error for file {file}" : "Erreur de flux de travail ROC pour le fichier {file}", 7 | "Workflow settings JSON value cannot be parsed" : "Impossible d'analyser la valeur JSON des paramètres de flux de travail", 8 | "OCR file" : "Fichier ROC", 9 | "OCR processing via workflow" : "Traitement ROC par flux de travail", 10 | "Server side OCR processing via workflow engine" : "Traitement ROC côté serveur via le moteur de flux de travail", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Cette application permet de traiter divers fichiers via des algorithmes de ROC (Reconnaissance Optique de Caractères).\n\tLe traitement est fait via moteur de flux de travail et peut donc facilement être personnalisé.\n\tVeuillez noter que vous devrez installer l'outil en ligne de commande OcrMyPDF sur votre serveur Nextcloud pour\n\ttraiter les fichiers PDF. Davantage d'informations concernant l'installation sont disponibles dans la documentation sur https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 12 | "Select language(s)" : "Sélectionner la ou les langue(s)", 13 | "OCR language" : "Langue d'OCR", 14 | "The language(s) to be used for OCR processing" : "La(les) langue(s) à utiliser pendant le traitement OCR", 15 | "Assign tags after OCR" : "Associer des étiquettes après l'OCR", 16 | "These tags will be assigned to the file after OCR processing has finished" : "Ces étiquettes seront associées au fichier après que le traitement OCR aura fini", 17 | "Remove tags after OCR" : "Supprimer les étiquettes après l'OCR", 18 | "These tags will be removed from the file after OCR processing has finished" : "Ces étiquettes seront supprimées du fichier après que le traitement OCR aura fini", 19 | "OCR mode" : "Mode OCR", 20 | "Apply this mode if file already has OCR content" : "Appliquer ce mode si le fichier a déjà du contenu OCR", 21 | "Skip text" : "Ignorer le texte", 22 | "Redo OCR" : "Refaire l'OCR", 23 | "Force OCR" : "Forcer l'OCR", 24 | "Skip file completely" : "Ignorer complètement le fichier", 25 | "Other settings" : "Autres paramètres", 26 | "Remove background" : "Retirer l'arrière-plan", 27 | "Keep original file version" : "Garder la version originale du fichier" 28 | }, 29 | "nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); 30 | -------------------------------------------------------------------------------- /l10n/fr.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Flux de travail ROC", 3 | "Workflow OCR error" : "Erreur de flux de travail ROC", 4 | "Workflow OCR error for file {file}" : "Erreur de flux de travail ROC pour le fichier {file}", 5 | "Workflow settings JSON value cannot be parsed" : "Impossible d'analyser la valeur JSON des paramètres de flux de travail", 6 | "OCR file" : "Fichier ROC", 7 | "OCR processing via workflow" : "Traitement ROC par flux de travail", 8 | "Server side OCR processing via workflow engine" : "Traitement ROC côté serveur via le moteur de flux de travail", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Cette application permet de traiter divers fichiers via des algorithmes de ROC (Reconnaissance Optique de Caractères).\n\tLe traitement est fait via moteur de flux de travail et peut donc facilement être personnalisé.\n\tVeuillez noter que vous devrez installer l'outil en ligne de commande OcrMyPDF sur votre serveur Nextcloud pour\n\ttraiter les fichiers PDF. Davantage d'informations concernant l'installation sont disponibles dans la documentation sur https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Select language(s)" : "Sélectionner la ou les langue(s)", 11 | "OCR language" : "Langue d'OCR", 12 | "The language(s) to be used for OCR processing" : "La(les) langue(s) à utiliser pendant le traitement OCR", 13 | "Assign tags after OCR" : "Associer des étiquettes après l'OCR", 14 | "These tags will be assigned to the file after OCR processing has finished" : "Ces étiquettes seront associées au fichier après que le traitement OCR aura fini", 15 | "Remove tags after OCR" : "Supprimer les étiquettes après l'OCR", 16 | "These tags will be removed from the file after OCR processing has finished" : "Ces étiquettes seront supprimées du fichier après que le traitement OCR aura fini", 17 | "OCR mode" : "Mode OCR", 18 | "Apply this mode if file already has OCR content" : "Appliquer ce mode si le fichier a déjà du contenu OCR", 19 | "Skip text" : "Ignorer le texte", 20 | "Redo OCR" : "Refaire l'OCR", 21 | "Force OCR" : "Forcer l'OCR", 22 | "Skip file completely" : "Ignorer complètement le fichier", 23 | "Other settings" : "Autres paramètres", 24 | "Remove background" : "Retirer l'arrière-plan", 25 | "Keep original file version" : "Garder la version originale du fichier" 26 | },"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" 27 | } -------------------------------------------------------------------------------- /l10n/hu.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Munkafolyamat OCR", 5 | "Workflow OCR error" : "Munkafolyamat OCR hiba", 6 | "Workflow OCR error for file {file}" : "OCR munkafolyamat hiba a következő fájlon: {file}", 7 | "Workflow settings JSON value cannot be parsed" : "A munkafolyamat-beállítások JSON-értéke nem dolgozható fel", 8 | "OCR file" : "OCR-fájl", 9 | "OCR processing via workflow" : "ORC-feldolgozás munkafolyamattal", 10 | "Server side OCR processing via workflow engine" : "Kiszolgálóoldali OCR-feldolgozás a munkafolyamat-motorral", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Az alkalmazás lehetővé teszi különböző fájlok OCR algoritmussal történő feldolgozását.\n\tA feldolgozást a munkafolyamat-motor végzi, így könnyen testreszabható.\n\tNe feledje, hogy a PDF-fájlok feldolgozásához telepítenie kell az\n\tOcrMyPDF CLI-t a Nextcloud-kiszolgálóra. További telepítési utasítások találhatók a dokumentációban: https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 12 | "Other settings" : "Egyéb beállítások", 13 | "Remove background" : "Háttér eltávolítása" 14 | }, 15 | "nplurals=2; plural=(n != 1);"); 16 | -------------------------------------------------------------------------------- /l10n/hu.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Munkafolyamat OCR", 3 | "Workflow OCR error" : "Munkafolyamat OCR hiba", 4 | "Workflow OCR error for file {file}" : "OCR munkafolyamat hiba a következő fájlon: {file}", 5 | "Workflow settings JSON value cannot be parsed" : "A munkafolyamat-beállítások JSON-értéke nem dolgozható fel", 6 | "OCR file" : "OCR-fájl", 7 | "OCR processing via workflow" : "ORC-feldolgozás munkafolyamattal", 8 | "Server side OCR processing via workflow engine" : "Kiszolgálóoldali OCR-feldolgozás a munkafolyamat-motorral", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Az alkalmazás lehetővé teszi különböző fájlok OCR algoritmussal történő feldolgozását.\n\tA feldolgozást a munkafolyamat-motor végzi, így könnyen testreszabható.\n\tNe feledje, hogy a PDF-fájlok feldolgozásához telepítenie kell az\n\tOcrMyPDF CLI-t a Nextcloud-kiszolgálóra. További telepítési utasítások találhatók a dokumentációban: https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Other settings" : "Egyéb beállítások", 11 | "Remove background" : "Háttér eltávolítása" 12 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 13 | } -------------------------------------------------------------------------------- /l10n/it.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Other settings" : "Altre impostazioni", 5 | "Remove background" : "Rimuovi sfondo" 6 | }, 7 | "nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"); 8 | -------------------------------------------------------------------------------- /l10n/it.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Other settings" : "Altre impostazioni", 3 | "Remove background" : "Rimuovi sfondo" 4 | },"pluralForm" :"nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;" 5 | } -------------------------------------------------------------------------------- /l10n/ja.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow settings JSON value cannot be parsed" : "ワークフロー設定のJSONの値を解析できません。", 5 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "このアプリは、OCRアルゴリズムを使用してさまざまなファイルを処理することができます。\n処理はワークフローエンジンを介して行われるため、簡単に処理内容をカスタマイズすることができます。\nPDFファイルを処理するには、OcrMyPDF CLIをNextcloudサーバーにインストールする必要がありますので、ご注意ください。\n詳しいインストール手順は、ドキュメントで確認できます。https://github.com/R0Wi/workflow_ocr/blob/master/README.md", 6 | "Other settings" : "他の設定" 7 | }, 8 | "nplurals=1; plural=0;"); 9 | -------------------------------------------------------------------------------- /l10n/ja.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow settings JSON value cannot be parsed" : "ワークフロー設定のJSONの値を解析できません。", 3 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "このアプリは、OCRアルゴリズムを使用してさまざまなファイルを処理することができます。\n処理はワークフローエンジンを介して行われるため、簡単に処理内容をカスタマイズすることができます。\nPDFファイルを処理するには、OcrMyPDF CLIをNextcloudサーバーにインストールする必要がありますので、ご注意ください。\n詳しいインストール手順は、ドキュメントで確認できます。https://github.com/R0Wi/workflow_ocr/blob/master/README.md", 4 | "Other settings" : "他の設定" 5 | },"pluralForm" :"nplurals=1; plural=0;" 6 | } -------------------------------------------------------------------------------- /l10n/lt_LT.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Skip text" : "Praleisti tekstą", 5 | "Other settings" : "Kiti nustatymai", 6 | "Remove background" : "Šalinti foną" 7 | }, 8 | "nplurals=4; plural=(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);"); 9 | -------------------------------------------------------------------------------- /l10n/lt_LT.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Skip text" : "Praleisti tekstą", 3 | "Other settings" : "Kiti nustatymai", 4 | "Remove background" : "Šalinti foną" 5 | },"pluralForm" :"nplurals=4; plural=(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);" 6 | } -------------------------------------------------------------------------------- /l10n/nb.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Arbeidsflyt OCR", 5 | "Workflow OCR error" : "Arbeidsflyt OCR-feil", 6 | "Workflow OCR error for file {file}" : "Arbeidsflyt OCR-feil for fil {fil}", 7 | "Workflow settings JSON value cannot be parsed" : "Arbeidsflytinnstillinger JSON-verdi kan ikke analyseres", 8 | "OCR file" : "OCR-fil", 9 | "OCR processing via workflow" : "OCR-behandling via arbeidsflyt", 10 | "Server side OCR processing via workflow engine" : "OCR-behandling på serversiden via arbeidsflytmotor", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Denne appen gjør det mulig å behandle ulike filer via OCR-algoritmer.\nBehandlingen gjøres via workflow-motor og kan derfor enkelt tilpasses.\nVær oppmerksom på at du må installere OcrMyPDF CLI på din Nextcloud-server for å\nbehandle PDF-filer. Flere installasjonsinstruksjoner finner du i dokumentene https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 12 | "Other settings" : "Andre innstillinger" 13 | }, 14 | "nplurals=2; plural=(n != 1);"); 15 | -------------------------------------------------------------------------------- /l10n/nb.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Arbeidsflyt OCR", 3 | "Workflow OCR error" : "Arbeidsflyt OCR-feil", 4 | "Workflow OCR error for file {file}" : "Arbeidsflyt OCR-feil for fil {fil}", 5 | "Workflow settings JSON value cannot be parsed" : "Arbeidsflytinnstillinger JSON-verdi kan ikke analyseres", 6 | "OCR file" : "OCR-fil", 7 | "OCR processing via workflow" : "OCR-behandling via arbeidsflyt", 8 | "Server side OCR processing via workflow engine" : "OCR-behandling på serversiden via arbeidsflytmotor", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Denne appen gjør det mulig å behandle ulike filer via OCR-algoritmer.\nBehandlingen gjøres via workflow-motor og kan derfor enkelt tilpasses.\nVær oppmerksom på at du må installere OcrMyPDF CLI på din Nextcloud-server for å\nbehandle PDF-filer. Flere installasjonsinstruksjoner finner du i dokumentene https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Other settings" : "Andre innstillinger" 11 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 12 | } -------------------------------------------------------------------------------- /l10n/pl.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Other settings" : "Ustawienia pozostałe", 5 | "Remove background" : "Usuń tło" 6 | }, 7 | "nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);"); 8 | -------------------------------------------------------------------------------- /l10n/pl.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Other settings" : "Ustawienia pozostałe", 3 | "Remove background" : "Usuń tło" 4 | },"pluralForm" :"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);" 5 | } -------------------------------------------------------------------------------- /l10n/sl.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Other settings" : "Druge nastavitve", 5 | "Remove background" : "Odstrani ozadje" 6 | }, 7 | "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);"); 8 | -------------------------------------------------------------------------------- /l10n/sl.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Other settings" : "Druge nastavitve", 3 | "Remove background" : "Odstrani ozadje" 4 | },"pluralForm" :"nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);" 5 | } -------------------------------------------------------------------------------- /l10n/sv.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "OCR-arbetsflöde", 5 | "Workflow settings JSON value cannot be parsed" : "JSON-värde för Workflow-inställningar förstås inte", 6 | "OCR file" : "OCR-fil", 7 | "OCR processing via workflow" : "OCR-inläsning via workflow", 8 | "Server side OCR processing via workflow engine" : "OCR-behandling på serversidan via arbetsflödesmotor", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Appen gör det möjligt att processa olika filer via OCR-algoritmer.\n\tProcessen sker via en arbetsflödesmotor och kan enkelt anpassas.\n\tNotera att OcrMyPDF CLI behöver installeras på din Nextcloud server to\n\tför att processa PDF filer. Mer instruktioner finns i dokumentationen på länken https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 10 | "Other settings" : "Andra inställningar", 11 | "Remove background" : "Ta bort bakgrund" 12 | }, 13 | "nplurals=2; plural=(n != 1);"); 14 | -------------------------------------------------------------------------------- /l10n/sv.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "OCR-arbetsflöde", 3 | "Workflow settings JSON value cannot be parsed" : "JSON-värde för Workflow-inställningar förstås inte", 4 | "OCR file" : "OCR-fil", 5 | "OCR processing via workflow" : "OCR-inläsning via workflow", 6 | "Server side OCR processing via workflow engine" : "OCR-behandling på serversidan via arbetsflödesmotor", 7 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "Appen gör det möjligt att processa olika filer via OCR-algoritmer.\n\tProcessen sker via en arbetsflödesmotor och kan enkelt anpassas.\n\tNotera att OcrMyPDF CLI behöver installeras på din Nextcloud server to\n\tför att processa PDF filer. Mer instruktioner finns i dokumentationen på länken https://github.com/R0Wi/workflow_ocr/blob/master/README.md.", 8 | "Other settings" : "Andra inställningar", 9 | "Remove background" : "Ta bort bakgrund" 10 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 11 | } -------------------------------------------------------------------------------- /l10n/ug.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "خىزمەت ئېقىمى OCR", 5 | "Workflow OCR error" : "خىزمەت ئېقىمى OCR خاتالىقى", 6 | "Workflow OCR error for file {file}" : "ھۆججەت {file} نىڭ خىزمەت ئېقىمى OCR خاتالىقى", 7 | "Workflow settings JSON value cannot be parsed" : "خىزمەت ئېقىمى تەڭشەكلىرى JSON قىممىتىنى تەھلىل قىلىشقا بولمايدۇ", 8 | "OCR file" : "OCR ھۆججىتى", 9 | "OCR processing via workflow" : "خىزمەت ئېقىمى ئارقىلىق OCR بىر تەرەپ قىلىش", 10 | "Server side OCR processing via workflow engine" : "خىزمەت ئېقىمى ماتورى ئارقىلىق مۇلازىمېتىر تەرەپ OCR بىر تەرەپ قىلىش", 11 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "بۇ ئەپ OCR ھېسابلاش ئۇسۇلى ئارقىلىق ھەر خىل ھۆججەتلەرنى بىر تەرەپ قىلالايدۇ.\n\tبىر تەرەپ قىلىش خىزمەت ئېقىمى ماتورى ئارقىلىق ئېلىپ بېرىلىدۇ ، شۇڭا ئاسانلا خاسلاشتۇرغىلى بولىدۇ.\n\tشۇنىڭغا دىققەت قىلىڭكى ، Nextcloud مۇلازىمېتىرىڭىزغا OcrMyPDF CLI نى ئورنىتىشىڭىز كېرەك\n\tPDF ھۆججىتىنى بىر تەرەپ قىلىڭ. تېخىمۇ كۆپ قاچىلاش كۆرسەتمىسىنى https://github.com/R0Wi/workflow_ocr/blob/master/README.md دىن تاپالايسىز.", 12 | "Other settings" : "باشقا تەڭشەكلەر" 13 | }, 14 | "nplurals=2; plural=(n != 1);"); 15 | -------------------------------------------------------------------------------- /l10n/ug.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "خىزمەت ئېقىمى OCR", 3 | "Workflow OCR error" : "خىزمەت ئېقىمى OCR خاتالىقى", 4 | "Workflow OCR error for file {file}" : "ھۆججەت {file} نىڭ خىزمەت ئېقىمى OCR خاتالىقى", 5 | "Workflow settings JSON value cannot be parsed" : "خىزمەت ئېقىمى تەڭشەكلىرى JSON قىممىتىنى تەھلىل قىلىشقا بولمايدۇ", 6 | "OCR file" : "OCR ھۆججىتى", 7 | "OCR processing via workflow" : "خىزمەت ئېقىمى ئارقىلىق OCR بىر تەرەپ قىلىش", 8 | "Server side OCR processing via workflow engine" : "خىزمەت ئېقىمى ماتورى ئارقىلىق مۇلازىمېتىر تەرەپ OCR بىر تەرەپ قىلىش", 9 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "بۇ ئەپ OCR ھېسابلاش ئۇسۇلى ئارقىلىق ھەر خىل ھۆججەتلەرنى بىر تەرەپ قىلالايدۇ.\n\tبىر تەرەپ قىلىش خىزمەت ئېقىمى ماتورى ئارقىلىق ئېلىپ بېرىلىدۇ ، شۇڭا ئاسانلا خاسلاشتۇرغىلى بولىدۇ.\n\tشۇنىڭغا دىققەت قىلىڭكى ، Nextcloud مۇلازىمېتىرىڭىزغا OcrMyPDF CLI نى ئورنىتىشىڭىز كېرەك\n\tPDF ھۆججىتىنى بىر تەرەپ قىلىڭ. تېخىمۇ كۆپ قاچىلاش كۆرسەتمىسىنى https://github.com/R0Wi/workflow_ocr/blob/master/README.md دىن تاپالايسىز.", 10 | "Other settings" : "باشقا تەڭشەكلەر" 11 | },"pluralForm" :"nplurals=2; plural=(n != 1);" 12 | } -------------------------------------------------------------------------------- /l10n/uk.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "Процес оптичного розпізнавання тексту", 5 | "Workflow OCR error" : "Помилка під час виконання процесу оптичного розпізнавання", 6 | "Workflow OCR error for file {file}" : "Помилка під час виконання процесу оптичного розпізнавання файлу {file}", 7 | "Workflow settings JSON value cannot be parsed" : "Не вдалося обробити значеня JSCON налаштування процесу", 8 | "OCR file" : "Файл оптичного розпізнавання", 9 | "OCR processing via workflow" : "Оптичне розпізнавання тексту через процес", 10 | "Server side OCR processing via workflow engine" : "Оптичне розпізнавання на стороні сервера через налаштовані процеси", 11 | "Remove background" : "Вилучити тло" 12 | }, 13 | "nplurals=4; plural=(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);"); 14 | -------------------------------------------------------------------------------- /l10n/uk.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "Процес оптичного розпізнавання тексту", 3 | "Workflow OCR error" : "Помилка під час виконання процесу оптичного розпізнавання", 4 | "Workflow OCR error for file {file}" : "Помилка під час виконання процесу оптичного розпізнавання файлу {file}", 5 | "Workflow settings JSON value cannot be parsed" : "Не вдалося обробити значеня JSCON налаштування процесу", 6 | "OCR file" : "Файл оптичного розпізнавання", 7 | "OCR processing via workflow" : "Оптичне розпізнавання тексту через процес", 8 | "Server side OCR processing via workflow engine" : "Оптичне розпізнавання на стороні сервера через налаштовані процеси", 9 | "Remove background" : "Вилучити тло" 10 | },"pluralForm" :"nplurals=4; plural=(n % 1 == 0 && n % 10 == 1 && n % 100 != 11 ? 0 : n % 1 == 0 && n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14) ? 1 : n % 1 == 0 && (n % 10 ==0 || (n % 10 >=5 && n % 10 <=9) || (n % 100 >=11 && n % 100 <=14 )) ? 2: 3);" 11 | } -------------------------------------------------------------------------------- /l10n/zh_CN.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow settings JSON value cannot be parsed" : "无法解析工作流设置的JSON值", 5 | "OCR file" : "OCR文件", 6 | "Other settings" : "其他设置" 7 | }, 8 | "nplurals=1; plural=0;"); 9 | -------------------------------------------------------------------------------- /l10n/zh_CN.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow settings JSON value cannot be parsed" : "无法解析工作流设置的JSON值", 3 | "OCR file" : "OCR文件", 4 | "Other settings" : "其他设置" 5 | },"pluralForm" :"nplurals=1; plural=0;" 6 | } -------------------------------------------------------------------------------- /l10n/zh_HK.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "OCR 工作流程", 5 | "Workflow OCR error" : "OCR 工作流程錯誤", 6 | "Workflow OCR error for file {file}" : "檔案 {file} 的工作流程 OCR 錯誤", 7 | "Workflow OCR success" : "OCR 工作流程成功", 8 | "Workflow OCR success for file {file}" : "檔案 {file} 的 OCR 工作流程成功", 9 | "Workflow settings JSON value cannot be parsed" : "無法分析工作流程設置 JSON 值", 10 | "OCR file" : "OCR 檔案", 11 | "OCR processing via workflow" : "通過工作流程進行 OCR 處理", 12 | "Is OCRmyPDF installed" : "OCRmyPDF 是否已安裝", 13 | "Workflow OCR Backend is installed." : "工作流程 OCR 後端已安裝。", 14 | "Workflow OCR Backend is installed but heartbeat failed." : "工作流程 OCR 後端已安裝,但心跳檢查失敗。", 15 | "OCRmyPDF CLI is not installed." : "尚未安裝 OCRmyPDF CLI", 16 | "OCRmyPDF CLI is not working correctly. Error was: %1$s" : "OCRmyPDF CLI 並未正確運作。錯誤為:%1$s", 17 | "OCRmyPDF is installed and has version %1$s." : "OCRmyPDF 已安裝,版本為 %1$s。", 18 | "Server side OCR processing via workflow engine" : "透過工作流程引擎進行伺服器端 OCR 處理", 19 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "此應用程式可以通過 OCR 算法處理各種檔案。\n\t處理是通過工作流程引擎完成的,因此可以輕鬆定制。\n\t請注意,您必須在 Nextcloud 伺服器上安裝 OcrMyPDF CLI 才能處理 PDF 檔案。詳細安裝說明可以在文檔 https://github.com/R0Wi/workflow_ocr/blob/master/README.md 中找到。", 20 | "Select language(s)" : "選取語言", 21 | "OCR language" : "OCR 語言", 22 | "The language(s) to be used for OCR processing" : "OCR 處理所使用的語言", 23 | "Assign tags after OCR" : "在 OCR 後指定標籤", 24 | "These tags will be assigned to the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後指定給檔案", 25 | "Remove tags after OCR" : "在 OCR 後移除標籤", 26 | "These tags will be removed from the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後從檔案中移除", 27 | "OCR mode" : "OCR 模式", 28 | "Apply this mode if file already has OCR content" : "若檔案已有 OCR 內容,則套用此模式", 29 | "Skip text" : "略過文字", 30 | "Redo OCR" : "重做 OCR", 31 | "Force OCR" : "強制 OCR", 32 | "Skip file completely" : "完全跳過檔案", 33 | "Other settings" : "其他設定", 34 | "Remove background" : "移除背景", 35 | "Keep original file version" : "保留原始檔案版本", 36 | "Keep original file modification date" : "保留原先的檔案的修改日期", 37 | "Send success notification" : "傳送成功通知", 38 | "Custom ocrMyPdf CLI arguments" : "自訂 ocrMyPdf CLI 參數" 39 | }, 40 | "nplurals=1; plural=0;"); 41 | -------------------------------------------------------------------------------- /l10n/zh_HK.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "OCR 工作流程", 3 | "Workflow OCR error" : "OCR 工作流程錯誤", 4 | "Workflow OCR error for file {file}" : "檔案 {file} 的工作流程 OCR 錯誤", 5 | "Workflow OCR success" : "OCR 工作流程成功", 6 | "Workflow OCR success for file {file}" : "檔案 {file} 的 OCR 工作流程成功", 7 | "Workflow settings JSON value cannot be parsed" : "無法分析工作流程設置 JSON 值", 8 | "OCR file" : "OCR 檔案", 9 | "OCR processing via workflow" : "通過工作流程進行 OCR 處理", 10 | "Is OCRmyPDF installed" : "OCRmyPDF 是否已安裝", 11 | "Workflow OCR Backend is installed." : "工作流程 OCR 後端已安裝。", 12 | "Workflow OCR Backend is installed but heartbeat failed." : "工作流程 OCR 後端已安裝,但心跳檢查失敗。", 13 | "OCRmyPDF CLI is not installed." : "尚未安裝 OCRmyPDF CLI", 14 | "OCRmyPDF CLI is not working correctly. Error was: %1$s" : "OCRmyPDF CLI 並未正確運作。錯誤為:%1$s", 15 | "OCRmyPDF is installed and has version %1$s." : "OCRmyPDF 已安裝,版本為 %1$s。", 16 | "Server side OCR processing via workflow engine" : "透過工作流程引擎進行伺服器端 OCR 處理", 17 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "此應用程式可以通過 OCR 算法處理各種檔案。\n\t處理是通過工作流程引擎完成的,因此可以輕鬆定制。\n\t請注意,您必須在 Nextcloud 伺服器上安裝 OcrMyPDF CLI 才能處理 PDF 檔案。詳細安裝說明可以在文檔 https://github.com/R0Wi/workflow_ocr/blob/master/README.md 中找到。", 18 | "Select language(s)" : "選取語言", 19 | "OCR language" : "OCR 語言", 20 | "The language(s) to be used for OCR processing" : "OCR 處理所使用的語言", 21 | "Assign tags after OCR" : "在 OCR 後指定標籤", 22 | "These tags will be assigned to the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後指定給檔案", 23 | "Remove tags after OCR" : "在 OCR 後移除標籤", 24 | "These tags will be removed from the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後從檔案中移除", 25 | "OCR mode" : "OCR 模式", 26 | "Apply this mode if file already has OCR content" : "若檔案已有 OCR 內容,則套用此模式", 27 | "Skip text" : "略過文字", 28 | "Redo OCR" : "重做 OCR", 29 | "Force OCR" : "強制 OCR", 30 | "Skip file completely" : "完全跳過檔案", 31 | "Other settings" : "其他設定", 32 | "Remove background" : "移除背景", 33 | "Keep original file version" : "保留原始檔案版本", 34 | "Keep original file modification date" : "保留原先的檔案的修改日期", 35 | "Send success notification" : "傳送成功通知", 36 | "Custom ocrMyPdf CLI arguments" : "自訂 ocrMyPdf CLI 參數" 37 | },"pluralForm" :"nplurals=1; plural=0;" 38 | } -------------------------------------------------------------------------------- /l10n/zh_TW.js: -------------------------------------------------------------------------------- 1 | OC.L10N.register( 2 | "workflow_ocr", 3 | { 4 | "Workflow OCR" : "OCR 工作流程", 5 | "Workflow OCR error" : "OCR 工作流程錯誤", 6 | "Workflow OCR error for file {file}" : "檔案 {file} 的 OCR 工作流程錯誤", 7 | "Workflow OCR success" : "OCR 工作流程成功", 8 | "Workflow OCR success for file {file}" : "檔案 {file} 的 OCR 工作流程成功", 9 | "Workflow settings JSON value cannot be parsed" : "無法分析工作流程設定的 JSON 值", 10 | "OCR file" : "OCR 檔案", 11 | "OCR processing via workflow" : "透過工作流程進行 OCR 處理", 12 | "Is OCRmyPDF installed" : "OCRmyPDF 是否已安裝", 13 | "Workflow OCR Backend is installed." : "已安裝 Workflow OCR 後端。", 14 | "Workflow OCR Backend is installed but heartbeat failed." : "已安裝 Workflow OCR 後端,但心跳檢查失敗。", 15 | "OCRmyPDF CLI is not installed." : "尚未安裝 OCRmyPDF CLI", 16 | "OCRmyPDF CLI is not working correctly. Error was: %1$s" : "OCRmyPDF CLI 並未正確運作。錯誤為:%1$s", 17 | "OCRmyPDF is installed and has version %1$s." : "OCRmyPDF 已安裝,版本為 %1$s。", 18 | "Server side OCR processing via workflow engine" : "透過工作引擎進行伺服器端 OCR 處理", 19 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "此應用程式可以透過 OCR 演算法處理各種檔案。\n\t處理是透過工作流程引擎完成的,因此可以很容易地自訂。\n\t請注意,您必須在 Nextcloud 伺服器上安裝 OcrMyPDF CLI 才能\n\t處理 PDF 檔案。詳細安裝說明可以在文件 https://github.com/R0Wi/workflow_ocr/blob/master/README.md 中找到。", 20 | "Select language(s)" : "選取語言", 21 | "OCR language" : "OCR 語言", 22 | "The language(s) to be used for OCR processing" : "OCR 處理所使用的語言", 23 | "Assign tags after OCR" : "在 OCR 後指定標籤", 24 | "These tags will be assigned to the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後指定給檔案", 25 | "Remove tags after OCR" : "在 OCR 後移除標籤", 26 | "These tags will be removed from the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後從檔案中移除", 27 | "OCR mode" : "OCR 模式", 28 | "Apply this mode if file already has OCR content" : "若檔案已有 OCR 內容,則套用此模式", 29 | "Skip text" : "略過文字", 30 | "Redo OCR" : "重作 OCR", 31 | "Force OCR" : "強制 OCR", 32 | "Skip file completely" : "完全跳過檔案", 33 | "Other settings" : "其他設定", 34 | "Remove background" : "移除背景", 35 | "Keep original file version" : "保留原始檔案版本", 36 | "Keep original file modification date" : "保留原始檔案修改日期", 37 | "Send success notification" : "傳送成功通知", 38 | "Custom ocrMyPdf CLI arguments" : "自訂 ocrMyPdf CLI 引數" 39 | }, 40 | "nplurals=1; plural=0;"); 41 | -------------------------------------------------------------------------------- /l10n/zh_TW.json: -------------------------------------------------------------------------------- 1 | { "translations": { 2 | "Workflow OCR" : "OCR 工作流程", 3 | "Workflow OCR error" : "OCR 工作流程錯誤", 4 | "Workflow OCR error for file {file}" : "檔案 {file} 的 OCR 工作流程錯誤", 5 | "Workflow OCR success" : "OCR 工作流程成功", 6 | "Workflow OCR success for file {file}" : "檔案 {file} 的 OCR 工作流程成功", 7 | "Workflow settings JSON value cannot be parsed" : "無法分析工作流程設定的 JSON 值", 8 | "OCR file" : "OCR 檔案", 9 | "OCR processing via workflow" : "透過工作流程進行 OCR 處理", 10 | "Is OCRmyPDF installed" : "OCRmyPDF 是否已安裝", 11 | "Workflow OCR Backend is installed." : "已安裝 Workflow OCR 後端。", 12 | "Workflow OCR Backend is installed but heartbeat failed." : "已安裝 Workflow OCR 後端,但心跳檢查失敗。", 13 | "OCRmyPDF CLI is not installed." : "尚未安裝 OCRmyPDF CLI", 14 | "OCRmyPDF CLI is not working correctly. Error was: %1$s" : "OCRmyPDF CLI 並未正確運作。錯誤為:%1$s", 15 | "OCRmyPDF is installed and has version %1$s." : "OCRmyPDF 已安裝,版本為 %1$s。", 16 | "Server side OCR processing via workflow engine" : "透過工作引擎進行伺服器端 OCR 處理", 17 | "This app makes it possible to process various files via OCR algorithms.\n\tThe processing is done via workflow-engine and can therefore easily be customized.\n\tPlease note that you'll have to install the OcrMyPDF CLI on your Nextcloud server to\n\tprocess PDF files. More installation instructions can be found in the docs https://github.com/R0Wi/workflow_ocr/blob/master/README.md." : "此應用程式可以透過 OCR 演算法處理各種檔案。\n\t處理是透過工作流程引擎完成的,因此可以很容易地自訂。\n\t請注意,您必須在 Nextcloud 伺服器上安裝 OcrMyPDF CLI 才能\n\t處理 PDF 檔案。詳細安裝說明可以在文件 https://github.com/R0Wi/workflow_ocr/blob/master/README.md 中找到。", 18 | "Select language(s)" : "選取語言", 19 | "OCR language" : "OCR 語言", 20 | "The language(s) to be used for OCR processing" : "OCR 處理所使用的語言", 21 | "Assign tags after OCR" : "在 OCR 後指定標籤", 22 | "These tags will be assigned to the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後指定給檔案", 23 | "Remove tags after OCR" : "在 OCR 後移除標籤", 24 | "These tags will be removed from the file after OCR processing has finished" : "這些標籤會在 OCR 處理完成後從檔案中移除", 25 | "OCR mode" : "OCR 模式", 26 | "Apply this mode if file already has OCR content" : "若檔案已有 OCR 內容,則套用此模式", 27 | "Skip text" : "略過文字", 28 | "Redo OCR" : "重作 OCR", 29 | "Force OCR" : "強制 OCR", 30 | "Skip file completely" : "完全跳過檔案", 31 | "Other settings" : "其他設定", 32 | "Remove background" : "移除背景", 33 | "Keep original file version" : "保留原始檔案版本", 34 | "Keep original file modification date" : "保留原始檔案修改日期", 35 | "Send success notification" : "傳送成功通知", 36 | "Custom ocrMyPdf CLI arguments" : "自訂 ocrMyPdf CLI 引數" 37 | },"pluralForm" :"nplurals=1; plural=0;" 38 | } -------------------------------------------------------------------------------- /lib/BackgroundJobs/ProcessFileJob.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\BackgroundJobs; 28 | 29 | use OCA\WorkflowOcr\Service\IOcrService; 30 | use OCP\AppFramework\Utility\ITimeFactory; 31 | use Psr\Log\LoggerInterface; 32 | 33 | /** 34 | * Represents a QuedJob which processes 35 | * a OCR on a single file. 36 | */ 37 | class ProcessFileJob extends \OCP\BackgroundJob\QueuedJob { 38 | /** @var LoggerInterface */ 39 | protected $logger; 40 | /** @var IOcrService */ 41 | private $ocrService; 42 | 43 | public function __construct( 44 | LoggerInterface $logger, 45 | IOcrService $ocrService, 46 | ITimeFactory $timeFactory) { 47 | parent::__construct($timeFactory); 48 | $this->logger = $logger; 49 | $this->ocrService = $ocrService; 50 | } 51 | 52 | /** 53 | * @param mixed $argument 54 | */ 55 | protected function run($argument) : void { 56 | $this->logger->debug('STARTED -- Run ' . self::class . ' job. Argument: {argument}.', ['argument' => $argument]); 57 | $this->ocrService->runOcrProcessWithJobArgument($argument); 58 | $this->logger->debug('ENDED -- Run ' . self::class . ' job. Argument: {argument}.', ['argument' => $argument]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/Controller/ControllerBase.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Controller; 28 | 29 | use OCP\AppFramework\Controller; 30 | use OCP\AppFramework\Http\JSONResponse; 31 | 32 | abstract class ControllerBase extends Controller { 33 | protected function tryExecute(callable $function) : JSONResponse { 34 | try { 35 | $result = $function(); 36 | return new JSONResponse($result); 37 | } catch (\Throwable $e) { 38 | return new JSONResponse(['error' => $e->getMessage()], 500); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/Controller/GlobalSettingsController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Controller; 28 | 29 | use OCA\WorkflowOcr\Model\GlobalSettings; 30 | use OCA\WorkflowOcr\Service\IGlobalSettingsService; 31 | use OCP\AppFramework\Http\JSONResponse; 32 | use OCP\IRequest; 33 | 34 | /** 35 | * This is the backend API controller for the Admin.vue component. 36 | */ 37 | class GlobalSettingsController extends ControllerBase { 38 | /** @var IGlobalSettingsService */ 39 | private $globalSettingsService; 40 | 41 | public function __construct($appName, IRequest $request, IGlobalSettingsService $globalSettingsService) { 42 | parent::__construct($appName, $request); 43 | $this->globalSettingsService = $globalSettingsService; 44 | } 45 | 46 | /** 47 | * @return JSONResponse 48 | */ 49 | public function getGlobalSettings() : JSONResponse { 50 | return $this->tryExecute(function () { 51 | return $this->globalSettingsService->getGlobalSettings(); 52 | }); 53 | } 54 | 55 | /** 56 | * @param array $globalSettings to be parsed into a GlobalSettings object 57 | * @return JSONResponse 58 | */ 59 | public function setGlobalSettings(array $globalSettings) : JSONResponse { 60 | return $this->tryExecute(function () use ($globalSettings) { 61 | $globalSettingsObject = new GlobalSettings(); 62 | $globalSettingsObject->processorCount = $globalSettings['processorCount']; 63 | 64 | $this->globalSettingsService->setGlobalSettings($globalSettingsObject); 65 | return $this->globalSettingsService->getGlobalSettings(); 66 | }); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/Controller/OcrBackendInfoController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Controller; 28 | 29 | use OCA\WorkflowOcr\Service\IOcrBackendInfoService; 30 | use OCP\AppFramework\Http\JSONResponse; 31 | use OCP\IRequest; 32 | 33 | /** 34 | * This is the backend API controller which provides informations about the OCR backend system. 35 | */ 36 | class OcrBackendInfoController extends ControllerBase { 37 | /** @var IOcrBackendInfoService */ 38 | private $ocrBackendInfoService; 39 | 40 | public function __construct($appName, IRequest $request, IOcrBackendInfoService $ocrBackendInfoService) { 41 | parent::__construct($appName, $request); 42 | $this->ocrBackendInfoService = $ocrBackendInfoService; 43 | } 44 | 45 | /** 46 | * @NoAdminRequired 47 | * @return JSONResponse 48 | */ 49 | public function getInstalledLanguages() : JSONResponse { 50 | return $this->tryExecute(function () { 51 | return $this->ocrBackendInfoService->getInstalledLanguages(); 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/Events/TextRecognizedEvent.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Events; 25 | 26 | use OCP\EventDispatcher\Event; 27 | use OCP\Files\File; 28 | 29 | /** 30 | * Class TextRecognizedEvent 31 | * 32 | * @package OCA\WorkflowOcr\Events 33 | */ 34 | class TextRecognizedEvent extends Event { 35 | /** @var string */ 36 | private $recognizedText; 37 | 38 | /** @var File */ 39 | private $file; 40 | 41 | 42 | /** 43 | * TextRecognizedEvent constructor. 44 | */ 45 | public function __construct(string $recognizedText, File $file) { 46 | parent::__construct(); 47 | 48 | $this->recognizedText = $recognizedText; 49 | $this->file = $file; 50 | } 51 | 52 | /** 53 | * @return string $recognizedText 54 | */ 55 | public function getRecognizedText(): string { 56 | return $this->recognizedText; 57 | } 58 | 59 | /** 60 | * @return File $file 61 | */ 62 | public function getFile(): File { 63 | return $this->file; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/Exception/CommandException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Exception; 25 | 26 | use Exception; 27 | 28 | class CommandException extends Exception { 29 | public function __construct(string $message, string $command) { 30 | $this->message = "The command '$command' produced an error: $message"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/Exception/OcrAlreadyDoneException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Exception; 25 | 26 | use Exception; 27 | 28 | class OcrAlreadyDoneException extends Exception { 29 | public function __construct(string $message) { 30 | $this->message = $message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/Exception/OcrNotPossibleException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Exception; 25 | 26 | use Exception; 27 | 28 | class OcrNotPossibleException extends Exception { 29 | public function __construct(string $message) { 30 | $this->message = $message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/Exception/OcrProcessorNotFoundException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Exception; 25 | 26 | use Exception; 27 | 28 | class OcrProcessorNotFoundException extends Exception { 29 | public function __construct(string $mimeType, bool $useRemoteBackend) { 30 | $this->message = 'OCR processor for mime type ' . $mimeType . '(useRemoteBackend=' . $useRemoteBackend . ') not found'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/Exception/OcrResultEmptyException.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Exception; 25 | 26 | use Exception; 27 | 28 | class OcrResultEmptyException extends Exception { 29 | public function __construct(string $message) { 30 | $this->message = $message; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/Helper/IProcessingFileAccessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Helper; 25 | 26 | interface IProcessingFileAccessor { 27 | /** 28 | * Returns the path of the file which is currently 29 | * processed via OCR 30 | * @return ?string 31 | */ 32 | public function getCurrentlyProcessedFilePath() : ?string; 33 | 34 | /** 35 | * Sets the path of the file which is currently 36 | * processed via OCR 37 | */ 38 | public function setCurrentlyProcessedFilePath(?string $filePath) : void; 39 | } 40 | -------------------------------------------------------------------------------- /lib/Helper/ISidecarFileAccessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Helper; 25 | 26 | interface ISidecarFileAccessor { 27 | /** 28 | * Creates a new temporary sidecar file for OCR text content. 29 | * If a file was already created, the path to the existing file is returned. 30 | * 31 | * @return string|bool Path to the sidecar file or false if the file could not be created 32 | */ 33 | public function getOrCreateSidecarFile(); 34 | 35 | /** 36 | * Gets the content of the created sidecar file. File has to be created 37 | * before calling this method. 38 | */ 39 | public function getSidecarFileContent(): string; 40 | } 41 | -------------------------------------------------------------------------------- /lib/Helper/ProcessingFileAccessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Helper; 25 | 26 | /** 27 | * This class is a singleton which holds the path 28 | * of the currently OCR processed file. This ensures 29 | * that a files is not added to the processing queue 30 | * if the 'postWrite' hook was triggered by a new 31 | * version created by the OCR process. 32 | */ 33 | class ProcessingFileAccessor implements IProcessingFileAccessor { 34 | /** @var ?string */ 35 | private $currentlyProcessedFilePath; 36 | 37 | /** @var ProcessingFileAccessor */ 38 | private static $instance; 39 | public static function getInstance() : ProcessingFileAccessor { 40 | if (self::$instance === null) { 41 | self::$instance = new ProcessingFileAccessor(); 42 | } 43 | return self::$instance; 44 | } 45 | 46 | private function __construct() { 47 | // Just ensuring singleton instance ... 48 | } 49 | 50 | /** 51 | * @inheritdoc 52 | */ 53 | public function getCurrentlyProcessedFilePath() : ?string { 54 | return $this->currentlyProcessedFilePath; 55 | } 56 | 57 | /** 58 | * @inheritdoc 59 | */ 60 | public function setCurrentlyProcessedFilePath(?string $filePath) : void { 61 | $this->currentlyProcessedFilePath = $filePath; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/Helper/SidecarFileAccessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Helper; 25 | 26 | use OCP\ITempManager; 27 | use Psr\Log\LoggerInterface; 28 | 29 | class SidecarFileAccessor implements ISidecarFileAccessor { 30 | /** @var ITempManager */ 31 | private $tempManager; 32 | 33 | /** @var LoggerInterface */ 34 | private $logger; 35 | 36 | /** @var string */ 37 | private $sidecarFilePath; 38 | 39 | public function __construct(ITempManager $tempManager, LoggerInterface $logger) { 40 | $this->tempManager = $tempManager; 41 | $this->logger = $logger; 42 | } 43 | 44 | /** 45 | * {@inheritdoc} 46 | */ 47 | public function getOrCreateSidecarFile() { 48 | if ($this->sidecarFilePath === null) { 49 | $this->sidecarFilePath = $this->tempManager->getTemporaryFile('sidecar'); 50 | if (!$this->sidecarFilePath) { 51 | $this->logger->warning('Could not create temporary sidecar file'); 52 | } elseif (!is_writable($this->sidecarFilePath)) { 53 | $this->logger->warning('Temporary sidecar file is not writable'); 54 | } 55 | } 56 | return $this->sidecarFilePath; 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | public function getSidecarFileContent(): string { 63 | return $this->sidecarFilePath ? file_get_contents($this->sidecarFilePath) : ''; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/Listener/RegisterFlowOperationsListener.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Listener; 25 | 26 | use OCA\WorkflowOcr\AppInfo\Application; 27 | use OCA\WorkflowOcr\Operation; 28 | use OCP\EventDispatcher\Event; 29 | use OCP\EventDispatcher\IEventListener; 30 | use OCP\Util; 31 | use OCP\WorkflowEngine\Events\RegisterOperationsEvent; 32 | use Psr\Container\ContainerInterface; 33 | 34 | /** 35 | * @template-implements IEventListener 36 | */ 37 | class RegisterFlowOperationsListener implements IEventListener { 38 | /** @var ContainerInterface */ 39 | private $container; 40 | 41 | public function __construct(ContainerInterface $container) { 42 | $this->container = $container; 43 | } 44 | 45 | public function handle(Event $event): void { 46 | if (!$event instanceof RegisterOperationsEvent) { 47 | return; 48 | } 49 | 50 | // Register workflow operation main class 51 | $event->registerOperation($this->container->get(Operation::class)); 52 | 53 | // Register webpack bundled script 'js/workflow_ocr-main.js' 54 | Util::addScript(Application::APP_NAME, Application::APP_NAME . '-main'); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/Model/GlobalSettings.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Model; 28 | 29 | class GlobalSettings { 30 | /** @var string? */ 31 | public $processorCount; 32 | } 33 | -------------------------------------------------------------------------------- /lib/OcrProcessors/ICommandLineUtils.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors; 25 | 26 | use OCA\WorkflowOcr\Model\GlobalSettings; 27 | use OCA\WorkflowOcr\Model\WorkflowSettings; 28 | 29 | interface ICommandLineUtils { 30 | public function getCommandlineArgs(WorkflowSettings $settings, GlobalSettings $globalSettings, ?string $sidecarFile = null, array $additionalCommandlineArgs = []): string; 31 | } 32 | -------------------------------------------------------------------------------- /lib/OcrProcessors/IOcrProcessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors; 25 | 26 | use OCA\WorkflowOcr\Exception\OcrNotPossibleException; 27 | use OCA\WorkflowOcr\Model\GlobalSettings; 28 | use OCA\WorkflowOcr\Model\WorkflowSettings; 29 | use OCP\Files\File; 30 | 31 | interface IOcrProcessor { 32 | /** 33 | * Processes OCR on the given file 34 | * @param File $file The file to be processed 35 | * @param WorkflowSettings $settings The settings to be used for this specific workflow 36 | * @param GlobalSettings $globalSettings The global settings configured for all OCR workflows on this system 37 | * @return OcrProcessorResult 38 | * @throws OcrNotPossibleException 39 | */ 40 | public function ocrFile(File $file, WorkflowSettings $settings, GlobalSettings $globalSettings) : OcrProcessorResult; 41 | } 42 | -------------------------------------------------------------------------------- /lib/OcrProcessors/IOcrProcessorFactory.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors; 25 | 26 | interface IOcrProcessorFactory { 27 | /** 28 | * Creates a IOcrProcessor object for the given mimetype 29 | */ 30 | public function create(string $mimeType) : IOcrProcessor; 31 | } 32 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Local/ImageOcrProcessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors\Local; 25 | 26 | use OCA\WorkflowOcr\Model\GlobalSettings; 27 | use OCA\WorkflowOcr\Model\WorkflowSettings; 28 | 29 | class ImageOcrProcessor extends OcrMyPdfBasedProcessor { 30 | protected function getAdditionalCommandlineArgs(WorkflowSettings $settings, GlobalSettings $globalSettings): array { 31 | return ['--image-dpi 300']; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Local/PdfOcrProcessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors\Local; 25 | 26 | class PdfOcrProcessor extends OcrMyPdfBasedProcessor { 27 | } 28 | -------------------------------------------------------------------------------- /lib/OcrProcessors/OcrProcessorResult.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors; 25 | 26 | /** 27 | * Represents a file which was processed via OCR. 28 | */ 29 | class OcrProcessorResult { 30 | /** @var string */ 31 | private $fileContent; 32 | /** @var string */ 33 | private $fileExtension; 34 | /** @var string */ 35 | private $recognizedText; 36 | 37 | 38 | public function __construct(string $fileContent, string $fileExtension, string $recognizedText) { 39 | $this->fileContent = $fileContent; 40 | $this->fileExtension = $fileExtension; 41 | $this->recognizedText = $recognizedText; 42 | } 43 | 44 | public function getFileContent(): string { 45 | return $this->fileContent; 46 | } 47 | 48 | public function getFileExtension(): string { 49 | return $this->fileExtension; 50 | } 51 | 52 | public function getRecognizedText(): string { 53 | return $this->recognizedText; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # Currently we're only generating Models (no API clients) 2 | !Model/ErrorResult.php 3 | !Model/ModelInterface.php 4 | !Model/OcrResult.php 5 | !ObjectSerializer.php 6 | !Configuration.php 7 | *.* 8 | .* 9 | **/* 10 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/.openapi-generator/FILES: -------------------------------------------------------------------------------- 1 | Configuration.php 2 | Model/ErrorResult.php 3 | Model/ModelInterface.php 4 | Model/OcrResult.php 5 | ObjectSerializer.php 6 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 7.10.0 2 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/IApiClient.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors\Remote\Client; 25 | 26 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\Model\ErrorResult; 27 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\Model\OcrResult; 28 | 29 | /** 30 | * Remote API supported by Workflow OCR Backend. 31 | */ 32 | interface IApiClient { 33 | /** 34 | * Process OCR on the given file. 35 | * @param resource $file The file to process OCR on. 36 | * @param string $fileName The name of the file. 37 | * @param string $ocrMyPdfParameters The parameters to pass to ocrmypdf. 38 | * @return OcrResult|ErrorResult The result of the OCR operation. 39 | */ 40 | public function processOcr($file, string $fileName, string $ocrMyPdfParameters): OcrResult|ErrorResult; 41 | 42 | /** 43 | * Get the list of installed Tesseract languages. 44 | * @return string[] 45 | */ 46 | public function getLanguages(): array; 47 | 48 | /** 49 | * Send a heartbeat to the remote backend. 50 | */ 51 | public function heartbeat(): bool; 52 | } 53 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/generate-client.sh: -------------------------------------------------------------------------------- 1 | 2 | # !/bin/bash 3 | 4 | # Note: both NodeJS (+npm) and Java are required to run this script 5 | # Update openapi-spec.json according to the Workflow OCR Backend API (/openapi.json) and run this script to generate Models 6 | npx -y @openapitools/openapi-generator-cli generate 7 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/openapitools.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 | "spaces": 2, 4 | "generator-cli": { 5 | "version": "7.10.0", 6 | "generators": { 7 | "php": { 8 | "generatorName": "php", 9 | "output": "#{cwd}", 10 | "glob": "openapi-spec.json", 11 | "additionalProperties": { 12 | "invokerPackage": "OCA\\\\WorkflowOcr\\\\OcrProcessors\\\\Remote\\\\Client", 13 | "variableNamingConvention": "camelCase", 14 | "srcBasePath": "." 15 | }, 16 | "templateDir": "templates" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/templates/model.mustache: -------------------------------------------------------------------------------- 1 | partial_header}} 7 | /** 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | 13 | namespace {{modelPackage}}; 14 | {{^isEnum}} 15 | {{^parentSchema}} 16 | 17 | use \ArrayAccess; 18 | {{/parentSchema}} 19 | {{/isEnum}} 20 | use \{{invokerPackage}}\ObjectSerializer; 21 | 22 | /** 23 | * {{classname}} Class Doc Comment 24 | * 25 | * @category Class 26 | {{#description}} 27 | * @description {{.}} 28 | {{/description}} 29 | * @package {{invokerPackage}} 30 | * @author OpenAPI Generator team 31 | * @link https://openapi-generator.tech 32 | {{^isEnum}} 33 | * @implements \ArrayAccess 34 | {{/isEnum}} 35 | */ 36 | {{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}} 37 | {{/model}}{{/models}} 38 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/Client/templates/partial_header.mustache: -------------------------------------------------------------------------------- 1 | /** 2 | * @copyright Copyright (c) 2025 Robin Windey 3 | * 4 | * @license GNU AGPL version 3 or any later version 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | -------------------------------------------------------------------------------- /lib/OcrProcessors/Remote/WorkflowOcrRemoteProcessor.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\OcrProcessors\Remote; 25 | 26 | use OCA\WorkflowOcr\Exception\OcrAlreadyDoneException; 27 | use OCA\WorkflowOcr\Exception\OcrNotPossibleException; 28 | use OCA\WorkflowOcr\Model\GlobalSettings; 29 | use OCA\WorkflowOcr\Model\WorkflowSettings; 30 | use OCA\WorkflowOcr\OcrProcessors\ICommandLineUtils; 31 | use OCA\WorkflowOcr\OcrProcessors\IOcrProcessor; 32 | use OCA\WorkflowOcr\OcrProcessors\OcrProcessorResult; 33 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\IApiClient; 34 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\Model\ErrorResult; 35 | use OCP\Files\File; 36 | use Psr\Log\LoggerInterface; 37 | 38 | /** 39 | * OCR Processor which utilizes the Workflow OCR Backend remote service to perform OCR. 40 | */ 41 | class WorkflowOcrRemoteProcessor implements IOcrProcessor { 42 | public function __construct( 43 | private IApiClient $apiClient, 44 | private ICommandLineUtils $commandLineUtils, 45 | private LoggerInterface $logger, 46 | ) { 47 | 48 | } 49 | 50 | public function ocrFile(File $file, WorkflowSettings $settings, GlobalSettings $globalSettings): OcrProcessorResult { 51 | $ocrMyPdfParameters = $this->commandLineUtils->getCommandlineArgs($settings, $globalSettings); 52 | $fileResource = $file->fopen('rb'); 53 | $fileName = $file->getName(); 54 | 55 | $this->logger->debug('Sending OCR request to remote backend'); 56 | $apiResult = $this->apiClient->processOcr($fileResource, $fileName, $ocrMyPdfParameters); 57 | $this->logger->debug('OCR result received', ['apiResult' => $apiResult]); 58 | 59 | if ($apiResult instanceof ErrorResult) { 60 | $resultMessage = $apiResult->getMessage(); 61 | $exitCode = $apiResult->getOcrMyPdfExitCode(); 62 | 63 | # Gracefully handle OCR_MODE_SKIP_FILE (ExitCode.already_done_ocr) 64 | if ($exitCode === 6) { 65 | throw new OcrAlreadyDoneException('File ' . $file->getPath() . ' appears to contain text so it may not need OCR. Message: ' . $resultMessage); 66 | } 67 | throw new OcrNotPossibleException($resultMessage); 68 | } 69 | 70 | return new OcrProcessorResult( 71 | base64_decode($apiResult->getFileContent()), 72 | pathinfo($apiResult->getFilename(), PATHINFO_EXTENSION), 73 | $apiResult->getRecognizedText() 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/Service/EventService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author g-schmitz 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | namespace OCA\WorkflowOcr\Service; 27 | 28 | use OCA\WorkflowOcr\Events\TextRecognizedEvent; 29 | use OCA\WorkflowOcr\OcrProcessors\OcrProcessorResult; 30 | use OCP\EventDispatcher\IEventDispatcher; 31 | use OCP\Files\File; 32 | 33 | class EventService implements IEventService { 34 | /** @var IEventDispatcher */ 35 | private $eventDispatcher; 36 | 37 | public function __construct(IEventDispatcher $eventDispatcher) { 38 | $this->eventDispatcher = $eventDispatcher; 39 | } 40 | 41 | /** 42 | * @return void 43 | */ 44 | public function textRecognized(OcrProcessorResult $result, File $node) { 45 | $event = new TextRecognizedEvent($result->getRecognizedText(), $node); 46 | $this->eventDispatcher->dispatchTyped($event); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/Service/GlobalSettingsService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\AppInfo\Application; 30 | use OCA\WorkflowOcr\Model\GlobalSettings; 31 | use OCP\IAppConfig; 32 | use ReflectionClass; 33 | use ReflectionProperty; 34 | 35 | /** 36 | * Class GlobalSettingsService 37 | * 38 | * Helper for writing and reading global settings stored in NC config. 39 | * @package OCA\WorkflowOcr\Service 40 | */ 41 | class GlobalSettingsService implements IGlobalSettingsService { 42 | 43 | public function __construct( 44 | private IAppConfig $config, 45 | ) { 46 | } 47 | 48 | /** 49 | * @inheritDoc 50 | */ 51 | public function getGlobalSettings() : GlobalSettings { 52 | $settings = new GlobalSettings(); 53 | 54 | foreach ($this->getProperties($settings) as $prop) { 55 | $key = $prop->getName(); 56 | $configValue = $this->config->getValueString(Application::APP_NAME, $key); 57 | $settings->$key = $configValue; 58 | } 59 | 60 | return $settings; 61 | } 62 | 63 | /** 64 | * @inheritDoc 65 | * 66 | * @return void 67 | */ 68 | public function setGlobalSettings(GlobalSettings $settings) : void { 69 | foreach ($this->getProperties($settings) as $prop) { 70 | $key = $prop->getName(); 71 | $value = $settings->$key; 72 | $this->config->setValueString(Application::APP_NAME, $key, $value); 73 | } 74 | } 75 | 76 | private function getProperties(GlobalSettings $settings) : array { 77 | $reflect = new ReflectionClass($settings); 78 | return $reflect->getProperties(ReflectionProperty::IS_PUBLIC); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/Service/IEventService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author g-schmitz 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\OcrProcessors\OcrProcessorResult; 30 | use OCP\Files\File; 31 | 32 | interface IEventService { 33 | /** 34 | * Emits events 35 | * 36 | * @param OcrProcessorResult $result The processed ocr result 37 | * 38 | */ 39 | public function textRecognized(OcrProcessorResult $result, File $node); 40 | } 41 | -------------------------------------------------------------------------------- /lib/Service/IGlobalSettingsService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\Model\GlobalSettings; 30 | 31 | interface IGlobalSettingsService { 32 | /** 33 | * Loads all global settings for OCR workflow app 34 | * @return GlobalSettings An data object of global settings 35 | */ 36 | public function getGlobalSettings() : GlobalSettings; 37 | 38 | /** 39 | * Saves all global settings for OCR workflow app 40 | * @param GlobalSettings $globalSettings An data object of global settings 41 | */ 42 | public function setGlobalSettings(GlobalSettings $globalSettings) : void; 43 | } 44 | -------------------------------------------------------------------------------- /lib/Service/INotificationService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | interface INotificationService { 30 | 31 | /** 32 | * Create a new notification for the given user if the OCR process of the given file failed. 33 | * @param string $userId The user ID of the user that should receive the notification. 34 | * @param string $message The error message that should be displayed in the notification. 35 | * @param int $fileId Optional file ID of the file that failed to OCR. If given, user can jump to the file via link. 36 | */ 37 | public function createErrorNotification(?string $userId, string $message, ?int $fileId = null); 38 | 39 | /** 40 | * Create a new notification for the given user if the OCR process of the given file was successful. 41 | * @param string $userId The user ID of the user that should receive the notification. 42 | * @param string $message The success message that should be displayed in the notification. 43 | * @param int $fileId Optional file ID of the file that was successfully OCR'd. If given, user can jump to the file via link. 44 | */ 45 | public function createSuccessNotification(?string $userId, ?int $fileId = null); 46 | } 47 | -------------------------------------------------------------------------------- /lib/Service/IOcrBackendInfoService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\Exception\CommandException; 30 | 31 | interface IOcrBackendInfoService { 32 | /** 33 | * Returns all languages that are supported by the OCR backend. 34 | * Languages will be returned as an array of language-code-strings, 35 | * currently defined at https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc#languages. 36 | * @return array string[] 37 | * @throws CommandException 38 | */ 39 | public function getInstalledLanguages() : array; 40 | 41 | /** 42 | * Returns whether the OCR backend is a remote backend. 43 | * @return bool false if ocrMyPdf is used locally, true if workflow_ocr_backend is used. 44 | */ 45 | public function isRemoteBackend() : bool; 46 | } 47 | -------------------------------------------------------------------------------- /lib/Service/IOcrService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\Model\WorkflowSettings; 30 | 31 | interface IOcrService { 32 | /** 33 | * Processes OCR on the given file. Creates a new file version and emits appropriate events. 34 | * 35 | * @param mixed $argument The argument from the \OCP\BackgroundJob\Job->run which executes this method 36 | * 37 | * @throws \OCA\WorkflowOcr\Exception\OcrNotPossibleException 38 | * @throws \OCA\WorkflowOcr\Exception\OcrProcessorNotFoundException 39 | * @throws \OCA\WorkflowOcr\Exception\OcrResultEmptyException 40 | * @throws \InvalidArgumentException 41 | */ 42 | public function runOcrProcessWithJobArgument($argument) : void; 43 | 44 | /** 45 | * Processes OCR on the given file. Creates a new file version and emits appropriate events. 46 | * 47 | * @param int $fileId The id if the file to be processed 48 | * @param string $uid The id of the user who has access to this file 49 | * @param WorkflowSettings $settings The settings to be used for processing 50 | * 51 | * @throws \OCA\WorkflowOcr\Exception\OcrNotPossibleException 52 | * @throws \OCA\WorkflowOcr\Exception\OcrProcessorNotFoundException 53 | * @throws \OCA\WorkflowOcr\Exception\OcrResultEmptyException 54 | * @throws \InvalidArgumentException 55 | */ 56 | public function runOcrProcess(int $fileId, string $uid, WorkflowSettings $settings) : void; 57 | } 58 | -------------------------------------------------------------------------------- /lib/Service/NotificationService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Service; 28 | 29 | use OCA\WorkflowOcr\AppInfo\Application; 30 | use OCP\Notification\IManager; 31 | 32 | /* 33 | * This class is used to create new NC notifications. 34 | * They will be displayed later with the help of Nofification\Notifier. 35 | */ 36 | class NotificationService implements INotificationService { 37 | 38 | private IManager $notificationManager; 39 | 40 | public function __construct(IManager $notificationManager) { 41 | $this->notificationManager = $notificationManager; 42 | } 43 | 44 | /** 45 | * @return void 46 | */ 47 | public function createErrorNotification(?string $userId, string $message, ?int $fileId = null) { 48 | $this->createNotification($userId, 'ocr_error', $message, $fileId); 49 | } 50 | 51 | /** 52 | * @return void 53 | */ 54 | public function createSuccessNotification(?string $userId, ?int $fileId = null) { 55 | $this->createNotification($userId, 'ocr_success', null, $fileId); 56 | } 57 | 58 | private function createNotification(?string $userId, string $type, ?string $message = null, ?int $fileId = null) { 59 | // We don't create unbound notifications 60 | if (!$userId) { 61 | return; 62 | } 63 | 64 | $parameters = $message ? ['message' => $message] : []; 65 | $notification = $this->notificationManager->createNotification(); 66 | $notification->setApp(Application::APP_NAME) 67 | ->setUser($userId) 68 | ->setDateTime(new \DateTime()) 69 | ->setSubject($type, $parameters); 70 | 71 | if ($fileId) { 72 | $notification->setObject('file', strval($fileId)); 73 | } else { 74 | $notification->setObject('ocr', 'ocr'); 75 | } 76 | 77 | $this->notificationManager->notify($notification); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/Settings/GlobalSettings.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Settings; 28 | 29 | use OCA\WorkflowOcr\AppInfo\Application; 30 | use OCP\AppFramework\Http\TemplateResponse; 31 | use OCP\Settings\ISettings; 32 | 33 | /** 34 | * Settings entry in Flows settings page. 35 | */ 36 | class GlobalSettings implements ISettings { 37 | public function getForm() : TemplateResponse { 38 | return new TemplateResponse(Application::APP_NAME, 'globalSettings', [], 'blank'); 39 | } 40 | 41 | public function getSection(): string { 42 | return 'workflow'; 43 | } 44 | 45 | public function getPriority(): int { 46 | return 75; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/SetupChecks/OcrMyPdfCheck.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\SetupChecks; 28 | 29 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\IApiClient; 30 | use OCA\WorkflowOcr\Service\IOcrBackendInfoService; 31 | use OCA\WorkflowOcr\Wrapper\ICommand; 32 | use OCP\IL10N; 33 | use OCP\SetupCheck\ISetupCheck; 34 | use OCP\SetupCheck\SetupResult; 35 | 36 | class OcrMyPdfCheck implements ISetupCheck { 37 | public function __construct( 38 | private IL10N $l10n, 39 | private ICommand $command, 40 | private IOcrBackendInfoService $ocrBackendInfoService, 41 | private IApiClient $apiClient, 42 | ) { 43 | } 44 | 45 | public function getCategory(): string { 46 | return 'system'; 47 | } 48 | 49 | public function getName(): string { 50 | return $this->l10n->t('Is OCRmyPDF installed'); 51 | } 52 | 53 | public function run(): SetupResult { 54 | if ($this->ocrBackendInfoService->isRemoteBackend()) { 55 | return $this->apiClient->heartbeat() ? 56 | SetupResult::success($this->l10n->t('Workflow OCR Backend is installed.')) : 57 | SetupResult::warning($this->l10n->t('Workflow OCR Backend is installed but heartbeat failed.')); 58 | } 59 | $this->command->setCommand('ocrmypdf --version')->execute(); 60 | if ($this->command->getExitCode() === 127) { 61 | return SetupResult::error($this->l10n->t('OCRmyPDF CLI is not installed.'), 'https://github.com/R0Wi-DEV/workflow_ocr?tab=readme-ov-file#backend'); 62 | } 63 | if ($this->command->getExitCode() !== 0) { 64 | return SetupResult::error($this->l10n->t('OCRmyPDF CLI is not working correctly. Error was: %1$s', [$this->command->getError()])); 65 | } 66 | $versionOutput = $this->command->getOutput(); 67 | return SetupResult::success($this->l10n->t('OCRmyPDF is installed and has version %1$s.', [$versionOutput])); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/Wrapper/AppApiWrapper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Wrapper; 25 | 26 | use OCA\AppAPI\PublicFunctions; 27 | use OCP\Http\Client\IResponse; 28 | use OCP\IRequest; 29 | use Psr\Container\ContainerExceptionInterface; 30 | use Psr\Container\ContainerInterface; 31 | use Psr\Container\NotFoundExceptionInterface; 32 | 33 | class AppApiWrapper implements IAppApiWrapper { 34 | public function __construct( 35 | private ContainerInterface $container, 36 | ) { 37 | } 38 | 39 | /** 40 | * @throws ContainerExceptionInterface 41 | * @throws NotFoundExceptionInterface 42 | */ 43 | public function exAppRequest( 44 | string $appId, 45 | string $route, 46 | ?string $userId = null, 47 | string $method = 'POST', 48 | array $params = [], 49 | array $options = [], 50 | ?IRequest $request = null, 51 | ): IResponse|array { 52 | $appApiFunctions = $this->container->get(PublicFunctions::class); 53 | return $appApiFunctions->exAppRequest( 54 | $appId, 55 | $route, 56 | $userId, 57 | $method, 58 | $params, 59 | $options, 60 | $request 61 | ); 62 | } 63 | 64 | /** 65 | * @throws ContainerExceptionInterface 66 | * @throws NotFoundExceptionInterface 67 | */ 68 | public function getExApp(string $appName): ?array { 69 | $appApiFunctions = $this->container->get(PublicFunctions::class); 70 | return $appApiFunctions->getExApp($appName); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/Wrapper/CommandWrapper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Wrapper; 25 | 26 | use mikehaertl\shellcommand\Command; 27 | 28 | class CommandWrapper implements ICommand { 29 | /** @var Command */ 30 | private $command; 31 | 32 | public function __construct() { 33 | $this->command = new Command(); 34 | } 35 | 36 | /** 37 | * @inheritdoc 38 | */ 39 | public function setCommand(string $command) : ICommand { 40 | $this->command->setCommand($command); 41 | return $this; 42 | } 43 | 44 | /** 45 | * @inheritdoc 46 | * 47 | * @param string $stdIn 48 | */ 49 | public function setStdIn(string $stdIn) : ICommand { 50 | $this->command->setStdIn($stdIn); 51 | return $this; 52 | } 53 | 54 | /** 55 | * @inheritdoc 56 | */ 57 | public function execute() : bool { 58 | return (bool)$this->command->execute(); 59 | } 60 | 61 | /** 62 | * @inheritdoc 63 | */ 64 | public function getOutput(bool $trim = true) : string { 65 | return (string)$this->command->getOutput($trim); 66 | } 67 | 68 | /** 69 | * @inheritdoc 70 | */ 71 | public function getError(bool $trim = true) : string { 72 | return (string)$this->command->getError($trim); 73 | } 74 | 75 | /** 76 | * @inheritdoc 77 | */ 78 | public function getStdErr(bool $trim = true) : string { 79 | return (string)$this->command->getStdErr($trim); 80 | } 81 | 82 | /** 83 | * @inheritdoc 84 | */ 85 | public function getExitCode() { 86 | return $this->command->getExitCode(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/Wrapper/Filesystem.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | class Filesystem implements IFilesystem { 30 | public function init(string $user, string $root) : void { 31 | \OC\Files\Filesystem::init($user, $root); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/Wrapper/IAppApiWrapper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Wrapper; 25 | 26 | use OCP\Http\Client\IResponse; 27 | use OCP\IRequest; 28 | 29 | /** 30 | * Consolidates all used calls to OCA\AppAPI\PublicFunctions 31 | */ 32 | interface IAppApiWrapper { 33 | public function exAppRequest( 34 | string $appId, 35 | string $route, 36 | ?string $userId = null, 37 | string $method = 'POST', 38 | array $params = [], 39 | array $options = [], 40 | ?IRequest $request = null, 41 | ): IResponse|array ; 42 | 43 | public function getExApp(string $appName): ?array; 44 | } 45 | -------------------------------------------------------------------------------- /lib/Wrapper/IFilesystem.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | interface IFilesystem { 30 | /** 31 | * Init mountpoints for given user with given root 32 | * @param $user Username 33 | * @param $root Path of root folder 34 | */ 35 | public function init(string $user, string $root) : void; 36 | } 37 | -------------------------------------------------------------------------------- /lib/Wrapper/IView.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | /** 30 | * Interface for wrapping \OC\Files\View 31 | */ 32 | interface IView { 33 | public function file_put_contents(string $filePath, string $content) : bool; 34 | public function touch($path, $mtime = null): bool; 35 | } 36 | -------------------------------------------------------------------------------- /lib/Wrapper/IViewFactory.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | interface IViewFactory { 30 | /** 31 | * Creates a new view wrapper for the given directory 32 | * @param $directoryPath The path of the directory for which the view shall be created 33 | * @return IView 34 | */ 35 | public function create(string $directoryPath) : IView; 36 | } 37 | -------------------------------------------------------------------------------- /lib/Wrapper/ViewFactory.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | class ViewFactory implements IViewFactory { 30 | public function create(string $directoryPath) : IView { 31 | return new ViewWrapper($directoryPath); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/Wrapper/ViewWrapper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @author Robin Windey 9 | * 10 | * @license GNU AGPL version 3 or any later version 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU Affero General Public License as 14 | * published by the Free Software Foundation, either version 3 of the 15 | * License, or (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Affero General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Affero General Public License 23 | * along with this program. If not, see . 24 | * 25 | */ 26 | 27 | namespace OCA\WorkflowOcr\Wrapper; 28 | 29 | use OC\Files\View; 30 | 31 | class ViewWrapper implements IView { 32 | /** @var View */ 33 | private $wrappedView; 34 | 35 | public function __construct(string $directoryPath) { 36 | $this->wrappedView = new View($directoryPath); 37 | } 38 | 39 | /** 40 | * @inheritdoc 41 | */ 42 | public function file_put_contents(string $filePath, string $content) : bool { 43 | $retVal = $this->wrappedView->file_put_contents($filePath, $content); 44 | return boolval($retVal); 45 | } 46 | 47 | /** 48 | * @inheritdoc 49 | */ 50 | public function touch($path, $mtime = null): bool { 51 | return $this->wrappedView->touch($path, $mtime); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "workflow_ocr", 3 | "version": "1.0.0", 4 | "bugs": { 5 | "url": "https://github.com/R0Wi/workflow_ocr/issues" 6 | }, 7 | "repository": { 8 | "url": "https://github.com/R0Wi/workflow_ocr", 9 | "type": "git" 10 | }, 11 | "homepage": "https://github.com/R0Wi/workflow_ocr", 12 | "license": "agpl", 13 | "private": true, 14 | "scripts": { 15 | "dev-install": "NODE_ENV=development npm install", 16 | "build": "NODE_ENV=production ./node_modules/.bin/webpack --progress --config webpack.js", 17 | "dev": "NODE_ENV=development ./node_modules/.bin/webpack --progress --config webpack.js", 18 | "watch": "NODE_ENV=development ./node_modules/.bin/webpack --progress --watch --config webpack.js", 19 | "test:unit": "jest", 20 | "test:debug": "jest --watch", 21 | "lint": "eslint --ext .js,.vue src && stylelint src", 22 | "lint:fix": "eslint --ext .js,.vue src --fix && stylelint src --fix" 23 | }, 24 | "dependencies": { 25 | "@nextcloud/axios": "^2.5.1", 26 | "@nextcloud/l10n": "^3.1.0", 27 | "@nextcloud/router": "^3.0.1", 28 | "@nextcloud/vue": "8.19.0", 29 | "vue": "^2.7.16", 30 | "vue-material-design-icons": "^5.3.0" 31 | }, 32 | "browserslist": [ 33 | "extends @nextcloud/browserslist-config" 34 | ], 35 | "engines": { 36 | "node": "^20.0.0", 37 | "npm": "^10.0.0" 38 | }, 39 | "devDependencies": { 40 | "@nextcloud/babel-config": "^1.0.0", 41 | "@nextcloud/browserslist-config": "^3.0.1", 42 | "@nextcloud/eslint-config": "^8.4.1", 43 | "@nextcloud/stylelint-config": "^3.0.1", 44 | "@nextcloud/webpack-vue-config": "^6.2.0", 45 | "@vue/cli": "^5.0.8", 46 | "@vue/test-utils": "^1.3.0", 47 | "@vue/vue2-jest": "^29.2.6", 48 | "babel-loader": "^9.1.3", 49 | "eslint": "^8.53.0", 50 | "eslint-webpack-plugin": "^4.0.1", 51 | "jest": "^29.7.0", 52 | "jest-environment-jsdom": "^29.7.0", 53 | "jest-transform-stub": "^2.0.0", 54 | "regenerator-runtime": "^0.14.0", 55 | "webpack": "^5.94.0", 56 | "webpack-cli": "^5.1.4" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /phpunit.integration.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | ./tests/Integration 11 | 12 | 13 | 14 | ./ 15 | 16 | 17 | ./appinfo 18 | ./l10n 19 | ./templates 20 | ./tests 21 | ./vendor 22 | ./node_modules 23 | ./lib/Migration 24 | ./lib/OcrProcessors/Remote/Client 25 | ./.php-cs-fixer.dist.php 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | ./tests/Unit 16 | 17 | 18 | 19 | ./ 20 | 21 | 22 | ./appinfo 23 | ./l10n 24 | ./templates 25 | ./tests 26 | ./vendor 27 | ./node_modules 28 | ./lib/Migration 29 | ./lib/OcrProcessors/Remote/Client/Model 30 | ./lib/OcrProcessors/Remote/Client/Configuration.php 31 | ./lib/OcrProcessors/Remote/Client/ObjectSerializer.php 32 | ./.php-cs-fixer.dist.php 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /psalm.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=R0Wi_workflow_ocr 2 | sonar.organization=r0wi 3 | sonar.php.coverage.reportPaths=./coverage/php-coverage.xml 4 | sonar.javascript.lcov.reportPaths=./coverage/lcov.info 5 | sonar.coverage.exclusions=\ 6 | **/lib/OcrProcessors/Remote/Client/** 7 | sonar.cpd.exclusions=\ 8 | **/lib/OcrProcessors/Remote/Client/** 9 | sonar.exclusions=\ 10 | **/lib/OcrProcessors/Remote/Client/** -------------------------------------------------------------------------------- /src/components/GlobalSettings.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 44 | 45 | 80 | 81 | 90 | -------------------------------------------------------------------------------- /src/components/SettingsItem.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 45 | 46 | 75 | 76 | 102 | -------------------------------------------------------------------------------- /src/globalSettings.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import GlobalSettings from './components/GlobalSettings' 3 | 4 | Vue.prototype.t = t 5 | const App = Vue.extend(GlobalSettings) 6 | const appInstance = new App() 7 | appInstance.$mount('#workflow_ocr_globalsettings') 8 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import WorkflowOcr from './components/WorkflowOcr' 2 | import { translate as t } from '@nextcloud/l10n' 3 | import Vue from 'vue' 4 | 5 | Vue.mixin({ 6 | methods: { 7 | t, 8 | }, 9 | }) 10 | 11 | window.OCA.WorkflowEngine.registerOperator({ 12 | id: 'OCA\\WorkflowOcr\\Operation', 13 | name: t('workflow_ocr'), 14 | description: t('workflow_ocr'), 15 | operation: '', 16 | options: WorkflowOcr, 17 | }) 18 | -------------------------------------------------------------------------------- /src/service/globalSettingsService.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @copyright Copyright (c) 2021 Robin Windey 4 | * 5 | * @author Robin Windey 6 | * 7 | * @license AGPL-3.0-or-later 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Affero General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Affero General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Affero General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | 24 | import { generateUrl } from '@nextcloud/router' 25 | import axios from '@nextcloud/axios' 26 | 27 | const relativeUrl = '/apps/workflow_ocr/globalSettings' 28 | 29 | /** 30 | * Create a new appointment config in the backend 31 | * 32 | * @return {Promise} Global settings for workflow OCR app 33 | */ 34 | export async function getGlobalSettings() { 35 | const url = generateUrl(relativeUrl) 36 | const axiosResponse = await axios.get(url) 37 | return axiosResponse.data 38 | } 39 | 40 | /** 41 | * Saves the given settings 42 | * 43 | * @param {object} globalSettings Settings to be saved 44 | * @return {Promise} Global settings for workflow OCR app 45 | */ 46 | export async function setGlobalSettings(globalSettings) { 47 | const url = generateUrl(relativeUrl) 48 | const axiosResponse = await axios.put(url, { globalSettings: globalSettings }) 49 | return axiosResponse.data 50 | } 51 | -------------------------------------------------------------------------------- /src/service/ocrBackendInfoService.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @copyright Copyright (c) 2022 Robin Windey 3 | * 4 | * @author Robin Windey 5 | * 6 | * @license AGPL-3.0-or-later 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | import { generateUrl } from '@nextcloud/router' 24 | import axios from '@nextcloud/axios' 25 | 26 | const relativeUrl = '/apps/workflow_ocr/ocrBackendInfo' 27 | 28 | /** 29 | * Get all installed OCR languages from the backend system 30 | * 31 | * @return {Promise} Installes languages as array of strings containing the language codes 32 | */ 33 | export async function getInstalledLanguages() { 34 | const url = generateUrl(relativeUrl + '/installedLangs') 35 | const axiosResponse = await axios.get(url) 36 | return axiosResponse.data 37 | } 38 | -------------------------------------------------------------------------------- /src/test/OC.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | getLanguage() { 4 | return 'en-GB' 5 | }, 6 | 7 | getLocale() { 8 | return 'en_GB' 9 | }, 10 | 11 | isUserAdmin() { 12 | return true 13 | }, 14 | 15 | Util: { 16 | naturalSortCompare(a, b) { 17 | return 0 18 | } 19 | }, 20 | 21 | coreApps: [ 22 | '', 23 | 'admin', 24 | 'log', 25 | 'core/search', 26 | 'core', 27 | '3rdparty', 28 | ], 29 | 30 | appswebroots: { 31 | calendar: '/apps/calendar', 32 | deck: '/apps/deck', 33 | files: '/apps/files', 34 | spreed: '/apps/spreed', 35 | }, 36 | 37 | config: { 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /src/test/components/GlobalSettings.spec.js: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import { getGlobalSettings, setGlobalSettings } from '../../service/globalSettingsService.js' 3 | import GlobalSettings from '../../components/GlobalSettings.vue' 4 | 5 | jest.mock('../../service/globalSettingsService') 6 | 7 | beforeEach(() => { 8 | global.t = jest.fn() 9 | jest.resetAllMocks() 10 | }) 11 | 12 | describe('Init tests', () => { 13 | test('Component values shall be empty if server returns null values', async () => { 14 | const mockSettings = { processorCount: null } 15 | getGlobalSettings.mockResolvedValueOnce(mockSettings) 16 | 17 | const wrapper = mount(GlobalSettings) 18 | await new Promise(process.nextTick) 19 | 20 | expect(getGlobalSettings).toHaveBeenCalledTimes(1) 21 | expect(wrapper.vm.settings).toEqual(mockSettings) 22 | const processorCount = wrapper.find('input[name="processorCount"]') 23 | expect(processorCount.element.value).toBe('') 24 | }) 25 | 26 | test('Component values shall reflect values given by server', async () => { 27 | const mockSettings = { processorCount: 42 } 28 | getGlobalSettings.mockResolvedValueOnce(mockSettings) 29 | 30 | const wrapper = mount(GlobalSettings) 31 | await new Promise(process.nextTick) 32 | 33 | expect(getGlobalSettings).toHaveBeenCalledTimes(1) 34 | expect(wrapper.vm.settings).toEqual(mockSettings) 35 | const processorCount = wrapper.find('input[name="processorCount"]') 36 | expect(processorCount.element.value).toBe('42') 37 | }) 38 | }) 39 | 40 | describe('Interaction tests', () => { 41 | test('Should update settings when processorCount is changed', async () => { 42 | const initialMockSettings = { processorCount: '2' } 43 | getGlobalSettings.mockResolvedValueOnce(initialMockSettings) 44 | 45 | const afterSaveMockSettings = { processorCount: '42' } 46 | setGlobalSettings.mockResolvedValueOnce(afterSaveMockSettings) 47 | 48 | const wrapper = mount(GlobalSettings) 49 | await new Promise(process.nextTick) 50 | 51 | const processorCount = wrapper.find('input[name="processorCount"]') 52 | processorCount.element.value = '42' 53 | await processorCount.trigger('input') 54 | 55 | expect(wrapper.vm.settings.processorCount).toBe('42') 56 | expect(setGlobalSettings).toHaveBeenCalledTimes(1) 57 | expect(setGlobalSettings).toHaveBeenCalledWith(expect.objectContaining({ 58 | processorCount: '42', 59 | })) 60 | }) 61 | }) 62 | -------------------------------------------------------------------------------- /src/test/components/SettingsItem.spec.js: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import SettingsItem from '../../components/SettingsItem.vue' 3 | import { NcPopover } from '@nextcloud/vue' 4 | 5 | beforeEach(() => { 6 | global.t = jest.fn() 7 | jest.resetAllMocks() 8 | }) 9 | 10 | describe('SettingsItem', () => { 11 | test('Should render label, infoText and child-content', async () => { 12 | const wrapper = mount(SettingsItem, { 13 | propsData: { 14 | label: 'label', 15 | infoText: 'infoText', 16 | }, 17 | slots: { 18 | default: '
', 19 | }, 20 | }) 21 | expect(wrapper.find('.help-circle-icon').exists()).toBe(true) 22 | // Simulate click on help icon 23 | await wrapper.find('.help-circle-icon').trigger('click') 24 | expect(wrapper.findComponent(NcPopover).exists()).toBe(true) 25 | 26 | // TODO :: check popover content 27 | // expect(wrapper.find('span.label').text()).toBe('label') 28 | // expect(wrapper.find('p').text()).toBe('infoText') 29 | // expect(wrapper.find('.child-content').exists()).toBe(true) 30 | }) 31 | 32 | test('Should not render info icon if infoText is not set', async () => { 33 | const wrapper = mount(SettingsItem, { 34 | propsData: { 35 | label: 'label', 36 | }, 37 | slots: { 38 | default: '
', 39 | }, 40 | }) 41 | 42 | expect(wrapper.find('.help-circle-icon').exists()).toBe(false) 43 | 44 | // TODO :: check popover content 45 | // expect(wrapper.find('span.label').text()).toBe('label') 46 | // expect(wrapper.find('.child-content').exists()).toBe(true) 47 | // expect(wrapper.findComponent(NcPopover).exists()).toBe(false) 48 | }) 49 | }) 50 | -------------------------------------------------------------------------------- /src/test/gobalSettings.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | beforeEach(() => { 4 | global.t = jest.fn() 5 | 6 | // Create the element that Vue will mount to 7 | const element = document.createElement('div') 8 | element.id = 'workflow_ocr_globalsettings' 9 | document.body.appendChild(element) 10 | }) 11 | 12 | // TODO :: extend this testcases by mocking Vue 13 | test('globalSettings.js sets global t variable', async () => { 14 | await import('../globalSettings.js') 15 | expect(Vue.prototype.t).toBeDefined() 16 | }) 17 | -------------------------------------------------------------------------------- /src/test/main.spec.js: -------------------------------------------------------------------------------- 1 | beforeEach(() => { 2 | global.OCA = { WorkflowEngine: { registerOperator: jest.fn() } } 3 | global.t = jest.fn() 4 | }) 5 | 6 | test('main registers component at workflow engine', async () => { 7 | // window.OCA.WorkflowEngine.registerOperator 8 | await import('../main.js') 9 | expect(global.OCA.WorkflowEngine.registerOperator).toHaveBeenCalledTimes(1) 10 | }) 11 | -------------------------------------------------------------------------------- /src/test/service/globalSettingsService.spec.js: -------------------------------------------------------------------------------- 1 | import axios from '@nextcloud/axios' 2 | import { getGlobalSettings, setGlobalSettings } from '../../service/globalSettingsService.js' 3 | 4 | jest.mock('@nextcloud/axios') 5 | jest.mock('@nextcloud/router', () => ({ 6 | generateUrl: url => url, 7 | })) 8 | 9 | afterEach(() => { 10 | jest.resetAllMocks() 11 | }) 12 | 13 | test('getGlobalSettings returns correct data from server', async () => { 14 | const mockedResponse = { data: { processorCount: 42 } } 15 | 16 | axios.get.mockResolvedValueOnce(mockedResponse) 17 | 18 | const result = await getGlobalSettings() 19 | 20 | expect(result.processorCount).toBe(42) 21 | expect(axios.get).toHaveBeenCalledTimes(1) 22 | expect(axios.get).toHaveBeenCalledWith('/apps/workflow_ocr/globalSettings') 23 | }) 24 | 25 | test('setGlobalSettings sends correct data to server', async () => { 26 | const request = { data: { processorCount: 42 } } 27 | const mockedResponse = { data: { processorCount: '42' } } 28 | 29 | axios.put.mockResolvedValueOnce(mockedResponse) 30 | 31 | const result = await setGlobalSettings(request) 32 | 33 | expect(result.processorCount).toBe('42') 34 | expect(axios.put).toHaveBeenCalledTimes(1) 35 | expect(axios.put).toHaveBeenCalledWith('/apps/workflow_ocr/globalSettings', { globalSettings: request }) 36 | }) 37 | -------------------------------------------------------------------------------- /src/test/service/ocrBackendInfoService.spec.js: -------------------------------------------------------------------------------- 1 | import axios from '@nextcloud/axios' 2 | import { getInstalledLanguages } from '../../service/ocrBackendInfoService.js' 3 | 4 | jest.mock('@nextcloud/axios') 5 | jest.mock('@nextcloud/router', () => ({ 6 | generateUrl: url => url, 7 | })) 8 | 9 | afterEach(() => { 10 | jest.resetAllMocks() 11 | }) 12 | 13 | test('getInstalledLanguages returns correct data from server', async () => { 14 | const mockedResponse = { data: ['deu', 'eng'] } 15 | 16 | axios.get.mockResolvedValueOnce(mockedResponse) 17 | 18 | const result = await getInstalledLanguages() 19 | 20 | expect(result.length).toBe(2) 21 | expect(axios.get).toHaveBeenCalledTimes(1) 22 | expect(axios.get).toHaveBeenCalledWith('/apps/workflow_ocr/ocrBackendInfo/installedLangs') 23 | }) 24 | -------------------------------------------------------------------------------- /src/test/setup-jest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @copyright Copyright (c) 2020 Raimund Schlüßler 3 | * 4 | * @author Raimund Schlüßler 5 | * 6 | * @license GNU AGPL version 3 or any later version 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | 23 | import OC from './OC.js' 24 | import 'regenerator-runtime/runtime' 25 | 26 | global.OC = OC 27 | 28 | global.PRODUCTION = false 29 | global.SCOPE_VERSION = 1 30 | global.TRANSLATIONS = [] -------------------------------------------------------------------------------- /stylelint.config.js: -------------------------------------------------------------------------------- 1 | const stylelintConfig = require('@nextcloud/stylelint-config') 2 | 3 | module.exports = stylelintConfig -------------------------------------------------------------------------------- /templates/globalSettings.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * @author Robin Windey 6 | * 7 | * @license GNU AGPL version 3 or any later version 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Affero General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Affero General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Affero General Public License 20 | * along with this program. If not, see . 21 | * 22 | * 23 | * This file represents the frontend snippet HTML code for global settings page. 24 | */ 25 | use OCA\WorkflowOcr\AppInfo\Application; 26 | 27 | // Add GlobalSettings.vue component 28 | script(Application::APP_NAME, Application::APP_NAME . '-globalSettings'); 29 | ?> 30 | 31 | 32 |
-------------------------------------------------------------------------------- /tests/Integration/Composer/AutoloaderTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Integration\Composer; 25 | 26 | use OCP\Security\ISecureRandom; 27 | use OCP\Server; 28 | use Test\TestCase; 29 | 30 | class AutoloaderTest extends TestCase { 31 | /** @var null|string */ 32 | private $testClass = null; 33 | 34 | private static function getClassPath(string $class): string { 35 | return __DIR__ . '/../../../lib/' . $class . '.php'; 36 | } 37 | 38 | protected function tearDown(): void { 39 | parent::tearDown(); 40 | 41 | if ($this->testClass !== null && file_exists(self::getClassPath($this->testClass))) { 42 | unlink(self::getClassPath($this->testClass)); 43 | } 44 | } 45 | 46 | public function testLoadDynamicClass(): void { 47 | $rand = Server::get(ISecureRandom::class); 48 | $className = ucfirst($rand->generate(10, ISecureRandom::CHAR_LOWER)); 49 | $namespace = 'OCA\\WorkflowOcr'; 50 | 51 | file_put_contents(self::getClassPath($className), <<testClass = $className; 57 | 58 | $this->assertTrue(class_exists($namespace . '\\' . $className)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tests/Integration/FileSystemTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Integration; 25 | 26 | use OCA\WorkflowOcr\Wrapper\Filesystem; 27 | use Test\TestCase; 28 | use Test\Traits\UserTrait; 29 | 30 | /** 31 | * @group DB 32 | */ 33 | class FileSystemTest extends TestCase { 34 | use UserTrait; 35 | 36 | private const USER = 'mytestuser'; 37 | 38 | protected function setUp() : void { 39 | parent::setUp(); 40 | $this->createUser(self::USER, 'pass'); 41 | $this->loginAsUser(self::USER); 42 | } 43 | 44 | public function testInit() { 45 | $path = '/mytestuser/files'; 46 | 47 | $fileSystem = new Filesystem(); 48 | $fileSystem->init(self::USER, $path); 49 | $this->assertTrue(\OC\Files\Filesystem::$loaded); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/Integration/IntegrationTestApiClient.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Integration; 25 | 26 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\ApiClient; 27 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\Model\ErrorResult; 28 | use OCA\WorkflowOcr\OcrProcessors\Remote\Client\Model\OcrResult; 29 | use OCA\WorkflowOcr\Wrapper\IAppApiWrapper; 30 | use Psr\Log\LoggerInterface; 31 | 32 | /** 33 | * Recorder for ApiClient - tracks requests 34 | */ 35 | class IntegrationTestApiClient extends ApiClient { 36 | private array $requests = []; 37 | private array $responses = []; 38 | 39 | public function __construct( 40 | private IAppApiWrapper $appApiWrapper, 41 | private LoggerInterface $logger, 42 | ) { 43 | parent::__construct($appApiWrapper, $logger); 44 | } 45 | 46 | public function processOcr($file, string $fileName, string $ocrMyPdfParameters): OcrResult|ErrorResult { 47 | $this->requests[] = [ 48 | 'file' => $file, 49 | 'fileName' => $fileName, 50 | 'ocrMyPdfParameters' => $ocrMyPdfParameters 51 | ]; 52 | $result = parent::processOcr($file, $fileName, $ocrMyPdfParameters); 53 | $this->responses[] = $result; 54 | return $result; 55 | } 56 | 57 | public function getRequests(): array { 58 | return $this->requests; 59 | } 60 | 61 | public function getResponses(): array { 62 | return $this->responses; 63 | } 64 | 65 | public function reset(): void { 66 | $this->requests = []; 67 | $this->responses = []; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /tests/Integration/Notification/AppFake.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * @license GNU AGPL version 3 or any later version 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | namespace OCA\WorkflowOcr\Tests\Integration\Notification; 23 | 24 | use OCP\Notification\IApp; 25 | use OCP\Notification\INotification; 26 | 27 | class AppFake implements IApp { 28 | private $notifications = []; 29 | private $processed = []; 30 | 31 | public function notify(INotification $notification): void { 32 | $this->notifications[] = $notification; 33 | } 34 | 35 | public function markProcessed(INotification $notification): void { 36 | $this->processed[] = $notification; 37 | } 38 | 39 | public function getCount(INotification $notification): int { 40 | return 0; 41 | } 42 | 43 | public function getNotifications() { 44 | return $this->notifications; 45 | } 46 | 47 | public function getProcessed() { 48 | return $this->processed; 49 | } 50 | 51 | public function resetNotifications() { 52 | $this->notifications = []; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Integration/ViewWrapperTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Integration; 25 | 26 | use OC\Files\View; 27 | use OCA\WorkflowOcr\Wrapper\ViewWrapper; 28 | use PHPUnit\Framework\Attributes\DataProvider; 29 | use Test\TestCase; 30 | use Test\Traits\UserTrait; 31 | 32 | /** 33 | * @group DB 34 | */ 35 | class ViewWrapperTest extends TestCase { 36 | use UserTrait; 37 | 38 | private const USER = 'mytestuser'; 39 | 40 | protected function setUp() : void { 41 | parent::setUp(); 42 | $this->createUser(self::USER, 'pass'); 43 | $this->loginAsUser(self::USER); 44 | } 45 | 46 | #[DataProvider('dataProvider_FilePutContents')] 47 | public function testFilePutContents(string $filename, bool $expectedResult) { 48 | $path = '/mytestuser/files'; 49 | $content = 'hello world'; 50 | $viewWrapper = new ViewWrapper($path); 51 | 52 | $result = $viewWrapper->file_put_contents($filename, $content); 53 | $this->assertEquals($expectedResult, $result); 54 | 55 | // If we expect that we can write to the file we should 56 | // be able to read the file afterwards 57 | if ($expectedResult) { 58 | $ncView = new View($path); 59 | $readContent = $ncView->file_get_contents($filename); 60 | $this->assertEquals($content, $readContent); 61 | } 62 | } 63 | 64 | public function testTouch() { 65 | $path = '/mytestuser/files'; 66 | $filename = 'testfile.txt'; 67 | $viewWrapper = new ViewWrapper($path); 68 | 69 | $result = $viewWrapper->touch($filename); 70 | $this->assertTrue($result); 71 | 72 | $ncView = new View($path); 73 | $this->assertTrue($ncView->file_exists($filename)); 74 | 75 | $viewWrapper->touch($filename, 1234567890); 76 | $stat = $ncView->stat($filename); 77 | $this->assertEquals(1234567890, $stat['mtime']); 78 | } 79 | 80 | public static function dataProvider_FilePutContents() { 81 | return [ 82 | ['testfile.txt', true], 83 | ['this_is_invalid/..', false] 84 | ]; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /tests/Integration/testdata/document-has-ocr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/R0Wi-DEV/workflow_ocr/79b364b1c0f889f1408ef360580bb272e48f2bc2/tests/Integration/testdata/document-has-ocr.pdf -------------------------------------------------------------------------------- /tests/Integration/testdata/document-ready-for-ocr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/R0Wi-DEV/workflow_ocr/79b364b1c0f889f1408ef360580bb272e48f2bc2/tests/Integration/testdata/document-ready-for-ocr.pdf -------------------------------------------------------------------------------- /tests/TestUtils.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * @copyright Robin Windey 2020 13 | */ 14 | 15 | namespace OCA\WorkflowOcr\Tests; 16 | 17 | use OCA\WorkflowOcr\AppInfo; 18 | use OCP\AppFramework\App; 19 | use OCP\IUser; 20 | use OCP\IUserManager; 21 | use OCP\IUserSession; 22 | use Psr\Container\ContainerInterface; 23 | 24 | class TestUtils { 25 | /** @var ContainerInterface */ 26 | private $container; 27 | 28 | public function __construct() { 29 | $app = new App(AppInfo\Application::APP_NAME); 30 | $this->container = $app->getContainer(); 31 | } 32 | 33 | public function createUser($user, $pw) : IUser { 34 | /** @var IUserManager */ 35 | $userManager = $this->container->get(IUserManager::class); 36 | return $userManager->createUser($user, $pw); 37 | } 38 | 39 | public function initUserEnvironment(IUser $user) : void { 40 | $this->setUser($user); 41 | } 42 | 43 | public function shutDownUserEnvironment() : void { 44 | $this->setUser(null); 45 | } 46 | 47 | private function setUser($user) : void { 48 | /** @var IUserSession */ 49 | $userSession = $this->container->get(IUserSession::class); 50 | $userSession->setUser($user); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/Unit/AppInfo/ApplicationTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\AppInfo; 25 | 26 | use OCA\WorkflowOcr\AppInfo\Application; 27 | use OCP\AppFramework\Bootstrap\IBootContext; 28 | use PHPUnit\Framework\MockObject\MockObject; 29 | use PHPUnit\Framework\TestCase; 30 | 31 | class ApplicationTest extends TestCase { 32 | public function testBootDoesNothingOnBootContext() { 33 | /** @var IBootContext|MockObject */ 34 | $bootContext = $this->createMock(IBootContext::class); 35 | $bootContext->expects($this->never()) 36 | ->method($this->anything()); 37 | 38 | $app = new Application(); 39 | 40 | $app->boot($bootContext); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tests/Unit/Controller/OcrBackendInfoControllerTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Controller; 25 | 26 | use OCA\WorkflowOcr\AppInfo\Application; 27 | use OCA\WorkflowOcr\Controller\OcrBackendInfoController; 28 | use OCA\WorkflowOcr\Service\IOcrBackendInfoService; 29 | use OCP\IRequest; 30 | use PHPUnit\Framework\Attributes\DataProvider; 31 | use PHPUnit\Framework\MockObject\MockObject; 32 | use PHPUnit\Framework\TestCase; 33 | 34 | class OcrBackendInfoControllerTest extends TestCase { 35 | /** @var IOcrBackendInfoService|MockObject */ 36 | private $ocrBackendInfoService; 37 | 38 | /** @var IRequest|MockObject */ 39 | private $request; 40 | 41 | /** @var OcrBackendInfoController */ 42 | private $controller; 43 | 44 | protected function setUp() : void { 45 | $this->ocrBackendInfoService = $this->createMock(IOcrBackendInfoService::class); 46 | $this->request = $this->createMock(IRequest::class); 47 | $this->controller = new OcrBackendInfoController(Application::APP_NAME, $this->request, $this->ocrBackendInfoService); 48 | parent::setUp(); 49 | } 50 | 51 | #[DataProvider('dataProviderInstalledLangsJson')] 52 | public function testGetInstalledLanguagesReturnsJsonArray(array $simulatedServiceResponse, string $expectedResultJson) : void { 53 | $this->ocrBackendInfoService->expects($this->once()) 54 | ->method('getInstalledLanguages') 55 | ->willReturn($simulatedServiceResponse); 56 | $response = $this->controller->getInstalledLanguages(); 57 | $this->assertEquals($expectedResultJson, $response->render()); 58 | } 59 | 60 | public static function dataProviderInstalledLangsJson() { 61 | return [ 62 | [['eng', 'deu', 'chi'], '["eng","deu","chi"]'], 63 | [['eng'], '["eng"]'] 64 | ]; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /tests/Unit/Helper/ProcessingFIleAccessorTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Helper; 25 | 26 | use OCA\WorkflowOcr\Helper\ProcessingFileAccessor; 27 | use PHPUnit\Framework\TestCase; 28 | 29 | class ProcessingFileAccessorTest extends TestCase { 30 | public function testSingleton() { 31 | $o1 = ProcessingFileAccessor::getInstance(); 32 | $o2 = ProcessingFileAccessor::getInstance(); 33 | 34 | $this->assertTrue($o1 === $o2); 35 | } 36 | 37 | public function testGetSet() { 38 | $o = ProcessingFileAccessor::getInstance(); 39 | $o ->setCurrentlyProcessedFilePath('/someuser/files/somefile.pdf'); 40 | $this->assertEquals('/someuser/files/somefile.pdf', $o->getCurrentlyProcessedFilePath()); 41 | $o->setCurrentlyProcessedFilePath(null); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/Unit/Model/WorkflowSettingsTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Model; 25 | 26 | use InvalidArgumentException; 27 | use OCA\WorkflowOcr\Model\WorkflowSettings; 28 | use PHPUnit\Framework\Attributes\DataProvider; 29 | use Test\TestCase; 30 | 31 | class WorkflowSettingsTest extends TestCase { 32 | #[DataProvider('dataProvider_testConstruction')] 33 | public function testWorkflowSettingsConstruction(string $json, bool $expectedRemoveBackground, array $expectedLangSettings) { 34 | $workflowSettings = new WorkflowSettings($json); 35 | $this->assertEquals($expectedRemoveBackground, $workflowSettings->getRemoveBackground()); 36 | $this->assertEquals($expectedLangSettings, $workflowSettings->getLanguages()); 37 | } 38 | 39 | public function testWorkflowSettingsConstructorThrowsInvalidArgumentExceptionOnInvalidJson() { 40 | $this->expectException(InvalidArgumentException::class); 41 | $this->expectExceptionMessage('Invalid JSON: "{"'); 42 | new WorkflowSettings('{'); 43 | } 44 | 45 | public static function dataProvider_testConstruction() { 46 | return [ 47 | [ 48 | '{"removeBackground":true,"languages":["eng","deu","spa","fra","ita"],"keepOriginalFileVersion":false}', 49 | true, 50 | ['eng', 'deu', 'spa', 'fra', 'ita'] 51 | ] 52 | ]; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Unit/OcrProcessors/Local/ImageOcrProcessorTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\OcrProcessors\Local; 25 | 26 | use OCA\WorkflowOcr\Helper\ISidecarFileAccessor; 27 | use OCA\WorkflowOcr\Model\GlobalSettings; 28 | use OCA\WorkflowOcr\Model\WorkflowSettings; 29 | use OCA\WorkflowOcr\OcrProcessors\ICommandLineUtils; 30 | use OCA\WorkflowOcr\OcrProcessors\Local\ImageOcrProcessor; 31 | use OCA\WorkflowOcr\Wrapper\ICommand; 32 | use OCP\Files\File; 33 | use PHPUnit\Framework\MockObject\MockObject; 34 | use Psr\Log\LoggerInterface; 35 | use Test\TestCase; 36 | 37 | class ImageOcrProcessorTest extends TestCase { 38 | public function testOcrFileSetsImageDpi() { 39 | /** @var ICommand|MockObject $command */ 40 | $command = $this->createMock(ICommand::class); 41 | /** @var LoggerInterface|MockObject $logger */ 42 | $logger = $this->createMock(LoggerInterface::class); 43 | /** @var File|MockObject $file */ 44 | $file = $this->createMock(File::class); 45 | /** @var ISidecarFileAccessor|MockObject $fileReader */ 46 | $sidecarFileAccessor = $this->createMock(ISidecarFileAccessor::class); 47 | /** @var ICommandLineUtils|MockObject $commandLineUtils */ 48 | $commandLineUtils = $this->createMock(ICommandLineUtils::class); 49 | $commandLineUtils->method('getCommandlineArgs') 50 | ->willReturnCallback(fn ($settings, $globalSettings, $sidecarFile, $additionalCommandlineArgs) => implode(' ', $additionalCommandlineArgs)); 51 | 52 | $processor = new ImageOcrProcessor($command, $logger, $sidecarFileAccessor, $commandLineUtils); 53 | 54 | $file->expects($this->once()) 55 | ->method('getContent') 56 | ->willReturn('content'); 57 | $command->expects($this->once()) 58 | ->method('setCommand') 59 | ->with($this->stringContains(' --image-dpi 300 ')) 60 | ->willReturnSelf(); 61 | $command->expects($this->once()) 62 | ->method('execute') 63 | ->willReturn(true); 64 | $command->expects($this->once()) 65 | ->method('getOutput') 66 | ->willReturn('output'); 67 | 68 | $processor->ocrFile($file, new WorkflowSettings(), new GlobalSettings()); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tests/Unit/Service/EventServiceTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Service; 25 | 26 | use OCA\WorkflowOcr\Events\TextRecognizedEvent; 27 | use OCA\WorkflowOcr\OcrProcessors\OcrProcessorResult; 28 | use OCA\WorkflowOcr\Service\EventService; 29 | use OCP\EventDispatcher\IEventDispatcher; 30 | use OCP\Files\File; 31 | use PHPUnit\Framework\MockObject\MockObject; 32 | use PHPUnit\Framework\TestCase; 33 | 34 | class EventServiceTest extends TestCase { 35 | /** @var IEventDispatcher|MockObject */ 36 | private $eventDispatcher; 37 | 38 | /** @var EventService */ 39 | private $service; 40 | 41 | public function setUp() : void { 42 | $this->eventDispatcher = $this->createMock(IEventDispatcher::class); 43 | $this->service = new EventService($this->eventDispatcher); 44 | parent::setUp(); 45 | } 46 | 47 | public function testTextRecognizedDispatchesEvent() { 48 | /** @var File|MockObject */ 49 | $file = $this->createMock(File::class); 50 | $recognizedText = 'recognizedText'; 51 | $ocrResult = new OcrProcessorResult('content', 'pdf', $recognizedText); 52 | $this->eventDispatcher->expects($this->once()) 53 | ->method('dispatchTyped') 54 | ->with($this->callback(function (TextRecognizedEvent $event) use ($recognizedText, $file) { 55 | return $event->getRecognizedText() === $recognizedText && $event->getFile() === $file; 56 | })); 57 | 58 | $this->service->textRecognized($ocrResult, $file); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tests/Unit/Service/GlobalSettingsServiceTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Service; 25 | 26 | use OCA\WorkflowOcr\AppInfo\Application; 27 | use OCA\WorkflowOcr\Model\GlobalSettings; 28 | use OCA\WorkflowOcr\Service\GlobalSettingsService; 29 | use OCP\IAppConfig; 30 | use PHPUnit\Framework\MockObject\MockObject; 31 | use Test\TestCase; 32 | 33 | class GlobalSettingsServiceTest extends TestCase { 34 | /** @var IAppConfig|MockObject */ 35 | private $config; 36 | 37 | /** @var GlobalSettingsService */ 38 | private $globalSettingsService; 39 | 40 | public function setUp() : void { 41 | parent::setUp(); 42 | $this->config = $this->createMock(IAppConfig::class); 43 | $this->globalSettingsService = new GlobalSettingsService($this->config); 44 | } 45 | 46 | public function testGetSettings_ReturnsCorrectSettings() { 47 | $this->config->expects($this->once()) 48 | ->method('getValueString') 49 | ->with(Application::APP_NAME, 'processorCount') 50 | ->willReturn('2'); 51 | 52 | $settings = $this->globalSettingsService->getGlobalSettings(); 53 | 54 | $this->assertInstanceOf(GlobalSettings::class, $settings); 55 | $this->assertEquals(2, $settings->processorCount); 56 | } 57 | 58 | public function testSetSettings_CallsConfigSetAppValue() { 59 | $settings = new GlobalSettings(); 60 | $settings->processorCount = '2'; 61 | 62 | $this->config->expects($this->once()) 63 | ->method('setValueString') 64 | ->with(Application::APP_NAME, 'processorCount', '2'); 65 | 66 | $this->globalSettingsService->setGlobalSettings($settings); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tests/Unit/Service/IMetadataVersionWithBackend.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Service; 25 | 26 | use OCA\Files_Versions\Versions\IMetadataVersion; 27 | 28 | /** 29 | * Interface for testing only. 30 | */ 31 | interface IMetadataVersionWithBackend extends IMetadataVersion { 32 | public function getBackend(): mixed; 33 | } 34 | -------------------------------------------------------------------------------- /tests/Unit/Settings/GlobalSettingsTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Settings; 25 | 26 | use OCA\WorkflowOcr\Settings\GlobalSettings; 27 | use Test\TestCase; 28 | 29 | class GlobalSettingsTest extends TestCase { 30 | /** @var GlobalSettings */ 31 | private $adminSettings; 32 | 33 | protected function setUp(): void { 34 | parent::setUp(); 35 | $this->adminSettings = new GlobalSettings(); 36 | } 37 | 38 | public function testGetSection() { 39 | $this->assertEquals('workflow', $this->adminSettings->getSection()); 40 | } 41 | 42 | public function testGetPriority() { 43 | $this->assertEquals(75, $this->adminSettings->getPriority()); 44 | } 45 | 46 | public function testGetForm() { 47 | $templateResponse = $this->adminSettings->getForm(); 48 | $templates = array_filter(scandir('./templates'), fn ($file) => is_file("./templates/$file")); 49 | $this->assertEquals(1, count($templates)); 50 | $templateFileName = './templates/' . $templates[array_keys($templates)[0]]; 51 | $templateNameWithoutExtension = pathinfo($templateFileName)['filename']; 52 | $this->assertEquals($templateNameWithoutExtension, $templateResponse->getTemplateName()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Unit/Wrapper/CommandWrapperTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Wrapper; 25 | 26 | use OCA\WorkflowOcr\Wrapper\CommandWrapper; 27 | use PHPUnit\Framework\TestCase; 28 | 29 | class CommandWrapperTest extends TestCase { 30 | public function testWrappingPositiveCommand() { 31 | $cmd = new CommandWrapper(); 32 | $cmd->setCommand('cat') 33 | ->setStdIn('hello'); 34 | $this->assertTrue($cmd->execute()); 35 | $this->assertEquals('hello', $cmd->getOutput()); 36 | $this->assertEquals(0, $cmd->getExitCode()); 37 | } 38 | 39 | public function testWrappingNegativeCommand() { 40 | $cmd = new CommandWrapper(); 41 | $cmd->setCommand('echo hello 1>&2'); 42 | $cmd->execute(); 43 | $this->assertEquals('hello', $cmd->getStdErr()); 44 | $this->assertEquals('', $cmd->getError()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/Unit/Wrapper/ViewFactoryTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\Wrapper; 25 | 26 | use OCA\WorkflowOcr\Wrapper\IView; 27 | use OCA\WorkflowOcr\Wrapper\ViewFactory; 28 | use PHPUnit\Framework\TestCase; 29 | 30 | class ViewFactoryTest extends TestCase { 31 | public function testFactoryReturnsIView() { 32 | $viewFactory = new ViewFactory(); 33 | $view = $viewFactory->create('somePath'); 34 | $this->assertTrue($view instanceof IView); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/Unit/composer/AutoloadTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * @license GNU AGPL version 3 or any later version 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see . 22 | */ 23 | 24 | namespace OCA\WorkflowOcr\Tests\Unit\composer; 25 | 26 | use OCA\WorkflowOcr\AppInfo\Application; 27 | use OCP\App\IAppManager; 28 | use OCP\AppFramework\App; 29 | use PHPUnit\Framework\TestCase; 30 | 31 | class AutoloadTest extends TestCase { 32 | public function testAutoloaderFileCanBeLoaded() { 33 | $app = new App(Application::APP_NAME); 34 | $container = $app->getContainer(); 35 | /** @var IAppManager */ 36 | $appManager = $container->get(IAppManager::class); 37 | $path = $appManager->getAppPath(Application::APP_NAME); 38 | $autoloaderFile = $path . '/composer/autoload.php'; 39 | $this->assertTrue(file_exists($autoloaderFile)); 40 | require $autoloaderFile; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 |