1
0
Fork 0

Adds more css options

This commit is contained in:
sloum 2023-12-20 20:40:05 -08:00
parent 06ee2af90b
commit e8e86d4589
8 changed files with 130 additions and 15 deletions

View File

@ -8,6 +8,7 @@
$media_files = array_values ( array_diff( scandir( "./media" ), ["..", "."] ) );
sort( $media_files );
include_once "common.php";
include_once "config.php";
?>
<!DOCTYPE html>
<html lang="en">
@ -35,6 +36,8 @@
details[open]{padding-bottom:1em}
details[open] summary {border-bottom: 1px solid #aaa;margin-bottom: 0.5em;background:#333;color:#DDD}
thead{background: #333;color:#EEE}
fieldset{display: inline;padding: 0 2px 0 0;margin: 0 5px 0 0;border: none;vertical-align: middle}
legend{float: left;border: none;padding-inline: 0 2px}
</style>
</head>
<body class="admin">
@ -55,7 +58,7 @@
<?php elseif ( $post_success === "1" ): ?>
<p><a href="/post.php?f=<?php echo $files[0]; ?>">New post</a> successfully added!</p>
<?php elseif ( $post_success === "2" ): ?>
<p>File updated successfully!</p>
<p>Updated successfully!</p>
<?php elseif ( $post_success === "3" ): ?>
<p>Media uploaded successfully!</p>
<?php elseif ( $post_success === "4" ): ?>
@ -139,6 +142,11 @@ HTML;
<summary>Site Actions</summary>
<ul>
<li><a href="edit.php?file=css%2Fstyle.css">Edit CSS</a></li>
<li>
<form action="site_actions.php" method="post">
<fieldset><legend>Use <i>simple.css</i></legend>
<label><input type="radio" name="simplecss" value="1"<?php echo SIMPLE_CSS ? " checked" : "";?>> Yes</label>
<label><input type="radio" name="simplecss" value="0"<?php echo SIMPLE_CSS ? "" : " checked";?>> No</label></fieldset><input type="submit" value="update"></form></li>
</ul>
</details>
<hr class="small-divider">

View File

@ -57,3 +57,14 @@ const SHOW_DATES = false;
* https://www.php.net/manual/en/datetime.format.php
*/
const DATE_STYLE = "m/d/y h:ia";
/*
* Use 'simple.css' css theme/styling. This is
* a boolean setting (true/false) that fill
* include this css theming. When true, simple.css
* will be added, but will not be directly
* editable. You will still have access to your
* css and be able to override any styles though.
*/
const SIMPLE_CSS = true;

1
css/simple.css Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,20 +1,19 @@
/* Uncomment the css below
* for basic css when not using
* simple.css in config.php
* */
/*
header{padding:1em 0}
header h1{font-size: 1.2rem;border-bottom:3px solid #333;display:inline-block}
header h1 a{text-decoration: none; color: inherit}
.article-head{margin-bottom:4em;padding:1em 0;border-bottom:1px dashed #333}
.article-head h1, .article-head .date{display:inline-block}
.article-head .date{margin-left:2em;font-style:italic}
blockquote{border-left:3px solid #333;padding-left:1em}
pre{border:1px dotted #333;background-color:#333;color:white;border-radius:10px;padding:1em;margin:2em 0}
body.post{color:#444;font-family:sans-serif;padding-left:2em}
body.post main h1,
body.post main h2,
body.post main h3,
body.post main h4,
body.post main h5,
body.post main h6{font-family:serif}
h1, h2, h3, h4, h5, h6{font-family:serif}
body.post main{max-width:900px}
img{max-width:100%}
*/

View File

@ -59,10 +59,12 @@
header ul.inline li::after{content:'' !important}
.post-list tbody tr:nth-child(odd){background-color: #DDD}
td{padding-left:1em}
details {border: 1px solid #aaa;border-radius: 4px;padding: 0.5em 0.5em 0}
details {border: 1px solid #aaa;border-radius: 4px;padding: 0.5em 0.5em 0;margin-top:2em}
summary {font-weight: bold;margin: -0.5em -0.5em 0;padding: 0.5em}
details[open] summary {border-bottom: 1px solid #aaa;margin-bottom: 0.5em}
details[open]{padding-bottom:1em}
details[open] summary {border-bottom: 1px solid #aaa;margin-bottom: 0.5em;background:#333;color:#DDD}
thead{background: #333;color:#EEE}
pre{background:#333;color:white;padding:1em;width:calc(90% - 2em);margin:1em auto;border-radius:5px}
</style>
</head>
<body class="admin">
@ -76,13 +78,71 @@
</header>
<main>
<form action="/edit.php" method="post">
<h2>Editing - <?php echo $title; ?>
<h2>Editing - <?php echo $title; ?></h2>
<p>
<label><br><textarea name="data" required><?php echo $update ?: "" ;?></textarea></label>
</p>
<input type="hidden" name="file" value="<?php echo $f; ?>">
<input type="submit" value="Submit">
</form>
<?php if ( $f == "css/style.css" ): ?>
<details>
<summary>Guide to simple.css variables</summary>
<p>The following are the default variable values for the active <i>simple.css</i> css theming. You can override any of them you like.</p>
<p>For example, to override the border color for both the light and dark modes you could do something like the following:</p>
<pre><code>:root, ::backdrop {
--border: darkred;
}
@media (prefers-color-scheme: dark) {
:root, ::backdrop {
--border: red;
}
}</code></pre>
<p>That would change the color everywhere on your site. You can override any other css (things not set by variables) by just writing your own css that overrides the things you want to change.</p>
<h2>Default Value Guide</h2>
<pre><code>:root,
::backdrop {
/* Set sans-serif &amp; mono fonts */
--sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
"Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
"Helvetica Neue", sans-serif;
--mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
--standard-border-radius: 5px;
/* Default (light) theme */
--bg: #fff;
--accent-bg: #f5f7ff;
--text: #212121;
--text-light: #585858;
--border: #898EA4;
--accent: #0d47a1;
--accent-text: var(--bg);
--code: #d81b60;
--preformatted: #444;
--marked: #ffdd33;
--disabled: #efefef;
}
/* Dark theme */
@media (prefers-color-scheme: dark) {
:root,
::backdrop {
color-scheme: dark;
--bg: #212121;
--accent-bg: #2b2b2b;
--text: #dcdcdc;
--text-light: #ababab;
--accent: #ffb300;
--accent-text: var(--bg);
--code: #f06292;
--preformatted: #ccc;
--disabled: #111;
}
}</code></pre>
</details>
<?php endif; ?>
</main>
</body>
</html>

View File

@ -11,6 +11,9 @@
<title><?php echo SITE_NAME; ?></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php if ( SIMPLE_CSS ): ?>
<link rel="stylesheet" href="/css/simple.css">
<?php endif; ?>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/admin-bar.css">
</head>

View File

@ -20,10 +20,13 @@
<html lang="<?php echo SITE_LANG; ?>">
<head>
<title><?php echo $parts["title"]; ?></title>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/admin-bar.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php if ( SIMPLE_CSS ): ?>
<link rel="stylesheet" href="/css/simple.css">
<?php endif; ?>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/admin-bar.css">
</head>
<body class="post">
<?php include_once "admin-bar-partial.php"; ?>

30
site_actions.php Normal file
View File

@ -0,0 +1,30 @@
<?php
include_once "logcheck.php";
function simple_css_update( $v ) {
$file_data = file_get_contents( "config.php" );
if ( !$file_data ) {
header("Location: /admin.php?success=0");
die();
}
$re = '/(const\s+SIMPLE_CSS\s+==\s+)(true|false)(\s*;)/m';
$subst = $v == "1" ? "$1true$3" : "$1false$3";
$result = preg_replace($re, $subst, $file_data);
$success = file_put_contents( "config.php", $file_data );
if ( $success ) {
header("Location: /admin.php?success=2");
die();
} else {
header("Location: /admin.php?success=0");
die();
}
}
$simplecss = $_POST["simplecss"] ?? null;
if ( !is_null( $simplecss ) ) {
}
header("Location: /admin.php");
die();