Simplify config, add config options for disabling parts of the wiki
This commit is contained in:
parent
33f955ad53
commit
11ea8ddaec
92
config.php
92
config.php
|
@ -7,100 +7,40 @@
|
||||||
* See LICENSE file for copyright and license details.
|
* See LICENSE file for copyright and license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// --------------------
|
|
||||||
// Site layout settings
|
|
||||||
// --------------------
|
|
||||||
|
|
||||||
// PAGES_PATH
|
|
||||||
//
|
|
||||||
// The path to the raw text documents maintained by W2
|
|
||||||
// You should not use a trailing slash.
|
|
||||||
|
|
||||||
define('PAGES_PATH', dirname(__FILE__). '/pages');
|
define('PAGES_PATH', dirname(__FILE__). '/pages');
|
||||||
|
|
||||||
// UPLOAD_FOLDER
|
|
||||||
//
|
|
||||||
// The subfolder in PAGES_PATH that uploads get stored to
|
|
||||||
define('UPLOAD_FOLDER', 'images');
|
define('UPLOAD_FOLDER', 'images');
|
||||||
|
|
||||||
// PAGES_EXT
|
|
||||||
//
|
|
||||||
// The extension of the Markdown files in the PAGES_PATH
|
|
||||||
// folder which are displayed by W2
|
|
||||||
define('PAGES_EXT', 'md');
|
define('PAGES_EXT', 'md');
|
||||||
|
|
||||||
|
|
||||||
// BASE_URI
|
|
||||||
//
|
|
||||||
// The base URI for this W2 installation. You only need to change this if we guess wrong.
|
|
||||||
// You should not use a trailing slash.
|
|
||||||
|
|
||||||
define('BASE_URI', str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']));
|
define('BASE_URI', str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']));
|
||||||
|
|
||||||
// SELF
|
|
||||||
//
|
|
||||||
// The path component of the URL to the main script, such as: /w2/index.php
|
|
||||||
|
|
||||||
define('SELF', $_SERVER['SCRIPT_NAME']);
|
define('SELF', $_SERVER['SCRIPT_NAME']);
|
||||||
|
define('VIEW', ''); // '?action=view&page='
|
||||||
// VIEW
|
|
||||||
//
|
|
||||||
// Needed only if your web server spawns PHP as a CGI instead of an internal module.
|
|
||||||
// For example: define('VIEW', '?action=view&page=');
|
|
||||||
|
|
||||||
define('VIEW', '');
|
|
||||||
|
|
||||||
// DEFAULT_PAGE
|
|
||||||
//
|
|
||||||
// The name of the page to show as the "Home" page.
|
|
||||||
// Value is a string, the title of a page (case-sensitive!)
|
|
||||||
|
|
||||||
define('DEFAULT_PAGE', 'Home');
|
define('DEFAULT_PAGE', 'Home');
|
||||||
|
define('SIDEBAR_PAGE', 'Sidebar');
|
||||||
// CSS_FILE
|
|
||||||
//
|
|
||||||
// The CSS file to load to style the wiki, relative to BASE_URI
|
|
||||||
|
|
||||||
define('CSS_FILE', 'css/index.css');
|
define('CSS_FILE', 'css/index.css');
|
||||||
|
|
||||||
// SIDEBAR_FILE
|
|
||||||
//
|
|
||||||
// The name of the page to be shown as sidebar (leave empty to disable sidebar feature)
|
|
||||||
|
|
||||||
define ('SIDEBAR_PAGE', 'Sidebar');
|
|
||||||
|
|
||||||
// PAGE_TITLE
|
|
||||||
//
|
|
||||||
// A title prepended to the title head tag of all pages of the wiki
|
|
||||||
|
|
||||||
define('PAGE_TITLE', 'spmenu wiki: ');
|
define('PAGE_TITLE', 'spmenu wiki: ');
|
||||||
|
|
||||||
// ------------------
|
define('ENABLE_FAVICON', true);
|
||||||
// Interface settings
|
define('ENABLE_TITLE', true);
|
||||||
// ------------------
|
define('ENABLE_CSS', true);
|
||||||
|
define('ENABLE_HEAD', true);
|
||||||
|
define('ENABLE_FOOTER', true);
|
||||||
|
define('ENABLE_TITLEBAR', true);
|
||||||
|
define('ENABLE_TOOLBAR', true);
|
||||||
|
define('ENABLE_SEARCH', true);
|
||||||
|
define('ENABLE_ALL', true);
|
||||||
|
define('ENABLE_HOME_ICON', true);
|
||||||
|
define('ENABLE_ALL_ICON', true);
|
||||||
|
|
||||||
// TITLE_DATE
|
define('META_DESC', true);
|
||||||
//
|
define('META_ENC', true);
|
||||||
// The format to use when displaying page modification times.
|
define('META_VIEWPORT', true);
|
||||||
// See the manual for the PHP 'date()' function for the specification:
|
|
||||||
// http://php.net/manual/en/function.date.php
|
|
||||||
// Note that these settings are overridden by the
|
|
||||||
|
|
||||||
define('TITLE_DATE', 'j M Y g:i A');
|
define('TITLE_DATE', 'j M Y g:i A');
|
||||||
define('TITLE_DATE_NO_TIME', 'j M Y');
|
define('TITLE_DATE_NO_TIME', 'j M Y');
|
||||||
|
|
||||||
// -----------------------------
|
|
||||||
// Git Integration
|
|
||||||
// -----------------------------
|
|
||||||
|
|
||||||
// GIT_COMMIT_ENABLED
|
|
||||||
//
|
|
||||||
// Enable/Disable committing changes in page folder to local git repository
|
|
||||||
|
|
||||||
define('GIT_COMMIT_ENABLED', false);
|
define('GIT_COMMIT_ENABLED', false);
|
||||||
|
|
||||||
// GIT_PUSH_ENABLED
|
|
||||||
//
|
|
||||||
// Enable/Disable pushing changes in page folder to a remote git repository
|
|
||||||
|
|
||||||
define('GIT_PUSH_ENABLED', false);
|
define('GIT_PUSH_ENABLED', false);
|
||||||
|
|
53
index.php
53
index.php
|
@ -39,6 +39,7 @@ function truncate($text, $chars) {
|
||||||
function printHeader($title, $action, $html, $bodyclass="")
|
function printHeader($title, $action, $html, $bodyclass="")
|
||||||
{
|
{
|
||||||
// TODO: Improve this garbage, I suck at PHP and this is just stuff I found on the internet.
|
// TODO: Improve this garbage, I suck at PHP and this is just stuff I found on the internet.
|
||||||
|
if (META_DESC) {
|
||||||
$nhtml = $html;
|
$nhtml = $html;
|
||||||
$nhtml = preg_replace( '@<p\b[^>]*>(?=.*?<a\b[^>]*>).*?<\@p>@si', '', $nhtml);
|
$nhtml = preg_replace( '@<p\b[^>]*>(?=.*?<a\b[^>]*>).*?<\@p>@si', '', $nhtml);
|
||||||
$nhtml = preg_replace( '@<(li)[^>]*?>.*?</\\1>@si', '', $nhtml);
|
$nhtml = preg_replace( '@<(li)[^>]*?>.*?</\\1>@si', '', $nhtml);
|
||||||
|
@ -46,26 +47,52 @@ function printHeader($title, $action, $html, $bodyclass="")
|
||||||
$nhtml = strip_tags($nhtml);
|
$nhtml = strip_tags($nhtml);
|
||||||
$nhtml = preg_replace('/\s*$^\s*/m', "\n", $nhtml);
|
$nhtml = preg_replace('/\s*$^\s*/m', "\n", $nhtml);
|
||||||
$nhtml = truncate($nhtml, 512);
|
$nhtml = truncate($nhtml, 512);
|
||||||
|
}
|
||||||
|
|
||||||
print "<!doctype html>\n";
|
print "<!doctype html>\n";
|
||||||
print "<html lang=\"en\">\n";
|
print "<html lang=\"en\">\n";
|
||||||
|
|
||||||
|
if (ENABLE_HEAD) {
|
||||||
print " <head>\n";
|
print " <head>\n";
|
||||||
|
|
||||||
|
if (META_ENC) {
|
||||||
print " <meta charset=\"UTF-8\">\n";
|
print " <meta charset=\"UTF-8\">\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (META_DESC) {
|
||||||
print " <meta name=\"description\" content=\"$nhtml\">\n";
|
print " <meta name=\"description\" content=\"$nhtml\">\n";
|
||||||
print " <link rel=\"icon\" href=\"/icons/fav.svg\"/>\n";
|
}
|
||||||
|
|
||||||
|
if (META_VIEWPORT) {
|
||||||
print " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
|
print " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_FAVICON) {
|
||||||
|
print " <link rel=\"icon\" href=\"/icons/fav.svg\"/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_CSS) {
|
||||||
print " <link type=\"text/css\" rel=\"stylesheet\" href=\"" . BASE_URI . "/" . CSS_FILE ."\" />\n";
|
print " <link type=\"text/css\" rel=\"stylesheet\" href=\"" . BASE_URI . "/" . CSS_FILE ."\" />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_TITLE) {
|
||||||
print " <title>".PAGE_TITLE."$title</title>\n";
|
print " <title>".PAGE_TITLE."$title</title>\n";
|
||||||
|
}
|
||||||
|
|
||||||
print " </head>\n";
|
print " </head>\n";
|
||||||
|
}
|
||||||
|
|
||||||
print " <body".($bodyclass != "" ? " class=\"$bodyclass\"":"").">\n";
|
print " <body".($bodyclass != "" ? " class=\"$bodyclass\"":"").">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function printFooter()
|
function printFooter()
|
||||||
{
|
{
|
||||||
|
if (ENABLE_FOOTER) {
|
||||||
print " </body>\n";
|
print " </body>\n";
|
||||||
print "<p class=\"footer\">Wiki licensed under the <a href=\"https://git.speedie.site/speedie/spmenu-wiki/raw/branch/master/LICENSE\">MIT</a> license. Articles and images licensed under the CC-BY-SA 4.0 license. <a href=\"https://git.speedie.site/speedie/spmenu-wiki\">Source code</a></p>";
|
print "<p class=\"footer\">Wiki licensed under the <a href=\"https://git.speedie.site/speedie/spmenu-wiki/raw/branch/master/LICENSE\">MIT</a> license. Articles and images licensed under the CC-BY-SA 4.0 license. <a href=\"https://git.speedie.site/speedie/spmenu-wiki\">Source code</a></p>";
|
||||||
print "</html>";
|
print "</html>";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Support functions
|
// Support functions
|
||||||
|
|
||||||
|
@ -250,7 +277,7 @@ if ($action === 'view')
|
||||||
$oldgitmsg = "";
|
$oldgitmsg = "";
|
||||||
$triedSave = false;
|
$triedSave = false;
|
||||||
|
|
||||||
if ( $action === 'all' )
|
if ( $action === 'all' && ENABLE_ALL )
|
||||||
{
|
{
|
||||||
$pageNames = getAllPageNames();
|
$pageNames = getAllPageNames();
|
||||||
$filelist = array();
|
$filelist = array();
|
||||||
|
@ -292,7 +319,7 @@ if ( $action === 'all' )
|
||||||
}
|
}
|
||||||
$html .= "</tbody></table>\n";
|
$html .= "</tbody></table>\n";
|
||||||
}
|
}
|
||||||
else if ( $action === 'search' )
|
else if ( $action === 'search' && ENABLE_SEARCH )
|
||||||
{
|
{
|
||||||
$matches = 0;
|
$matches = 0;
|
||||||
$q = $_REQUEST['q'];
|
$q = $_REQUEST['q'];
|
||||||
|
@ -345,11 +372,11 @@ if ( $action === 'all' )
|
||||||
|
|
||||||
$datetime = '';
|
$datetime = '';
|
||||||
|
|
||||||
if ( ($action === 'all'))
|
if ( ($action === 'all') && ENABLE_ALL)
|
||||||
{
|
{
|
||||||
$title = __("All");
|
$title = __("All");
|
||||||
}
|
}
|
||||||
else if ( $action === 'search' )
|
else if ( $action === 'search' && ENABLE_SEARCH )
|
||||||
{
|
{
|
||||||
$title = __("Search");
|
$title = __("Search");
|
||||||
}
|
}
|
||||||
|
@ -370,14 +397,30 @@ if ( $action === 'all' )
|
||||||
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||||
printHeader($title, $action, $html);
|
printHeader($title, $action, $html);
|
||||||
|
|
||||||
|
if (ENABLE_TITLEBAR) {
|
||||||
print " <div class=\"titlebar\"><span class=\"title\">$title</span>$datetime";
|
print " <div class=\"titlebar\"><span class=\"title\">$title</span>$datetime";
|
||||||
print " </div>\n";
|
print " </div>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_TOOLBAR) {
|
||||||
print " <div class=\"toolbar\">\n";
|
print " <div class=\"toolbar\">\n";
|
||||||
|
|
||||||
|
if (ENABLE_HOME_ICON) {
|
||||||
print " <a href=\"" . SELF . "\"><img src=\"/icons/home.svg\" alt=\"". __(DEFAULT_PAGE) . "\" title=\"". __(DEFAULT_PAGE) . "\" class=\"icon\"></a>\n";
|
print " <a href=\"" . SELF . "\"><img src=\"/icons/home.svg\" alt=\"". __(DEFAULT_PAGE) . "\" title=\"". __(DEFAULT_PAGE) . "\" class=\"icon\"></a>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_ALL_ICON) {
|
||||||
print " <a href=\"" . SELF . "?action=all\"><img src=\"/icons/list.svg\" alt=\"". __('All') . "\" title=\"". __('All') . "\" class=\"icon\"></a>\n";
|
print " <a href=\"" . SELF . "?action=all\"><img src=\"/icons/list.svg\" alt=\"". __('All') . "\" title=\"". __('All') . "\" class=\"icon\"></a>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_SEARCH) {
|
||||||
print " <form method=\"post\" action=\"" . SELF . "?action=search\">\n";
|
print " <form method=\"post\" action=\"" . SELF . "?action=search\">\n";
|
||||||
print " <input class=\"search\" placeholder=\"". __('Search') ."\" size=\"20\" id=\"search\" type=\"text\" name=\"q\" />\n </form>\n";
|
print " <input class=\"search\" placeholder=\"". __('Search') ."\" size=\"20\" id=\"search\" type=\"text\" name=\"q\" />\n </form>\n";
|
||||||
|
}
|
||||||
|
|
||||||
print " </div>\n";
|
print " </div>\n";
|
||||||
|
}
|
||||||
if (SIDEBAR_PAGE != '')
|
if (SIDEBAR_PAGE != '')
|
||||||
{
|
{
|
||||||
print " <div class=\"sidebar\">\n\n";
|
print " <div class=\"sidebar\">\n\n";
|
||||||
|
|
Loading…
Reference in a new issue