Skip to content
Snippets Groups Projects
Commit 904da5a7 authored by echicken's avatar echicken :chicken:
Browse files

Fix missing page title when defaulting to home.

Exit immediately if client attempting redirect to arbitrary external site. (This won't work for them anyway, but no need to run the rest of the script.)
Use js.exec() for components instead of load().
Use <? ... ?> instead of <?xjs ... ?> for XJS one-liners.
parent 8e441dc6
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
<?xjs <?xjs
var page = typeof http_request.query.page == 'undefined' ? '000-home.xjs' : http_request.query.page[0];
if (page.search(/^http(s)*:\/\//) > -1) exit();
var settings = load('modopts.js', 'web') || { web_directory: web_root_dir + '/..' }; var settings = load('modopts.js', 'web') || { web_directory: web_root_dir + '/..' };
load(settings.web_directory + '/lib/init.js'); load(settings.web_directory + '/lib/init.js');
load(settings.web_lib + 'auth.js'); load(settings.web_lib + 'auth.js');
load(settings.web_lib + 'pages.js'); load(settings.web_lib + 'pages.js');
load(settings.web_lib + 'sidebar.js'); load(settings.web_lib + 'sidebar.js');
var page = typeof http_request.query.page == 'undefined' ? '000-home.xjs' : http_request.query.page[0];
if (page.search(/\.link$/) > -1) { if (page.search(/\.link$/) > -1) {
var loc = getExternalLink(page); var loc = getExternalLink(page);
http_reply.status = '301 Moved Permanently'; http_reply.status = '301 Moved Permanently';
...@@ -13,7 +15,10 @@ ...@@ -13,7 +15,10 @@
exit(); exit();
} }
var pagePath = getPagePath(page); var pagePath = getPagePath(page);
if (pagePath == null) page = '000-home.xjs'; if (pagePath == null) {
page = '000-home.xjs';
pagePath = getPagePath('000-home.xjs');
}
var page_ctrl = getCtrlLine(pagePath); var page_ctrl = getCtrlLine(pagePath);
?> ?>
...@@ -27,11 +32,11 @@ ...@@ -27,11 +32,11 @@
return (function () { return (function () {
const cdir = backslash(fullpath(settings.web_mods + 'components')); const cdir = backslash(fullpath(settings.web_mods + 'components'));
if (file_isdir(cdir) && file_exists(cdir + fn)) { if (file_isdir(cdir) && file_exists(cdir + fn)) {
load(xjs_compile(cdir + fn)); js.exec(xjs_compile(cdir + fn), new function () {});
return true; return true;
} }
if (file_exists(settings.web_components + fn)) { if (file_exists(settings.web_components + fn)) {
load(xjs_compile(settings.web_components + fn)); js.exec(xjs_compile(settings.web_components + fn), new function () {});
return true; return true;
} }
return false; return false;
...@@ -47,7 +52,7 @@ ...@@ -47,7 +52,7 @@
</style> </style>
<script src="./js/jquery.min.js"></script> <script src="./js/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
jQuery('html').addClass('hidden'); $('html').addClass('hidden');
</script> </script>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
...@@ -57,9 +62,9 @@ ...@@ -57,9 +62,9 @@
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="./css/offcanvas.css" rel="stylesheet"> <link href="./css/offcanvas.css" rel="stylesheet">
<link href="./css/style.css" rel="stylesheet"> <link href="./css/style.css" rel="stylesheet">
<?xjs if (settings.darkmode_allow) { ?> <? if (settings.darkmode_allow) { ?>
<link href="./css/checkbox.css" rel="stylesheet"> <link href="./css/checkbox.css" rel="stylesheet">
<?xjs } ?> <? } ?>
<? if (file_exists(settings.web_root + 'css/custom.css')) { ?> <? if (file_exists(settings.web_root + 'css/custom.css')) { ?>
<link href="./css/custom.css" rel="stylesheet"> <link href="./css/custom.css" rel="stylesheet">
<? } ?> <? } ?>
...@@ -76,13 +81,15 @@ ...@@ -76,13 +81,15 @@
loadComponent('navbar.xjs'); loadComponent('navbar.xjs');
?> ?>
<div class="container<?xjs if (settings.layout_full_width) write('-fluid'); ?>"> <div class="container<? if (settings.layout_full_width) write('-fluid'); ?>">
<div class="row row-offcanvas row-offcanvas-<?xjs write(settings.layout_sidebar_left ? 'left' : 'right'); ?>"> <div class="row row-offcanvas row-offcanvas-<? write(settings.layout_sidebar_left ? 'left' : 'right'); ?>">
<? if (settings.layout_sidebar_left) _sidebar(); ?> <? if (settings.layout_sidebar_left) _sidebar(); ?>
<div class="col-xs-12 col-sm-<?xjs write(settings.layout_sidebar_off || page_ctrl.options.no_sidebar ? 12 : 9); ?>"> <div class="col-xs-12 col-sm-<? write(settings.layout_sidebar_off || page_ctrl.options.no_sidebar ? 12 : 9); ?>">
<div style="clear:both;"> <div style="clear:both;">
<p class="pull-<?xjs write(settings.layout_sidebar_left ? 'left' : 'right'); ?> visible-xs"> <p class="pull-<? write(settings.layout_sidebar_left ? 'left' : 'right'); ?> visible-xs">
<button title="Toggle sidebar" type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas"><span class="glyphicon glyphicon-tasks"></span><?xjs write(locale.strings.main.label_sidebar); ?></button> <button title="Toggle sidebar" type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">
<span class="glyphicon glyphicon-tasks"></span><? write(locale.strings.main.label_sidebar); ?>
</button>
</p> </p>
</div> </div>
<? writePage(page); ?> <? writePage(page); ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment