aboutsummaryrefslogtreecommitdiff
path: root/_site/includes/dom
diff options
context:
space:
mode:
Diffstat (limited to '_site/includes/dom')
-rw-r--r--_site/includes/dom/footer.php3
-rw-r--r--_site/includes/dom/header.php84
2 files changed, 82 insertions, 5 deletions
diff --git a/_site/includes/dom/footer.php b/_site/includes/dom/footer.php
index 1d0fb97..2b0a1f2 100644
--- a/_site/includes/dom/footer.php
+++ b/_site/includes/dom/footer.php
@@ -1,4 +1,5 @@
-<p style="margin-top:20px;text-align:center;"><a href="/feed.xml" style="text-decoration: underline;">View RSS feed</a></p>
+
+<p style="margin-top:20px;text-align:center;"><a href="/feed.xml" style="text-decoration: underline;">View RSS feed</a><?= $admin ? "<span class='admin-text'> (doesn't include unreleased articles)</span>" : "" ?></p>
<hr>
diff --git a/_site/includes/dom/header.php b/_site/includes/dom/header.php
index db37bab..7f4bcf5 100644
--- a/_site/includes/dom/header.php
+++ b/_site/includes/dom/header.php
@@ -3,9 +3,44 @@
$listGetTimeout = 0;
ob_start();
+$admin = true;
+if (!isset($_COOKIE["ADMIN_TOKEN"])) {
+ $admin = false;
+ if (isset($__ADMIN)) header("Location: /admin/offline") and die();
+} else {
+ if (!(strpos("/", $_COOKIE['ADMIN_TOKEN']) === false && strpos(".", $_COOKIE['ADMIN_TOKEN']) === false && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $_COOKIE['ADMIN_TOKEN']))) {
+ $admin = false;
+ if (isset($__ADMIN)) header("Location: /admin/offline") and die();
+ } else {
+ $_USER = trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/tokens/" . $_COOKIE['ADMIN_TOKEN']));
+ }
+}
+
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/markdown.php";
$Parsedown = new Parsedown();
+function gh_api($api) {
+ $crl = curl_init("https://api.github.com/" . $api);
+ curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+ curl_setopt($crl, CURLOPT_POST, false);
+
+ curl_setopt($crl, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: application/json',
+ "Accept: application/json",
+ "Authorization: token " . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["token"],
+ "User-Agent: Blogchain-Admin/0.0.0 (nekostarfan@gmail.com)"
+ ));
+
+ $result = curl_exec($crl);
+
+ if ($result === false) {
+ throw new ErrorException("GitHub API unexpectedly interrupted", 214, E_ERROR);
+ }
+
+ return $result;
+}
+
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/articles/getlist.php";
function customShutdown() {
@@ -16,7 +51,7 @@ function customShutdown() {
<!DOCTYPE html>
<html>
<head>
- <title>Something went wrong - Blogchain</title>
+ <title>Something went wrong on Blogchain 🌙</title>
<style>
@font-face {
@@ -117,7 +152,7 @@ function customError($errno, $errstr, $errfile = "&lt;unknown file&gt;", $errlin
<!DOCTYPE html>
<html>
<head>
- <title>Something went wrong - Blogchain</title>
+ <title>Something went wrong on Blogchain 🌙</title>
<style>
@font-face {
@@ -187,12 +222,15 @@ set_error_handler("customError", E_ALL);
register_shutdown_function("customShutdown");
?>
+
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
- <title><?= isset($_TITLE) ? $_TITLE . " - Blogchain" : "Blogchain" ?></title>
+ <meta name="description" content="<?= $_DESCRIPTION ?? "A page from Blogchain, a blog made by technology enthusiasts that talks about all sorts of stuff." ?>">
+ <title><?= isset($_TITLE) ? $_TITLE . " on Blogchain 🌙" : "Blogchain" ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="icon" href="/logo.svg">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<style>
@@ -299,11 +337,44 @@ register_shutdown_function("customShutdown");
background-position: center;
}
+ .badge-secondary {
+ background: black;
+ border: 1px solid #ffff00;
+ color: #ffff00 !important;
+ font-weight: normal;
+ }
+
+ .nav-admin {
+ color: #ffff00 !important;
+ outline-color: #ffff00 !important;
+ }
+
+ a.list-group-item.list-group-item-action.list-group-item-admin {
+ border-color: #ffff00;
+ color: #ffff00 !important;
+ }
+
+ a.list-group-item.list-group-item-action.list-group-item-admin:hover {
+ background-color: #ffff00 !important;
+ }
+
+ .card-admin {
+ filter: hue-rotate(-45deg);
+ }
+
+ .admin-text {
+ color: #ffff00 !important;
+ }
+
+ .list-admin-warning, .list-admin-warning * {
+ color: #ff0000 !important;
+ }
+
</style>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
- <a class="navbar-brand" href="/"># blogchain_</a>
+ <a class="navbar-brand" href="/"><img id="siteicon" src="/logo-alt.svg" width="32px"> <span style="vertical-align: middle;"># blogchain_ <?= $admin ? '<span class="badge badge-secondary">admin</span>' : '' ?></span></a>
<ul class="navbar-nav">
<li class="nav-item">
@@ -315,6 +386,11 @@ register_shutdown_function("customShutdown");
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
+ <?php if ($admin): ?>
+ <li class="nav-item">
+ <a class="nav-link nav-admin" href="/admin">Administration</a>
+ </li>
+ <?php endif; ?>
</ul>
</nav> \ No newline at end of file