Commit 2764affb authored by barth23's avatar barth23
Browse files

sendmail external xq script

parent f9f7473f
xquery version "3.1";
import module namespace console="http://exist-db.org/xquery/console";
declare namespace mail="http://exist-db.org/xquery/mail";
declare variable $message external;
(:~ let $log := console:log($message) ~:)
(:~ declare variable $log := console:log("print out"); ~:)
(:~ console:log("print out") ~:)
declare variable $mailsend := mail:send-email($message, (), "UTF-8");
declare variable $json := map { "success": "Nachricht gesendet.",
"name": name,
"email": email,
"message": message
};
$json
\ No newline at end of file
......@@ -15,10 +15,10 @@ xquery version "3.1";
module namespace semapi="http://architrave.eu/ns/semapi";
import module namespace config="https://sade.textgrid.de/ns/config" at "/db/apps/sade-architrave/modules/config.xqm";
import module namespace rest="http://exquery.org/ns/restxq";
import module namespace console="http://exist-db.org/xquery/console";
declare namespace mail="http://exist-db.org/xquery/mail";
declare namespace output ="http://www.w3.org/2010/xslt-xquery-serialization";
declare
......@@ -84,17 +84,30 @@ declare
map { "error_email": $error_email }
else if (string-length($message) = 0) then
map { "error_message": $error_message}
else if ( mail:send-email($mail, (), "UTF-8") ) then
(:~ else if ( mail:send-email($mail, (), "UTF-8") ) then
map { "success": "Nachricht gesendet.",
"name": $name,
"email": $email,
"message": $message
}
} ~:)
else
map { "error": $error}
(
console:log("launch sendmail.xq"),
let $message := "bla"
let $json_launch_mail := util:eval($config:app-root||"/modules/architrave/sendmail.xq")
return
$json_launch_mail
(:~ map { "success": "Nachricht gesendet.",
"name": $name,
"email": $email,
"message": $message
} ~:)
)
(:~ else
map { "error": $error} ~:)
return
$json_map
};
......@@ -129,12 +129,21 @@ let $path := $system-path
let $user := util:system-property("user.name")
let $message1 := $path || " is not available. Create it and make sure " || $user || " can write there."
let $message2 := "Could not write to " || $path || "."
(:~ let $restxq_register_msg := util:log-system-out("register sendmail api")
let $restxq_register := exrest:register-module(xs:anyURI($target||"modules/architrave/sendmail.xqm")) ~:)
let $indexing_msg := util:log-system-out("indexing edition pages and registers ...")
let $indexing := elastic:setup()
let $map-tiles-msg := util:log-system-out("importing paris map tiles ...")
let $map-tiles := local:inject-map-tiles('/var/www/map-tiles.git/raster')
(:~ version a ~:)
let $restxq_register_msg := util:log-system-out("register sendmail api")
let $restxq_register := exrest:register-module(xs:anyURI($target||"modules/architrave/sendmail.xqm"))
let $log := util:log-system-out($restxq_register)
let $restxq_register_msg := util:log-system-out("register sendmail api FINISHED")
(:~ version b ~:)
(:~ let $restxq_register_msg := util:log-system-out("restore sendmail api to enable restxq")
let $restxq_register := xmldb:move( $target||"modules/architrave", $target||"modules/", "sendmail.xqm")
let $restxq_register := xmldb:move( $target||"modules/", $target||"modules/architrave", "sendmail.xqm")
let $restxq_register_msg := util:log-system-out("restore sendmail api to enable restxq FINISHED") ~:)
return (
if
(file:is-directory($path))
......@@ -162,5 +171,3 @@ let $parameters :=
return
util:log-system-out($file-name || " saved.")
)
......@@ -10,7 +10,7 @@
$(document).ready(function() {
$('#form_sendemail').submit(function() {
$.ajax({
url: 'https://architrave.eu/api/form',
url: 'http://localhost:8080/exist/restxq/api/form',
type: 'POST',
data: $('#form_sendemail').serialize(),
contentType:'application/x-www-form-urlencoded',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment