mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
added regex matching to templates/ajaxify. needs cleanup, just unblocking baris
This commit is contained in:
@@ -31,8 +31,9 @@ var ajaxify = {};
|
||||
app.enter_room('global');
|
||||
|
||||
var url = url.replace(/\/$/, "");
|
||||
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
||||
tpl_url = templates.get_custom_map(tpl_url);
|
||||
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
||||
|
||||
|
||||
if (templates[tpl_url]) {
|
||||
window.history.pushState({}, url, "/" + url);
|
||||
|
||||
@@ -5,7 +5,15 @@ var templates = {};
|
||||
config = {};
|
||||
|
||||
templates.get_custom_map = function(tpl) {
|
||||
return (config['custom_mapping'] && config['custom_mapping'][tpl]) ? config['custom_mapping'][tpl] : tpl;
|
||||
if (config['custom_mapping'] && tpl) {
|
||||
for (var pattern in config['custom_mapping']) {
|
||||
console.log(pattern);
|
||||
if (tpl.match(pattern)) {
|
||||
return (config['custom_mapping'][pattern]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
templates.ready = function(callback) {
|
||||
@@ -156,18 +164,15 @@ function load_template(callback, custom_tpl) {
|
||||
|
||||
|
||||
jQuery.get(API_URL + url, function(data) {
|
||||
|
||||
var splits = url.split('/');
|
||||
var tpl = url;
|
||||
|
||||
if(splits.length) {
|
||||
tpl = splits[0];
|
||||
tpl = templates.get_custom_map(tpl);
|
||||
var tpl = templates.get_custom_map(url);
|
||||
if (tpl == false) {
|
||||
tpl = url.split('/')[0];
|
||||
}
|
||||
|
||||
if (custom_tpl && custom_tpl != "undefined")
|
||||
tpl = custom_tpl;
|
||||
|
||||
|
||||
|
||||
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
||||
if (callback) callback();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"custom_mapping": {
|
||||
"users[^]*edit": "accountedit",
|
||||
"users": "account",
|
||||
"latest": "category",
|
||||
"popular": "category",
|
||||
|
||||
Reference in New Issue
Block a user