소스 검색

robots.txt

George S. Baugh 5 년 전
부모
커밋
3b705df058
2개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      lib/Trog/Routes/HTML.pm
  2. 11 0
      www/templates/robots.tx

+ 11 - 2
lib/Trog/Routes/HTML.pm

@@ -123,12 +123,15 @@ our %routes = (
         captures => ['map'],
     },
     '/sitemap/(.*).xml.gz' => {
-        method => 'GET',
+        method   => 'GET',
         callback => \&Trog::Routes::HTML::sitemap,
         data     => { xml => 1, compressed => 1},
         captures => ['map'],
     },
-
+    '/robots.txt' => {
+        method   => 'GET',
+        callback => \&Trog::Routes::HTML::robots,
+    },
 );
 
 # Build aliases for /posts and /post with extra data
@@ -157,6 +160,12 @@ if ($theme_dir) {
     }
 }
 
+sub robots ($query, $input, $render_cb) {
+    my $processor = Text::Xslate->new(
+        path   => $template_dir,
+    );
+    return [200, ["Content-type:text/plain\n"],[$processor->render('robots.tx', { domain => $query->{domain} })]];
+}
 
 sub index ($query, $input, $render_cb, $content = '', $i_styles = []) {
     $query->{theme_dir}  = $theme_dir || '';

+ 11 - 0
www/templates/robots.tx

@@ -0,0 +1,11 @@
+User-agent: *
+Sitemap: http://<: $domain :>/sitemap_index.xml.gz
+Disallow: /config
+Disallow: /login
+Disallow: /auth
+Disallow: /json
+Disallow: /sitemap
+Disallow: /themes
+Disallow: /templates
+Disallow: /scripts
+Disallow: /styles