Make room for vendor CSS

* Creates a default directory for the default css.
* Changes the way to address CSS: "," used as "/" (see htmgem/css/index.gmi).
* "src" style replaces the "pre": display the source code onscreen.
* Removes the "None" style, useless after all.
* Removes the absolute stylesheet path, now always in /htmgem/css.
This commit is contained in:
Christophe HENRY 2022-07-29 11:08:28 +02:00
parent 8e74403bc4
commit 678778ba2c
10 changed files with 17 additions and 19 deletions

View File

@ -1,13 +1,12 @@
# Styles
=> index.gmi|htmgem htmgem.css
=> index.gmi|none None
=> index.gmi|terminal terminal.css
=> index.gmi|black_wide black_wide.css
=> index.gmi|simple simple.css
=> index.gmi|raw raw.css
=> index.gmi|debug debug.css
=> index.gmi|pre Source code
=> index.gmi|default,htmgem.css htmgem.css
=> index.gmi|default,terminal.css terminal.css
=> index.gmi|default,black_wide.css black_wide.css
=> index.gmi|default,simple.css simple.css
=> index.gmi|default,raw.css raw.css
=> index.gmi|default,debug.css debug.css
=> index.gmi|src Source code
=> index.gmi|source Download source code
Lorem ipsum dolor sit amet.

View File

@ -3,7 +3,7 @@
<head>
<title>HtmGem</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type='text/css' rel='StyleSheet' href='css/htmgem.css'>
<link type='text/css' rel='StyleSheet' href='css/default/htmgem.css'>
</head>
<body>
<h1>HtmGem</h1>

View File

@ -4,6 +4,8 @@ require_once "lib-htmgem.inc.php";
require_once "lib-html.inc.php";
require_once "lib-io.inc.php";
define("DEFAULT_CSS", "/css/default/htmgem.css");
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
$scheme = (@$_SERVER['REQUEST_SCHEME']??"http")."://";
$domain = $_SERVER['HTTP_HOST'];
@ -24,7 +26,7 @@ if (empty($url)) {
http_response_code(403);
} else {
$gt_html = new \htmgem\GemTextTranslate_html(file_get_contents("index.gmi"), true, "$php_self?url=", $php_self_dir);
if (empty($gt_html->getCss)) $gt_html->addCss($php_self_dir."/css/htmgem.css");
if (empty($gt_html->getCss)) $gt_html->addCss($php_self_dir.DEFAULT_CSS);
// No URL Rewritting assumed
echo \htmgem\html\getHtmlWithMenu($gt_html, $scheme, $domain, $php_self, "$php_self?url=");
@ -91,7 +93,7 @@ if ("source" == $style) {
header('Content-Length: ' . filesize($filePath));
echo $fileContents;
exit();
} elseif ("pre" == $style) {
} elseif ("src" == $style) {
# Gets the page title: the first occurrence with # at the line start
mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches);
$page_title = @$matches[1];
@ -116,11 +118,7 @@ if ($urlRewriting)
else
$gt_html = new \htmgem\GemTextTranslate_html($fileContents, $gt_htmlextDecoration, "$php_self?url=", dirname($url));
if ("none" == $style) {
#$gt_html->addCss("");
} elseif ("/" == @$style[0]) {
$gt_html->addCss($style);
} elseif (empty($style)) {
if (empty($style)) { // Searches for a stylesheet for the current page.
$parts = pathinfo($filePath);
$localCss = $parts["filename"].".css";
$localCssFilePath = $parts["dirname"]."/".$localCss;
@ -129,10 +127,11 @@ if ("none" == $style) {
# as the path is relative to htmgem.php and not / !
$gt_html->addCss($localCss);
} else { // No local style
$gt_html->addCss($php_self_dir."/css/htmgem.css");
$gt_html->addCss($php_self_dir.DEFAULT_CSS);
}
} else { #TODO: regex check for $style
$gt_html->addCss("$php_self_dir/css/$style.css");
} else {
$style = preg_replace("/,/", "/", $style);
$gt_html->addCss("$php_self_dir/css/$style");
}
if ($urlRewriting)