Browse Source

Fix various little things encountered by reality

George S. Baugh 5 năm trước cách đây
mục cha
commit
8f04ad97a3
4 tập tin đã thay đổi với 16 bổ sung12 xóa
  1. 10 8
      lib/Trog/Routes/HTML.pm
  2. 3 1
      www/server.psgi
  3. 1 1
      www/templates/header.tx
  4. 2 2
      www/templates/notconfigured.tx

+ 10 - 8
lib/Trog/Routes/HTML.pm

@@ -15,8 +15,9 @@ use Trog::Data;
 
 my $conf = Trog::Config::get();
 my $template_dir = 'www/templates';
-my $theme_dir;
+my $theme_dir = '';
 $theme_dir = "themes/".$conf->param('general.theme') if $conf->param('general.theme') && -d "www/themes/".$conf->param('general.theme');
+my $td = $theme_dir ? "/$theme_dir" : '';
 
 use lib 'www';
 
@@ -210,7 +211,7 @@ Most subsequent functions simply pass content to this function.
 =cut
 
 sub index ($query,$render_cb, $content = '', $i_styles = []) {
-    $query->{theme_dir}  = $theme_dir || '';
+    $query->{theme_dir}  = $td;
 
     my $processor = Text::Xslate->new(
         path   => $template_dir,
@@ -240,7 +241,7 @@ sub index ($query,$render_cb, $content = '', $i_styles = []) {
         search_lang => $search_info->{lang},
         search_help => $search_info->{help},
         route       => $query->{route},
-        theme_dir   => $theme_dir,
+        theme_dir   => $td,
         content     => $content,
         title       => $query->{title} // $Theme::default_title // 'tCMS',
         htmltitle   => _pick_processor("templates/$htmltitle" ,$processor,$t_processor)->render($htmltitle,$query),
@@ -375,6 +376,7 @@ sub login ($query, $render_cb) {
         message => int( $query->{failed} ) < 1 ? "Login Successful, Redirecting..." : "Login Failed.",
         btnmsg        => $btnmsg,
         stylesheets   => _build_themed_styles('login.css'),
+        theme_dir     => $td,
     }, @headers);
 }
 
@@ -688,8 +690,8 @@ sub posts ($query, $render_cb) {
             path =>  "www/$theme_dir/templates",
         ) if $theme_dir;
 
-        $header = _pick_processor("templates/about_header.tx"  ,$processor,$t_processor)->render('about_header.tx', { theme_dir => $theme_dir } );
-        $footer = _pick_processor("templates/about_header.tx"  ,$processor,$t_processor)->render('about_footer.tx', { theme_dir => $theme_dir } );
+        $header = _pick_processor("templates/about_header.tx"  ,$processor,$t_processor)->render('about_header.tx', { theme_dir => $td } );
+        $footer = _pick_processor("templates/about_header.tx"  ,$processor,$t_processor)->render('about_footer.tx', { theme_dir => $td } );
     }
 
     my $styles = _build_themed_styles('posts.css');
@@ -870,17 +872,17 @@ sub _rss ($query,$posts) {
         pubDate        => $now,
         lastBuildDate  => $now,
     );
- 
+
     #TODO configurability
     $rss->image(
         title       => $query->{domain},
-        url         => "/$theme_dir/img/icon/favicon.ico",
+        url         => "$td/img/icon/favicon.ico",
         link        => "http://$query->{domain}",
         width       => 88,
         height      => 31,
         description => "$query->{domain} favicon",
     );
- 
+
     foreach my $post (@$posts) {
         my $url = "http://$query->{domain}/posts/$post->{id}";
         $rss->add_item(

+ 3 - 1
www/server.psgi

@@ -67,7 +67,7 @@ my $app = sub {
     my $path = $env->{PATH_INFO};
 
     # Let's open up our default route before we bother to see if users even exist
-    return $routes{default}{callback}->($query,$env->{'psgi.input'}, \&_render) unless -f "$ENV{HOME}/.tcms/setup";
+    return $routes{default}{callback}->($query,\&_render) unless -f "$ENV{HOME}/.tcms/setup";
 
     my $cookies = {};
     if ($env->{HTTP_COOKIE}) {
@@ -154,6 +154,8 @@ sub _serve ($path, $last_fetch=0) {
     my @gm = gmtime($mt);
     my $now_string = strftime( "%a, %d %b %Y %H:%M:%S GMT", @gm );
     my $code = $mt > $last_fetch ? 200 : 304;
+    #XXX something broken about the above logic
+    $code=200;
 
     push(@headers, "Last-Modified: $now_string\n");
 

+ 1 - 1
www/templates/header.tx

@@ -3,7 +3,7 @@
     <head>
         <title><: $title :></title>
         <meta charset="utf-8" />
-        <link rel="icon" type="image/vnd.microsoft.icon" href="/<: $theme_dir :>/img/icon/favicon.ico" />
+        <link rel="icon" type="image/vnd.microsoft.icon" href="<: $theme_dir :>/img/icon/favicon.ico" />
         <meta name="description" content="A Simple CMS by teodesian.net"/>
         <meta name="viewport" content="width=device-width">
         <link rel="stylesheet" type="text/css" href="/styles/structure.css" />

+ 2 - 2
www/templates/notconfigured.tx

@@ -3,7 +3,7 @@
 </nav>
 <section>
     <div id="notice">
-        <img alt="Icon indicating a missing file" src="img/mime/missing.gif" />
+        <img alt="Icon indicating a missing file" src="/img/mime/missing.gif" />
         <span>
             [INFO] This page is being displayed because the main configuration file is missing
             (or corrupted).
@@ -11,7 +11,7 @@
     </div>
     <p>
         <strong>Note:</strong> Please see the
-        <a href="https://tcms.troglodyne.net/index.php?nav=5&post=fileshare/manual/Chapter%2000-Introduction.post">
+        <a href="/manual">
             tCMS Manual
         </a>
         for full instructions on how configure tCMS.