-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.template.php
More file actions
31 lines (30 loc) · 1.3 KB
/
Copy pathindex.template.php
File metadata and controls
31 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<html>
<?php include "../../../../parsedown/Parsedown.php";
//check if `?post` is set, display that post
//if not build a list of `?post` links
if ( isset($_GET["post"]) ) { //`post` should be as generated by an archive listing
$post_fname = $_GET["post"] . ".md"; //turn it into a filename
$post_contents = file_get_contents( $post_fname );
$Parsedown = new Parsedown();
$page_content = $Parsedown->text($post_contents);
} else {
$page_content = "<ol>";
foreach ( glob( "*.md" ) as $post_fname ) { //list all markdown files
$post_nicename = substr( $post_fname, 3, -3 ); //strip to title
$post_nicename = str_replace( "_", "-", str_replace( "-", " ", $post_nicename ) ); //and clean it back up
$page_content .= "<li><a href='?post=" . substr( $post_fname, 0, -3 ) . "'>"; //strip the extension for a pretty link
$page_content .= $post_nicename;
$page_content .= "</a></li>";
}
$page_content .= "</ol>";
}
?>
<head>
<link href="../../../../blog.css" rel="stylesheet"/>
</head>
<body>
<?php
include "../../../../navbar.php";
echo $page_content; ?>
</body>
</html>