Browse Source

replace is_* template vars with 'page'

Byron Jones 6 years ago
parent
commit
65dc259ed7
4 changed files with 11 additions and 14 deletions
  1. 1 1
      lib/LogBot/Web/Search.pm
  2. 3 3
      lib/LogBot/Web/Stats.pm
  3. 2 4
      logbot-web
  4. 5 6
      web/templates/layouts/logbot.html.ep

+ 1 - 1
lib/LogBot/Web/Search.pm

@@ -54,7 +54,7 @@ sub render {
     }
 
     $c->stash(
-        is_search => 1,
+        page => 'search',
 
         q   => $q,                                  # query
         ch  => $ch,                                 # channel

+ 3 - 3
lib/LogBot/Web/Stats.pm

@@ -23,9 +23,9 @@ sub render {
     }
 
     $c->stash(
-        is_stats => 1,
-        url      => irc_host($config, channel => $c->stash('channel'), url => 1),
-        now      => time_to_datetimestr(DateTime->now()->epoch),
+        page => 'stats',
+        url  => irc_host($config, channel => $c->stash('channel'), url => 1),
+        now  => time_to_datetimestr(DateTime->now()->epoch),
     );
 
     return $c->render('stats');

+ 2 - 4
logbot-web

@@ -119,9 +119,7 @@ under sub {
         error           => '',
         event_count     => 0,
         bot_event_count => 0,
-        is_logs         => 0,
-        is_search       => 0,
-        is_stats        => 0,
+        page            => '',
         today           => DateTime->now()->truncate(to => 'day'),
         is_today        => 0,
         cache_prefix    => $config->{_derived}->{time} . '.' . $config->{name} . '.',
@@ -248,7 +246,7 @@ get '/#channel/:date' => [date => qr/\d{8}/] => sub {
     $c->stash(
         channel  => $channel,
         date     => $date,
-        is_logs  => 1,
+        page     => 'logs',
         is_today => $date == $c->stash('today'),
     );
 

+ 5 - 6
web/templates/layouts/logbot.html.ep

@@ -7,15 +7,14 @@
   <link rel="stylesheet" href="<%= static('logbot.min.css') %>">
   <meta name="viewport" content="initial-scale=1">
 </head>
-<body class="<%= 'font-s ' if $font_s =%>
+<body class="<%= $page =%>
+             <%= 'font-s ' if $font_s =%>
              <%= 'nick-u ' if $nick_u =%>
              <%= 'nick-w ' if $nick_w =%>
              <%= 'menu-c ' if $menu_c =%>
              <%= 'hide-b ' if $hide_b =%>
              <%= 'norm-b ' if $norm_b =%>
-             <%= 'topic'   if $topic && $is_logs %>
-             <%= 'stats '  if $is_stats =%>
-             <%= 'search'  if $is_search =%>">
+             <%= 'topic'   if $topic && $page eq 'logs' %>">
 
   <noscript><h1>This site requires JavaScript</h1></noscript>
 
@@ -161,7 +160,7 @@
       </div>
     % }
 
-    % if ($channel && $is_stats) {
+    % if ($channel && $page eq 'stats') {
       <div id="logs-container" class="nav-button">
         <a id="channel-logs" class="button" title="<%= $channel %> Logs"
             href="<%= url_for_channel( channel => $channel )%>">
@@ -206,7 +205,7 @@
 
   </div>
 
-  <div id="main" class="<%= 'logs' if $is_logs %>">
+  <div id="main">
     % if ($error) {
       <div class="notification is-warning"><%= $error %></div>
     % }