From 14908d75d87255d07dd1b8a60e21b567c1bd46e0 Mon Sep 17 00:00:00 2001 From: Emre Date: Mon, 19 Aug 2019 20:38:14 -0700 Subject: [PATCH] new admin pages --- CHANGELOG.md | 6 +- index.js | 4 +- server.js | 1 + site/components/member-table-row.njk | 22 +++ site/components/pending-member-row.njk | 19 ++ site/scripts/md5.js | 186 ++++++++++++++++++++ site/scripts/member-administration.js | 110 ++++++++++++ site/scripts/minajax.js | 2 + site/scripts/network-administration.js | 75 ++++++++ site/scripts/pending-members.js | 112 ++++++++++++ site/templates/custom-profile-questions.njk | 0 site/templates/layout/base.njk | 2 +- site/templates/member-administration.njk | 29 +++ site/templates/members.njk | 2 +- site/templates/network-administration.njk | 48 +++++ site/templates/pending-members.njk | 30 ++++ site/vendor/nunjucks/nunjucks-slim.min.js | 3 + site/vendor/nunjucks/nunjucks.min.js | 3 + 18 files changed, 649 insertions(+), 5 deletions(-) create mode 100644 site/components/member-table-row.njk create mode 100644 site/components/pending-member-row.njk create mode 100644 site/scripts/md5.js create mode 100644 site/scripts/member-administration.js create mode 100644 site/scripts/minajax.js create mode 100644 site/scripts/network-administration.js create mode 100644 site/scripts/pending-members.js create mode 100644 site/templates/custom-profile-questions.njk create mode 100644 site/templates/member-administration.njk create mode 100644 site/templates/network-administration.njk create mode 100644 site/templates/pending-members.njk create mode 100644 site/vendor/nunjucks/nunjucks-slim.min.js create mode 100644 site/vendor/nunjucks/nunjucks.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f49617..b2e7a09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ ## 0.2 to 0.3 * /feed design improved * Redirect to /account after register so they can change their profiles -* Newsfeed comes with individual feed links \ No newline at end of file +* Newsfeed comes with individual feed links + +## 0.3 to 0.4 +* feed permalinks now show in "dialog" not window.alert +* member management \ No newline at end of file diff --git a/index.js b/index.js index 2b07277..cc63992 100644 --- a/index.js +++ b/index.js @@ -27,8 +27,8 @@ module.exports = async function (req, res) { const host = "https://accounts.groups2.com"; const streamHost = ""; const theme = "light"; - const moduleForum = "off"; - const moduleGroups = "off"; + const moduleForum = query.module_forum || "off"; + const moduleGroups = query.module_groups ||"off"; const extraHead = ""; let page = query.page; diff --git a/server.js b/server.js index 3dcd670..7e161f1 100644 --- a/server.js +++ b/server.js @@ -22,6 +22,7 @@ app.use(morgan('combined', { app.get('/', asyncMiddleware(require('./index'))); app.get('/generate', asyncMiddleware(require('./generate/index'))); +app.use('/site/components', express.static('site/components')); app.use('/site/vendor', express.static('site/vendor')); app.use('/site/scripts', express.static('site/scripts')); app.use('/site/styles', express.static('site/styles')); diff --git a/site/components/member-table-row.njk b/site/components/member-table-row.njk new file mode 100644 index 0000000..6b497af --- /dev/null +++ b/site/components/member-table-row.njk @@ -0,0 +1,22 @@ + + + + + {{member.username}} + + + + + {% if member.username !== 'admin' %} + {% if member.is_editor === 1 %} + + {% else %} + + {% endif %} + {% endif %} + + {% if (member.username !== 'admin') %} + + {% endif %} + + \ No newline at end of file diff --git a/site/components/pending-member-row.njk b/site/components/pending-member-row.njk new file mode 100644 index 0000000..1b4dac1 --- /dev/null +++ b/site/components/pending-member-row.njk @@ -0,0 +1,19 @@ + + + + + {{member.username}} + + + + + + {{member.signup_time}} + + + + + + + + \ No newline at end of file diff --git a/site/scripts/md5.js b/site/scripts/md5.js new file mode 100644 index 0000000..d17b0c3 --- /dev/null +++ b/site/scripts/md5.js @@ -0,0 +1,186 @@ +// http://www.myersdaily.org/joseph/javascript/md5.js + +function md5cycle(x, k) { + var a = x[0], b = x[1], c = x[2], d = x[3]; + + a = ff(a, b, c, d, k[0], 7, -680876936); + d = ff(d, a, b, c, k[1], 12, -389564586); + c = ff(c, d, a, b, k[2], 17, 606105819); + b = ff(b, c, d, a, k[3], 22, -1044525330); + a = ff(a, b, c, d, k[4], 7, -176418897); + d = ff(d, a, b, c, k[5], 12, 1200080426); + c = ff(c, d, a, b, k[6], 17, -1473231341); + b = ff(b, c, d, a, k[7], 22, -45705983); + a = ff(a, b, c, d, k[8], 7, 1770035416); + d = ff(d, a, b, c, k[9], 12, -1958414417); + c = ff(c, d, a, b, k[10], 17, -42063); + b = ff(b, c, d, a, k[11], 22, -1990404162); + a = ff(a, b, c, d, k[12], 7, 1804603682); + d = ff(d, a, b, c, k[13], 12, -40341101); + c = ff(c, d, a, b, k[14], 17, -1502002290); + b = ff(b, c, d, a, k[15], 22, 1236535329); + + a = gg(a, b, c, d, k[1], 5, -165796510); + d = gg(d, a, b, c, k[6], 9, -1069501632); + c = gg(c, d, a, b, k[11], 14, 643717713); + b = gg(b, c, d, a, k[0], 20, -373897302); + a = gg(a, b, c, d, k[5], 5, -701558691); + d = gg(d, a, b, c, k[10], 9, 38016083); + c = gg(c, d, a, b, k[15], 14, -660478335); + b = gg(b, c, d, a, k[4], 20, -405537848); + a = gg(a, b, c, d, k[9], 5, 568446438); + d = gg(d, a, b, c, k[14], 9, -1019803690); + c = gg(c, d, a, b, k[3], 14, -187363961); + b = gg(b, c, d, a, k[8], 20, 1163531501); + a = gg(a, b, c, d, k[13], 5, -1444681467); + d = gg(d, a, b, c, k[2], 9, -51403784); + c = gg(c, d, a, b, k[7], 14, 1735328473); + b = gg(b, c, d, a, k[12], 20, -1926607734); + + a = hh(a, b, c, d, k[5], 4, -378558); + d = hh(d, a, b, c, k[8], 11, -2022574463); + c = hh(c, d, a, b, k[11], 16, 1839030562); + b = hh(b, c, d, a, k[14], 23, -35309556); + a = hh(a, b, c, d, k[1], 4, -1530992060); + d = hh(d, a, b, c, k[4], 11, 1272893353); + c = hh(c, d, a, b, k[7], 16, -155497632); + b = hh(b, c, d, a, k[10], 23, -1094730640); + a = hh(a, b, c, d, k[13], 4, 681279174); + d = hh(d, a, b, c, k[0], 11, -358537222); + c = hh(c, d, a, b, k[3], 16, -722521979); + b = hh(b, c, d, a, k[6], 23, 76029189); + a = hh(a, b, c, d, k[9], 4, -640364487); + d = hh(d, a, b, c, k[12], 11, -421815835); + c = hh(c, d, a, b, k[15], 16, 530742520); + b = hh(b, c, d, a, k[2], 23, -995338651); + + a = ii(a, b, c, d, k[0], 6, -198630844); + d = ii(d, a, b, c, k[7], 10, 1126891415); + c = ii(c, d, a, b, k[14], 15, -1416354905); + b = ii(b, c, d, a, k[5], 21, -57434055); + a = ii(a, b, c, d, k[12], 6, 1700485571); + d = ii(d, a, b, c, k[3], 10, -1894986606); + c = ii(c, d, a, b, k[10], 15, -1051523); + b = ii(b, c, d, a, k[1], 21, -2054922799); + a = ii(a, b, c, d, k[8], 6, 1873313359); + d = ii(d, a, b, c, k[15], 10, -30611744); + c = ii(c, d, a, b, k[6], 15, -1560198380); + b = ii(b, c, d, a, k[13], 21, 1309151649); + a = ii(a, b, c, d, k[4], 6, -145523070); + d = ii(d, a, b, c, k[11], 10, -1120210379); + c = ii(c, d, a, b, k[2], 15, 718787259); + b = ii(b, c, d, a, k[9], 21, -343485551); + + x[0] = add32(a, x[0]); + x[1] = add32(b, x[1]); + x[2] = add32(c, x[2]); + x[3] = add32(d, x[3]); + + } + + function cmn(q, a, b, x, s, t) { + a = add32(add32(a, q), add32(x, t)); + return add32((a << s) | (a >>> (32 - s)), b); + } + + function ff(a, b, c, d, x, s, t) { + return cmn((b & c) | ((~b) & d), a, b, x, s, t); + } + + function gg(a, b, c, d, x, s, t) { + return cmn((b & d) | (c & (~d)), a, b, x, s, t); + } + + function hh(a, b, c, d, x, s, t) { + return cmn(b ^ c ^ d, a, b, x, s, t); + } + + function ii(a, b, c, d, x, s, t) { + return cmn(c ^ (b | (~d)), a, b, x, s, t); + } + + function md51(s) { + txt = ''; + var n = s.length, + state = [1732584193, -271733879, -1732584194, 271733878], i; + for (i=64; i<=s.length; i+=64) { + md5cycle(state, md5blk(s.substring(i-64, i))); + } + s = s.substring(i-64); + var tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; + for (i=0; i>2] |= s.charCodeAt(i) << ((i%4) << 3); + tail[i>>2] |= 0x80 << ((i%4) << 3); + if (i > 55) { + md5cycle(state, tail); + for (i=0; i<16; i++) tail[i] = 0; + } + tail[14] = n*8; + md5cycle(state, tail); + return state; + } + + /* there needs to be support for Unicode here, + * unless we pretend that we can redefine the MD-5 + * algorithm for multi-byte characters (perhaps + * by adding every four 16-bit characters and + * shortening the sum to 32 bits). Otherwise + * I suggest performing MD-5 as if every character + * was two bytes--e.g., 0040 0025 = @%--but then + * how will an ordinary MD-5 sum be matched? + * There is no way to standardize text to something + * like UTF-8 before transformation; speed cost is + * utterly prohibitive. The JavaScript standard + * itself needs to look at this: it should start + * providing access to strings as preformed UTF-8 + * 8-bit unsigned value arrays. + */ + function md5blk(s) { /* I figured global was faster. */ + var md5blks = [], i; /* Andy King said do it this way. */ + for (i=0; i<64; i+=4) { + md5blks[i>>2] = s.charCodeAt(i) + + (s.charCodeAt(i+1) << 8) + + (s.charCodeAt(i+2) << 16) + + (s.charCodeAt(i+3) << 24); + } + return md5blks; + } + + var hex_chr = '0123456789abcdef'.split(''); + + function rhex(n) + { + var s='', j=0; + for(; j<4; j++) + s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + + hex_chr[(n >> (j * 8)) & 0x0F]; + return s; + } + + function hex(x) { + for (var i=0; i> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); + } + } \ No newline at end of file diff --git a/site/scripts/member-administration.js b/site/scripts/member-administration.js new file mode 100644 index 0000000..01f7167 --- /dev/null +++ b/site/scripts/member-administration.js @@ -0,0 +1,110 @@ +function getHash() +{ + let admin_password = window.prompt("You must enter admin password to continue (warning: cleartext)"); + if(!admin_password) { + window.alert("Invalid Password"); + return ""; + } + return md5(admin_password); +} +function loadMemberAdministrationTable() +{ + //console.log("begin"); + var env = new nunjucks.Environment(new nunjucks.WebLoader('/site/components')); + var template = env.getTemplate('member-table-row.njk'); + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + var members = []; + minAjax({ + url: network+"/getMembers", + type: "GET", + data: { + "public_id": graphjs_id, + "offset": 0, + "limit": 10000 // CHANGE ME + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + let table = $("#members-list"); + members = Object.values(data.members); + members.forEach(function (member) { + table.append( + nunjucks.render( template, { "member": member} ) + ); + }); + } + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} + +function kickMember(id) +{ + if(!confirm("Please note when you kick a member, they will not be notified. DM them beforehand if you'd like to let them know. Do you still want to continue?")) + return; + let hash = getHash(); + if(hash=="") return; + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + minAjax({ + url: network+"/deleteMember", + type: "GET", + data: { + "public_id": graphjs_id, + "hash": hash, + "id": id + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + $("#member-"+id).addClass("d-none"); + alert("Success"); + return; + } + alert("Failure"); + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} + + +function setEditor(id, mode) +{ + let hash = getHash(); + if(hash=="") return; + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + minAjax({ + url: network+"/setBlogEditor", + type: "GET", + data: { + "public_id": graphjs_id, + "hash": hash, + "user_id": id, + "is_editor": mode + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + // do something in the UI + alert("Success"); + return; + } + alert("Failure"); + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} \ No newline at end of file diff --git a/site/scripts/minajax.js b/site/scripts/minajax.js new file mode 100644 index 0000000..51102b2 --- /dev/null +++ b/site/scripts/minajax.js @@ -0,0 +1,2 @@ +// https://flouthoc.github.io/minAjax.js/ +function initXMLhttp(){var e;return e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")}function minAjax(e){if(!e.url)return void(1==e.debugLog&&console.log("No Url!"));if(!e.type)return void(1==e.debugLog&&console.log("No Default type (GET/POST) given!"));e.method||(e.method=!0),e.debugLog||(e.debugLog=!1);var o=initXMLhttp();o.onreadystatechange=function(){4==o.readyState&&200==o.status?(e.success&&e.success(o.responseText,o.readyState),1==e.debugLog&&console.log("SuccessResponse"),1==e.debugLog&&console.log("Response Data:"+o.responseText)):1==e.debugLog&&console.log("FailureResponse --> State:"+o.readyState+"Status:"+o.status)};var t=[],n=e.data;if("string"==typeof n)for(var s=String.prototype.split.call(n,"&"),r=0,a=s.length;a>r;r++){var c=s[r].split("=");t.push(encodeURIComponent(c[0])+"="+encodeURIComponent(c[1]))}else if("object"==typeof n&&!(n instanceof String||FormData&&n instanceof FormData))for(var p in n){var c=n[p];if("[object Array]"==Object.prototype.toString.call(c))for(var r=0,a=c.length;a>r;r++)t.push(encodeURIComponent(p)+"[]="+encodeURIComponent(c[r]));else t.push(encodeURIComponent(p)+"="+encodeURIComponent(c))}t=t.join("&"),"GET"==e.type&&(o.open("GET",e.url+"?"+t,e.method),o.send(),1==e.debugLog&&console.log("GET fired at:"+e.url+"?"+t)),"POST"==e.type&&(o.open("POST",e.url,e.method),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send(t),1==e.debugLog&&console.log("POST fired at:"+e.url+" || Data:"+t))} diff --git a/site/scripts/network-administration.js b/site/scripts/network-administration.js new file mode 100644 index 0000000..62c2f84 --- /dev/null +++ b/site/scripts/network-administration.js @@ -0,0 +1,75 @@ +/* + This script file contains functions that only work on Settings page. +*/ + +function loadNetworkSettings() +{ + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + minAjax({ + url: network+"/getAllModes", + type: "GET", + data: { + "public_id": graphjs_id + }, + //CALLBACK FUNCTION with RESPONSE as argument + success: function(data){ + data = JSON.parse(data); + if(data.success) + { + $("#network_is_public")[0].checked = data.membership_moderated; + $("#network_let_anyone_post")[0].checked = !data.read_only; + } + } + + }); +} + +function saveNetworkAdministration() +{ + let admin_password = window.prompt("You must enter admin password to continue (warning: cleartext)"); + if(!admin_password) { + window.alert("Invalid Password"); + return; + } + $("#save-button").addClass('d-none'); + $("#loading-button").removeClass('d-none'); + let hash = md5(admin_password); + // let is_open = $("#network_is_open")[0].checked; + let is_public = $("#network_is_public")[0].checked ? 1 : 0; + let is_readonly = !$("#network_let_anyone_post")[0].checked ? 1 : 0; + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + console.log("about to query"); + minAjax({ + url: network+"/setAllModes", + type: "GET", + data: { + "public_id": graphjs_id, + "read_only": is_readonly, + "verification_required": false, + "membership_moderated": is_public, + "hash": hash + }, + //CALLBACK FUNCTION with RESPONSE as argument + success: function(data){ + data = JSON.parse(data); + $("#save-button").removeClass('d-none'); + $("#loading-button").addClass('d-none'); + if(!data.success) { + $(".alert-danger").removeClass('d-none'); + loadNetworkSettings(); + return; + } + $(".alert-success").removeClass('d-none'); + }, + + errorCallback: function(){ + $("#save-button").removeClass('d-none'); + $("#loading-button").addClass('d-none'); + $(".alert-danger").removeClass('d-none'); + loadNetworkSettings(); + } + + }); +} \ No newline at end of file diff --git a/site/scripts/pending-members.js b/site/scripts/pending-members.js new file mode 100644 index 0000000..9a4e935 --- /dev/null +++ b/site/scripts/pending-members.js @@ -0,0 +1,112 @@ +function getHash() +{ + let admin_password = window.prompt("You must enter admin password to continue (warning: cleartext)"); + if(!admin_password) { + window.alert("Invalid Password"); + return ""; + } + return md5(admin_password); +} + +function loadPendingMembersTable() +{ + let hash = getHash(); + if(hash=="") return; + var env = new nunjucks.Environment(new nunjucks.WebLoader('/site/components')); + var template = env.getTemplate('pending-member-row.njk'); + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + var members = []; + minAjax({ + url: network+"/getPendingMemberships", + type: "GET", + data: { + "public_id": graphjs_id, + "hash": hash + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + let table = $("#members-list"); + members = Object.values(data.members); + members.forEach(function (member) { + table.append( + nunjucks.render( template, { "member": member} ) + ); + }); + } + else { + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} + +function acceptPendingMember(id) +{ + let hash = getHash(); + if(hash=="") return; + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + minAjax({ + url: network+"/approveMembership", + type: "GET", + data: { + "public_id": graphjs_id, + "hash": hash, + "member_id": id + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + $("#member-"+id).addClass("d-none"); + alert("Success"); + return; + } + alert("Failure"); + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} + + +function rejectPendingMember(id) +{ + console.log("hello"); + let hash = getHash(); + if(hash=="") return; + let network = "https://accounts-dev.graphjs.com"; // GraphJSConfig.host; + let graphjs_id = GraphJSConfig.id; + minAjax({ + url: network+"/deleteMember", + type: "GET", + data: { + "public_id": graphjs_id, + "hash": hash, + "id": id + }, + success: function(data){ + console.log("success"); + data = JSON.parse(data); + if(data.success) + { + $("#member-"+id).addClass("d-none"); + alert("Success"); + return; + } + alert("Failure"); + }, + errorCallback: function(){ + alert("Wrong Password or a temporary server issue. Please try again later."); + } + }); +} \ No newline at end of file diff --git a/site/templates/custom-profile-questions.njk b/site/templates/custom-profile-questions.njk new file mode 100644 index 0000000..e69de29 diff --git a/site/templates/layout/base.njk b/site/templates/layout/base.njk index 96031c6..08a76c4 100644 --- a/site/templates/layout/base.njk +++ b/site/templates/layout/base.njk @@ -139,7 +139,7 @@ just_registered = true; }) - dialogPolyfill.registerDialog(); + dialogPolyfill.registerDialog(document.getElementsByTagName("dialog")[0]); // Settings //if(initiateSettings) initiateSettings(); } diff --git a/site/templates/member-administration.njk b/site/templates/member-administration.njk new file mode 100644 index 0000000..dbc1a63 --- /dev/null +++ b/site/templates/member-administration.njk @@ -0,0 +1,29 @@ +{% set title = 'Network Administration' %} +{% extends 'layout/template_' + goal + '.njk' %} + +{% block content %} +
+

