Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Make summary mode sticky, when prev/next day links are clicked #7

Merged
merged 2 commits into from about 1 year ago

2 participants

Prakash Kailasa Moritz Lenz
Prakash Kailasa

I saw this comment on reddit by raiph. I have felt the same need in the past when I was trying to catch up with Perl 6 irc logs. So, raiph's comment made me look at the code, and it was pretty easy to make a fix. The changes are very minor.

Please note that these are untested changes. I suppose I'd have to install my own IRC server, MySQL server and a web server in order to run ilbot and test these changes. The effort involved in setting this up seemed more than I can spare my time at present, so I punted on doing this. If this is a problem, feel free to reject the pull request.

Moritz Lenz moritz merged commit ceeec37 into from April 05, 2013
Moritz Lenz moritz closed this April 05, 2013
Moritz Lenz
Owner

FWIW I needed commit 5ed2682 to fix the hilighting of github links. The first problem was that the regex was too liberal, never letting the old 'RT #123456' links match. And the second problem was that in channels other #moe and #parrot, it swallowed #123456-style text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6  cgi/out.pl
@@ -237,6 +237,9 @@ sub irclog_output {
237 237
             # where the hell does the leading double slash come from?
238 238
             $next_url =~ s{^//+}{/};
239 239
             $t->param(NEXT_URL => $next_url);
  240
+            if ($summary) {
  241
+                $t->param(NEXT_DATE => $tomorrow);
  242
+            }
240 243
         }
241 244
 
242 245
         my $yesterday = date($date) - 1;
@@ -246,6 +249,9 @@ sub irclog_output {
246 249
             my $prev_url = $base_url . "$channel/$yesterday";
247 250
             $prev_url =~ s{^//+}{/};
248 251
             $t->param(PREV_URL => $prev_url);
  252
+            if ($summary) {
  253
+                $t->param(PREV_DATE => $yesterday);
  254
+            }
249 255
         }
250 256
 
251 257
     }
19  cgi/template/linkblock.tmpl
... ...
@@ -1,12 +1,21 @@
1  
-    <p><TMPL_IF NAME=PREV_URL><a href="<TMPL_VAR NAME=PREV_URL>" rel="prev">&larr; Previous
2  
-    day</a> |</TMPL_IF> 
  1
+    <p><TMPL_IF NAME=PREV_URL>
  2
+        <TMPL_IF NAME=IS_SUMMARY>
  3
+        <a href="<TMPL_VAR NAME=BASE_URL>out.pl?channel=<TMPL_VAR NAME=CHANNEL>;date=<TMPL_VAR NAME=PREV_DATE>;summary=1" rel="prev">
  4
+        <TMPL_ELSE>
  5
+        <a href="<TMPL_VAR NAME=PREV_URL>" rel="prev">
  6
+        </TMPL_IF>&larr; Previous day</a> |
  7
+    </TMPL_IF> 
3 8
     <a href="<TMPL_VAR NAME=BASE_URL>">Channels</a> |
4 9
 	<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/">#<TMPL_VAR
5 10
     CHANNEL> index</a> |
6  
-	<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today">Today</a> |
  11
+	<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today<TMPL_IF NAME=IS_SUMMARY>?summary=1</TMPL_IF>">Today</a> |
7 12
     <TMPL_IF NAME=NEXT_URL>
8  
-		<a href="<TMPL_VAR NAME=NEXT_URL>" rel="next">Next day &rarr;</a> |
9  
-	</TMPL_IF>
  13
+        <TMPL_IF NAME=IS_SUMMARY>
  14
+        <a href="<TMPL_VAR NAME=BASE_URL>out.pl?channel=<TMPL_VAR NAME=CHANNEL>;date=<TMPL_VAR NAME=NEXT_DATE>;summary=1" rel="next">
  15
+        <TMPL_ELSE>
  16
+        <a href="<TMPL_VAR NAME=NEXT_URL>" rel="next">
  17
+        </TMPL_IF>Next day &rarr;</a> |
  18
+    </TMPL_IF>
10 19
     <a href="<TMPL_VAR BASE_URL>search.pl?channel=<TMPL_VAR CHANNEL>">Search</a> |
11 20
     <a href="http://www.google.com/search?q=site%3Airclog.perlgeek.de+inurl%3A<TMPL_VAR NAME=CHANNEL ESCAPE=URL>">Google Search</a>
12 21
 	<TMPL_IF NAME=DATE>| <a href="<TMPL_VAR
31  lib/IrcLog/WWW.pm
@@ -319,6 +319,30 @@ my $re_links = qr/(?!)/;
319 319
 
320 320
 }
321 321
 
  322
+sub github_links {
  323
+    my ($key, $state, $channel, $nick) = @_;
  324
+    if ($key =~ m/^GH/i) {
  325
+        $key =~ m/(\d+)/;
  326
+        if ($channel eq "parrot") {
  327
+            return qq{<a href="https://github.com/parrot/parrot/issues/$1">}
  328
+                . encode_entities($key, ENTITIES)
  329
+                . qq{</a> };
  330
+        }
  331
+        elsif ($channel eq "moe") {
  332
+            return qq{<a href="https://github.com/MoeOrganization/moe/issues/$1">}
  333
+                . encode_entities($key, ENTITIES)
  334
+                . qq{</a> };
  335
+        }
  336
+    }
  337
+    elsif ($key =~ m/^pull request/i) {
  338
+        if ($channel eq "moe") {
  339
+            return qq{<a href="https://github.com/MoeOrganization/moe/pull/$1">}
  340
+                . encode_entities($key, ENTITIES)
  341
+                . qq{</a> };
  342
+        }
  343
+    }
  344
+}
  345
+
322 346
 sub rt_links {
323 347
     my ($key, $state) = @_;
324 348
     if ($key =~ m/^tt/i) {
@@ -386,7 +410,12 @@ my %output_chain = (
386 410
         static_links => {
387 411
              re     => $re_links,
388 412
              match  => \&expand_links,
389  
-             rest   => 'rt_links'
  413
+             rest   => 'github_links'
  414
+        },
  415
+        github_links     => {
  416
+            re     => qr{(?i:\b(?:GH|pull request)\s*)?#\d{2,6}\b},
  417
+            match  => \&github_links,
  418
+            rest   => 'rt_links',
390 419
         },
391 420
         rt_links     => {
392 421
              re     => qr{(?i:\btt\s*)?#\d{2,6}\b},
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.