diff options
author | Nathan Lasseter <nathan@4574.co.uk> | 2013-04-14 14:33:40 +0100 |
---|---|---|
committer | Nathan Lasseter <nathan@4574.co.uk> | 2013-04-14 14:33:40 +0100 |
commit | 34981fa32374a97416e292f4cd385852fc5ae2f3 (patch) | |
tree | 67735106af9e5b3da3a70f39be8023989bb98f36 /widget.php | |
parent | 8229a7413975534fe9c185749facfb21fe505257 (diff) |
Added widget.php
Diffstat (limited to 'widget.php')
-rw-r--r-- | widget.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/widget.php b/widget.php new file mode 100644 index 0000000..89ec7c4 --- /dev/null +++ b/widget.php @@ -0,0 +1,48 @@ +<?php + require("settings.php"); +?> +<!DOCTYPE html> +<html> + +<head> + <title><?php echo $blogTitle; ?></title> + <link rel="stylesheet" type="text/css" href="<?php echo $blogRoot; ?>styles.css" /> +</head> + +<body> + +<?php + $file = ""; + if (!isset($_GET['post'])) { + $ls = explode("\n", `ls -1t {$blogPosts}/`); + foreach($ls as $entry) { + if (preg_match('/^\./', $entry)) continue; + if ($entry === "") continue; + $file = $entry; + break; + } + } else + $file = preg_replace('/\+/', ' ', $_GET['post']); + + echo "<div>\n"; + echo "<a class=\"title\" href=\"{$blogRoot}post/" . urlencode($file) . "\">$file <span id=\"perma\">[Permalink]</span></a> "; +?> + +<a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php echo "$blogTitle: {$file}"; ?>" data-url="http://<?php echo "{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"; ?>">[Tweet]</a> +<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> + +<?php + $stat = stat("{$blogPosts}$file"); + $date = date('d-m-Y H:i T', $stat['mtime']); + echo "<span class=\"date\">$date</span>\n"; + echo "<br><br>\n"; + + $post = file_get_contents("{$blogPosts}$file"); + $post = preg_replace('/\n/', "<br>\n", $post); + echo $post; + echo "</div>\n</a>\n\n"; +?> + +</body> + +</html> |