Verified Commit 35398fbf authored by Marco Kellershoff's avatar Marco Kellershoff 🤸
Browse files

Add precompiled ejs template

parent a2043c02
......@@ -36,7 +36,7 @@ function clean {
}
function build {
cp src/app.js src/app.css src/index.html src/xml.txt \
cp src/app.js src/app.css src/index.html src/xml.txt src/xml.txt.js \
dist/
cp -r src/assets \
dist/
......
(function(window, document) {
"use strict";
const ALLOWED_CHARACTERS_IN_FILENAME = "A-z0-9_.-";
const getValue = function(id) {
......@@ -87,8 +86,7 @@
const data = fetchData();
const filename = generateFilenameFromTitle(data.title);
const _generateXML = function(xml) {
const template = ejs.compile(xml);
const generatedXML = template(data);
const generatedXML = xml_txt(data);
downloadXML(filename, generatedXML);
};
const _fetchXML = function() {
......
......@@ -11,6 +11,7 @@
<script src="assets/jquery/jquery-3.2.1.min.js"></script>
<script src="assets/bootstrap/bootstrap.min.js"></script>
<script src="lib/moment-with-locales.min.js"></script>
<script src="xml.txt.js"></script>
<script src="lib/ejs.min.js"></script>
<script src="lib/jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script src="lib/jquery-ui-timepicker-addon.js"></script>
......
function xml_txt(locals, escapeFn, include, rethrow) {
var escapeFn =
escapeFn ||
function(markup) {
return markup == undefined
? ""
: String(markup).replace(
_MATCH_HTML,
encode_char
);
};
var _ENCODE_HTML_RULES = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&#34;",
"'": "&#39;"
},
_MATCH_HTML = /[&<>'"]/g;
function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
}
var __output = [],
__append = __output.push.bind(__output);
with (locals || {}) {
__append(
'<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n<video:video xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">\n <video:thumbnail_loc>'
);
__append(escapeFn(thumbnail));
__append("</video:thumbnail_loc>\n <video:title>");
__append(escapeFn(title));
__append("</video:title>\n <video:description>");
__append(escapeFn(description));
__append("</video:description>\n <video:content_loc>");
__append(escapeFn(video));
__append("</video:content_loc>\n <video:duration>");
__append(escapeFn(video_length));
__append("</video:duration>\n <video:expiration_date>");
__append(escapeFn(expdate));
__append(
"</video:expiration_date>\n <video:publication_date>"
);
__append(escapeFn(pubdate));
__append(
"</video:publication_date>\n <video:family_friendly>"
);
__append(escapeFn(famfriendly));
__append("</video:family_friendly>\n</video:video>\n");
}
return __output.join("");
}
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