|
<?php
|
|
// Copyright (C) 2021 Socialist Rifle Association
|
|
//
|
|
// This file is part of SRA Website.
|
|
//
|
|
// website is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// website is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with website. If not, see <http://www.gnu.org/licenses/>.
|
|
?>
|
|
<?php
|
|
$file = $_GET['id'];
|
|
if (file_exists("./stories/$file/meta.json")) {
|
|
$data = json_decode(file_get_contents("./stories/$file/meta.json"), true);
|
|
}
|
|
else {
|
|
header("Location: https://socialistra.org");
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Socialist Rifle Association</title>
|
|
<?php include("../res/php/headtags.php") ?>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
include("../res/php/top.php");
|
|
date_default_timezone_set('America/New_York');
|
|
?>
|
|
<div id="article-title"><?php echo $data['title'];?></div>
|
|
<p class="article-subtitle"><?php echo $data['subtitle'];?></p>
|
|
<div id="author">
|
|
<div id="author-info">
|
|
<span style="display: inline-block;">by <b><?php echo $data['author'];?></b></span> |
|
|
<span style="display: inline-block;color:#909090;"><?php echo $data["date"] ?></span>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div id="article-content">
|
|
<?php
|
|
require "../vendor/autoload.php";
|
|
require "../res/php/markdownpage.php";
|
|
|
|
$md = file_get_contents("./stories/$file/content.md");
|
|
$Parsedown = new Parsedown();
|
|
$html = $Parsedown -> text($md);
|
|
|
|
$htmlWithID = auto_id_headings($html);
|
|
|
|
$replacements = preg_replace_callback('/< *img src="(.+)" alt=".*" *\/>/', function ($matches) use ($file, $htmlWithID) {
|
|
$match = $matches[1];
|
|
global $htmlWithID;
|
|
$htmlWithID = str_replace($match, "https://srastatic.nyc3.cdn.digitaloceanspaces.com/web/img/news/$file/$match", $htmlWithID);
|
|
}, $htmlWithID);
|
|
|
|
echo($htmlWithID);
|
|
?>
|
|
</div>
|
|
<hr>
|
|
<?php include("../res/php/bottom.php") ?>
|
|
</body>
|
|
</html>
|