mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 23:45:45 +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');
|
app.enter_room('global');
|
||||||
|
|
||||||
var url = url.replace(/\/$/, "");
|
var url = url.replace(/\/$/, "");
|
||||||
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
|
||||||
tpl_url = templates.get_custom_map(tpl_url);
|
tpl_url = templates.get_custom_map(tpl_url);
|
||||||
|
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
||||||
|
|
||||||
|
|
||||||
if (templates[tpl_url]) {
|
if (templates[tpl_url]) {
|
||||||
window.history.pushState({}, url, "/" + url);
|
window.history.pushState({}, url, "/" + url);
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ var templates = {};
|
|||||||
config = {};
|
config = {};
|
||||||
|
|
||||||
templates.get_custom_map = function(tpl) {
|
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) {
|
templates.ready = function(callback) {
|
||||||
@@ -156,18 +164,15 @@ function load_template(callback, custom_tpl) {
|
|||||||
|
|
||||||
|
|
||||||
jQuery.get(API_URL + url, function(data) {
|
jQuery.get(API_URL + url, function(data) {
|
||||||
|
var tpl = templates.get_custom_map(url);
|
||||||
var splits = url.split('/');
|
if (tpl == false) {
|
||||||
var tpl = url;
|
tpl = url.split('/')[0];
|
||||||
|
|
||||||
if(splits.length) {
|
|
||||||
tpl = splits[0];
|
|
||||||
tpl = templates.get_custom_map(tpl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_tpl && custom_tpl != "undefined")
|
if (custom_tpl && custom_tpl != "undefined")
|
||||||
tpl = custom_tpl;
|
tpl = custom_tpl;
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"custom_mapping": {
|
"custom_mapping": {
|
||||||
|
"users[^]*edit": "accountedit",
|
||||||
"users": "account",
|
"users": "account",
|
||||||
"latest": "category",
|
"latest": "category",
|
||||||
"popular": "category",
|
"popular": "category",
|
||||||
|
|||||||
Reference in New Issue
Block a user