diff options
Diffstat (limited to 'src/web/_controller/_meta.php')
-rw-r--r-- | src/web/_controller/_meta.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/web/_controller/_meta.php b/src/web/_controller/_meta.php new file mode 100644 index 0000000..801d254 --- /dev/null +++ b/src/web/_controller/_meta.php @@ -0,0 +1,76 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ +class _meta_controller extends Controller { + + function __construct($load) { + parent::__construct($load); + } + + public function robots() { + header("Content-Type: text/plain"); + $sitemap = $this->main->get_url_full('sitemap.xml'); + + echo "User-agent: *\n"; + echo "Disallow:\n"; + echo "Crawl-delay: 5\n"; + echo "Disallow: /_comments/\n"; + echo "Disallow: /pacbattle/\n"; + echo "Disallow: /bucket/\n"; + echo "Sitemap: {$sitemap}\n"; + } + + private function sitemap_page($url, $priority) { + echo "<url>\n"; + echo "<loc>{$this->main->get_url_full($url)}</loc>\n"; + echo "<priority>{$priority}</priority>\n"; + echo "</url>"; + } + + public function sitemap() { + header("Content-Type: application/xml"); + + echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; + + $this->sitemap_page('home', 1); + $this->sitemap_page('projects', 0.8); + $this->sitemap_page('blog', 0.8); + + $this->load->app_lang('blog'); + $blog_modal = $this->load->model('blog'); + $blog = $blog_modal->get_data()['blog']; + + foreach ($blog as $name => $_) { + $this->sitemap_page("blog/post?name={$name}", 0.5); + } + + echo "</urlset>\n"; + } + + public function manifest() { + $json = array( + 'short_name' => lang('domain'), + 'name' => lang('domain'), + 'icons' => [ + array( + 'src' => $this->main->get_url('public/icons/logo512.png'), + 'type' => 'image/png', + 'sizes' => '512x512', + 'purpose' => 'any maskable' + ) + ], + 'id' => $this->main->get_url('home'), + 'start_url' => $this->main->get_url('home'), + 'background_color' => lang('theme_color'), + 'display' => 'standalone', + 'scope' => lang('base_path'), + 'theme_color' => lang('theme_color'), + 'shortcuts' => [], + 'description' => lang('default_short_desc'), + 'screenshots' => [] + ); + + header('Content-type: application/json'); + echo json_encode($json); + } + +} |