1
0
mirror of https://tildegit.org/sbgodin/HtmGem.git synced 2023-08-25 13:53:12 +02:00

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 # Styles
=> index.gmi|htmgem htmgem.css => index.gmi|default,htmgem.css htmgem.css
=> index.gmi|none None => index.gmi|default,terminal.css terminal.css
=> index.gmi|terminal terminal.css => index.gmi|default,black_wide.css black_wide.css
=> index.gmi|black_wide black_wide.css => index.gmi|default,simple.css simple.css
=> index.gmi|simple simple.css => index.gmi|default,raw.css raw.css
=> index.gmi|raw raw.css => index.gmi|default,debug.css debug.css
=> index.gmi|debug debug.css => index.gmi|src Source code
=> index.gmi|pre Source code
=> index.gmi|source Download source code => index.gmi|source Download source code
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.

View File

@ -3,7 +3,7 @@
<head> <head>
<title>HtmGem</title> <title>HtmGem</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <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> </head>
<body> <body>
<h1>HtmGem</h1> <h1>HtmGem</h1>

View File

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