You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
4.8 KiB
165 lines
4.8 KiB
<?php |
|
if(array_key_exists('p', $_GET)) { |
|
if(!is_numeric($_GET['p'])) { |
|
header('Location: .'); |
|
die(); |
|
} |
|
$page = $_GET['p']; |
|
} |
|
?> |
|
<!DOCTYPE html> |
|
<html lang="en-GB"> |
|
<head> |
|
<?php |
|
/* index all entries. obviously, this will all explode if i put an |
|
* unexpected file in the directory. next up: figuring out how to |
|
* database, ah s'poose */ |
|
$entries = array_map('basename', array_filter(glob('html/*')) ); |
|
|
|
if(isset($page) && array_key_exists($page, $entries) ) { |
|
/* try to display a specific entry */ |
|
preg_match("/-.*$/", $entries[$page], $matches); |
|
$title=$matches[0]; |
|
$title=substr($title, 1); |
|
preg_match("/^.*-/", $entries[$page], $matches); |
|
$timestamp=$matches[0]; |
|
$timestamp=substr($timestamp, 0, -1); |
|
|
|
echo '<title>'. $title . ' - blog - 哀憐の実験</title>'; |
|
echo '<meta property="og:type" content="article" />'; |
|
echo '<meta property="article:published_time" content="' . str_replace('.', '-', $timestamp) . '" />'; |
|
echo '<meta property="og:url" content="https://airen-no-jikken.icu/blog/?p=' . $page . '" />'; |
|
} else { |
|
echo '<title>blog - 哀憐の実験</title>'; |
|
echo '<meta property="og:type" content="website">'; |
|
echo '<meta property="og:url" content="https://airen-no-jikken.icu/blog/"' . ' />'; |
|
} |
|
?> |
|
|
|
<meta name="description" content="katherine's internet presence - blog"> |
|
<meta name="keywords" content="katherine,ageha,shmibs,blog"> |
|
|
|
<meta property="og:title" content="blog - 隠語 spoken here" /> |
|
<meta property="og:description" content="katherine's internet presence - blog" /> |
|
|
|
<link rel="alternate" type="application/rss+xml" title="katherine's blog" href="https://airen-no-jikken.icu/blog/feed/" /> |
|
|
|
<?php |
|
include $_SERVER['DOCUMENT_ROOT']."/meta.php" |
|
?> |
|
</head> |
|
|
|
<body> |
|
<div id="bg-cover"></div> |
|
|
|
<header> |
|
<nav id="header-links"> |
|
<span id="header-lhs"> |
|
<a id="lhs-main" href="/">隠語 Spoken Here</a> |
|
<a id="lhs-mobile" href="/">about</a> |
|
</span> |
|
<span id="header-rhs"> |
|
<a href="/art/">art</a> |
|
<a href="/projects/">projects</a> |
|
<a class="header-sel" href="/blog/">blog</a> |
|
</span> |
|
</nav> |
|
</header> |
|
|
|
<main class="appear"> |
|
<section> |
|
<?php |
|
if(isset($page) && array_key_exists($page, $entries) ) { |
|
echo '<h2>' . $title . '</h2>'; |
|
|
|
echo '<div id="blog-body">'; |
|
|
|
echo '<h3>' . $timestamp . '</h3>'; |
|
|
|
/* read the entry into a variable */ |
|
$blogbody = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/blog/html/" . $entries[$page]); |
|
|
|
/* display the entry */ |
|
echo $blogbody; |
|
|
|
echo '</div>'; |
|
echo '<footer>'; |
|
echo '<div class="links" id="blog-nav">'; |
|
|
|
/* first */ |
|
if($page != key(array_slice($entries, 0, 1, TRUE)) ) { |
|
echo '<a id="first" href='; |
|
echo '"?p=' . key(array_slice($entries, 0, 1, TRUE)); |
|
echo '"><<</a>'; |
|
} else { |
|
echo '<span id="first"><<</span>'; |
|
} |
|
|
|
/* prev */ |
|
if( array_key_exists($page, $entries) and array_key_exists($page - 1, $entries) ) { |
|
echo '<a rel="prev" id="prev" href='; |
|
echo '"?p=' . ($page - 1) . '">'; |
|
echo '<</a>'; |
|
} else { |
|
echo '<span id="prev"><</span>'; |
|
} |
|
|
|
/* index */ |
|
if( array_key_exists($page, $entries) ) { |
|
echo '<a id="index" href=".">'; |
|
echo 'index'; |
|
echo '</a>'; |
|
} else { |
|
echo '<span id="index">index</span>'; |
|
} |
|
|
|
/* next */ |
|
if( array_key_exists($page, $entries) and array_key_exists($page + 1, $entries) ) { |
|
echo '<a rel="next" id="next" href='; |
|
echo '"?p=' . ($page + 1) . '">'; |
|
echo '></a>'; |
|
} else { |
|
echo '<span id="next">></span>'; |
|
} |
|
|
|
/* last */ |
|
if($page != key(array_slice($entries, -1, 1, TRUE)) ) { |
|
echo '<a id="last" href='; |
|
echo '"?p=' . key(array_slice($entries, -1, 1, TRUE)); |
|
echo '">>></a>'; |
|
} else { |
|
echo '<span id="last">>></span>'; |
|
} |
|
|
|
echo '</div>'; |
|
echo '</footer>'; |
|
} else { |
|
/* display the index */ |
|
echo '<h2>Blog!</h2>'; |
|
echo '<p>紀行無常: computer notes, music, book reviews, and blatherings</p>'; |
|
echo '<p class="links"><a href="https://airen-no-jikken.icu/blog/feed/">rss feed</a></p>'; |
|
echo '</section>'; |
|
echo '<section>'; |
|
echo '<h2 class="centre">Blog index</h2>'; |
|
echo '<div id="blog-body">'; |
|
foreach(array_reverse($entries, true) as $key => $value) { |
|
preg_match("/-.*$/", $value, $matches); |
|
$title=$matches[0]; |
|
$title=substr($title, 1); |
|
preg_match("/^.*-/", $value, $matches); |
|
$timestamp=$matches[0]; |
|
$timestamp=substr($timestamp, 0, -1); |
|
$content = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/blog/html/$value"); |
|
preg_match("/^([^\n]{30,80}[\s]|.*[\n])/", preg_replace('(<[^>]*>)', '', $content), $matches); |
|
$description = substr($matches[0], 0, -1); |
|
echo '<h3>' . $timestamp . ' - <a href="?p=' . $key . '">' . $title . '</a></h3>'; |
|
echo '<p>' . $description . ' <a href="?p=' . $key . '">...</a><p>'; |
|
} |
|
echo '</div>'; |
|
} |
|
?> |
|
|
|
</section> |
|
</main> |
|
</body> |
|
</html>
|
|
|