Browse Source

add hidden channels

Byron Jones 6 years ago
parent
commit
e527db4936
5 changed files with 35 additions and 11 deletions
  1. 4 0
      etc/_sample.yaml
  2. 9 5
      lib/LogBot/Config.pm
  3. 4 5
      lib/LogBot/Web/Search.pm
  4. 18 1
      web/logbot.js
  5. 0 0
      web/public/static/logbot.min.js

+ 4 - 0
etc/_sample.yaml

@@ -91,3 +91,7 @@ channels:
 # web_only
 #   boolean
 #   manually set this to '1' to have disabled channels visible on the web ui
+#
+# hidden
+#   boolean
+#   hide from channel list and search results.  can navigate directly to channel.

+ 9 - 5
lib/LogBot/Config.pm

@@ -72,19 +72,23 @@ sub load_config {
 
     if ($params{web}) {
 
-        # build sorted channel list, and list of disabled channels
-        my (@visible, @disabled);
+        # build sorted channel list, and list of hidden/disabled channels
+        my (@visible, @hidden);
         foreach my $channel (sort keys %{ $config->{channels} }) {
             next if $channels->{$channel}->{no_logs};
             if ($channels->{$channel}->{disabled} && !$channels->{$channel}->{web_only}) {
-                push @disabled, normalise_channel($channel);
+                push @hidden, normalise_channel($channel);
+                next;
+            }
+            if ($channels->{$channel}->{hidden}) {
+                push @hidden, normalise_channel($channel);
                 next;
             }
             push @visible, { name => $channel, archived => $config->{channels}->{$channel}->{archived} };
         }
 
-        $config->{_derived}->{visible_channels}  = \@visible;
-        $config->{_derived}->{disabled_channels} = \@disabled;
+        $config->{_derived}->{visible_channels} = \@visible;
+        $config->{_derived}->{hidden_channels}  = \@hidden;
     }
 
     # default timings

+ 4 - 5
lib/LogBot/Web/Search.pm

@@ -50,7 +50,7 @@ sub render {
     my $last_c = $c->cookie('last-c') // '';
     if ($last_c ne '') {
         $last_c = normalise_channel($last_c);
-        $last_c = '' if any { $_ eq $last_c } @{ $config->{_derived}->{disabled_channels} };
+        $last_c = '' if any { $_ eq $last_c } @{ $config->{_derived}->{hidden_channels} };
     }
 
     $c->stash(
@@ -192,11 +192,10 @@ sub render {
         push @where, 'NOT(nick COLLATE NOCASE IN (' . join(',', map { $dbh->quote($_) } @bots) . '))';
     }
 
-    # exclude disabled channels
-    if (@{ $config->{_derived}->{disabled_channels} }) {
+    # exclude hidden channels
+    if (@{ $config->{_derived}->{hidden_channels} }) {
         push @where,
-            'NOT(channel IN ('
-            . join(',', map { $dbh->quote($_) } @{ $config->{_derived}->{disabled_channels} }) . '))';
+            'NOT(channel IN (' . join(',', map { $dbh->quote($_) } @{ $config->{_derived}->{hidden_channels} }) . '))';
     }
 
     # build sql

+ 18 - 1
web/logbot.js

@@ -92,7 +92,24 @@ $(function() {
 
     // highlight active channel
     if ($('body').hasClass('logs')) {
-        $('#ch-' + current_channel.substring(1)).addClass('is-active');
+        var ch = current_channel.substring(1);
+        var $ch = $('#ch-' + ch);
+        if ($ch.length) {
+            $ch.addClass('is-active');
+        } else {
+            // hidden channel, add to top of channel list
+            var $li = $('#channel-menu li:first');
+            if ($li.length) {
+                $li = $li.clone();
+                $li.find('a')
+                    .addClass('is-active')
+                    .attr('id', 'ch-' + ch)
+                    .attr('href', '/' + ch)
+                    .attr('title', $('#topic').text().trim())
+                    .text(current_channel);
+                $('#channel-menu').prepend($li);
+            }
+        }
     }
 
     // about

File diff suppressed because it is too large
+ 0 - 0
web/public/static/logbot.min.js


Some files were not shown because too many files changed in this diff