Skip to content

Commit

Permalink
- Fixed xslt bugs in web version and updated index.php.
Browse files Browse the repository at this point in the history
- Changed schema validation of both desktop and web versions using the new pagecontent_omnius.xsd but ignoring xmlns value.
- A couple of more docker ignores.
- Minor fixes in readme related to web version.
  • Loading branch information
mauvilsa committed Mar 3, 2020
1 parent e8f95d2 commit 6110d08
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ debian
html
bin
js/nw-*.js
githook-pre-commit
[WT]*
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

nw-page-editor - Simple app for visual editing of Page XML files.

Version: 2020.03.02
Version: 2020.03.03


# Description
Expand Down Expand Up @@ -172,7 +172,7 @@ The page editor can also be used as a web server allowing multiple users to edit

1. [Install docker](https://docs.docker.com/install/) in the server and for convenience configure it so that [sudo is not required](https://docs.docker.com/install/linux/linux-postinstall/) to run containers.

2. Either pull the latest image of nw-page-editor-web from [docker hub](https://cloud.docker.com/repository/docker/mauvilsa/nw-page-editor-web/tags) by choosing one of the available tags.
2. Either pull the latest image of nw-page-editor-web from [docker hub](https://cloud.docker.com/repository/docker/mauvilsa/nw-page-editor-web/tags) by choosing one of the available tags or build the docker image from the source.

```bash
### Pull from docker hub ###
Expand Down Expand Up @@ -201,14 +201,14 @@ git init data

```bash
### Create users and passwords ###
docker-command-line-interface -- mauvilsa/nw-page-editor-web:$TAG htpasswd -cb data/.htpasswd user1 pass1
docker-command-line-interface -- mauvilsa/nw-page-editor-web:$TAG htpasswd -b data/.htpasswd user2 pass2
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd -cb data/.htpasswd user1 pass1
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd -b data/.htpasswd user2 pass2

### For more details on htpasswd usage ###
docker-command-line-interface -- mauvilsa/nw-page-editor-web:$TAG htpasswd --help
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd --help
```

5. Start a container exposing the web server port 80 to a port of your liking (e.g. 8080) and set the data directory as a volume.
5. Start a container exposing the web server port 80 to a port of your preferece (e.g. 8080) and set the data directory as a volume.

```bash
docker run -d -p 8080:80 -v $(pwd)/data:/var/www/nw-page-editor/data mauvilsa/nw-page-editor-web:$TAG
Expand Down
5 changes: 3 additions & 2 deletions js/nw-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* NW.js app functionality for nw-page-editor.
*
* @version $Version: 2020.03.02$
* @version $Version: 2020.03.03$
* @author Mauricio Villegas <mauricio_ville@yahoo.com>
* @copyright Copyright(c) 2015-present, Mauricio Villegas <mauricio_ville@yahoo.com>
* @license MIT License
Expand Down Expand Up @@ -476,7 +476,7 @@ $(window).on('load', function () {

/// Setup Page XML schema validation ///
var
pagexml_xsd_file = '../xsd/pagecontent_searchink.xsd',
pagexml_xsd_file = '../xsd/pagecontent_omnius.xsd',
pagexml_xsd = false;
function loadPageXmlXsd( async ) {
if ( ! pagexml_xsd )
Expand All @@ -496,6 +496,7 @@ $(window).on('load', function () {
pageXml = pageCanvas.getXmlPage();
if ( ! pageXml )
return;
pageXml = pageXml.replace(/ xmlns="[^"]+"/, ' xmlns="'+pageCanvas.cfg.pagexmlns+'"');
pageXml = unescape(encodeURIComponent(pageXml));
loadPageXmlXsd(false);
try {
Expand Down
6 changes: 4 additions & 2 deletions js/web-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* App functionality for the web edition of nw-page-editor.
*
* @version $Version: 2017.10.04$
* @version $Version: 2020.03.03$
* @author Mauricio Villegas <mauricio_ville@yahoo.com>
* @copyright Copyright(c) 2015-present, Mauricio Villegas <mauricio_ville@yahoo.com>
* @license MIT License
Expand All @@ -11,7 +11,9 @@ $(window).on('load', function () {

/// Additional pageCanvas configuration ///
pageCanvas.setConfig(
{ onLoad: successfulFileLoad,
{ importSvgXsltHref: [ '../xslt/page2svg.xslt', '../xslt/page_from_2010-03-19.xslt', '../xslt/page_from_2017-07-15.xslt', '../xslt/page_from_omnius.xslt', '../xslt/alto_v2_to_page.xslt', '../xslt/alto_v3_to_page.xslt' ],
exportSvgXsltHref: [ '../xslt/svg2page.xslt', '../xslt/sortattr.xslt', '../xslt/page_fix_xsd_sequence.xslt' ],
onLoad: successfulFileLoad,
onUnload: function () { $('#saveFile').prop('disabled',true); },
onChange: function () { autosavetime = 0; },
onFirstChange: function () { $('#saveFile').prop('disabled',false); /*$('title').text($('title').text()+' *');*/ }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nw-page-editor",
"version": "2020.03.02",
"version": "2020.03.03",
"description": "Simple app for visual editing of Page XML files",
"main": "./html/index.html#1",
"author": "Mauricio Villegas <mauricio_ville@yahoo.com>",
Expand Down
4 changes: 2 additions & 2 deletions web-app/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/**
* Common code to be executed by other php scripts.
*
* @version $Version: 2020.03.02$
* @version $Version: 2020.03.03$
* @author Mauricio Villegas <mauricio_ville@yahoo.com>
* @copyright Copyright(c) 2017-present, Mauricio Villegas <mauricio_ville@yahoo.com>
* @license MIT License
*/

$version = str_replace('Version: ','',"Version: 2020.03.02");
$version = str_replace('Version: ','',"Version: 2020.03.03");
$v = '?v='.$version;

/// User authentication ///
Expand Down
4 changes: 2 additions & 2 deletions web-app/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
- Main PHP file of nw-page-editor web edition.
-
- @version $Version: 2019.07.01$
- @version $Version: 2020.03.03$
- @author Mauricio Villegas <mauricio_ville@yahoo.com>
- @copyright Copyright(c) 2015-present, Mauricio Villegas <mauricio_ville@yahoo.com>
- @license MIT License
Expand Down Expand Up @@ -84,7 +84,7 @@
</div>
<button id="nextPage" disabled="" class="tooltip-down" data-tooltip="next document">→</button>
<div id="textFilter" style="display:none;">
<b class="tooltip-down" data-tooltip="Keep only elements containing some text and/or matching css selector&#xa; or xpath (e.g. 'lorem ipsum [id^=reg1]', '!//_:g[*[@value=&quot;printed&quot;]]')">Filter:</b>
<b class="tooltip-down" data-tooltip="Keep only elements containing some text and/or matching css selector&#xa;(e.g. lorem ipsum [id^=reg1]) or if starting with '!' an xpath (e.g.&#xa;!//_:g[*[@value=&quot;printed&quot;]])">Filter:</b>
<input name="filter" type="text" placeholder="text or css/xpath selector" class="mousetrap"/>
<button id="clearFilter" tabindex="-1">X</button>
</div>
Expand Down
18 changes: 15 additions & 3 deletions web-app/saveFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Saves Page XML files and if configured, requests the file to be commited to git.
*
* @version $Version: 2017.10.06$
* @version $Version: 2020.03.03$
* @author Mauricio Villegas <mauricio_ville@yahoo.com>
* @copyright Copyright(c) 2017-present, Mauricio Villegas <mauricio_ville@yahoo.com>
* @license MIT License
Expand Down Expand Up @@ -48,15 +48,27 @@
echo json_encode($resp)."\n";
exit($resp->code);
}
$cmd = 'xmllint --noout --schema ../xsd/pagecontent_searchink.xsd '.$_GET['fname'].'~'.$numtemp.' 2>&1';
$last = exec($cmd,$output,$valid);
exec("sed -n -r '/ xmlns=\"[^\"]+\"/{ s|.* xmlns=\"||; s|\".*||; p; }' ../xsd/pagecontent_omnius.xsd",$ns_schema,$rc1);
exec("sed -r '/ xmlns=\"[^\"]+\"/{ s| xmlns=\"[^\"]+\"| xmlns=\"".$ns_schema[0]."\"|; }' ".$_GET['fname'].'~'.$numtemp,$output,$rc2);
if( $rc1 != 0 || $rc2 != 0 ) {
file_put_contents($_GET['fname'].'.svg~'.$numtemp,$_GET['xml']);
$resp->code = 400;
$resp->message = "Problems handling namespace of schema.";
echo json_encode($resp)."\n";
exit($resp->code);
}
file_put_contents($_GET['fname'].'~'.$numtemp.'-',implode("\n",$output));
$cmd = 'xmllint --noout --schema ../xsd/pagecontent_omnius.xsd '.$_GET['fname'].'~'.$numtemp.'- 2>&1';
unset($output);
exec($cmd,$output,$valid);
if( $valid != 0 ) {
file_put_contents($_GET['fname'].'.svg~'.$numtemp,$_GET['xml']);
$resp->code = 400;
$resp->message = "Page XML schema validation failed:\n".implode("\n",$output);
echo json_encode($resp)."\n";
exit($resp->code);
}
unlink($_GET['fname'].'~'.$numtemp.'-');

/// Rename temporal XML ///
rename( $_GET['fname'].'~'.$numtemp, $_GET['fname'] );
Expand Down

0 comments on commit 6110d08

Please sign in to comment.