The SRA Website https://socialistra.org
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.

70 lines
2.3 KiB

9 months ago
9 months ago
8 months ago
8 months ago
9 months ago
8 months ago
9 months ago
  1. <?php
  2. // Copyright (C) 2021 Socialist Rifle Association
  3. //
  4. // This file is part of SRA Website.
  5. //
  6. // website is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // website is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with website. If not, see <http://www.gnu.org/licenses/>.
  18. ?>
  19. <?php
  20. $file = $_GET['id'];
  21. if (file_exists("./stories/$file/meta.json")) {
  22. $data = json_decode(file_get_contents("./stories/$file/meta.json"), true);
  23. }
  24. else {
  25. header("Location: https://socialistra.org");
  26. }
  27. ?>
  28. <!DOCTYPE html>
  29. <html lang="en">
  30. <head>
  31. <title>Socialist Rifle Association</title>
  32. <?php include("../res/php/headtags.php") ?>
  33. </head>
  34. <body>
  35. <?php
  36. include("../res/php/top.php");
  37. date_default_timezone_set('America/New_York');
  38. ?>
  39. <div id="article-title"><?php echo $data['title'];?></div>
  40. <p class="article-subtitle"><?php echo $data['subtitle'];?></p>
  41. <div id="author">
  42. <div id="author-info">
  43. <span style="display: inline-block;">by <b><?php echo $data['author'];?></b></span>&nbsp;|
  44. <span style="display: inline-block;color:#909090;"><?php echo $data["date"] ?></span>
  45. </div>
  46. </div>
  47. <hr>
  48. <div id="article-content">
  49. <?php
  50. require "../vendor/autoload.php";
  51. require "../res/php/markdownpage.php";
  52. $md = file_get_contents("./stories/$file/content.md");
  53. $Parsedown = new Parsedown();
  54. $html = $Parsedown -> text($md);
  55. $htmlWithID = auto_id_headings($html);
  56. $replacements = preg_replace_callback('/< *img src="(.+)" alt=".*" *\/>/', function ($matches) use ($file, $htmlWithID) {
  57. $match = $matches[1];
  58. global $htmlWithID;
  59. $htmlWithID = str_replace($match, "https://srastatic.nyc3.cdn.digitaloceanspaces.com/web/img/news/$file/$match", $htmlWithID);
  60. }, $htmlWithID);
  61. echo($htmlWithID);
  62. ?>
  63. </div>
  64. <hr>
  65. <?php include("../res/php/bottom.php") ?>
  66. </body>
  67. </html>