Add version to page header

This commit is contained in:
Daniel J. Summers 2024-04-27 14:11:31 -04:00
parent bf6b2a0ffa
commit 0df40f3cfd
3 changed files with 37 additions and 23 deletions

View File

@ -30,6 +30,12 @@ header {
font-size: 1.5rem;
}
.version {
font-size: .85rem;
padding-left: .5rem;
color: rgba(255, 255, 255, .75);
}
a:link, a:visited {
color: white;
}

View File

@ -43,7 +43,14 @@ function add_info(string $message): void {
* @param string $title The title of the page being displayed
*/
function page_head(string $title): void {
?><!DOCTYPE html>
if (str_ends_with(FRC_VERSION, '.0.0')) {
$version = substr(FRC_VERSION, 0, strlen(FRC_VERSION) - 4);
} elseif (str_ends_with(FRC_VERSION, '.0')) {
$version = substr(FRC_VERSION, 0, strlen(FRC_VERSION) - 2);
} else {
$version = FRC_VERSION;
} ?>
<!DOCTYPE html>
<html lang=en>
<head>
<meta name=viewport content="width=device-width, initial-scale=1">
@ -52,7 +59,7 @@ function page_head(string $title): void {
</head>
<body>
<header>
<a class=title href="/">Feed Reader Central</a>
<div><a class=title href="/">Feed Reader Central</a><span class=version>v<?=$version?></span></div>
<div><?php
if (array_key_exists(Key::USER_ID, $_SESSION)) {
echo '<a href=/feed?id=new>Add Feed</a> | <a href=/user/log-off>Log Off</a>';
@ -75,7 +82,7 @@ function page_head(string $title): void {
* Render the end of the page
*/
function page_foot(): void {
?></main></body></html><?php
echo '</main></body></html>';
session_commit();
}

View File

@ -5,26 +5,6 @@ require __DIR__ . '/../cli-start.php';
cli_title('USER MAINTENANCE');
/**
* Display the options for this utility and exit
*/
#[NoReturn]
function display_help(): void {
printfn('Options:');
printfn(' - add-user [e-mail] [password]');
printfn(' Adds a new user to this instance');
printfn(' - set-password [e-mail] [password]');
printfn(' Sets the password for the given user');
printfn(' - delete-user [e-mail]');
printfn(' Deletes a user and all their data' . PHP_EOL);
printfn('To assist with migrating from single-user to multi-user mode:');
printfn(' - migrate-single-user [e-mail] [password]');
printfn(' Changes the e-mail address and password for the single-user mode user');
printfn(' - remove-single-user');
printfn(' Removes the single-user mode user and its data');
exit(0);
}
if ($argc < 2) display_help();
switch ($argv[1]) {
@ -65,11 +45,32 @@ switch ($argv[1]) {
}
/**
* Display the options for this utility and exit
*/
#[NoReturn]
function display_help(): void {
printfn('Options:');
printfn(' - add-user [e-mail] [password]');
printfn(' Adds a new user to this instance');
printfn(' - set-password [e-mail] [password]');
printfn(' Sets the password for the given user');
printfn(' - delete-user [e-mail]');
printfn(' Deletes a user and all their data' . PHP_EOL);
printfn('To assist with migrating from single-user to multi-user mode:');
printfn(' - migrate-single-user [e-mail] [password]');
printfn(' Changes the e-mail address and password for the single-user mode user');
printfn(' - remove-single-user');
printfn(' Removes the single-user mode user and its data');
exit(0);
}
/**
* Add a new user
*/
function add_user(): void {
global $argv;
$db = Data::getConnection();
try {