From d69492a2e4b8a802eb85f5653a4201537095577d Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 25 Sep 2020 15:34:50 +0200 Subject: [PATCH] Remove obsolete files --- functions.php | 235 ------------------------ index.php | 413 ------------------------------------------ scripts/minifyCSS.php | 19 -- 3 files changed, 667 deletions(-) delete mode 100644 functions.php delete mode 100644 index.php delete mode 100644 scripts/minifyCSS.php diff --git a/functions.php b/functions.php deleted file mode 100644 index b4739c1..0000000 --- a/functions.php +++ /dev/null @@ -1,235 +0,0 @@ - $entry) { - $time = strtotime($entry["created_at"]); - $data[$id]["date"] = date("Y-m-d",$time); - $data[$id]["time"] = date("H:i:s",$time); - } - - return $data; -} - -function getFOSS() { - return Yaml::parseFile('content/foss/foss.yaml'); -} - -function getVinyl() { - return Yaml::parseFile('content/music/vinyl.yaml'); -} - -function getAOTW() { - return Yaml::parseFile('content/music/aotw.yaml'); -} - -function getRSS($params) { - header("Content-Type: text/xml"); - $feed = new Feed(); - - $channel = new Channel(); - $channel - ->title($params['feed']['title']) - ->description($params['feed']['description']) - ->url($params['feed']['url']) - ->atomLinkSelf($params['feed']['linkself']) - ->appendTo($feed); - - $dates = array_column($params['posts'], 'date'); - array_multisort($dates, SORT_DESC, $params['posts']); - - foreach($params['posts'] as $post) { - $item = new Item(); - $item - ->title($post['title']) - ->creator($post['author']) - // ->content($post['content']) - ->description($post['content']) - ->url($post['url']) - ->guid($post['url'], true) - ->pubDate(strtotime($post['date'])) - ->appendTo($channel); - } - - echo $feed; -} - -function scandirRec($path, $category, $params) { - $Parsedown = new Parsedown(); - $mp = new MetaParsedown(); - $items = array(); - - // If a directory - if(is_dir($path)) { - $files = glob($path . '*', GLOB_MARK); - foreach($files as $file) { - if(is_dir($file)) { - $items = array_merge($items, scandirRec($file, $category, $params)); - } else { - $return = scandirRec($file, $category, $params); - if (!empty($return)) { - $items[] = $return; - } - } - } - return $items; - } - - // If a file - if (($path == '.') || ($path == '..')) { - return; - } - - $content = file_get_contents($path); - $meta = $mp->meta($content); - - switch ($category) { - case 'blog': - $item = array( - "type" => "blog", - "title" => $meta["title"], - "author" => $meta["author"], - "urlrel" => "/post/".$meta["slug"], - "url" => "https://yarmo.eu/post/".$meta["slug"], - "slug" => $meta["slug"], - "date" => $meta["date"], - "published" => $meta["published"], - "discussion" => $meta["discussion"], - "content" => $mp->text($content)); - - $date = new DateTime($item['date']); - $item['date_formatted'] = $date->format('Y-m-d'); - $item['date_rss'] = $date->format('Y-m-d'); - - if (!$item['published'] && !(isset($params['slug']) && $item['slug'] == $params['slug'])) { - return; - } - break; - - case 'notes': - $item = array( - "type" => "note", - "title" => $meta["title"], - "author" => $meta["author"], - "urlrel" => "/post/".$meta["slug"], - "url" => "https://yarmo.eu/post/".$meta["slug"], - "slug" => $meta["slug"], - "date" => $meta["date"], - "published" => $meta["published"], - "discussion" => $meta["discussion"], - "content" => $mp->text($content)); - - $date = new DateTime($item['date']); - $item['date_formatted'] = $date->format('Y-m-d'); - $item['date_rss'] = $date->format('Y-m-d'); - - if (!$item['published'] && !(isset($params['slug']) && $item['slug'] == $params['slug'])) { - return; - } - break; - - case 'projects': - $item = array( - "title" => $meta["title"], - "status" => $meta["status"], - "urlrel" => "/projects/".$meta["slug"], - "url" => "https://yarmo.eu/projects/".$meta["slug"], - "slug" => $meta["slug"], - "date" => $meta["date"], - "listed" => $meta["listed"], - "content" => $mp->text($content)); - - $date = new DateTime($item['date']); - $item['date_formatted'] = $date->format('Y-m-d'); - $item['date_rss'] = $date->format('Y-m-d'); - - if (!$item['listed'] && !(isset($params['slug']) && $item['slug'] == $params['slug'])) { - return; - } - break; - - case 'replies': - $item = array( - "type" => "note", - "title" => $meta["title"], - "reply-url" => $meta["reply-url"], - "reply-title" => $meta["reply-title"], - "author" => $meta["author"], - "urlrel" => "/reply/".$meta["slug"], - "url" => "https://yarmo.eu/reply/".$meta["slug"], - "slug" => $meta["slug"], - "date" => $meta["date"], - "published" => $meta["published"], - "content" => $mp->text($content)); - - $date = new DateTime($item['date']); - $item['date_formatted'] = $date->format('Y-m-d'); - $item['date_rss'] = $date->format('Y-m-d'); - - if (!$item['published'] && !(isset($params['slug']) && $item['slug'] == $params['slug'])) { - return; - } - break; - - default: - return; - break; - } - - if (isset($params['slug']) && $item['slug'] != $params['slug']) { - return; - } - if (isset($params['slug'])) { - $item["webmentions"] = array_merge( - getWebmentions($item["url"]), - getWebmentions("https://yarmo.eu/blog/".$meta["slug"]), - getWebmentions("https://yarmo.eu/notes/".$meta["slug"]) - ); - $item["hasWebmentions"] = count($item["webmentions"]) > 0; - } - - return $item; -} diff --git a/index.php b/index.php deleted file mode 100644 index b882d1e..0000000 --- a/index.php +++ /dev/null @@ -1,413 +0,0 @@ -map('GET', '/', function() {}, 'home'); -$router->map('GET', '/rss', function() {}, 'rss'); -$router->map('GET', '/rss.xml', function() {}, 'rss-xml'); -$router->map('GET', '/rss/all', function() {}, 'rss-all'); -$router->map('GET', '/rss/blog', function() {}, 'rss-blog'); -$router->map('GET', '/rss/notes', function() {}, 'rss-notes'); -$router->map('GET', '/about', function() {}, 'about'); -$router->map('GET', '/feeds', function() {}, 'feeds'); -$router->map('GET', '/uses', function() {}, 'uses'); -$router->map('GET', '/now', function() {}, 'now'); -$router->map('GET', '/blogroll', function() {}, 'blogroll'); -$router->map('GET', '/blog', function() {}, 'blog'); -$router->map('GET', '/blog/[*:slug]', function() {}, 'blog_post'); -$router->map('GET', '/notes', function() {}, 'notes'); -$router->map('GET', '/notes/[*:slug]', function() {}, 'notes_post'); -$router->map('GET', '/post/[*:slug]', function() {}, 'post'); -$router->map('GET', '/reply/[*:slug]', function() {}, 'reply'); -$router->map('GET', '/projects', function() {}, 'projects'); -$router->map('GET', '/projects/[*:slug]', function() {}, 'projects_details'); -$router->map('GET', '/foss', function() {}, 'foss'); -$router->map('GET', '/music', function() {}, 'music'); -$router->map('GET', '/vinyl', function() {}, 'vinyl'); -$router->map('GET', '/aotw', function() {}, 'aotw'); -$router->map('GET', '/pgp', function() {}, 'pgp'); -$router->map('GET', '/contact', function() {}, 'contact'); - -// Router matching -$match = $router->match(); - -// Template engine settings and variables -$basetitle = 'yarmo'; -$environment = getenv('ENVIRONMENT') ?: 'production'; -$options = [ - 'paths' => [ - 'views/', - ], - 'cache_dir' => 'cache/', - 'enable_profiler' => false, - 'profiler' => [ - 'time_precision' => 3, - 'line_height' => 30, - 'display' => true, - 'log' => false, - ], -]; -$variables = [ - 'title' => $basetitle -]; - -// If we are dealing with the home page -if ($match['name'] == 'home') { - $variables['posts'] = getBlogPosts($match['params']); - $variables['title'] = 'Blog — '.$basetitle; - // $variables['icons'] = getIcons(); -} - -// If we are dealing with the about page -if ($match['name'] == 'about') { -} - -// If we are dealing with the rss feed -if ($match['name'] == 'rss' || $match['name'] == 'rss-all' || $match['name'] == 'rss-xml') { - $blogposts = getBlogPosts($match['params']); - $notes = getNotes($match['params']); - $variables['posts'] = array_merge($blogposts, $notes); - $variables['feed']['title'] = "Yarmo's blog and notes"; - $variables['feed']['description'] = "Blog and notes feed for yarmo.eu discussing homelab and selfhosted stuff"; - $variables['feed']['url'] = "https://yarmo.eu"; - $variables['feed']['linkself'] = "https://yarmo.eu/rss/all"; -} -// If we are dealing with the blog rss feed -if ($match['name'] == 'rss-blog') { - $variables['posts'] = getBlogPosts($match['params']); - $variables['feed']['title'] = "Yarmo's blog"; - $variables['feed']['description'] = "Blog feed for yarmo.eu discussing homelab and selfhosted stuff"; - $variables['feed']['url'] = "https://yarmo.eu/blog"; - $variables['feed']['linkself'] = "https://yarmo.eu/rss/blog"; -} -// If we are dealing with the notes rss feed -if ($match['name'] == 'rss-notes') { - $variables['posts'] = getNotes($match['params']); - $variables['feed']['title'] = "Yarmo's blog"; - $variables['feed']['description'] = "Notes feed for yarmo.eu discussing homelab and selfhosted stuff"; - $variables['feed']['url'] = "https://yarmo.eu/notes"; - $variables['feed']['linkself'] = "https://yarmo.eu/rss/notes"; -} - -// If we are dealing with the feeds -if ($match['name'] == 'feeds') { - $variables['title'] = 'Feeds — '.$basetitle; -} - -// If we are dealing with the uses -if ($match['name'] == 'uses') { - $variables['title'] = 'Uses — '.$basetitle; -} - -// If we are dealing with the now -if ($match['name'] == 'now') { - $variables['title'] = 'Now — '.$basetitle; -} - -// If we are dealing with the blogroll -if ($match['name'] == 'blogroll') { - $variables['title'] = 'Blogroll — '.$basetitle; -} - -// If we are dealing with the blog -if ($match['name'] == 'blog') { - $variables['posts'] = getBlogPosts($match['params']); - $variables['title'] = 'Blog — '.$basetitle; -} - -// If we are dealing with the notes -if ($match['name'] == 'notes') { - $variables['posts'] = getNotes($match['params']); - $variables['title'] = 'Notes — '.$basetitle; -} - -// If we are dealing with a post (old format) -if (($match['name'] == 'blog_post') || ($match['name'] == 'notes_post')) { - header('Location: https://yarmo.eu/post/'.$match['params']['slug']); -} - -// If we are dealing with a post -if ($match['name'] == 'post') { - $variables['post'] = getBlogPosts($match['params']); - if (count($variables['post']) == 0) { - $variables['post'] = getNotes($match['params']); - } - if (count($variables['post']) > 0) { - $variables['post'] = $variables['post'][0]; - $variables['title'] = htmlspecialchars_decode(str_replace('·','·',$variables['post']['title'])).' — '.$basetitle; - } else { - $match['name'] = '404'; - } -} - -// If we are dealing with a reply -if ($match['name'] == 'reply') { - $variables['reply'] = getReplies($match['params']); - $variables['reply'] = $variables['reply'][0]; - $variables['title'] = htmlspecialchars_decode(str_replace('·','·',$variables['reply']['title'])).' — '.$basetitle; -} - -// If we are dealing with the projects -if ($match['name'] == 'projects') { - $variables['projects'] = getProjects($match['params']); - $variables['title'] = 'Projects — '.$basetitle; -} - -// If we are dealing with a project's details -if ($match['name'] == 'projects_details') { - $variables['project'] = getProjects($match['params']); - $variables['project'] = $variables['project'][0]; - $variables['title'] = htmlspecialchars_decode(str_replace('·','·',$variables['project']['title'])).' — '.$basetitle; -} - -// If we are dealing with foss -if ($match['name'] == 'foss') { - $variables['foss'] = getFOSS(); - $variables['title'] = 'FOSS — '.$basetitle; -} - -// If we are dealing with vinyl -if ($match['name'] == 'vinyl') { - $variables['vinyl'] = getVinyl(); - $variables['albums'] = $variables['vinyl']['albums']; - $variables['title'] = 'Vinyl — '.$basetitle; -} - -// If we are dealing with Album Of The Week -if ($match['name'] == 'aotw') { - $variables['albums'] = getAOTW(); - $variables['title'] = 'Album Of The Week — '.$basetitle; -} - -// If we are dealing with the pgp page -if ($match['name'] == 'pgp') { - $variables['title'] = 'PGP — '.$basetitle; -} - -// If we are dealing with the contact page -if ($match['name'] == 'contact') { - $variables['title'] = 'Contact me — '.$basetitle; -} - -// Add Phug dyninclude -Phug::addKeyword('dyninclude', function ($args) { - return array( - 'beginPhp' => 'echo file_get_contents(' . $args . ');', - ); -}); - -// PRODUCTION -// Render the appropriate route -if ($environment === 'production') { - if(is_array($match) && is_callable($match['target'])) { - switch ($match['name']) { - case 'home': - // Phug optimizer - \Phug\Optimizer::call('displayFile', ['index', $variables], $options); - // Phug::displayFile('index', $variables, $options); - break; - - case 'about': - // Phug optimizer - \Phug\Optimizer::call('displayFile', ['about', $variables], $options); - // Phug::displayFile('index', $variables, $options); - break; - - case 'rss': - case 'rss-xml': - case 'rss-all': - case 'rss-blog': - case 'rss-notes': - getRSS($variables); - break; - - case 'feeds': - \Phug\Optimizer::call('displayFile', ['feeds', $variables], $options); - break; - - case 'uses': - \Phug\Optimizer::call('displayFile', ['uses', $variables], $options); - break; - - case 'now': - \Phug\Optimizer::call('displayFile', ['now', $variables], $options); - break; - - case 'blogroll': - \Phug\Optimizer::call('displayFile', ['blogroll', $variables], $options); - break; - - case 'blog': - \Phug\Optimizer::call('displayFile', ['blog', $variables], $options); - break; - - case 'blog_post': - \Phug\Optimizer::call('displayFile', ['blog_post', $variables], $options); - break; - - case 'notes': - \Phug\Optimizer::call('displayFile', ['notes', $variables], $options); - break; - - case 'notes_post': - \Phug\Optimizer::call('displayFile', ['notes_post', $variables], $options); - break; - - case 'post': - \Phug\Optimizer::call('displayFile', ['post', $variables], $options); - break; - - case 'reply': - \Phug\Optimizer::call('displayFile', ['reply', $variables], $options); - break; - - case 'projects': - \Phug\Optimizer::call('displayFile', ['projects', $variables], $options); - break; - - case 'projects_details': - \Phug\Optimizer::call('displayFile', ['projects_details', $variables], $options); - break; - - case 'foss': - \Phug\Optimizer::call('displayFile', ['foss', $variables], $options); - break; - - case 'music': - \Phug\Optimizer::call('displayFile', ['music', $variables], $options); - break; - - case 'vinyl': - \Phug\Optimizer::call('displayFile', ['vinyl', $variables], $options); - break; - - case 'aotw': - \Phug\Optimizer::call('displayFile', ['aotw', $variables], $options); - break; - - case 'contact': - \Phug\Optimizer::call('displayFile', ['contact', $variables], $options); - break; - - case 'pgp': - \Phug\Optimizer::call('displayFile', ['pgp', $variables], $options); - break; - - default: - \Phug\Optimizer::call('displayFile', ['404', $variables], $options); - break; - } - } else { - // No route was matched - \Phug\Optimizer::call('displayFile', ['404', $variables], $options); - } - - exit; -} - -# DEVELOPMENT -// Render the appropriate route -if(is_array($match) && is_callable($match['target'])) { - switch ($match['name']) { - case 'home': - Phug::displayFile('index', $variables, $options); - break; - - case 'about': - Phug::displayFile('about', $variables, $options); - break; - - case 'rss': - case 'rss-xml': - case 'rss-all': - case 'rss-blog': - case 'rss-notes': - getRSS($variables); - break; - - case 'feeds': - Phug::displayFile('feeds', $variables, $options); - break; - - case 'uses': - Phug::displayFile('uses', $variables, $options); - break; - - case 'now': - Phug::displayFile('now', $variables, $options); - break; - - case 'blogroll': - Phug::displayFile('blogroll', $variables, $options); - break; - - case 'blog': - Phug::displayFile('blog', $variables, $options); - break; - - case 'blog_post': - Phug::displayFile('blog_post', $variables, $options); - break; - - case 'notes': - Phug::displayFile('notes', $variables, $options); - break; - - case 'notes_post': - Phug::displayFile('notes_post', $variables, $options); - break; - - case 'post': - Phug::displayFile('post', $variables, $options); - break; - - case 'reply': - Phug::displayFile('reply', $variables, $options); - break; - - case 'projects': - Phug::displayFile('projects', $variables, $options); - break; - - case 'projects_details': - Phug::displayFile('projects_details', $variables, $options); - break; - - case 'foss': - Phug::displayFile('foss', $variables, $options); - break; - - case 'music': - Phug::displayFile('music', $variables, $options); - break; - - case 'vinyl': - Phug::displayFile('vinyl', $variables, $options); - break; - - case 'aotw': - Phug::displayFile('aotw', $variables, $options); - break; - - case 'contact': - Phug::displayFile('contact', $variables, $options); - break; - - case 'pgp': - Phug::displayFile('pgp', $variables, $options); - break; - - default: - Phug::displayFile('404', $variables, $options); - break; - } -} else { - // No route was matched - Phug::displayFile('404', $variables, $options); -} diff --git a/scripts/minifyCSS.php b/scripts/minifyCSS.php deleted file mode 100644 index a8754b7..0000000 --- a/scripts/minifyCSS.php +++ /dev/null @@ -1,19 +0,0 @@ -removeImportantComments(); -$compressor->setLineBreakPosition(1000); - -$input_css = file_get_contents('./static/style.css'); -$output_css = $compressor->run($input_css); -file_put_contents('./static/style.css', $output_css); - -$input_css = file_get_contents('./static/norm.css'); -$output_css = $compressor->run($input_css); -file_put_contents('./static/norm.css', $output_css); - -?>