Skip to content

Commit

Permalink
web-app:
Browse files Browse the repository at this point in the history
- Data is truly sent as json to saveFile.php.
  • Loading branch information
mauvilsa committed Oct 28, 2020
1 parent 038257a commit 9ce7bd0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 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.10.09
Version: 2020.10.28


# Description
Expand Down Expand Up @@ -180,7 +180,7 @@ docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd -b data/.htpasswd user2@
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 preferece
5. Start a container exposing the web server port 80 to a port of your preference
(e.g. 8080) and set the data directory as a volume.

```bash
Expand Down
4 changes: 2 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: 2020.04.07$
* @version $Version: 2020.10.28$
* @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 @@ -169,7 +169,7 @@ $(window).on('load', function () {
xml: pageXml
};

$.ajax({ url: 'saveFile.php', method: 'POST', data: data, dataType: 'json', timeout: 8000 })
$.ajax({ url: 'saveFile.php', method: 'POST', data: JSON.stringify(data), dataType: 'json', timeout: 8000, contentType: 'application/json;charset=UTF-8' })
.fail( function () {
savingFile = false;
$('#spinner').removeClass('spinner-active');
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.10.09",
"version": "2020.10.28",
"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.10.09$
* @version $Version: 2020.10.28$
* @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.10.09");
$version = str_replace('Version: ','',"Version: 2020.10.28");
$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: 2020.06.25$
- @version $Version: 2020.10.28$
- @author Mauricio Villegas <mauricio_ville@yahoo.com>
- @copyright Copyright(c) 2015-present, Mauricio Villegas <mauricio_ville@yahoo.com>
- @license MIT License
Expand All @@ -29,7 +29,7 @@
exit;
}
if ( ! preg_match('/\.xml$/',$_GET['f']) ) {
echo 'error: expected file to have a .xml extension: '.$_GET['f'];
echo 'error: expected file to have an .xml extension: '.$_GET['f'];
exit;
}
}
Expand Down
4 changes: 3 additions & 1 deletion 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: 2020.10.09$
* @version $Version: 2020.10.28$
* @author Mauricio Villegas <mauricio_ville@yahoo.com>
* @copyright Copyright(c) 2017-present, Mauricio Villegas <mauricio_ville@yahoo.com>
* @license MIT License
Expand All @@ -17,6 +17,8 @@
$resp->code = 200;

/// Accept any of GET, POST and command line ///
$json = json_decode(file_get_contents('php://input'), true);
$_GET = array_merge( $_GET, $json );
$_GET = array_merge( $_GET, $_POST );
if( ! isset($_SERVER['HTTP_HOST']) )
for( $k = 1; $k < count($argv); $k++ ) {
Expand Down

0 comments on commit 9ce7bd0

Please sign in to comment.