Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

2 participants

@prakashk

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 moritz merged commit ceeec37 into from
@moritz
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.
Showing with 50 additions and 6 deletions.
  1. +6 −0 cgi/out.pl
  2. +14 −5 cgi/template/linkblock.tmpl
  3. +30 −1 lib/IrcLog/WWW.pm
View
6 cgi/out.pl
@@ -237,6 +237,9 @@ sub irclog_output {
# where the hell does the leading double slash come from?
$next_url =~ s{^//+}{/};
$t->param(NEXT_URL => $next_url);
+ if ($summary) {
+ $t->param(NEXT_DATE => $tomorrow);
+ }
}
my $yesterday = date($date) - 1;
@@ -246,6 +249,9 @@ sub irclog_output {
my $prev_url = $base_url . "$channel/$yesterday";
$prev_url =~ s{^//+}{/};
$t->param(PREV_URL => $prev_url);
+ if ($summary) {
+ $t->param(PREV_DATE => $yesterday);
+ }
}
}
View
19 cgi/template/linkblock.tmpl
@@ -1,12 +1,21 @@
- <p><TMPL_IF NAME=PREV_URL><a href="<TMPL_VAR NAME=PREV_URL>" rel="prev">&larr; Previous
- day</a> |</TMPL_IF>
+ <p><TMPL_IF NAME=PREV_URL>
+ <TMPL_IF NAME=IS_SUMMARY>
+ <a href="<TMPL_VAR NAME=BASE_URL>out.pl?channel=<TMPL_VAR NAME=CHANNEL>;date=<TMPL_VAR NAME=PREV_DATE>;summary=1" rel="prev">
+ <TMPL_ELSE>
+ <a href="<TMPL_VAR NAME=PREV_URL>" rel="prev">
+ </TMPL_IF>&larr; Previous day</a> |
+ </TMPL_IF>
<a href="<TMPL_VAR NAME=BASE_URL>">Channels</a> |
<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/">#<TMPL_VAR
CHANNEL> index</a> |
- <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today">Today</a> |
+ <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today<TMPL_IF NAME=IS_SUMMARY>?summary=1</TMPL_IF>">Today</a> |
<TMPL_IF NAME=NEXT_URL>
- <a href="<TMPL_VAR NAME=NEXT_URL>" rel="next">Next day &rarr;</a> |
- </TMPL_IF>
+ <TMPL_IF NAME=IS_SUMMARY>
+ <a href="<TMPL_VAR NAME=BASE_URL>out.pl?channel=<TMPL_VAR NAME=CHANNEL>;date=<TMPL_VAR NAME=NEXT_DATE>;summary=1" rel="next">
+ <TMPL_ELSE>
+ <a href="<TMPL_VAR NAME=NEXT_URL>" rel="next">
+ </TMPL_IF>Next day &rarr;</a> |
+ </TMPL_IF>
<a href="<TMPL_VAR BASE_URL>search.pl?channel=<TMPL_VAR CHANNEL>">Search</a> |
<a href="http://www.google.com/search?q=site%3Airclog.perlgeek.de+inurl%3A<TMPL_VAR NAME=CHANNEL ESCAPE=URL>">Google Search</a>
<TMPL_IF NAME=DATE>| <a href="<TMPL_VAR
View
31 lib/IrcLog/WWW.pm
@@ -319,6 +319,30 @@ my $re_links = qr/(?!)/;
}
+sub github_links {
+ my ($key, $state, $channel, $nick) = @_;
+ if ($key =~ m/^GH/i) {
+ $key =~ m/(\d+)/;
+ if ($channel eq "parrot") {
+ return qq{<a href="https://github.com/parrot/parrot/issues/$1">}
+ . encode_entities($key, ENTITIES)
+ . qq{</a> };
+ }
+ elsif ($channel eq "moe") {
+ return qq{<a href="https://github.com/MoeOrganization/moe/issues/$1">}
+ . encode_entities($key, ENTITIES)
+ . qq{</a> };
+ }
+ }
+ elsif ($key =~ m/^pull request/i) {
+ if ($channel eq "moe") {
+ return qq{<a href="https://github.com/MoeOrganization/moe/pull/$1">}
+ . encode_entities($key, ENTITIES)
+ . qq{</a> };
+ }
+ }
+}
+
sub rt_links {
my ($key, $state) = @_;
if ($key =~ m/^tt/i) {
@@ -386,7 +410,12 @@ my %output_chain = (
static_links => {
re => $re_links,
match => \&expand_links,
- rest => 'rt_links'
+ rest => 'github_links'
+ },
+ github_links => {
+ re => qr{(?i:\b(?:GH|pull request)\s*)?#\d{2,6}\b},
+ match => \&github_links,
+ rest => 'rt_links',
},
rt_links => {
re => qr{(?i:\btt\s*)?#\d{2,6}\b},
Something went wrong with that request. Please try again.