diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index a46ad5129..ca8d01b6a 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 - name: Get short sha - uses: benjlevesque/short-sha@v2.2 + uses: benjlevesque/short-sha@v3.0 id: short-sha with: length: 7 @@ -31,7 +31,7 @@ jobs: - name: Upload Artifacts to action run if: github.repository == 'Edirom/Edirom-Online' - uses: actions/upload-artifact@v4.3.0 + uses: actions/upload-artifact@v4.3.1 with: # The name that the artifact will be made available under name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip diff --git a/add/data/xqm/source.xqm b/add/data/xqm/source.xqm index 001ab77cb..812eb1920 100644 --- a/add/data/xqm/source.xqm +++ b/add/data/xqm/source.xqm @@ -34,20 +34,29 @@ declare namespace mei="http://www.music-encoding.org/ns/mei"; import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; (:~ -: Returns whether a document is a source or not +: Returns whether a document is a source or not. Generally this should work for MEI versions +: 2011-05 through 5.0 : : @param $uri The URI of the document -: @return Is work or not +: +: @return xs:boolean indicating whether the document referenced by @param $uri +: is considered a music source or not. :) declare function source:isSource($uri as xs:string) as xs:boolean { let $doc := eutil:getDoc($uri) - let $meiVersionRegex := '(([4-9])|(\d+[0-9]))\.\d+\.\d+(-dev)?' + let $meiVersion4To5Regex := '^[4-5](\.\d){1,2}(-dev)?(\+(anyStart|basic|CMN|Mensural|Neumes))?$' + (: 2010-05 pre camelCase :) + (: 2011-05 2012 :) + (: 2013 +meiversion.num 2.1.1:) + (: 3.0.0 :) + (:mei2 and ?3 :) return (exists($doc//mei:mei) and exists($doc//mei:source)) (:mei2 and ?3 :) or - (matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation[@singleton='true'])) (:mei4+ for manuscripts:) + (: MEI 4.0.1 and 5.0 with all dev and cutomization variants :) + (matches($doc//mei:mei/@meiversion, $meiVersion4To5Regex) and exists($doc//mei:manifestation[@singleton='true'])) (:mei4+ for manuscripts:) or - (matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation//mei:item)) (: mei4+ for prints :) + (matches($doc//mei:mei/@meiversion, $meiVersion4ToRegex) and exists($doc//mei:manifestation//mei:item)) (: mei4+ for prints :) }; (:~ diff --git a/app/controller/window/text/FacsimileView.js b/app/controller/window/text/FacsimileView.js index 642fc00d3..930f79d27 100644 --- a/app/controller/window/text/FacsimileView.js +++ b/app/controller/window/text/FacsimileView.js @@ -16,75 +16,85 @@ * You should have received a copy of the GNU General Public License * along with Edirom Online. If not, see . */ -Ext.define('EdiromOnline.controller.window.text.FacsimileView', { +Ext.define("EdiromOnline.controller.window.text.FacsimileView", { + extend: "Ext.app.Controller", - extend: 'Ext.app.Controller', + views: ["window.text.FacsimileView"], - views: [ - 'window.text.FacsimileView' - ], - - init: function() { + init: function () { this.control({ - 'facsimileView': { - afterlayout : this.onAfterLayout, - single: true - } + facsimileView: { + afterlayout: this.onAfterLayout, + single: true, + }, }); }, - - onAfterLayout: function(view) { + onAfterLayout: function (view) { var me = this; - if(view.initialized) return; + if (view.initialized) return; view.initialized = true; - view.on('gotoChapter', me.onGotoChapter, me); + view.on("gotoChapter", me.onGotoChapter, me); var uri = view.uri; - window.doAJAXRequest('data/xql/getPages.xql', - 'GET', + window.doAJAXRequest( + "data/xql/getPages.xql", + "GET", { - uri: uri + uri: uri, }, - Ext.bind(function(response){ + Ext.bind(function (response) { var data = response.responseText; - var pages = Ext.create('Ext.data.Store', { - fields: ['id', 'name', 'path', 'width', 'height', 'measures', 'annotations'], - data: Ext.JSON.decode(data) + var pages = Ext.create("Ext.data.Store", { + fields: [ + "id", + "name", + "path", + "width", + "height", + "measures", + "annotations", + ], + data: Ext.JSON.decode(data), }); - view.setImageSet(pages); - }, this) + me.pagesLoaded(pages, view); + }, this), ); - - window.doAJAXRequest('data/xql/getChapters.xql', - 'GET', + + window.doAJAXRequest( + "data/xql/getChapters.xql", + "GET", { uri: view.uri, - mode: 'pageMode' + mode: "pageMode", }, - Ext.bind(function(response){ + Ext.bind(function (response) { var data = response.responseText; - var chapters = Ext.create('Ext.data.Store', { - fields: ['id', 'name', 'pageId'], - data: Ext.JSON.decode(data) + var chapters = Ext.create("Ext.data.Store", { + fields: ["id", "name", "pageId"], + data: Ext.JSON.decode(data), }); me.chaptersLoaded(chapters, view); - }, this) + }, this), ); }, - - chaptersLoaded: function(chapters, view) { + + pagesLoaded: function (pages, view) { + view.setImageSet(pages); + }, + + chaptersLoaded: function (chapters, view) { view.setChapters(chapters); }, - - onGotoChapter: function(view, pageId) { + + onGotoChapter: function (view, pageId) { view.gotoPage(pageId); - } + }, }); diff --git a/app/view/window/text/FacsimileView.js b/app/view/window/text/FacsimileView.js index 7a17c0ef1..bbb101d2c 100644 --- a/app/view/window/text/FacsimileView.js +++ b/app/view/window/text/FacsimileView.js @@ -1,14 +1,34 @@ -Ext.define('EdiromOnline.view.window.text.FacsimileView', { - extend: 'EdiromOnline.view.window.View', +/** + * Edirom Online + * Copyright (C) 2014 The Edirom Project + * http://www.edirom.de + * + * Edirom Online is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Edirom Online is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Edirom Online. If not, see . + * + */ +Ext.define("EdiromOnline.view.window.text.FacsimileView", { + extend: "EdiromOnline.view.window.View", requires: [ - 'EdiromOnline.view.window.image.ImageViewer', - 'EdiromOnline.view.window.image.LeafletFacsimile' + "EdiromOnline.view.window.image.ImageViewer", + "EdiromOnline.view.window.image.OpenSeaDragonViewer", + "EdiromOnline.view.window.image.LeafletFacsimile", ], - alias : 'widget.facsimileView', + alias: "widget.facsimileView", - layout: 'border', + layout: "border", border: 0, @@ -18,95 +38,110 @@ Ext.define('EdiromOnline.view.window.text.FacsimileView', { measuresVisible: false, annotationsVisible: false, - image_server: null, + image_server: null, + + cls: "facsimileView", initComponent: function () { + var me = this; - this.addEvents(); - - this.image_server = getPreference('image_server'); - - if(this.image_server === 'leaflet'){ - this.imageViewer = Ext.create('EdiromOnline.view.window.image.LeafletFacsimile'); - } - else{ - this.imageViewer = Ext.create('EdiromOnline.view.window.image.ImageViewer'); - } + me.addEvents(); + + var image_server = getPreference("image_server"); + + if (image_server === "leaflet") { + me.imageViewer = Ext.create( + "EdiromOnline.view.window.image.LeafletFacsimile", + { flex: 1, width: "100%" }, + ); + } else if (image_server === "openseadragon") { + me.imageViewer = Ext.create( + "EdiromOnline.view.window.image.OpenSeaDragonViewer", + ); + } else { + /*TODO: test agains 'digilib'? -> what should be the fallback? */ + me.imageViewer = Ext.create( + "EdiromOnline.view.window.image.ImageViewer", + ); + } - this.imageViewer.region = 'center'; + me.imageViewer.region = "center"; - this.bottomBar = new EdiromOnline.view.window.BottomBar({owner:this, region:'south'}); + me.bottomBar = new EdiromOnline.view.window.BottomBar({ + owner: me, + region: "south", + enableOverflow: false, + }); - this.items = [ - this.imageViewer, - this.bottomBar - ]; + me.items = [me.imageViewer, me.bottomBar]; - this.callParent(); + me.callParent(); - this.on('afterrender', this.createMenuEntries, this, {single: true}); - this.on('afterrender', this.createToolbarEntries, this, {single: true}); - this.imageViewer.on('zoomChanged', this.updateZoom, this); + me.on("afterrender", me.createMenuEntries, me, { single: true }); + me.on("afterrender", me.createToolbarEntries, me, { single: true }); + me.imageViewer.on("zoomChanged", me.updateZoom, me); - this.window.on('loadInternalLink', this.loadInternalId, this); + me.window.on("loadInternalLink", me.loadInternalId, me); }, - getWeightForInternalLink: function(uri, type, id) { + getWeightForInternalLink: function (uri, type, id) { var me = this; - - if(me.uri != uri) - return 0; - - if(type == 'graphic' || type == 'surface' || type == 'zone') - return 70; - + + if (me.uri != uri) return 0; + + if (type == "graphic" || type == "surface" || type == "zone") return 70; + return 0; }, - loadInternalId: function() { + loadInternalId: function () { var me = this; - if(me.window.internalIdType == 'surface' || me.window.internalIdType == 'graphic' ) { + if ( + me.window.internalIdType == "surface" || + me.window.internalIdType == "graphic" + ) { me.window.requestForActiveView(me); me.showPage(me.window.internalId); } }, - setImageSet: function(imageSet) { + setImageSet: function (imageSet) { var me = this; me.imageSet = imageSet; me.pageSpinner.setStore(me.imageSet); - if(me.imageToShow != null) { + if (me.imageToShow != null) { me.pageSpinner.setPage(me.imageSet.getById(me.imageToShow)); me.imageToShow = null; - - }else if(me.imageSet.getCount() > 0) + } else if (me.imageSet.getCount() > 0) me.pageSpinner.setPage(me.imageSet.getAt(0)); - - me.fireEvent('afterImagesLoaded', me, imageSet); - }, - setPage: function(combo, store) { + me.fireEvent("afterImagesLoaded", me, imageSet); + }, + setPage: function (combo, store) { var me = this; // Remove old stuff me.imageViewer.clear(); var id = combo.getValue(); - var imgIndex = me.imageSet.findExact('id', id); + var imgIndex = me.imageSet.findExact("id", id); me.activePage = me.imageSet.getAt(imgIndex); - me.imageViewer.showImage(me.activePage.get('path'), - me.activePage.get('width'), me.activePage.get('height')); + me.imageViewer.showImage( + me.activePage.get("path"), + me.activePage.get("width"), + me.activePage.get("height"), + ); }, - showPage: function(pageId) { + showPage: function (pageId) { var me = this; - if(me.imageSet == null) { + if (me.imageSet == null) { me.imageToShow = pageId; return; } @@ -114,113 +149,236 @@ Ext.define('EdiromOnline.view.window.text.FacsimileView', { me.pageSpinner.setPage(me.imageSet.getById(pageId)); }, - getActivePage: function() { + getActivePage: function () { return this.activePage; }, - createMenuEntries: function() { - + createMenuEntries: function () { var me = this; - me.viewMenu = Ext.create('Ext.button.Button', { - text: getLangString('view.window.source.SourceView_viewMenu'), + var image_server = getPreference("image_server"); + + if (image_server === "digilib") { + me.zoomSlider = Ext.create("Ext.slider.Single", { + width: 140, + value: 100, + increment: 5, + minValue: 10, + maxValue: 400, + checkChangeBuffer: 100, + useTips: true, + cls: "zoomSlider", + tipText: function (thumb) { + return Ext.String.format("{0}%", thumb.value); + }, + listeners: { + change: Ext.bind(me.zoomChanged, me, [], 0), + }, + }); + } + if (image_server === "openseadragon") { + me.zoomSlider = Ext.create("Ext.slider.Single", { + width: 140, + value: 100, + increment: 5, + minValue: 90, + maxValue: 700, + checkChangeBuffer: 100, + useTips: true, + cls: "zoomSlider", + tipText: function (thumb) { + return Ext.String.format("{0}%", thumb.value); + }, + listeners: { + change: Ext.bind(me.zoomChanged, me, [], 0), + }, + }); + } + + /*TODO + pageSppinner + separator + */ + + if (image_server === "digilib" || image_server === "openseadragon") { + return [me.zoomSlider, me.separator, me.pageSpinner]; + } else { + return [me.pageSpinner]; + } + + me.viewMenu = Ext.create("Ext.button.Button", { + text: getLangString("view.window.source.SourceView_viewMenu"), indent: false, - cls: 'menuButton', - menu : { + cls: "menuButton", + menu: { items: [ { - id: me.id + '_fitFacsimile', - text: getLangString('view.window.source.SourceView_fitView'), - handler: Ext.bind(me.fitFacsimile, me, [], 0) - } - ] - } + id: me.id + "_fitFacsimile", + text: getLangString( + "view.window.source.SourceView_fitView", + ), + handler: Ext.bind(me.fitFacsimile, me, [], 0), + }, + ], + }, }); me.window.getTopbar().addViewSpecificItem(me.viewMenu, me.id); }, - createToolbarEntries: function() { - + createToolbarEntries: function () { var me = this; - if(me.image_server === 'digilib'){ - me.zoomSlider = Ext.create('Ext.slider.Single', { - width: 140, - value: 100, - increment: 5, - minValue: 10, - maxValue: 400, - checkChangeBuffer: 100, - useTips: true, - cls: 'zoomSlider', - tipText: function(thumb){ - return Ext.String.format('{0}%', thumb.value); - }, - listeners: { - change: Ext.bind(me.zoomChanged, me, [], 0) - } - }); - me.bottomBar.add(me.zoomSlider); - } - - me.pageSpinner = Ext.create('EdiromOnline.view.window.util.PageSpinner', { - width: 121, - cls: 'pageSpinner', - owner: me + var image_server = getPreference("image_server"); + + if (image_server === "digilib") { + me.zoomSlider = Ext.create("Ext.slider.Single", { + width: 140, + value: 100, + increment: 5, + minValue: 10, + maxValue: 400, + checkChangeBuffer: 100, + useTips: true, + cls: "zoomSlider", + tipText: function (thumb) { + return Ext.String.format("{0}%", thumb.value); + }, + listeners: { + change: Ext.bind(me.zoomChanged, me, [], 0), + }, + }); + } + if (image_server === "openseadragon") { + me.zoomSlider = Ext.create("Ext.slider.Single", { + width: 140, + value: 100, + increment: 5, + minValue: 90, + maxValue: 700, + checkChangeBuffer: 100, + useTips: true, + cls: "zoomSlider", + tipText: function (thumb) { + return Ext.String.format("{0}%", thumb.value); + }, + listeners: { + change: Ext.bind(me.zoomChanged, me, [], 0), + }, + }); + } + + me.pageSpinner = Ext.create( + "EdiromOnline.view.window.util.PageSpinner", + { + width: 121, + cls: "pageSpinner", + owner: me, + }, + ); + + me.separator = Ext.create("Ext.toolbar.Separator"); + + var entries = []; + + if (image_server === "digilib" || image_server === "openseadragon") { + entries = [me.zoomSlider, me.separator, me.pageSpinner]; + } else { + entries = [me.pageSpinner]; + } + + Ext.Array.each(entries, function (entry) { + if ( + image_server === "digilib" || + image_server === "openseadragon" + ) { + me.bottomBar.add(entry); + } else if ( + entry.initialCls !== "zoomSlider" && + entry.xtype !== "tbseparator" + ) { + me.bottomBar.add(entry); + } }); - me.bottomBar.add(me.pageSpinner); }, - fitFacsimile: function() { + hideToolbarEntries: function () { + var me = this; + if (typeof me.zoomSlider !== "undefined") { + me.zoomSlider.hide(); + } + me.pageSpinner.hide(); + if (typeof me.separator !== "undefined") { + me.separator.hide(); + } + }, + + showToolbarEntries: function () { + var me = this; + if (typeof me.zoomSlider !== "undefined") { + me.zoomSlider.show(); + } + me.pageSpinner.show(); + if (typeof me.separator !== "undefined") { + me.separator.show(); + } + }, + + fitFacsimile: function () { this.imageViewer.fitInImage(); }, - updateZoom: function(zoom) { - this.zoomSlider.suspendEvents(); - this.zoomSlider.setValue(Math.round(zoom * 100)); - this.zoomSlider.resumeEvents(); + updateZoom: function (zoom) { + if (typeof this.zoomSlider !== "undefined") { + this.zoomSlider.suspendEvents(); + this.zoomSlider.setValue(Math.round(zoom * 100)); + this.zoomSlider.resumeEvents(); + } }, - zoomChanged: function(slider) { + zoomChanged: function (slider) { this.imageViewer.setZoomAndCenter(slider.getValue() / 100); }, - - setChapters: function(chapters) { + + setChapters: function (chapters) { var me = this; - if(chapters.getTotalCount() == 0) return; + if (chapters.getTotalCount() == 0) return; - me.gotoMenu = Ext.create('Ext.button.Button', { - text: getLangString('view.window.text.TextView_gotoMenu'), + me.gotoMenu = Ext.create("Ext.button.Button", { + text: getLangString("view.window.text.TextView_gotoMenu"), indent: false, - cls: 'menuButton', - menu : { - items: [ - ] - } + cls: "menuButton", + menu: { + items: [], + }, }); me.window.getTopbar().addViewSpecificItem(me.gotoMenu, me.id); me.chapters = chapters; var chapterItems = []; - chapters.each(function(chapter) { + chapters.each(function (chapter) { chapterItems.push({ - text: chapter.get('name'), - handler: Ext.bind(me.gotoChapter, me, chapter.get('pageId'), true) + text: chapter.get("name"), + handler: Ext.bind( + me.gotoChapter, + me, + chapter.get("pageId"), + true, + ), }); }); me.gotoMenu.menu.add(chapterItems); me.gotoMenu.show(); }, - - gotoChapter: function (menuItem, event, pageId) { - this.fireEvent('gotoChapter', this, pageId); - }, - + + gotoChapter: function (menuItem, event, pageId) { + this.fireEvent("gotoChapter", this, pageId); + }, + gotoPage: function (pageId) { - var me = this; - me.pageSpinner.setPage(me.imageSet.getById(pageId)); - } -}); \ No newline at end of file + var me = this; + me.pageSpinner.setPage(me.imageSet.getById(pageId)); + }, +});