Member Administration

+ + + + + + + + + +
NicknameOperations
+
+ + + + + + +{% endblock %} + diff --git a/site/templates/members.njk b/site/templates/members.njk index 5036fb9..1b0c798 100644 --- a/site/templates/members.njk +++ b/site/templates/members.njk @@ -3,7 +3,7 @@ {% block content %}
- +
{% endblock %} diff --git a/site/templates/network-administration.njk b/site/templates/network-administration.njk new file mode 100644 index 0000000..2679aec --- /dev/null +++ b/site/templates/network-administration.njk @@ -0,0 +1,48 @@ +{% set title = 'Network Administration' %} +{% extends 'layout/template_' + goal + '.njk' %} + +{% block content %} +
+
+

Network Administration

+
+ + + +
+ + +
+
+ + +
+ + +

 

+

⚠️ For more settings, go to https://grou.ps or tune it in HTML.

+
+
+ + + + + +{% endblock %} + diff --git a/site/templates/pending-members.njk b/site/templates/pending-members.njk new file mode 100644 index 0000000..516186a --- /dev/null +++ b/site/templates/pending-members.njk @@ -0,0 +1,30 @@ +{% set title = 'Pending Members' %} +{% extends 'layout/template_' + goal + '.njk' %} + +{% block content %} +
+

Pending Members

+ + + + + + + + + + +
NicknameJoining DateActions
+
+ + + + + + +{% endblock %} + diff --git a/site/vendor/nunjucks/nunjucks-slim.min.js b/site/vendor/nunjucks/nunjucks-slim.min.js new file mode 100644 index 0000000..0382b58 --- /dev/null +++ b/site/vendor/nunjucks/nunjucks-slim.min.js @@ -0,0 +1,3 @@ +/*! Browser bundle of nunjucks 3.2.0 (slim, only works with precompiled templates) */ +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.nunjucks=n():t.nunjucks=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function r(i){if(n[i])return n[i].exports;var e=n[i]={i:i,l:!1,exports:{}};return t[i].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=t,r.c=n,r.d=function(t,n,i){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=6)}([function(t,n){},function(t,n,r){"use strict";var i=Array.prototype,e=Object.prototype,u={"&":"&",'"':""","'":"'","<":"<",">":">"},o=/[&"'<>]/g;function f(t,n){return e.hasOwnProperty.call(t,n)}function c(t){return u[t]}function s(t,n,r){var i,e,u;if(t instanceof Error&&(t=(e=t).name+": "+e.message),Object.setPrototypeOf?Object.setPrototypeOf(i=Error(t),s.prototype):Object.defineProperty(i=this,"message",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),e){var o=Object.getOwnPropertyDescriptor(e,"stack");(u=o&&(o.get||function(){return o.value}))||(u=function(){return e.stack})}else{var f=Error(t).stack;u=function(){return f}}return Object.defineProperty(i,"stack",{get:function(){return u.call(i)}}),Object.defineProperty(i,"cause",{value:e}),i.lineno=n,i.colno=r,i.firstUpdate=!0,i.Update=function(t){var n="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?n+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(n+=" [Line "+this.lineno+"]")),n+="\n ",this.firstUpdate&&(n+=" "),this.message=n+(this.message||""),this.firstUpdate=!1,this},i}function a(t){return"[object Function]"===e.toString.call(t)}function h(t){return"[object Array]"===e.toString.call(t)}function v(t){return"[object String]"===e.toString.call(t)}function l(t){return"[object Object]"===e.toString.call(t)}function d(t){return Array.prototype.slice.call(t)}function p(t,n,r){return Array.prototype.indexOf.call(t||[],n,r)}function y(t){var n=[];for(var r in t)f(t,r)&&n.push(r);return n}(n=t.exports={}).hasOwnProp=f,n.t=function(t,r,i){if(i.Update||(i=new n.TemplateError(i)),i.Update(t),!r){var e=i;(i=Error(e.message)).name=e.name}return i},Object.setPrototypeOf?Object.setPrototypeOf(s.prototype,Error.prototype):s.prototype=Object.create(Error.prototype,{constructor:{value:s}}),n.TemplateError=s,n.escape=function(t){return t.replace(o,c)},n.isFunction=a,n.isArray=h,n.isString=v,n.isObject=l,n.groupBy=function(t,n){for(var r={},i=a(n)?n:function(t){return t[n]},e=0;et.length)s=u.slice(0,t.length),u.slice(s.length,a).forEach(function(t,r){ro){for(var n=0,r=e.length-u;n=n)return t;var r=n-t.length,o=i.repeat(" ",r/2-r%2),f=i.repeat(" ",r/2);return e.copySafeness(t,o+t+f)},n.default=function(t,n,r){return r?t||n:void 0!==t?t:n},n.dictsort=function(t,n,r){if(!i.isObject(t))throw new i.TemplateError("dictsort filter: val must be an object");var e,u=[];for(var o in t)u.push([o,t[o]]);if(void 0===r||"key"===r)e=0;else{if("value"!==r)throw new i.TemplateError("dictsort filter: You can only sort by either key or value");e=1}return u.sort(function(t,r){var u=t[e],o=r[e];return n||(i.isString(u)&&(u=u.toUpperCase()),i.isString(o)&&(o=o.toUpperCase())),u>o?1:u===o?0:-1}),u},n.dump=function(t,n){return JSON.stringify(t,null,n)},n.escape=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString())))},n.safe=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(t.toString()))},n.first=function(t){return t[0]},n.forceescape=function(t){return t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString()))},n.groupby=function(t,n){return i.groupBy(t,n)},n.indent=function(t,n,r){if(""===(t=u(t,"")))return"";n=n||4;var o=t.split("\n"),f=i.repeat(" ",n),c=o.map(function(t,n){return 0!==n||r?""+f+t+"\n":t+"\n"}).join("");return e.copySafeness(t,c)},n.join=function(t,n,r){return n=n||"",r&&(t=i.map(t,function(t){return t[r]})),t.join(n)},n.last=function(t){return t[t.length-1]},n.length=function(t){var n=u(t,"");return void 0!==n?"function"==typeof Map&&n instanceof Map||"function"==typeof Set&&n instanceof Set?n.size:!i.isObject(n)||n instanceof e.SafeString?n.length:i.keys(n).length:0},n.list=c,n.lower=function(t){return(t=u(t,"")).toLowerCase()},n.nl2br=function(t){return null===t||void 0===t?"":e.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},n.random=function(t){return t[Math.floor(Math.random()*t.length)]},n.rejectattr=function(t,n){return t.filter(function(t){return!t[n]})},n.selectattr=function(t,n){return t.filter(function(t){return!!t[n]})},n.replace=function(t,n,r,i){var u=t;if(n instanceof RegExp)return t.replace(n,r);void 0===i&&(i=-1);var o="";if("number"==typeof n)n=""+n;else if("string"!=typeof n)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof e.SafeString))return t;if(""===n)return o=r+t.split("").join(r)+r,e.copySafeness(t,o);var f=t.indexOf(n);if(0===i||-1===f)return t;for(var c=0,s=0;f>-1&&(-1===i||s=e&&a.push(r),u.push(a)}return u},n.sum=function(t,n,r){return void 0===r&&(r=0),n&&(t=i.map(t,function(t){return t[n]})),r+t.reduce(function(t,n){return t+n},0)},n.sort=e.makeMacro(["value","reverse","case_sensitive","attribute"],[],function(t,n,r,e){var u=i.map(t,function(t){return t});return u.sort(function(t,u){var o=e?t[e]:t,f=e?u[e]:u;return!r&&i.isString(o)&&i.isString(f)&&(o=o.toLowerCase(),f=f.toLowerCase()),of?n?-1:1:0}),u}),n.string=function(t){return e.copySafeness(t,t)},n.striptags=function(t,n){var r=s((t=u(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,"")),i="";return i=n?r.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):r.replace(/\s+/gi," "),e.copySafeness(t,i)},n.title=function(t){var n=(t=u(t,"")).split(" ").map(function(t){return f(t)});return e.copySafeness(t,n.join(" "))},n.trim=s,n.truncate=function(t,n,r,i){var o=t;if(t=u(t,""),n=n||255,t.length<=n)return t;if(r)t=t.substring(0,n);else{var f=t.lastIndexOf(" ",n);-1===f&&(f=n),t=t.substring(0,f)}return t+=void 0!==i&&null!==i?i:"...",e.copySafeness(o,t)},n.upper=function(t){return(t=u(t,"")).toUpperCase()},n.urlencode=function(t){var n=encodeURIComponent;return i.isString(t)?n(t):(i.isArray(t)?t:i.r(t)).map(function(t){var r=t[0],i=t[1];return n(r)+"="+n(i)}).join("&")};var a=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,v=/^https?:\/\/.*$/,l=/^www\./,d=/\.(?:org|net|com)(?:\:|\/|$)/;n.urlize=function(t,n,r){o(n)&&(n=1/0);var i=!0===r?' rel="nofollow"':"";return t.split(/(\s+)/).filter(function(t){return t&&t.length}).map(function(t){var r=t.match(a),e=r?r[1]:t,u=e.substr(0,n);return v.test(e)?'"+u+"":l.test(e)?'"+u+"":h.test(e)?''+e+"":d.test(e)?'"+u+"":t}).join("")},n.wordcount=function(t){var n=(t=u(t,""))?t.match(/\w+/g):null;return n?n.length:null},n.float=function(t,n){var r=parseFloat(t);return o(r)?n:r},n.int=function(t,n){var r=parseInt(t,10);return o(r)?n:r},n.d=n.default,n.e=n.escape},function(t,n,r){"use strict";var i,e="object"==typeof Reflect?Reflect:null,u=e&&"function"==typeof e.apply?e.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)};i=e&&"function"==typeof e.ownKeys?e.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function f(){f.init.call(this)}t.exports=f,f.EventEmitter=f,f.prototype.y=void 0,f.prototype.b=0,f.prototype.w=void 0;var c=10;function s(t){return void 0===t.w?f.defaultMaxListeners:t.w}function a(t,n,r,i){var e,u,o;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(u=t.y)?(u=t.y=Object.create(null),t.b=0):(void 0!==u.newListener&&(t.emit("newListener",n,r.listener?r.listener:r),u=t.y),o=u[n]),void 0===o)o=u[n]=r,++t.b;else if("function"==typeof o?o=u[n]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(e=s(t))>0&&o.length>e&&!o.warned){o.warned=!0;var f=Error("Possible EventEmitter memory leak detected. "+o.length+" "+n+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=n,f.count=o.length,console&&console.warn&&console.warn(f)}return t}function h(t,n,r){var i={fired:!1,wrapFn:void 0,target:t,type:n,listener:r},e=function(){for(var t=[],n=0;n0&&(o=n[0]),o instanceof Error)throw o;var f=Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=e[t];if(void 0===c)return!1;if("function"==typeof c)u(c,this,n);else{var s=c.length,a=d(c,s);for(r=0;r=0;u--)if(r[u]===n||r[u].listener===n){o=r[u].listener,e=u;break}if(e<0)return this;0===e?r.shift():function(t,n){for(;n+1=0;i--)this.removeListener(t,n[i]);return this},f.prototype.listeners=function(t){return v(this,t,!0)},f.prototype.rawListeners=function(t){return v(this,t,!1)},f.listenerCount=function(t,n){return"function"==typeof t.listenerCount?t.listenerCount(n):l.call(t,n)},f.prototype.listenerCount=l,f.prototype.eventNames=function(){return this.b>0?i(this.y):[]}},function(t,n,r){"use strict";var i=r(2).SafeString;n.callable=function(t){return"function"==typeof t},n.defined=function(t){return void 0!==t},n.divisibleby=function(t,n){return t%n==0},n.escaped=function(t){return t instanceof i},n.equalto=function(t,n){return t===n},n.eq=n.equalto,n.sameas=n.equalto,n.even=function(t){return t%2==0},n.falsy=function(t){return!t},n.ge=function(t,n){return t>=n},n.greaterthan=function(t,n){return t>n},n.gt=n.greaterthan,n.le=function(t,n){return t<=n},n.lessthan=function(t,n){return t0)for(var e=t;en;u+=r)i.push(u);return i},cycler:function(){return t=Array.prototype.slice.call(arguments),n=-1,{current:null,reset:function(){n=-1,this.current=null},next:function(){return++n>=t.length&&(n=0),this.current=t[n],this.current}};var t,n},joiner:function(t){return function(t){t=t||",";var n=!0;return function(){var r=n?"":t;return n=!1,r}}(t)}}}},function(t,n,r){var i=r(0);t.exports=function(t,n){function r(t,n){if(this.name=t,this.path=t,this.defaultEngine=n.defaultEngine,this.ext=i.extname(t),!this.ext&&!this.defaultEngine)throw Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return r.prototype.render=function(n,r){t.render(this.name,n,r)},n.set("view",r),n.set("nunjucksEnv",t),t}},function(t,n,r){t.exports=function(){"use strict";var t,n,r=this.runtime,i=this.lib,e=this.compiler.Compiler,u=this.parser.Parser,o=(this.nodes,this.lexer,r.contextOrFrameLookup),f=r.memberLookup;function c(t,n){return Object.prototype.hasOwnProperty.call(t,n)}e&&(t=e.prototype.assertType),u&&(n=u.prototype.parseAggregate),r.contextOrFrameLookup=function(t,n,r){var i=o.apply(this,arguments);if(void 0!==i)return i;switch(r){case"True":return!0;case"False":return!1;case"None":return null;default:return}};var s={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var n=0;nt.length||e>0&&o>=i||e<0&&o<=i);o+=e)u.push(r.memberLookup(t,o));return u}.apply(this,arguments):(t=t||{},i.isArray(t)&&c(s,n)?s[n].bind(t):i.isObject(t)&&c(a,n)?a[n].bind(t):f.apply(this,arguments))},function(){r.contextOrFrameLookup=o,r.memberLookup=f,e&&(e.prototype.assertType=t),u&&(u.prototype.parseAggregate=n)}}}])}); +//# sourceMappingURL=nunjucks-slim.min.js.map \ No newline at end of file diff --git a/site/vendor/nunjucks/nunjucks.min.js b/site/vendor/nunjucks/nunjucks.min.js new file mode 100644 index 0000000..66546aa --- /dev/null +++ b/site/vendor/nunjucks/nunjucks.min.js @@ -0,0 +1,3 @@ +/*! Browser bundle of nunjucks 3.2.0 */ +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.nunjucks=n():t.nunjucks=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function i(r){if(n[r])return n[r].exports;var e=n[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,i),e.l=!0,e.exports}return i.m=t,i.c=n,i.d=function(t,n,r){i.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="",i(i.s=11)}([function(t,n,i){"use strict";var r=Array.prototype,e=Object.prototype,s={"&":"&",'"':""","'":"'","<":"<",">":">"},o=/[&"'<>]/g;function u(t,n){return e.hasOwnProperty.call(t,n)}function h(t){return s[t]}function f(t,n,i){var r,e,s;if(t instanceof Error&&(t=(e=t).name+": "+e.message),Object.setPrototypeOf?Object.setPrototypeOf(r=Error(t),f.prototype):Object.defineProperty(r=this,"message",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(r,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(r,this.constructor),e){var o=Object.getOwnPropertyDescriptor(e,"stack");(s=o&&(o.get||function(){return o.value}))||(s=function(){return e.stack})}else{var u=Error(t).stack;s=function(){return u}}return Object.defineProperty(r,"stack",{get:function(){return s.call(r)}}),Object.defineProperty(r,"cause",{value:e}),r.lineno=n,r.colno=i,r.firstUpdate=!0,r.Update=function(t){var n="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?n+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(n+=" [Line "+this.lineno+"]")),n+="\n ",this.firstUpdate&&(n+=" "),this.message=n+(this.message||""),this.firstUpdate=!1,this},r}function c(t){return"[object Function]"===e.toString.call(t)}function a(t){return"[object Array]"===e.toString.call(t)}function l(t){return"[object String]"===e.toString.call(t)}function v(t){return"[object Object]"===e.toString.call(t)}function p(t){return Array.prototype.slice.call(t)}function d(t,n,i){return Array.prototype.indexOf.call(t||[],n,i)}function m(t){var n=[];for(var i in t)u(t,i)&&n.push(i);return n}(n=t.exports={}).hasOwnProp=u,n.t=function(t,i,r){if(r.Update||(r=new n.TemplateError(r)),r.Update(t),!i){var e=r;(r=Error(e.message)).name=e.name}return r},Object.setPrototypeOf?Object.setPrototypeOf(f.prototype,Error.prototype):f.prototype=Object.create(Error.prototype,{constructor:{value:f}}),n.TemplateError=f,n.escape=function(t){return t.replace(o,h)},n.isFunction=c,n.isArray=a,n.isString=l,n.isObject=v,n.groupBy=function(t,n){for(var i={},r=c(n)?n:function(t){return t[n]},e=0;et.length)f=s.slice(0,t.length),s.slice(f.length,c).forEach(function(t,i){i2?e-2:0),o=2;o0||!i)&&process.stdout.write(" ".repeat(n));var s=e===r.length-1?"":"\n";process.stdout.write(""+t+s)})}t.exports={Node:u,Root:c,NodeList:f,Value:h,Literal:a,Symbol:l,Group:v,Array:p,Pair:d,Dict:m,Output:B,Capture:V,TemplateData:D,If:b,IfAsync:y,InlineIf:g,For:k,AsyncEach:E,AsyncAll:x,Macro:O,Caller:T,Import:A,FromImport:j,FunCall:_,Filter:N,FilterAsync:S,KeywordArgs:L,Block:F,Super:I,Extends:C,Include:R,Set:K,Switch:M,Case:P,LookupVal:w,BinOp:$,In:G,Is:W,Or:H,And:J,Not:z,Add:Y,Concat:q,Sub:X,Mul:Q,Div:Z,FloorDiv:tt,Mod:nt,Pow:it,Neg:rt,Pos:et,Compare:st,CompareOperand:ot,CallExtension:ut,CallExtensionAsync:ht,printNodes:function t(n,i){if(i=i||0,ft(n.typename+": ",i),n instanceof f)ft("\n"),n.children.forEach(function(n){t(n,i+2)});else if(n instanceof ut)ft(n.extName+"."+n.prop+"\n"),n.args&&t(n.args,i+2),n.contentArgs&&n.contentArgs.forEach(function(n){t(n,i+2)});else{var r=[],e=null;n.iterFields(function(t,n){t instanceof u?r.push([n,t]):(e=e||{})[n]=t}),e?ft(JSON.stringify(e,null,2)+"\n",null,!0):ft("\n"),r.forEach(function(n){var r=n[0],e=n[1];ft("["+r+"] =>",i+2),t(e,i+4)})}}}},function(t,n){},function(t,n,i){"use strict";var r=i(8),e=i(17),s=i(3),o=i(0).TemplateError,u=i(2).Frame,h={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},f=function(t){var n,i;function r(){return t.apply(this,arguments)||this}i=t,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,n.__proto__=i;var e=r.prototype;return e.init=function(t,n){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this.f="",this.inBlock=!1,this.throwOnUndefined=n},e.fail=function(t,n,i){throw void 0!==n&&(n+=1),void 0!==i&&(i+=1),new o(t,n,i)},e.a=function(){var t=this.v();return this.bufferStack.push(this.buffer),this.buffer=t,this.w("var "+this.buffer+' = "";'),t},e.b=function(){this.buffer=this.bufferStack.pop()},e.w=function(t){this.codebuf.push(t)},e.y=function(t){this.w(t+"\n")},e.g=function(){for(var t=this,n=arguments.length,i=Array(n),r=0;r0&&e.w(","),e.compile(t,n)}),r&&this.w(r)},e.L=function(t,n){this.assertType(t,s.Literal,s.Symbol,s.Group,s.Array,s.Dict,s.FunCall,s.Caller,s.Filter,s.LookupVal,s.Compare,s.InlineIf,s.In,s.Is,s.And,s.Or,s.Not,s.Add,s.Concat,s.Sub,s.Mul,s.Div,s.FloorDiv,s.Mod,s.Pow,s.Neg,s.Pos,s.Compare,s.NodeList),this.compile(t,n)},e.assertType=function(t){for(var n=arguments.length,i=Array(n>1?n-1:0),r=1;r0&&r.w(","),t){r.y("function(cb) {"),r.y("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var e=r.a();r.A(function(){r.compile(t,n),r.y("cb(null, "+e+");")}),r.b(),r.y("return "+e+";"),r.y("}")}else r.w("null")}),i){var h=this.v();this.y(", "+this.j(h)),this.y(this.buffer+" += runtime.suppressValue("+h+", "+u+" && env.opts.autoescape);"),this.T()}else this.w(")"),this.w(", "+u+" && env.opts.autoescape);\n")},e.compileCallExtensionAsync=function(t,n){this.compileCallExtension(t,n,!0)},e.compileNodeList=function(t,n){this.N(t,n)},e.compileLiteral=function(t){if("string"==typeof t.value){var n=t.value.replace(/\\/g,"\\\\");n=(n=(n=(n=(n=n.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this.w('"'+n+'"')}else null===t.value?this.w("null"):this.w(t.value.toString())},e.compileSymbol=function(t,n){var i=t.value,r=n.lookup(i);r?this.w(r):this.w('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},e.compileGroup=function(t,n){this.S(t,n,"(",")")},e.compileArray=function(t,n){this.S(t,n,"[","]")},e.compileDict=function(t,n){this.S(t,n,"{","}")},e.compilePair=function(t,n){var i=t.key,r=t.value;i instanceof s.Symbol?i=new s.Literal(i.lineno,i.colno,i.value):i instanceof s.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,n),this.w(": "),this.L(r,n)},e.compileInlineIf=function(t,n){this.w("("),this.compile(t.cond,n),this.w("?"),this.compile(t.body,n),this.w(":"),null!==t.else_?this.compile(t.else_,n):this.w('""'),this.w(")")},e.compileIn=function(t,n){this.w("runtime.inOperator("),this.compile(t.left,n),this.w(","),this.compile(t.right,n),this.w(")")},e.compileIs=function(t,n){var i=t.right.name?t.right.name.value:t.right.value;this.w('env.getTest("'+i+'").call(context, '),this.compile(t.left,n),t.right.args&&(this.w(","),this.compile(t.right.args,n)),this.w(") === true")},e.F=function(t,n,i){this.compile(t.left,n),this.w(i),this.compile(t.right,n)},e.compileOr=function(t,n){return this.F(t,n," || ")},e.compileAnd=function(t,n){return this.F(t,n," && ")},e.compileAdd=function(t,n){return this.F(t,n," + ")},e.compileConcat=function(t,n){return this.F(t,n,' + "" + ')},e.compileSub=function(t,n){return this.F(t,n," - ")},e.compileMul=function(t,n){return this.F(t,n," * ")},e.compileDiv=function(t,n){return this.F(t,n," / ")},e.compileMod=function(t,n){return this.F(t,n," % ")},e.compileNot=function(t,n){this.w("!"),this.compile(t.target,n)},e.compileFloorDiv=function(t,n){this.w("Math.floor("),this.compile(t.left,n),this.w(" / "),this.compile(t.right,n),this.w(")")},e.compilePow=function(t,n){this.w("Math.pow("),this.compile(t.left,n),this.w(", "),this.compile(t.right,n),this.w(")")},e.compileNeg=function(t,n){this.w("-"),this.compile(t.target,n)},e.compilePos=function(t,n){this.w("+"),this.compile(t.target,n)},e.compileCompare=function(t,n){var i=this;this.compile(t.expr,n),t.ops.forEach(function(t){i.w(" "+h[t.type]+" "),i.compile(t.expr,n)})},e.compileLookupVal=function(t,n){this.w("runtime.memberLookup(("),this.L(t.target,n),this.w("),"),this.L(t.val,n),this.w(")")},e.I=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this.I(t.name)+")";case"LookupVal":return this.I(t.target)+'["'+this.I(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},e.compileFunCall=function(t,n){this.w("(lineno = "+t.lineno+", colno = "+t.colno+", "),this.w("runtime.callWrap("),this.L(t.name,n),this.w(', "'+this.I(t.name).replace(/"/g,'\\"')+'", context, '),this.S(t.args,n,"[","])"),this.w(")")},e.compileFilter=function(t,n){var i=t.name;this.assertType(i,s.Symbol),this.w('env.getFilter("'+i.value+'").call(context, '),this.S(t.args,n),this.w(")")},e.compileFilterAsync=function(t,n){var i=t.name,r=t.symbol.value;this.assertType(i,s.Symbol),n.set(r,r),this.w('env.getFilter("'+i.value+'").call(context, '),this.S(t.args,n),this.y(", "+this.j(r)),this.T()},e.compileKeywordArgs=function(t,n){this.w("runtime.makeKeywordArgs("),this.compileDict(t,n),this.w(")")},e.compileSet=function(t,n){var i=this,r=[];t.targets.forEach(function(t){var e=t.value,s=n.lookup(e);null!==s&&void 0!==s||(s=i.v(),i.y("var "+s+";")),r.push(s)}),t.value?(this.w(r.join(" = ")+" = "),this.L(t.value,n),this.y(";")):(this.w(r.join(" = ")+" = "),this.compile(t.body,n),this.y(";")),t.targets.forEach(function(t,n){var e=r[n],s=t.value;i.y('frame.set("'+s+'", '+e+", true);"),i.y("if(frame.topLevel) {"),i.y('context.setVariable("'+s+'", '+e+");"),i.y("}"),"_"!==s.charAt(0)&&(i.y("if(frame.topLevel) {"),i.y('context.addExport("'+s+'", '+e+");"),i.y("}"))})},e.compileSwitch=function(t,n){var i=this;this.w("switch ("),this.compile(t.expr,n),this.w(") {"),t.cases.forEach(function(t,r){i.w("case "),i.compile(t.cond,n),i.w(": "),i.compile(t.body,n),t.body.children.length&&i.y("break;")}),t.default&&(this.w("default:"),this.compile(t.default,n)),this.w("}")},e.compileIf=function(t,n,i){var r=this;this.w("if("),this.L(t.cond,n),this.y(") {"),this.A(function(){r.compile(t.body,n),i&&r.w("cb()")}),t.else_?(this.y("}\nelse {"),this.A(function(){r.compile(t.else_,n),i&&r.w("cb()")})):i&&(this.y("}\nelse {"),this.w("cb()")),this.y("}")},e.compileIfAsync=function(t,n){this.w("(function(cb) {"),this.compileIf(t,n,!0),this.w("})("+this.j()),this.T()},e.C=function(t,n,i,r){var e=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:r+" - "+i},{name:"revindex0",val:r+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+r+" - 1"},{name:"length",val:r}].forEach(function(t){e.y('frame.set("loop.'+t.name+'", '+t.val+");")})},e.compileFor=function(t,n){var i=this,r=this.v(),e=this.v(),o=this.v();if(n=n.push(),this.y("frame = frame.push();"),this.w("var "+o+" = "),this.L(t.arr,n),this.y(";"),this.w("if("+o+") {"),this.y(o+" = runtime.fromIterator("+o+");"),t.name instanceof s.Array){this.y("var "+r+";"),this.y("if(runtime.isArray("+o+")) {"),this.y("var "+e+" = "+o+".length;"),this.y("for("+r+"=0; "+r+" < "+o+".length; "+r+"++) {"),t.name.children.forEach(function(e,s){var u=i.v();i.y("var "+u+" = "+o+"["+r+"]["+s+"];"),i.y('frame.set("'+e+'", '+o+"["+r+"]["+s+"]);"),n.set(t.name.children[s].value,u)}),this.C(t,o,r,e),this.A(function(){i.compile(t.body,n)}),this.y("}"),this.y("} else {");var u=t.name.children,h=u[0],f=u[1],c=this.v(),a=this.v();n.set(h.value,c),n.set(f.value,a),this.y(r+" = -1;"),this.y("var "+e+" = runtime.keys("+o+").length;"),this.y("for(var "+c+" in "+o+") {"),this.y(r+"++;"),this.y("var "+a+" = "+o+"["+c+"];"),this.y('frame.set("'+h.value+'", '+c+");"),this.y('frame.set("'+f.value+'", '+a+");"),this.C(t,o,r,e),this.A(function(){i.compile(t.body,n)}),this.y("}"),this.y("}")}else{var l=this.v();n.set(t.name.value,l),this.y("var "+e+" = "+o+".length;"),this.y("for(var "+r+"=0; "+r+" < "+o+".length; "+r+"++) {"),this.y("var "+l+" = "+o+"["+r+"];"),this.y('frame.set("'+t.name.value+'", '+l+");"),this.C(t,o,r,e),this.A(function(){i.compile(t.body,n)}),this.y("}")}this.y("}"),t.else_&&(this.y("if (!"+e+") {"),this.compile(t.else_,n),this.y("}")),this.y("frame = frame.pop();")},e.R=function(t,n,i){var r=this,e=this.v(),o=this.v(),u=this.v(),h=i?"asyncAll":"asyncEach";if(n=n.push(),this.y("frame = frame.push();"),this.w("var "+u+" = runtime.fromIterator("),this.L(t.arr,n),this.y(");"),t.name instanceof s.Array){var f=t.name.children.length;this.w("runtime."+h+"("+u+", "+f+", function("),t.name.children.forEach(function(t){r.w(t.value+",")}),this.w(e+","+o+",next) {"),t.name.children.forEach(function(t){var i=t.value;n.set(i,i),r.y('frame.set("'+i+'", '+i+");")})}else{var c=t.name.value;this.y("runtime."+h+"("+u+", 1, function("+c+", "+e+", "+o+",next) {"),this.y('frame.set("'+c+'", '+c+");"),n.set(c,c)}this.C(t,u,e,o),this.A(function(){var s;i&&(s=r.a()),r.compile(t.body,n),r.y("next("+e+(s?","+s:"")+");"),i&&r.b()});var a=this.v();this.y("}, "+this.j(a)),this.T(),i&&this.y(this.buffer+" += "+a+";"),t.else_&&(this.y("if (!"+u+".length) {"),this.compile(t.else_,n),this.y("}")),this.y("frame = frame.pop();")},e.compileAsyncEach=function(t,n){this.R(t,n)},e.compileAsyncAll=function(t,n){this.R(t,n,!0)},e.K=function(t,n){var i=this,r=[],e=null,o="macro_"+this.v(),h=void 0!==n;t.args.children.forEach(function(n,o){o===t.args.children.length-1&&n instanceof s.Dict?e=n:(i.assertType(n,s.Symbol),r.push(n))});var f,c=[].concat(r.map(function(t){return"l_"+t.value}),["kwargs"]),a=r.map(function(t){return'"'+t.value+'"'}),l=(e&&e.children||[]).map(function(t){return'"'+t.key.value+'"'});f=h?n.push(!0):new u,this.g("var "+o+" = runtime.makeMacro(","["+a.join(", ")+"], ","["+l.join(", ")+"], ","function ("+c.join(", ")+") {","var callerFrame = frame;","frame = "+(h?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),r.forEach(function(t){i.y('frame.set("'+t.value+'", l_'+t.value+");"),f.set(t.value,"l_"+t.value)}),e&&e.children.forEach(function(t){var n=t.key.value;i.w('frame.set("'+n+'", '),i.w('Object.prototype.hasOwnProperty.call(kwargs, "'+n+'")'),i.w(' ? kwargs["'+n+'"] : '),i.L(t.value,f),i.w(");")});var v=this.a();return this.A(function(){i.compile(t.body,f)}),this.y("frame = "+(h?"frame.pop();":"callerFrame;")),this.y("return new runtime.SafeString("+v+");"),this.y("});"),this.b(),o},e.compileMacro=function(t,n){var i=this.K(t),r=t.name.value;n.set(r,i),n.parent?this.y('frame.set("'+r+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this.y('context.addExport("'+r+'");'),this.y('context.setVariable("'+r+'", '+i+");"))},e.compileCaller=function(t,n){this.w("(function (){");var i=this.K(t,n);this.w("return "+i+";})()")},e.M=function(t,n,i,r){var e=this.v(),s=this._(),o=this.j(e),u=i?"true":"false",h=r?"true":"false";return this.w("env.getTemplate("),this.L(t.template,n),this.y(", "+u+", "+s+", "+h+", "+o),e},e.compileImport=function(t,n){var i=t.target.value,r=this.M(t,n,!1,!1);this.T(),this.y(r+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this.j(r)),this.T(),n.set(i,r),n.parent?this.y('frame.set("'+i+'", '+r+");"):this.y('context.setVariable("'+i+'", '+r+");")},e.compileFromImport=function(t,n){var i=this,r=this.M(t,n,!1,!1);this.T(),this.y(r+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this.j(r)),this.T(),t.names.children.forEach(function(t){var e,o,u=i.v();t instanceof s.Pair?(e=t.key.value,o=t.value.value):o=e=t.value,i.y("if(Object.prototype.hasOwnProperty.call("+r+', "'+e+'")) {'),i.y("var "+u+" = "+r+"."+e+";"),i.y("} else {"),i.y("cb(new Error(\"cannot import '"+e+"'\")); return;"),i.y("}"),n.set(o,u),n.parent?i.y('frame.set("'+o+'", '+u+");"):i.y('context.setVariable("'+o+'", '+u+");")})},e.compileBlock=function(t){var n=this.v();this.inBlock||this.w('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this.w('context.getBlock("'+t.name.value+'")'),this.inBlock||this.w(")"),this.y("(env, context, frame, runtime, "+this.j(n)),this.y(this.buffer+" += "+n+";"),this.T()},e.compileSuper=function(t,n){var i=t.blockName.value,r=t.symbol.value,e=this.j(r);this.y('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+e),this.y(r+" = runtime.markSafe("+r+");"),this.T(),n.set(r,r)},e.compileExtends=function(t,n){var i=this.v(),r=this.M(t,n,!0,!1);this.y("parentTemplate = "+r),this.y("for(var "+i+" in parentTemplate.blocks) {"),this.y("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this.y("}"),this.T()},e.compileInclude=function(t,n){this.y("var tasks = [];"),this.y("tasks.push("),this.y("function(callback) {");var i=this.M(t,n,!1,t.ignoreMissing);this.y("callback(null,"+i+");});"),this.y("});");var r=this.v();this.y("tasks.push("),this.y("function(template, callback){"),this.y("template.render(context.getVariables(), frame, "+this.j(r)),this.y("callback(null,"+r+");});"),this.y("});"),this.y("tasks.push("),this.y("function(result, callback){"),this.y(this.buffer+" += result;"),this.y("callback(null);"),this.y("});"),this.y("env.waterfall(tasks, function(){"),this.T()},e.compileTemplateData=function(t,n){this.compileLiteral(t,n)},e.compileCapture=function(t,n){var i=this,r=this.buffer;this.buffer="output",this.y("(function() {"),this.y('var output = "";'),this.A(function(){i.compile(t.body,n)}),this.y("return output;"),this.y("})()"),this.buffer=r},e.compileOutput=function(t,n){var i=this;t.children.forEach(function(r){r instanceof s.TemplateData?r.value&&(i.w(i.buffer+" += "),i.compileLiteral(r,n),i.y(";")):(i.w(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i.w("runtime.ensureDefined("),i.compile(r,n),i.throwOnUndefined&&i.w(","+t.lineno+","+t.colno+")"),i.w(", env.opts.autoescape);\n"))})},e.compileRoot=function(t,n){var i=this;n&&this.fail("compileRoot: root node can't have frame"),n=new u,this.k(t,"root"),this.y("var parentTemplate = null;"),this.N(t,n),this.y("if(parentTemplate) {"),this.y("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this.y("} else {"),this.y("cb(null, "+this.buffer+");"),this.y("}"),this.x(!0),this.inBlock=!0;var r=[],e=t.findAll(s.Block);e.forEach(function(t,n){var e=t.name.value;if(-1!==r.indexOf(e))throw Error('Block "'+e+'" defined more than once.');r.push(e),i.k(t,"b_"+e);var s=new u;i.y("var frame = frame.push(true);"),i.compile(t.body,s),i.x()}),this.y("return {"),e.forEach(function(t,n){var r="b_"+t.name.value;i.y(r+": "+r+",")}),this.y("root: root\n};")},e.compile=function(t,n){var i=this["compile"+t.typename];i?i.call(this,t,n):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},e.getCode=function(){return this.codebuf.join("")},r}(i(1).Obj);t.exports={compile:function(t,n,i,s,o){void 0===o&&(o={});var u=new f(s,o.throwOnUndefined),h=(i||[]).map(function(t){return t.preprocess}).filter(function(t){return!!t}).reduce(function(t,n){return n(t)},t);return u.compile(e.transform(r.parse(h,i,o),n,s)),u.getCode()},Compiler:f}},function(t,n,i){"use strict";var r=i(4),e=i(1).EmitterObj;t.exports=function(t){var n,i;function e(){return t.apply(this,arguments)||this}i=t,(n=e).prototype=Object.create(i.prototype),n.prototype.constructor=n,n.__proto__=i;var s=e.prototype;return s.resolve=function(t,n){return r.resolve(r.dirname(t),n)},s.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},e}(e)},function(t,n,i){"use strict";function r(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}var e=i(12),s=i(15),o=i(0),u=i(5),h=i(18),f=i(10),c=f.FileSystemLoader,a=f.WebLoader,l=f.PrecompiledLoader,v=i(20),p=i(21),d=i(1),m=d.Obj,w=d.EmitterObj,b=i(2),y=b.handleError,g=b.Frame,k=i(22);function E(t,n,i){e(function(){t(n,i)})}var x={type:"code",obj:{root:function(t,n,i,r,e){try{e(null,"")}catch(t){e(y(t,null,null))}}}},O=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.init=function(t,n){var i=this;n=this.opts=n||{},this.opts.dev=!!n.dev,this.opts.autoescape=null==n.autoescape||n.autoescape,this.opts.throwOnUndefined=!!n.throwOnUndefined,this.opts.trimBlocks=!!n.trimBlocks,this.opts.lstripBlocks=!!n.lstripBlocks,this.loaders=[],t?this.loaders=o.isArray(t)?t:[t]:c?this.loaders=[new c("views")]:a&&(this.loaders=[new a("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new l(window.nunjucksPrecompiled)),this.P(),this.globals=p(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],o.r(h).forEach(function(t){var n=t[0],r=t[1];return i.addFilter(n,r)}),o.r(v).forEach(function(t){var n=t[0],r=t[1];return i.addTest(n,r)})},i.P=function(){var t=this;this.loaders.forEach(function(n){n.cache={},"function"==typeof n.on&&(n.on("update",function(i,r){n.cache[i]=null,t.emit("update",i,r,n)}),n.on("load",function(i,r){t.emit("load",i,r,n)}))})},i.invalidateCache=function(){this.loaders.forEach(function(t){t.cache={}})},i.addExtension=function(t,n){return n.__name=t,this.extensions[t]=n,this.extensionsList.push(n),this},i.removeExtension=function(t){var n=this.getExtension(t);n&&(this.extensionsList=o.without(this.extensionsList,n),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,n){return this.globals[t]=n,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,n,i){var r=n;return i&&this.asyncFilters.push(t),this.filters[t]=r,this},i.getFilter=function(t){if(!this.filters[t])throw Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,n){return this.tests[t]=n,this},i.getTest=function(t){if(!this.tests[t])throw Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,n,i){return!(!t.isRelative||!n)&&t.isRelative(i)&&t.resolve?t.resolve(n,i):i},i.getTemplate=function(t,n,i,r,e){var s,u=this,h=this,f=null;if(t&&t.raw&&(t=t.raw),o.isFunction(i)&&(e=i,i=null,n=n||!1),o.isFunction(n)&&(e=n,n=!1),t instanceof A)f=t;else{if("string"!=typeof t)throw Error("template names must be a string: "+t);for(var c=0;c0&&!this.skip(r.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var u=this.parsePrimary();if("_"===u.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",u.lineno,u.colno),this.skipSymbol("as")){var h=this.parsePrimary();s.addChild(new e.Pair(u.lineno,u.colno,u,h))}else s.addChild(u);i=this.parseWithContext()}return new e.FromImport(t.lineno,t.colno,n,s,i)},u.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var n=new e.Block(t.lineno,t.colno);n.name=this.parsePrimary(),n.name instanceof e.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),n.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(n.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),n},u.parseExtends=function(){var t=this.peekToken();this.skipSymbol("extends")||this.fail("parseTemplateRef: expected extends");var n=new e.Extends(t.lineno,t.colno);return n.template=this.parseExpression(),this.advanceAfterBlockEnd(t.value),n},u.parseInclude=function(){var t=this.peekToken();this.skipSymbol("include")||this.fail("parseInclude: expected include");var n=new e.Include(t.lineno,t.colno);return n.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(n.ignoreMissing=!0),this.advanceAfterBlockEnd(t.value),n},u.parseIf=function(){var t,n=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new e.If(n.lineno,n.colno):this.skipSymbol("ifAsync")?t=new e.IfAsync(n.lineno,n.colno):this.fail("parseIf: expected if, elif, or elseif",n.lineno,n.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(n.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},u.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var n,i=new e.Set(t.lineno,t.colno,[]);(n=this.parsePrimary())&&(i.targets.push(n),this.skip(r.TOKEN_COMMA)););return this.skipValue(r.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(r.TOKEN_BLOCK_END)?(i.body=new e.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},u.parseSwitch=function(){var t=this.peekToken();this.skipSymbol("switch")||this.skipSymbol("case")||this.skipSymbol("default")||this.fail('parseSwitch: expected "switch," "case" or "default"',t.lineno,t.colno);var n=this.parseExpression();this.advanceAfterBlockEnd("switch"),this.parseUntilBlocks("case","default","endswitch");var i,r=this.peekToken(),s=[];do{this.skipSymbol("case");var o=this.parseExpression();this.advanceAfterBlockEnd("switch");var u=this.parseUntilBlocks("case","default","endswitch");s.push(new e.Case(r.line,r.col,o,u)),r=this.peekToken()}while(r&&"case"===r.value);switch(r.value){case"default":this.advanceAfterBlockEnd(),i=this.parseUntilBlocks("endswitch"),this.advanceAfterBlockEnd();break;case"endswitch":this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new e.Switch(t.lineno,t.colno,n,s,i)},u.parseStatement=function(){var t=this.peekToken();if(t.type!==r.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==o.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var n=0;n0;){var h=o[0],f=o[1],c=o[2];c===t?r+=1:c===n&&(r-=1),0===r?(s+=f,this.tokens.backN(h.length-f.length)):s+=h}return new e.Output(u.lineno,u.colno,[new e.TemplateData(u.lineno,u.colno,s)])},u.parsePostfix=function(t){for(var n,i=this.peekToken();i;){if(i.type===r.TOKEN_LEFT_PAREN)t=new e.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===r.TOKEN_LEFT_BRACKET)(n=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new e.LookupVal(i.lineno,i.colno,t,n.children[0]);else{if(i.type!==r.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var s=this.nextToken();s.type!==r.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+s.value,s.lineno,s.colno),n=new e.Literal(s.lineno,s.colno,s.value),t=new e.LookupVal(i.lineno,i.colno,t,n)}i=this.peekToken()}return t},u.parseExpression=function(){return this.parseInlineIf()},u.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var n=this.parseOr(),i=t;(t=new e.InlineIf(t.lineno,t.colno)).body=i,t.cond=n,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},u.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var n=this.parseAnd();t=new e.Or(t.lineno,t.colno,t,n)}return t},u.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var n=this.parseNot();t=new e.And(t.lineno,t.colno,t,n)}return t},u.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new e.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},u.parseIn=function(){for(var t=this.parseIs();;){var n=this.nextToken();if(!n)break;var i=n.type===r.TOKEN_SYMBOL&&"not"===n.value;if(i||this.pushToken(n),!this.skipSymbol("in")){i&&this.pushToken(n);break}var s=this.parseIs();t=new e.In(t.lineno,t.colno,t,s),i&&(t=new e.Not(t.lineno,t.colno,t))}return t},u.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var n=this.skipSymbol("not"),i=this.parseCompare();t=new e.Is(t.lineno,t.colno,t,i),n&&(t=new e.Not(t.lineno,t.colno,t))}return t},u.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],n=this.parseConcat(),i=[];;){var r=this.nextToken();if(!r)break;if(-1===t.indexOf(r.value)){this.pushToken(r);break}i.push(new e.CompareOperand(r.lineno,r.colno,this.parseConcat(),r.value))}return i.length?new e.Compare(i[0].lineno,i[0].colno,n,i):n},u.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(r.TOKEN_TILDE,"~");){var n=this.parseAdd();t=new e.Concat(t.lineno,t.colno,t,n)}return t},u.parseAdd=function(){for(var t=this.parseSub();this.skipValue(r.TOKEN_OPERATOR,"+");){var n=this.parseSub();t=new e.Add(t.lineno,t.colno,t,n)}return t},u.parseSub=function(){for(var t=this.parseMul();this.skipValue(r.TOKEN_OPERATOR,"-");){var n=this.parseMul();t=new e.Sub(t.lineno,t.colno,t,n)}return t},u.parseMul=function(){for(var t=this.parseDiv();this.skipValue(r.TOKEN_OPERATOR,"*");){var n=this.parseDiv();t=new e.Mul(t.lineno,t.colno,t,n)}return t},u.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(r.TOKEN_OPERATOR,"/");){var n=this.parseFloorDiv();t=new e.Div(t.lineno,t.colno,t,n)}return t},u.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(r.TOKEN_OPERATOR,"//");){var n=this.parseMod();t=new e.FloorDiv(t.lineno,t.colno,t,n)}return t},u.parseMod=function(){for(var t=this.parsePow();this.skipValue(r.TOKEN_OPERATOR,"%");){var n=this.parsePow();t=new e.Mod(t.lineno,t.colno,t,n)}return t},u.parsePow=function(){for(var t=this.parseUnary();this.skipValue(r.TOKEN_OPERATOR,"**");){var n=this.parseUnary();t=new e.Pow(t.lineno,t.colno,t,n)}return t},u.parseUnary=function(t){var n,i=this.peekToken();return n=this.skipValue(r.TOKEN_OPERATOR,"-")?new e.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(r.TOKEN_OPERATOR,"+")?new e.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(n=this.parseFilter(n)),n},u.parsePrimary=function(t){var n,i=this.nextToken(),s=null;if(i?i.type===r.TOKEN_STRING?n=i.value:i.type===r.TOKEN_INT?n=parseInt(i.value,10):i.type===r.TOKEN_FLOAT?n=parseFloat(i.value):i.type===r.TOKEN_BOOLEAN?"true"===i.value?n=!0:"false"===i.value?n=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===r.TOKEN_NONE?n=null:i.type===r.TOKEN_REGEX&&(n=RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==n?s=new e.Literal(i.lineno,i.colno,n):i.type===r.TOKEN_SYMBOL?s=new e.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),s=this.parseAggregate()),t||(s=this.parsePostfix(s)),s)return s;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},u.parseFilterName=function(){for(var t=this.expect(r.TOKEN_SYMBOL),n=t.value;this.skipValue(r.TOKEN_OPERATOR,".");)n+="."+this.expect(r.TOKEN_SYMBOL).value;return new e.Symbol(t.lineno,t.colno,n)},u.parseFilterArgs=function(t){return this.peekToken().type===r.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},u.parseFilter=function(t){for(;this.skip(r.TOKEN_PIPE);){var n=this.parseFilterName();t=new e.Filter(n.lineno,n.colno,n,new e.NodeList(n.lineno,n.colno,[t].concat(this.parseFilterArgs(t))))}return t},u.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var n=this.parseFilterName(),i=this.parseFilterArgs(n);this.advanceAfterBlockEnd(t.value);var r=new e.Capture(n.lineno,n.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var s=new e.Filter(n.lineno,n.colno,n,new e.NodeList(n.lineno,n.colno,[r].concat(i)));return new e.Output(n.lineno,n.colno,[s])},u.parseAggregate=function(){var t,n=this.nextToken();switch(n.type){case r.TOKEN_LEFT_PAREN:t=new e.Group(n.lineno,n.colno);break;case r.TOKEN_LEFT_BRACKET:t=new e.Array(n.lineno,n.colno);break;case r.TOKEN_LEFT_CURLY:t=new e.Dict(n.lineno,n.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===r.TOKEN_RIGHT_PAREN||i===r.TOKEN_RIGHT_BRACKET||i===r.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(r.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",n.lineno,n.colno)),t instanceof e.Dict){var s=this.parsePrimary();this.skip(r.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",n.lineno,n.colno);var o=this.parseExpression();t.addChild(new e.Pair(s.lineno,s.colno,s,o))}else{var u=this.parseExpression();t.addChild(u)}}return t},u.parseSignature=function(t,n){var i=this.peekToken();if(!n&&i.type!==r.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===r.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var s=new e.NodeList(i.lineno,i.colno),o=new e.KeywordArgs(i.lineno,i.colno),u=!1;;){if(i=this.peekToken(),!n&&i.type===r.TOKEN_RIGHT_PAREN){this.nextToken();break}if(n&&i.type===r.TOKEN_BLOCK_END)break;if(u&&!this.skip(r.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var h=this.parseExpression();this.skipValue(r.TOKEN_OPERATOR,"=")?o.addChild(new e.Pair(h.lineno,h.colno,h,this.parseExpression())):s.addChild(h)}u=!0}return o.children.length&&s.addChild(o),s},u.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,n=arguments.length,i=Array(n),r=0;r=!".indexOf(e)){this.forward();var h,f=["==","===","!=","!==","<=",">=","//","**"],a=e+this.current();switch(-1!==r.indexOf(f,a)&&(this.forward(),e=a,-1!==r.indexOf(f,a+this.current())&&(e=a+this.current(),this.forward())),e){case"(":h="left-paren";break;case")":h="right-paren";break;case"[":h="left-bracket";break;case"]":h="right-bracket";break;case"{":h="left-curly";break;case"}":h="right-curly";break;case",":h="comma";break;case":":h="colon";break;case"~":h="tilde";break;case"|":h="pipe";break;default:h="operator"}return c(h,e,n,i)}if((t=this.W(" \n\t\r ()[]{}%*-+~/#,:|.<>=!")).match(/^[-+]?[0-9]+$/))return"."===this.current()?(this.forward(),c("float",t+"."+this.$("0123456789"),n,i)):c("int",t,n,i);if(t.match(/^(true|false)$/))return c("boolean",t,n,i);if("none"===t)return c("none",t,n,i);if("null"===t)return c("none",t,n,i);if(t)return c("symbol",t,n,i);throw Error("Unexpected value while parsing: "+t)}var l,v=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this.G(this.tags.BLOCK_START+"-"))||(t=this.G(this.tags.BLOCK_START)))return this.in_code=!0,c("block-start",t,n,i);if((t=this.G(this.tags.VARIABLE_START+"-"))||(t=this.G(this.tags.VARIABLE_START)))return this.in_code=!0,c("variable-start",t,n,i);t="";var p=!1;for(this.H(this.tags.COMMENT_START)&&(p=!0,t=this.G(this.tags.COMMENT_START));null!==(l=this.W(v));){if(t+=l,(this.H(this.tags.BLOCK_START)||this.H(this.tags.VARIABLE_START)||this.H(this.tags.COMMENT_START))&&!p){if(this.lstripBlocks&&this.H(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var d=t.slice(-this.colno);if(/^\s+$/.test(d)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this.H(this.tags.COMMENT_END)){if(!p)throw Error("unexpected end of comment");t+=this.G(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===l&&p)throw Error("expected end of comment, got end of file");return c(p?"comment":"data",t,n,i)},n.U=function(t){this.forward();for(var n="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":n+="\n";break;case"t":n+="\t";break;case"r":n+="\r";break;default:n+=this.current()}this.forward()}else n+=i,this.forward()}return this.forward(),n},n.H=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},n.G=function(t){return this.H(t)?(this.forwardN(t.length),t):null},n.W=function(t){return this.J(!0,t||"")},n.$=function(t){return this.J(!1,t)},n.J=function(t,n){if(this.isFinished())return null;var i=n.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var r=this.current();this.forward();for(var e=n.indexOf(this.current());(t&&-1===e||!t&&-1!==e)&&!this.isFinished();)r+=this.current(),this.forward(),e=n.indexOf(this.current());return r}return""},n.D=function(t){var n=this.currentStr().match(t);return n?(this.forwardN(n[0].length),n):null},n.isFinished=function(){return this.index>=this.len},n.forwardN=function(t){for(var n=0;no){for(var n=0,i=e.length-s;n0&&o.length>e&&!o.warned){o.warned=!0;var u=Error("Possible EventEmitter memory leak detected. "+o.length+" "+n+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=n,u.count=o.length,console&&console.warn&&console.warn(u)}return t}function a(t,n,i){var r={fired:!1,wrapFn:void 0,target:t,type:n,listener:i},e=function(){for(var t=[],n=0;n0&&(o=n[0]),o instanceof Error)throw o;var u=Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var h=e[t];if(void 0===h)return!1;if("function"==typeof h)s(h,this,n);else{var f=h.length,c=p(h,f);for(i=0;i=0;s--)if(i[s]===n||i[s].listener===n){o=i[s].listener,e=s;break}if(e<0)return this;0===e?i.shift():function(t,n){for(;n+1=0;r--)this.removeListener(t,n[r]);return this},u.prototype.listeners=function(t){return l(this,t,!0)},u.prototype.rawListeners=function(t){return l(this,t,!1)},u.listenerCount=function(t,n){return"function"==typeof t.listenerCount?t.listenerCount(n):v.call(t,n)},u.prototype.listenerCount=v,u.prototype.eventNames=function(){return this.Y>0?r(this.z):[]}},function(t,n,i){"use strict";var r=i(3),e=i(0),s=0;function o(){return"hole_"+s++}function u(t,n){for(var i=null,r=0;r=n)return t;var i=n-t.length,o=r.repeat(" ",i/2-i%2),u=r.repeat(" ",i/2);return e.copySafeness(t,o+t+u)},n.default=function(t,n,i){return i?t||n:void 0!==t?t:n},n.dictsort=function(t,n,i){if(!r.isObject(t))throw new r.TemplateError("dictsort filter: val must be an object");var e,s=[];for(var o in t)s.push([o,t[o]]);if(void 0===i||"key"===i)e=0;else{if("value"!==i)throw new r.TemplateError("dictsort filter: You can only sort by either key or value");e=1}return s.sort(function(t,i){var s=t[e],o=i[e];return n||(r.isString(s)&&(s=s.toUpperCase()),r.isString(o)&&(o=o.toUpperCase())),s>o?1:s===o?0:-1}),s},n.dump=function(t,n){return JSON.stringify(t,null,n)},n.escape=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(r.escape(t.toString())))},n.safe=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(t.toString()))},n.first=function(t){return t[0]},n.forceescape=function(t){return t=null===t||void 0===t?"":t,e.markSafe(r.escape(t.toString()))},n.groupby=function(t,n){return r.groupBy(t,n)},n.indent=function(t,n,i){if(""===(t=s(t,"")))return"";n=n||4;var o=t.split("\n"),u=r.repeat(" ",n),h=o.map(function(t,n){return 0!==n||i?""+u+t+"\n":t+"\n"}).join("");return e.copySafeness(t,h)},n.join=function(t,n,i){return n=n||"",i&&(t=r.map(t,function(t){return t[i]})),t.join(n)},n.last=function(t){return t[t.length-1]},n.length=function(t){var n=s(t,"");return void 0!==n?"function"==typeof Map&&n instanceof Map||"function"==typeof Set&&n instanceof Set?n.size:!r.isObject(n)||n instanceof e.SafeString?n.length:r.keys(n).length:0},n.list=h,n.lower=function(t){return(t=s(t,"")).toLowerCase()},n.nl2br=function(t){return null===t||void 0===t?"":e.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},n.random=function(t){return t[Math.floor(Math.random()*t.length)]},n.rejectattr=function(t,n){return t.filter(function(t){return!t[n]})},n.selectattr=function(t,n){return t.filter(function(t){return!!t[n]})},n.replace=function(t,n,i,r){var s=t;if(n instanceof RegExp)return t.replace(n,i);void 0===r&&(r=-1);var o="";if("number"==typeof n)n=""+n;else if("string"!=typeof n)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof e.SafeString))return t;if(""===n)return o=i+t.split("").join(i)+i,e.copySafeness(t,o);var u=t.indexOf(n);if(0===r||-1===u)return t;for(var h=0,f=0;u>-1&&(-1===r||f=e&&c.push(i),s.push(c)}return s},n.sum=function(t,n,i){return void 0===i&&(i=0),n&&(t=r.map(t,function(t){return t[n]})),i+t.reduce(function(t,n){return t+n},0)},n.sort=e.makeMacro(["value","reverse","case_sensitive","attribute"],[],function(t,n,i,e){var s=r.map(t,function(t){return t});return s.sort(function(t,s){var o=e?t[e]:t,u=e?s[e]:s;return!i&&r.isString(o)&&r.isString(u)&&(o=o.toLowerCase(),u=u.toLowerCase()),ou?n?-1:1:0}),s}),n.string=function(t){return e.copySafeness(t,t)},n.striptags=function(t,n){var i=f((t=s(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,"")),r="";return r=n?i.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):i.replace(/\s+/gi," "),e.copySafeness(t,r)},n.title=function(t){var n=(t=s(t,"")).split(" ").map(function(t){return u(t)});return e.copySafeness(t,n.join(" "))},n.trim=f,n.truncate=function(t,n,i,r){var o=t;if(t=s(t,""),n=n||255,t.length<=n)return t;if(i)t=t.substring(0,n);else{var u=t.lastIndexOf(" ",n);-1===u&&(u=n),t=t.substring(0,u)}return t+=void 0!==r&&null!==r?r:"...",e.copySafeness(o,t)},n.upper=function(t){return(t=s(t,"")).toUpperCase()},n.urlencode=function(t){var n=encodeURIComponent;return r.isString(t)?n(t):(r.isArray(t)?t:r.r(t)).map(function(t){var i=t[0],r=t[1];return n(i)+"="+n(r)}).join("&")};var c=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,a=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,l=/^https?:\/\/.*$/,v=/^www\./,p=/\.(?:org|net|com)(?:\:|\/|$)/;n.urlize=function(t,n,i){o(n)&&(n=1/0);var r=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter(function(t){return t&&t.length}).map(function(t){var i=t.match(c),e=i?i[1]:t,s=e.substr(0,n);return l.test(e)?'"+s+"":v.test(e)?'"+s+"":a.test(e)?''+e+"":p.test(e)?'"+s+"":t}).join("")},n.wordcount=function(t){var n=(t=s(t,""))?t.match(/\w+/g):null;return n?n.length:null},n.float=function(t,n){var i=parseFloat(t);return o(i)?n:i},n.int=function(t,n){var i=parseInt(t,10);return o(i)?n:i},n.d=n.default,n.e=n.escape},function(t,n,i){"use strict";var r=function(t){var n,i;function r(n){var i;return(i=t.call(this)||this).precompiled=n||{},i}return i=t,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,n.__proto__=i,r.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},r}(i(6));t.exports={PrecompiledLoader:r}},function(t,n,i){"use strict";var r=i(2).SafeString;n.callable=function(t){return"function"==typeof t},n.defined=function(t){return void 0!==t},n.divisibleby=function(t,n){return t%n==0},n.escaped=function(t){return t instanceof r},n.equalto=function(t,n){return t===n},n.eq=n.equalto,n.sameas=n.equalto,n.even=function(t){return t%2==0},n.falsy=function(t){return!t},n.ge=function(t,n){return t>=n},n.greaterthan=function(t,n){return t>n},n.gt=n.greaterthan,n.le=function(t,n){return t<=n},n.lessthan=function(t,n){return t0)for(var e=t;en;s+=i)r.push(s);return r},cycler:function(){return t=Array.prototype.slice.call(arguments),n=-1,{current:null,reset:function(){n=-1,this.current=null},next:function(){return++n>=t.length&&(n=0),this.current=t[n],this.current}};var t,n},joiner:function(t){return function(t){t=t||",";var n=!0;return function(){var i=n?"":t;return n=!1,i}}(t)}}}},function(t,n,i){var r=i(4);t.exports=function(t,n){function i(t,n){if(this.name=t,this.path=t,this.defaultEngine=n.defaultEngine,this.ext=r.extname(t),!this.ext&&!this.defaultEngine)throw Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(n,i){t.render(this.name,n,i)},n.set("view",i),n.set("nunjucksEnv",t),t}},function(t,n,i){"use strict";var r=i(4),e=i(4),s=i(0).t,o=i(5),u=i(7).Environment,h=i(24);function f(t,n){return!!Array.isArray(n)&&n.some(function(n){return t.match(n)})}function c(t,n){(n=n||{}).isString=!0;var i=n.env||new u([]),r=n.wrapper||h;if(!n.name)throw Error('the "name" option is required when compiling a string');return r([a(t,n.name,i)],n)}function a(t,n,i){var r,e=(i=i||new u([])).asyncFilters,h=i.extensionsList;n=n.replace(/\\/g,"/");try{r=o.compile(t,e,h,n,i.opts)}catch(t){throw s(n,!1,t)}return{name:n,template:r}}t.exports={precompile:function(t,n){var i=(n=n||{}).env||new u([]),s=n.wrapper||h;if(n.isString)return c(t,n);var o=r.existsSync(t)&&r.statSync(t),l=[],v=[];if(o.isFile())l.push(a(r.readFileSync(t,"utf-8"),n.name||t,i));else if(o.isDirectory()){!function i(s){r.readdirSync(s).forEach(function(o){var u=e.join(s,o),h=u.substr(e.join(t,"/").length),c=r.statSync(u);c&&c.isDirectory()?f(h+="/",n.exclude)||i(u):f(h,n.include)&&v.push(u)})}(t);for(var p=0;p=this.length||t<0)throw Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var n=0;nt.length||e>0&&o>=r||e<0&&o<=r);o+=e)s.push(i.memberLookup(t,o));return s}.apply(this,arguments):(t=t||{},r.isArray(t)&&l(v,n)?v[n].bind(t):r.isObject(t)&&l(p,n)?p[n].bind(t):f.apply(this,arguments))},function(){i.contextOrFrameLookup=h,i.memberLookup=f,e&&(e.prototype.assertType=t),s&&(s.prototype.parseAggregate=n)}}}])}); +//# sourceMappingURL=nunjucks.min.js.map \ No newline at end of file