a poorly-written personal website
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.
 
 
 

204 lines
5.8 KiB

<?php
if (array_key_exists('l', $_GET) && $_GET['l'] == 'jp') {
$lang = 'jp';
} else {
$lang = 'en';
}
if(array_key_exists('p', $_GET)) {
if(!is_numeric($_GET['p'])) {
header('Location: .');
die();
}
$page = $_GET['p'];
}
?>
<!DOCTYPE html>
<html lang=<?php echo ($lang == 'jp' ? "\"ja-JP\"" : "\"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=<?php echo ($lang == 'jp' ? '"/?l=jp"' : '"/"'); ?>>隠語 Spoken Here</a>
<a id="lhs-mobile" href=<?php echo ($lang == 'jp' ? '"/?l=jp" class="jp-small">ホーム</a' : '"/">about</a'); ?>>
</span>
<span id="header-rhs"<?php if ($lang == 'jp') echo ' class="jp-small"'; ?>>
<a href=<?php echo ($lang == 'jp' ? '"/art/?l=jp">画廊' : '"/art/">art'); ?></a>
<a href=<?php echo ($lang == 'jp' ? '"/projects/?l=jp">作品' : '"/projects/">projects'); ?></a>
<a class="header-sel" href=<?php echo ($lang == 'jp' ? '"/blog/?l=jp">ブログ' : '"/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='
. '"?p='
. key(array_slice($entries, 0, 1, TRUE))
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">&lt;&lt;</a>';
} else {
echo '<span id="first">&lt;&lt;</span>';
}
/* prev */
if( array_key_exists($page, $entries) and array_key_exists($page - 1, $entries) ) {
echo '<a rel="prev" id="prev" href='
. '"?p='
. ($page - 1)
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">&lt;</a>';
} else {
echo '<span id="prev">&lt;</span>';
}
/* index */
echo '<a id="index" href=".'
. ($lang == 'jp' ? '?l=jp' : '')
. '">'
. ($lang == 'jp' ? 'アーカイブ' : 'index')
. '</a>';
/* next */
if( array_key_exists($page, $entries) and array_key_exists($page + 1, $entries) ) {
echo '<a rel="next" id="next" href='
. '"?p='
. ($page + 1)
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">'
. '&gt;</a>';
} else {
echo '<span id="next">&gt;</span>';
}
/* last */
if($page != key(array_slice($entries, -1, 1, TRUE)) ) {
echo '<a id="last" href='
. '"?p='
. key(array_slice($entries, -1, 1, TRUE))
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">&gt;&gt;</a>';
} else {
echo '<span id="last">&gt;&gt;</span>';
}
echo '</div>';
echo '</footer>';
} else {
/* display the index */
echo '<h2>' . ($lang == 'jp' ? 'ブログ!' : 'Blog!') . '</h2>';
echo ($lang == 'jp'
? '<p>紀行無常(全て英語だけではごめんね…)</p>'
: '<p>紀行無常: computer notes, music, book reviews, and blatherings</p>'
);
echo '<p class="links"><a href="https://airen-no-jikken.icu/blog/feed/">';
echo ($lang == 'jp'
? 'RSSフィード'
: 'rss feed'
);
echo '</a></p>';
echo '</section>';
echo '<section>';
echo ($lang == 'jp'
? '<h2 class="centre">ブログアーカイブ</h2>'
: '<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
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">'
. $title
. '</a></h3>';
echo '<p>'
. $description
. ' <a href="?p='
. $key
. ($lang == 'jp' ? '&amp;l=jp' : '')
. '">...</a></p>';
}
echo '</div>';
}
?>
</section>
<?php include $_SERVER['DOCUMENT_ROOT']."/lang-switch.php" ?>
</main>
</body>
</html>