Skip to content

Commit

Permalink
Extend serialization prefs to Synchronize command
Browse files Browse the repository at this point in the history
Requires eXist-db/exist#4254, merged and planned for inclusion in eXist 6.1.0.
  • Loading branch information
joewiz committed Jan 24, 2023
1 parent d2e5146 commit 16673c1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ When loading XML documents from the database into an editor window, you can cont
as whether indentation is automatically applied, whether XInclude elements are automatically expanded, and whether XML
declarations are omitted. Set these preferences in "Edit > Preferences > Serialization." Additional sets of these preferences
are available for download of XML documents via "File > Download" and for
the serialization of XML documents included in application packages via ["Application > Download app"](#Support-for-EXPath-Packages).
By default, indentation is turned on for opening and downloading files but is off for downloading EXPath Packages; XInclude
the serialization of XML documents included in application packages via ["Application > Download app and Synchronize"](#Support-for-EXPath-Packages).
By default, indentation is turned on for opening and downloading files but is off for downloading and synchronizing EXPath Packages; XInclude
expansion is turned off in all cases; and the XML declaration is omitted in all cases.

## Options for displaying query results
Expand Down
2 changes: 1 addition & 1 deletion expath-pkg.xml.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg" name="http://exist-db.org/apps/eXide" abbrev="eXide" version="{{version}}" spec="1.0">
<title>eXide - XQuery IDE</title>
<dependency processor="http://exist-db.org" semver-min="5.3.0"/>
<dependency processor="http://exist-db.org" semver-min="6.1.0"/>
</package>
2 changes: 1 addition & 1 deletion index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
<input type="checkbox" name="omit-xml-decl-on-download" id="omit-xml-decl-on-download"/>
</li>
</ol>
<h3>Downloading EXPath packages (via Application > Download App)</h3>
<h3>Downloading and synchronizing EXPath packages (via Application > Download App and Synchronize) </h3>
<ol>
<li>
<label for="indent-on-download-package">Indent:</label>
Expand Down
15 changes: 12 additions & 3 deletions modules/synchronize.xq
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
: You should have received a copy of the GNU General Public License
: along with this program. If not, see <http://www.gnu.org/licenses/>.
:)
xquery version "1.0";
xquery version "3.1";

import module namespace file="http://exist-db.org/xquery/file" at "java:org.exist.xquery.modules.file.FileModule";
import module namespace apputil="http://exist-db.org/apps/eXide/apputil" at "util.xqm";
Expand All @@ -43,9 +43,18 @@ declare function local:format-output($output) {
};

let $startParam := request:get-parameter("start", ())
let $startTime := if (empty($startParam) or $startParam eq "") then () else $startParam
let $startTime := if (empty($startParam) or $startParam eq "") then () else $startParam cast as xs:dateTime
let $collection := request:get-parameter("collection", ())
let $dir := request:get-parameter("dir", apputil:get-info-from-descriptor($collection)/workingDir/string())
let $output := file:sync($collection, $dir, $startTime)
let $indent := request:get-parameter("indent", true()) cast as xs:boolean
let $expand-xincludes := request:get-parameter("expand-xincludes", false()) cast as xs:boolean
let $omit-xml-declaration := request:get-parameter("omit-xml-declaration", true()) cast as xs:boolean
let $sync-params := map {
"after": $startTime,
"indent": $indent,
"expand-xincludes": $expand-xincludes,
"omit-xml-declaration": $omit-xml-declaration
}
let $output := file:sync($collection, $dir, $sync-params)
return
local:format-output($output)
28 changes: 23 additions & 5 deletions src/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ eXide.edit.PackageEditor = (function () {
}
$this.currentProject.dir = dir;

var params = $this.syncDialog.find("form").serialize();
var params = {
start: $this.syncDialog.find("input[name=\"start\"]").val(),
dir: dir,
auto: $this.syncDialog.find("input[name=\"auto\"]").val(),
collection: $this.syncDialog.find("input[name=\"collection\"]").val(),
indent: $("#indent-on-download-package").is(":checked"),
"expand-xincludes": $("#expand-xincludes-on-download-package").is(":checked"),
"omit-xml-declarationaration": $("#omit-xml-declaration-on-download-package").is(":checked")
};
$("#synchronize-report").text("Synchronization in progress ...");
$("#synchronize-report").load("modules/synchronize.xq", params);
},
Expand Down Expand Up @@ -193,10 +201,17 @@ eXide.edit.PackageEditor = (function () {
return;
}

var params = {
collection: $this.currentProject.root,
start: start,
indent: $("#indent-on-download-package").is(":checked"),
"expand-xincludes": $("#expand-xincludes-on-download-package").is(":checked"),
"omit-xml-declaration": $("#omit-xml-declaration-on-download-package").is(":checked")
};
$(statusAnchor).text("Synchronization in progress ...");
$(statusAnchor).load(
"modules/synchronize.xq",
{ collection : $this.currentProject.root, start :start},
params,
function(responseText, status){if(status == 'success') {eXide.app.git.command($this.currentProject, 'commit', option);}}
);

Expand All @@ -214,8 +229,8 @@ eXide.edit.PackageEditor = (function () {
Constr.prototype.download = function (collection) {
var indentOnDownloadPackage = $("#indent-on-download-package").is(":checked");
var expandXIncludesOnDownloadPackage = $("#expand-xincludes-on-download-package").is(":checked");
var omitXMLDeclatarionOnDownloadPackage = $("#omit-xml-decl-on-download-package").is(":checked");
const url = "modules/deployment.xq?download=true&collection=" + encodeURIComponent(collection) + "&indent=" + indentOnDownloadPackage + "&expand-xincludes=" + expandXIncludesOnDownloadPackage + "&omit-xml-decl=" + omitXMLDeclatarionOnDownloadPackage;
var omitXMLDeclatarionOnDownloadPackage = $("#omit-xml-declaration-on-download-package").is(":checked");
const url = "modules/deployment.xq?download=true&collection=" + encodeURIComponent(collection) + "&indent=" + indentOnDownloadPackage + "&expand-xincludes=" + expandXIncludesOnDownloadPackage + "&omit-xml-declaration=" + omitXMLDeclatarionOnDownloadPackage;
fetch(url)
.then(resp => resp.blob())
.then(blob => {
Expand Down Expand Up @@ -267,7 +282,10 @@ eXide.edit.PackageEditor = (function () {
var params = {
collection: project.root,
start: project.deployed,
dir: project.dir
dir: project.dir,
indent: $("#indent-on-download-package").is(":checked"),
"expand-xincludes": $("#expand-xincludes-on-download-package").is(":checked"),
"omit-xml-declaration": $("#omit-xml-declaration-on-download-package").is(":checked")
};
$.ajax({
url: "modules/synchronize.xq",
Expand Down

0 comments on commit 16673c1

Please sign in to comment.