From f554fad674b9672ddaded45fdbeaf439ee92e02e Mon Sep 17 00:00:00 2001
From: echicken <echicken@bbs.electronicchicken.com>
Date: Thu, 8 Oct 2020 15:50:40 -0400
Subject: [PATCH] If ctrl/modopts.ini -> [web] is missing, start with minimum
 viable best-guess settings ({web_directory: '../webv4}). This gives
 lib/init.js a chance to set further defaults.

---
 webv4/root/index.xjs | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/webv4/root/index.xjs b/webv4/root/index.xjs
index b5d9cac0fc..6445845624 100644
--- a/webv4/root/index.xjs
+++ b/webv4/root/index.xjs
@@ -1,7 +1,6 @@
 <?xjs
-	var settings = load('modopts.js', 'web');
+	var settings = load('modopts.js', 'web') || { web_directory: '../webv4' };
 	load(settings.web_directory + '/lib/init.js');
-
 	load(settings.web_lib + 'auth.js');
 	load(settings.web_lib + 'pages.js');
 	load(settings.web_lib + 'sidebar.js');
@@ -17,14 +16,10 @@
 	var page_ctrl = getCtrlLine(pagePath);
 ?>
 
-<?xjs
-	function _sidebar() {
-		if (settings.layout_sidebar_off || page_ctrl.options.no_sidebar) return;
-?>
+<? function _sidebar() { ?>
+	<? if (settings.layout_sidebar_off || page_ctrl.options.no_sidebar) return; ?>
 		<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar"><? writeSidebarModules(); ?></div>
-<?xjs
-	}
-?>
+<? } ?>
 
 <?xjs
 	function loadComponent(fn) {
@@ -54,9 +49,9 @@
 		<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
 		<link href="./css/offcanvas.css" rel="stylesheet">
 		<link href="./css/style.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">
-		<?xjs } ?>
+		<? } ?>
 	</head>
 
 	<body>
@@ -73,22 +68,22 @@
 
 		<div class="container<?xjs if (settings.layout_full_width) write('-fluid'); ?>">
 			<div class="row row-offcanvas row-offcanvas-<?xjs write(settings.layout_sidebar_left ? 'left' : 'right'); ?>">
-				<?xjs 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 style="clear:both;">
 					<p class="pull-<?xjs 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>
 					</p>
 					</div>
-					<?xjs writePage(page); ?>
+					<? writePage(page); ?>
 				</div>
-				<?xjs if (!settings.layout_sidebar_left || settings.layout_sidebar_right) _sidebar(); ?>
+				<? if (!settings.layout_sidebar_left || settings.layout_sidebar_right) _sidebar(); ?>
 			</div>
 		  	<hr>
 			<footer>
-				<?xjs if (!loadComponent('footer.xjs')) { ?>
-					<p>&copy; <?xjs write(system.name + ", " + strftime("%Y")); ?></p>
-				<?xjs } ?>
+				<? if (!loadComponent('footer.xjs')) { ?>
+					<p>&copy; <? write(system.name + ", " + strftime("%Y")); ?></p>
+				<? } ?>
 			</footer>
 		</div>
 
-- 
GitLab