diff --git a/.github/workflows/npm-grunt.yml b/.github/workflows/npm-grunt.yml index a07f907c2..b196966a9 100644 --- a/.github/workflows/npm-grunt.yml +++ b/.github/workflows/npm-grunt.yml @@ -1,5 +1,52 @@ name: GruntComparison +on: + push: + branches: [ "master", "6.x-ocr" ] + pull_request: + branches: [ "master", "6.x-ocr" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + cache-dependency-path: './Build/package-lock.json' + + - name: Install and run Grunt + working-directory: ./Build + run: | + npm install -g grunt-cli + npm audit fix + echo "Running `grunt less`" + grunt less + echo "Running `grunt terser`" + grunt terser + + - name: Test for changes + working-directory: ./ + run: | + git diff -- ./Resources/Public/ + if [ -n "$(git status --porcelain -- ./Resources/Public/)" ]; then + echo "Changes detected in compiled files" + exit 1 + else + echo "No changes detected in compiled files" + fi +name: GruntComparison + on: push: branches: [ "master" ] diff --git a/Build/package.json b/Build/package.json index cba94b755..0622eb332 100644 --- a/Build/package.json +++ b/Build/package.json @@ -9,7 +9,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:slub/dfg-viewer.git" + "url": "git@github.com:csidirop/dfg-viewer.git" }, "author": "Alexander Bigga", "license": "GPL-3.0-or-later", diff --git a/Resources/Private/JavaScript/dfgviewerScripts.js b/Resources/Private/JavaScript/dfgviewerScripts.js index d14e4e8b2..c9c50bf66 100644 --- a/Resources/Private/JavaScript/dfgviewerScripts.js +++ b/Resources/Private/JavaScript/dfgviewerScripts.js @@ -1,4 +1,4 @@ -/*! + /*! Custom scripts ------------------------ @@ -20,11 +20,20 @@ $(document).ready(function() { // menu toggles for offcanvas toc and metadata $('.offcanvas-toggle').on(mobileEvent, function(event) { + // close nav on link or download if opened + close_all_submenus(); + $(this).parent().toggleClass('open'); }); // active toggle for submenus $('.document-functions li.submenu > a').on(mobileEvent, function(event) { + // close nav on link or download if opened + close_all_submenus('in-secondary-nav'); + + // close secondary nav if click on link or download + $('nav .secondary-nav').removeClass('open'); + $('li.submenu.open a').not(this).parent().removeClass('open'); $(this).parent().toggleClass('open'); return false; @@ -34,8 +43,18 @@ $(document).ready(function() { $('nav .nav-toggle').on(mobileEvent, function(event) { $(this).toggleClass('active'); $('nav .viewer-nav').toggleClass('open'); + + // close subnav if primary nav if opened + close_all_submenus('in-primary-nav'); + + }); + // active toggle for subsubmenus + $('.document-functions li.subsubmenu > a').on(mobileEvent, function(event) { + $(this).parent().toggleClass('open'); + return false; }); + // calendar dropdowns $('.calendar-view .contains-issues').on(mobileEvent, function(event) { $('.calendar-view table td.open').not($(this).parent()).removeClass('open'); @@ -104,6 +123,7 @@ $(document).ready(function() { // enable click on fullscreen button $('a.fullscreen').on(mobileEvent, function() { + close_all_submenus('all'); if($('body.fullscreen')[0]) { exitFullscreen(); } else { @@ -164,10 +184,80 @@ $(document).ready(function() { $('body').removeClass('static'); }, 1000); + // Closing open menus in different situations + $('.tx-dlf-tools-imagetools').on('click', function (event) { + close_all_submenus('all'); + }); + $('.page-control').on('click', function (event) { + close_all_submenus('all'); + }); + $('.tx-dlf-map').on('click', function (event) { + close_all_submenus('all'); + }); + + // Parse OCR options submenu + function parseOcrMenu() { + let lang = $('html').attr('lang').substr(0,2); + let ulid = $('#ocr-engine'); + let enginesData = JSON.parse(Cookies.get('tx-dlf-ocrEngines')).ocrEngines; + /* Expected scheme: + { + "menu":[ + {"name": "Tesseract", "de": "Tesseract", "en": "Tesseract", "class": "tesseract", "data": "tesseract-basic" + }, + {"name": "Tess", "de": "Tess (de)", "en": "Tess (en)", "class": "tess", "data": "tess-basic" + } + ]} + */ + + // get cookie for ocrEngine + let ocrEngine = Cookies.get('tx-dlf-ocrEngine'); + let active = ''; + + // Set listelement for remote fulltext (independent of the OCR engines): + if (Cookies.get('tx-dlf-ocr-remotepresent') === "Y") { // only if remote fulltext is present + active = ((ocrEngine === "originalremote") ? ' active' : ''); // set class active if this remote is active + + // Build element: + $(ulid).append('
  • Original fulltext
  • '); + $(ulid).append('
    '); // Add a dividing line + + if (active.length != 0) { + $('.ocr-create').addClass('disabled-item'); // deactivte OCR buttons + } + + // add class active to subelement, store info in cookie and deactivate OCR buttons: + $('#ocr-on-demand-id-originalremote').on(mobileEvent, function(event) { + $('.subli a').removeClass('active'); + $(this).addClass('active'); + Cookies.set('tx-dlf-ocrEngine', "originalremote", { sameSite: 'lax' }); // store in cookie + $('.ocr-create').addClass('disabled-item'); + }); + } + + // Set all other listelements (depending on the OCR engines): + for (let i=0; i' + + '' + + enginesData[i][lang] + ''); + + // add class active to subelement, store selected engine in cookie and reactivate OCR buttons: + $('#ocr-on-demand-id-' + enginesData[i].data).on(mobileEvent, function(event) { + $('.subli a').removeClass('active'); + $(this).addClass('active'); + Cookies.set('tx-dlf-ocrEngine', this.dataset.engine, { sameSite: 'lax' }); // store in cookie + $('.ocr-create').removeClass('disabled-item'); + }); + } + } + parseOcrMenu(); }); $(document).keyup(function(e) { - // Check if ESC key is pressed. Then end fullscreen mode or close SRU form. if (e.keyCode == 27) { if($('body.fullscreen')[0]) { @@ -181,7 +271,6 @@ $(document).keyup(function(e) { if (e.keyCode == 70 && !$('#tx-dfgviewer-sru-query').is(':focus')) { return enterFullscreen(); } - }); // Activate fullscreen mode and set corresponding cookie @@ -202,8 +291,21 @@ function exitFullscreen() { // hide warning about outdated browser and save decision to cookie function hideBrowserAlert(){ - $('#browser-hint').addClass('hidden'); Cookies.set('tx-dlf-pageview-hidebrowseralert', 'true', { sameSite: 'lax' }); +} +// Auto close submenus when other menus are opened +function close_all_submenus(environment = '') { + // close nav on link or download if opened + if (environment !== 'in-secondary-nav') { + // Not with in-secondary-nav otherwise menus can no longer be closed + $('li.submenu.open a').parent().removeClass('open'); + }; + if ((environment === 'in-secondary-nav') || (environment === 'all') ) { + // close subnav if opend + $('nav .nav-toggle').removeClass('active'); + $('nav .secondary-nav').removeClass('open'); + $('nav ul.viewer-nav').removeClass('open'); + }; } diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 429beaffe..24497391e 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -45,6 +45,14 @@ + + + + + + + + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 94a1251b4..e1e96773f 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -26,6 +26,12 @@ Download whole work + + Create text for all pages + + + Create text for current page + No fulltext in gridpage mode. @@ -35,6 +41,12 @@ No fulltext in double page mode. + + Perform OCR for current page + + + Perform OCR for current document + Thumbnail Preview diff --git a/Resources/Private/Less/components/controls.less b/Resources/Private/Less/components/controls.less index 4d9ce562d..ac3ba3d18 100644 --- a/Resources/Private/Less/components/controls.less +++ b/Resources/Private/Less/components/controls.less @@ -174,16 +174,72 @@ } } } + &.links { + > a, > span { + background-position: 0px 0; + } + } &.downloads { > a, > span { background-position: -40px 0; } } &.fulltext { + span.fulltext { + a.select { + &.active:before { + position: absolute; + top: 2px; + right: 0px; + width: 8px; + height: 8px; + border-radius: 8px; + border: 2px solid #fff; + background: @okay-green; + display: block; + content: " "; + } + } + } > a, > span { background-position: -120px 0; } } + &.ocr-on-demand { + > a, > span { + background: #fff url("../Images/PageOCR.svg") no-repeat 0 0 !important; + } + > ul { + li { + &.ocr-page { + a, span { + &:before { + background: url('../Images/PageOCR-white.svg') no-repeat 0 0 !important; + } + } + &.disabled-item { + a { + opacity: 0.4; /* 40% opacity */ + cursor: not-allowed; /* Show not-allowed cursor */ + } + } + } + &.ocr-book { + a, span { + &:before { + background: url('../Images/BookOCR-white.svg') no-repeat 0 0 !important; + } + } + &.disabled-item { + a { + opacity: 0.4; /* 40% opacity */ + cursor: not-allowed; /* Show not-allowed cursor */ + } + } + } + } + } + } &.doublepage { display: none; > a, > span { @@ -226,24 +282,6 @@ } } } - &.fulltext { - span.fulltext { - a.select { - &.active:before { - position: absolute; - top: 2px; - right: 0px; - width: 8px; - height: 8px; - border-radius: 8px; - border: 2px solid #fff; - background: @okay-green; - display: block; - content: " "; - } - } - } - } &.grid { > a, > span { background-position: -160px 0; @@ -322,6 +360,138 @@ } } +/* ==============[ OCR-on-Demand Settings Submenu ]===================== */ +.subsubmenu.ocr-on-demand-sub { + > a { + &#ocr-menu { + &:before { + padding-right: 30px; + background: url('../Images/OCR-Options-white.svg') no-repeat 0 0; + } + } + + &:after { + content: "+"; + margin-left: 8px; + position: absolute; + right: 10px; + left: auto; + } + } + + &.open { + > a:after { + content: "⌄"; + } + } + + ul.subunter { + position: absolute; + //left: 104%; // outside main box + left: 90%; // overlap with main box + right: auto; + background: fade(@base-blue,90%); + display: none; + top: auto; + } + + &.open { + ul.subunter { + display: list-item; + } + } + + #ocr-engine { + margin-right: 0; + padding-right: 0; + overflow-x: hidden; + overflow-y: auto; + + li.subli { + width: 100%; + margin-right: 30px; + + a { + width: 100%; + + // OCR-Engine Icons: + &.originalremote { + .ocr-engine-setup('../Images/OCR-FT-remote-white.svg'); + } + &.tesseract { + .ocr-engine-setup('../Images/OCR-Engines-Tesseract-white.svg'); + } + &.OCRD { + .ocr-engine-setup('../Images/OCR-Engines-OCRD-white.svg'); + } + &.kraken { + .ocr-engine-setup('../Images/OCR-Engines-Kraken-white.svg'); + } + + // OCR-Engine states: + &.active { + i.checks { + margin-left: 10px; + + &:before { + position: absolute; + top: 0; + left: auto; + right: 0; + width: 40px; + height: 40px; + content: ''; + background: url('../Images/checks.svg') no-repeat 0 0; + } + } + } + + &.present::before { + position: absolute; + top: 2px; + left: 4px; + width: 8px; + height: 8px; + border-radius: 8px; + border: 2px solid #fff; + background: @okay-green; + display: block; + content: " "; + } + + &.present:hover::after { + content: "Fulltext available"; + position: absolute; + z-index: 1; + top: -12px; + left: 16px; + background-color: transparent; + padding-right: 5px; + padding-left: 5px; + border-radius: 261px; + color: @okay-green; + text-shadow: + -1px -1px 0 @base-blue, /* top-left */ + 1px -1px 0 @base-blue, /* top-right */ + -1px 1px 0 @base-blue, /* bottom-left */ + 1px 1px 0 @base-blue; /* bottom-right */ + } + } + } + + // function for setting all ocr settings: + .ocr-engine-setup(@bgImage) { + background: url(@bgImage) no-repeat 0 0; + &:hover{ + background-color: rgba(255,255,255,0.2); + } + &::before{ // overwrite parent + background: none; + } + } + } +} + /* ==============[ view functions for zoom, rotate and other view related functions ]===== */ .view-functions { ul { diff --git a/Resources/Private/Less/modules/fulltext.less b/Resources/Private/Less/modules/fulltext.less index 3add201ce..c1bfb72d5 100644 --- a/Resources/Private/Less/modules/fulltext.less +++ b/Resources/Private/Less/modules/fulltext.less @@ -47,7 +47,9 @@ padding: 0; } .textline { + display: block; &:after { + display: block; content: " "; } } diff --git a/Resources/Private/Less/website/content.less b/Resources/Private/Less/website/content.less index e18ae1783..53b1f680e 100644 --- a/Resources/Private/Less/website/content.less +++ b/Resources/Private/Less/website/content.less @@ -7,7 +7,7 @@ * */ -.website { + .website { .page-container { text-align: left; line-height: 1.7; @@ -127,6 +127,7 @@ border: 1px solid @light-blue; border-width: 1px 0; padding: 20px 0; + padding-top: 0px; margin: 50px 0; br { display: none; @@ -169,7 +170,7 @@ outline: 0 none; } } - input[type="submit"], button[type="submit"], button[type="button"] { + input[type="submit"], button[type="submit"], button[type="button"], input[type="reset"], button[type="reset"] { position: relative; width: 100%; margin-top: 20px; @@ -214,10 +215,15 @@ padding: 0 150px; form { margin: 70px 0; + margin-top: 30px; input[type="submit"], button[type="submit"] { width: 32%; float: right; } + input[type="reset"], button[type="reset"] { + width: 32%; + float: left; + } button[type="button"] { width: 32%; float: left; diff --git a/Resources/Private/Less/website/home.less b/Resources/Private/Less/website/home.less index 3f3446468..f75f35c27 100644 --- a/Resources/Private/Less/website/home.less +++ b/Resources/Private/Less/website/home.less @@ -183,8 +183,11 @@ } } @media screen and (min-width: @tabletViewportWidth) { + .header { + padding-top: 140px; + } .header-image { - height: 340px; + height: 140px; &:after { background-size: 50% auto; } @@ -200,8 +203,11 @@ } } @media screen and (min-width: @desktopViewportWidth) { + .header { + padding-top: 220px; + } .header-image { - height: 440px; + height: 220px; } .frame-layout-101 { position: relative; diff --git a/Resources/Private/Partials/ControlBar.html b/Resources/Private/Partials/ControlBar.html index b08cb06bf..861b5830d 100644 --- a/Resources/Private/Partials/ControlBar.html +++ b/Resources/Private/Partials/ControlBar.html @@ -5,7 +5,7 @@
    -

    +