New short summary view for vdradmin-am-3.4.4

Message ID 200604281316.44351.joachimbanzhaf@compuserve.de
State New
Headers

Commit Message

Joachim Banzhaf (compuserve) April 28, 2006, 11:16 a.m. UTC
  Hi list,

I implemented an extension for vdradmin-am-3.4.4 and posted it on

http://www.vdr-portal.de/board/thread.php?postid=458137#post458137

It just occured to me, that not everyone likes reading german portals (I 
prefer international ML's too :-)).

So here it comes again:

actually I have two patches:

the first (vdradmin-am-3.4.4-summary-next.patch) just implemented a 
next-button on the summary view to get me warm a bit with perl.
It displays all the shows that immediatelly follow the current shows.

It was quite easy to do, so I was encouraged to start the second patch which 
actually includes the first one and adds a second summary view with just two 
lines per show (one for the title an one for the subtitle).

The patches are absolutely usable but there are still some rough edges in it. 
Maybe someone here can help out with them:

There is no translation yet, beause I don't know how to do it (the words - at, 
after, next, ... - are not the main problem;-))

The first line of the summary list should include heading infos like title, 
show, station, ... and not be just empty. Just a matter of time, i guess.

I didn't manage to display the percentage for current shows in a graphical 
manner. I thought it would be quite obvious to use something like this:

<table height="8px" width="70px" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor=#111111 width="19%"> </td>
    <td bgcolor=#eeeeee> </td>
  </tr>
</table>

and it works standalone (see test.html.gz or test.png) but not in vdradmin-am. 
I suspect css is in my way, but my knowledge on this is not enough to solve 
it.

The code for the new summary is just a copy and paste of the old view with 
only a few changes. Someone with more perl knowledge than me may want to 
merge the code. Even better (in my opinion) would be a persistent toggle in 
the header of the old summary view that switches to the new view and back.

Last, Andreas Mair - the current author/maintainer of the vdradmin-am fork - 
didn't like the big icons that I reused too much. Maybe someone can provide 
us with a set of new small icons like in the autotimer view?

For those of you not that familiar with using patches:
untar vdradmin-am-3.4.4.tar.bz2
change in the new vdradmin-am-3.4.4 directory.
Patch with patch -p0 /path/to/the/patchfile
start the modified ./vdradmind.pl

Thats it so far, keep your ideas, patches, icons etc. coming...

Joachim Banzhaf
  

Patch

--- vdradmind.pl.orig	2006-04-27 12:55:09.000000000 +0200
+++ vdradmind.pl	2006-04-27 17:40:05.000000000 +0200
@@ -252,7 +252,7 @@ 
 	js   => "application/x-javascript",
 	swf  => "application/x-shockwave-flash"
 );
-my @LOGINPAGES = qw(prog_summary prog_list2 prog_timeline prog_list timer_list rec_list);
+my @LOGINPAGES = qw(prog_summary prog_summary2 prog_list2 prog_timeline prog_list timer_list rec_list);
 
 $SIG{INT} = \&Shutdown;
 $SIG{TERM} = \&Shutdown;
@@ -381,7 +381,7 @@ 
 ##
 my($Client, $MyURL, $Referer, $Request, $Query, $Guest);
 my @GUEST_USER = qw(prog_detail prog_list prog_list2 prog_timeline timer_list at_timer_list
-	prog_summary rec_list rec_detail show_top toolbar show_help about);
+	prog_summary prog_summary2 rec_list rec_detail show_top toolbar show_help about);
 my @TRUSTED_USER = (@GUEST_USER, qw(at_timer_edit at_timer_new at_timer_save at_timer_test
 	at_timer_delete timer_new_form timer_add timer_delete timer_toggle rec_delete rec_rename rec_edit
 	config prog_switch rc_show rc_hitk grab_picture at_timer_toggle tv_show tv_switch
@@ -3792,6 +3792,7 @@ 
   return if(UptoDate());
   my $time = $q->param("time");
   my $search = $q->param("search");
+  my $next = $q->param("next"); 
 
   # zeitpunkt bestimmen
   my $event_time;
@@ -3853,7 +3854,8 @@ 
 					}
 				 next if(!$f);
 				}
-				next if($event_time > $event->{stop});
+				next if(!$next && $event_time > $event->{stop});
+				next if($next && $event_time >= $event->{start});
 			} else {
 				my($found);
 				if($pattern) {
@@ -3940,12 +3942,179 @@ 
 
 		#
 		my $template = TemplateNew("prog_summary.html");
+    my $label = $next ? gettext("after") : gettext("at");
   my $vars = {
 		usercss => $UserCSS,
     rows    => \@shows,
     now     => strftime("%H:%M", localtime($event_time)),
-		title   => $search ? gettext("Suitable matches for:") . " " . $search : strftime("%H:%M", localtime($event_time)) . " " . gettext("o'clock"),
+		title   => $search ? gettext("Suitable matches for:") . " " . $search : $label . " " . strftime("%H:%M", localtime($event_time)) . " " . gettext("o'clock"),
     nowurl  => $MyURL . "?aktion=prog_summary",
+    nexturl => $MyURL . "?aktion=prog_summary&next=1",
+    url     => $MyURL
+  };
+  $template->param($vars);
+  my $output;
+  my $out = $template->output;
+  $Xtemplate->process(\$out, $vars, \$output) || return(header("500", "text/html", $Xtemplate->error()));
+  return(header("200", "text/html", $output));
+}
+
+
+#############################################################################
+# one line summary
+#############################################################################
+sub prog_summary2 {
+  return if(UptoDate());
+  my $time = $q->param("time");
+  my $search = $q->param("search");
+  my $next = $q->param("next"); 
+
+  # zeitpunkt bestimmen
+  my $event_time;
+  if($time) {
+    my ($hour, $minute);
+    if($time =~ /(\d{1,2})(\D?)(\d{1,2})/) {
+      if(length($1) == 1 && length($3) == 1 && !$2) {
+				$hour = $1 . $3;
+      } else {
+				($hour, $minute) = ($1, $3);
+      }
+    } elsif($time =~ /\d/) {
+      $hour = $time;
+    }
+
+    if($hour <= my_strftime("%H") && $minute < my_strftime("%M")) {
+      $event_time = timelocal(
+				0,
+				$minute,
+				$hour,
+				my_strftime("%d", time + 86400),
+				(my_strftime("%m", time + 86400) - 1),
+				my_strftime("%Y")
+			) + 1;
+    } else {
+      $event_time = timelocal(
+				0,
+				$minute,
+				$hour,
+				my_strftime("%d"),
+				(my_strftime("%m") - 1),
+				my_strftime("%Y")
+			) + 1;
+    }
+  } else {
+    $event_time = time();
+  }
+
+	my $pattern;
+	my $mode;
+	if($search) {
+		if($search =~ /^\/(.*)\/(i?)$/) {
+			$pattern=$1;
+			$mode=$2
+		} else {
+			$search =~ s/([\+\?\.\*\^\$\(\)\[\]\{\}\|\\])/\\$1/g;
+		}
+	}
+			
+	my $now = time();
+  my(@show, @shows, @temp);
+  for(keys(%EPG)) {
+    for my $event (@{$EPG{$_}}) {
+      if(!$search) {
+				if($CONFIG{CHANNELS_WANTED_SUMMARY}) {
+					my $f = 0;
+					for my $n (split(/\,/, $CONFIG{CHANNELS_WANTED})) {
+						($f = 1) if($n eq $event->{vdr_id});
+					}
+				 next if(!$f);
+				}
+				next if(!$next && $event_time > $event->{stop});
+				next if($next && $event_time >= $event->{start});
+			} else {
+				my($found);
+				if($pattern) {
+					# We have a RegExp
+					next if(!length($pattern));
+					next if(!defined($pattern));
+					my $SearchStr = $event->{title} . "~" . $event->{subtitle} . "~" . $event->{summary};
+					# Shall we search case insensitive?
+					if(($mode eq "i") && ($SearchStr !~ /$pattern/i)) {
+						next;
+					} elsif(($mode ne "i") && ($SearchStr !~ /$pattern/)) {
+						next;
+					} else {
+						$found = 1;
+					}
+				} else {
+					next if(! length($search));
+					for my $word (split(/ +/, $search)) {
+						$found = 0;
+						for my $section (qw(title subtitle summary)) {
+							if($event->{$section} =~ /$word/i) {
+								$found = 1;
+							}
+						}
+						if(!$found) {
+							last;
+						}
+					}
+				}
+				next if(!$found);
+			}
+
+			my $displaytext = CGI::escapeHTML($event->{summary});
+			my $displaytitle = CGI::escapeHTML($event->{title});
+			my $displaysubtitle = CGI::escapeHTML($event->{subtitle});
+
+			$displaytext =~ s/\n/<br \/>\n/g;
+			$displaytext =~ s/\|/<br \/>\n/g;
+			$displaytitle =~ s/\n/<br \/>\n/g;
+			$displaytitle =~ s/\|/<br \/>\n/g;
+			if ($displaysubtitle) {
+				$displaysubtitle =~ s/\n/<br \/>\n/g;
+				$displaysubtitle =~ s/\|/<br \/>\n/g;
+			}
+			my $myself = Encode_Referer($MyURL . "?" . $Query);
+      push(@show,  {
+				date           => my_strftime("%x", $event->{start}),
+				longdate       => my_strftime("%A, %x", $event->{start}),
+				start          => my_strftime("%H:%M", $event->{start}),
+				stop           => my_strftime("%H:%M", $event->{stop}),
+				percent        => int(($now-$event->{start})/($event->{stop}-$event->{start})*100),
+				title          => $displaytitle,
+				subtitle       => $displaysubtitle,
+				progname       => CGI::escapeHTML($event->{channel_name}),
+				summary        => $displaytext,
+				vdr_id         => $event->{vdr_id},
+				proglink       => sprintf("%s?aktion=prog_list&amp;vdr_id=%s", $MyURL, $event->{vdr_id}),
+				switchurl      => sprintf("%s?aktion=prog_switch&amp;channel=%s", $MyURL, $event->{vdr_id}),
+				streamurl      => sprintf("%s%s?aktion=live_stream&amp;channel=%s", $MyStreamBase, $CONFIG{TV_EXT}, $event->{vdr_id}),
+				stream_live_on => $event->{start} <= $now && $now <= $event->{stop} ? $CONFIG{ST_FUNC} && $CONFIG{ST_LIVE_ON} : undef,
+				infurl         => $event->{summary} ? sprintf("%s?aktion=prog_detail&amp;epg_id=%s&amp;vdr_id=%s&amp;referer=%s", $MyURL, $event->{event_id}, $event->{vdr_id}, $myself) : undef,
+				recurl         => sprintf("%s?aktion=timer_new_form&amp;epg_id=%s&amp;vdr_id=%s&amp;referer=%s", $MyURL, $event->{event_id}, $event->{vdr_id}, $myself),
+				find_title     => uri_escape($event->{title}),
+        anchor         => "id" . $event->{event_id}
+				});
+				last if(!$search);
+			}
+		}
+
+		# needed for vdr 1.0.x, dunno why
+		@show = sort({ $a->{vdr_id} <=> $b->{vdr_id} } @show);
+
+		push(@shows, { day => [ @show ], status => [ @show ] });
+
+		#
+		my $template = TemplateNew("prog_summary2.html");
+    my $label = $next ? gettext("after") : gettext("at");
+  my $vars = {
+		usercss => $UserCSS,
+    rows    => \@shows,
+    now     => strftime("%H:%M", localtime($event_time)),
+		title   => $search ? gettext("Suitable matches for:") . " " . $search : $label . " " . strftime("%H:%M", localtime($event_time)) . " " . gettext("o'clock"),
+    nowurl  => $MyURL . "?aktion=prog_summary2",
+    nexturl => $MyURL . "?aktion=prog_summary2&next=1",
     url     => $MyURL
   };
   $template->param($vars);
--- template/default/navigation.html.orig	2006-03-11 06:41:12.000000000 +0100
+++ template/default/navigation.html	2006-04-27 14:36:32.000000000 +0200
@@ -31,6 +31,10 @@ 
 		</div>
 		<div class="separator"></div>
 		<div class="navi">
+			<a href="vdradmin.pl?aktion=prog_summary2" target="main"><%! Short What's On? !%></a>
+		</div>
+		<div class="separator"></div>
+		<div class="navi">
 			<a href="vdradmin.pl?aktion=prog_list2" target="main"><%! Playing Today !%></a>
 		</div>
 		<div class="separator"></div>
--- template/default/prog_summary.html.orig	2006-02-27 12:44:36.000000000 +0100
+++ template/default/prog_summary.html	2006-04-27 13:10:09.000000000 +0200
@@ -21,7 +21,8 @@ 
 					<h1><tmpl_var title></h1>
 				</td>
 				<td class="col_other">
-					<%! What's on: !%>&nbsp;<a href="<tmpl_var nowurl>"><%! now !%></a>&nbsp;|<%! at: !%>&nbsp;
+					<%! What's on: !%>&nbsp;<a href="<tmpl_var nowurl>"><%! now !%></a>&nbsp;|
+					<a href="<tmpl_var nexturl>"><%! next !%></a>&nbsp;|<%! at: !%>&nbsp;
 					<input type="text" name="time" size="5" value="<tmpl_var now>" />
 					&nbsp;<%! o'clock !%>
 				</td>
--- template/default/prog_summary2.html.new	1970-01-01 01:00:00.000000000 +0100
+++ template/default/prog_summary2.html	2006-04-27 18:11:17.000000000 +0200
@@ -0,0 +1,106 @@ 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+
+<head>
+	<meta http-equiv="refresh" content="600; URL=vdradmin.pl?aktion=prog_summary2" />
+	<meta http-equiv="content-type" content="text/html;<%! charset=ISO-8859-1 !%>" />
+	<title>VDRAdmin-AM - <%! What's On Now? !%></title>
+	<link href="style.css" rel="stylesheet" media="screen" type="text/css" />
+	<tmpl_if usercss>
+		<link href="user.css" rel="stylesheet" media="screen" type="text/css" />
+	</tmpl_if>
+	<script type="text/javascript" language="JavaScript" src="library.js"></script>
+</head>
+
+<body id="prog_summary2">
+	<form action="<tmpl_var url>" method="get" name="FormName">
+		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="heading">
+			<tr>
+				<td class="col_left"></td>
+				<td class="col_title">
+					<h1><tmpl_var title></h1>
+				</td>
+				<td class="col_other">
+					<%! What's on: !%>&nbsp;<a href="<tmpl_var nowurl>"><%! now !%></a>&nbsp;|
+					<a href="<tmpl_var nexturl>"><%! next !%></a>&nbsp;|<%! at: !%>&nbsp;
+					<input type="text" name="time" size="5" value="<tmpl_var now>" />
+					&nbsp;<%! o'clock !%>
+				</td>
+				<td class="col_right"></td>
+			</tr>
+		</table>
+		<input type="hidden" name="aktion" value="prog_summary2" />
+
+		<table border="0" cellspacing="0" cellpadding="0" class="group">
+			<tr class="heading">
+				<td class="col_left"></td>
+				<td class="col_center" colspan="4"></td>
+				<td class="col_right"></td>
+			</tr>
+
+<tmpl_loop rows>
+	<tmpl_loop day>
+		<tmpl_if longdate>
+
+			<tr class="<tmpl_if __ODD__>row_odd<tmpl_else>row_even</tmpl_if>">
+				<td class="col_left"></td>
+
+				<td class="col_center" width="100">
+					<div class="duration">
+						<tmpl_if start><tmpl_var start>-<tmpl_var stop></tmpl_if>
+					</div>
+					<tmpl_if stream_live_on>
+						<a href="<tmpl_var streamurl>" title="<%! Stream !%>"><tmpl_var percent> %</a>
+					<tmpl_else>
+						&nbsp;
+					</tmpl_if>
+				</td>
+
+				<td class="col_center">
+					<div class="title">
+						<h3>
+							<tmpl_if summary>
+								<a href="javascript:popup('<tmpl_var infurl>');">
+							</tmpl_if>
+							<tmpl_var title>
+							<tmpl_if summary>
+								</a>
+							</tmpl_if>
+						</h3>
+						<tmpl_if subtitle>
+							<tmpl_var subtitle>
+						<tmpl_else>
+							&nbsp;
+						</tmpl_if>
+					</div>
+				</td>
+
+				<td class="col_center">
+					<a id="<tmpl_var anchor>" name="<tmpl_var anchor>"></a>
+					<h2><a href="<tmpl_var proglink>"><tmpl_var progname></a></h2>
+				</td>
+
+				<td class="col_center" width="190">
+					<tmpl_if recurl>
+						<a href="javascript:callurl('<tmpl_var switchurl>');"><img src="bilder/sum_view.gif" width="58" height="22" border="0" alt="<%! TV select !%>" onmouseover="window.status='<%! TV select !%>';return true" title="<%! TV select !%>" /></a>
+						<a href="vdradmin.pl?search=<tmpl_var find_title>&amp;aktion=prog_summary&amp;submit=go11"><img src="bilder/sum_find.gif" width="58" height="22" border="0" alt="<%! Search for other show times !%>" onmouseover="window.status='<%! Search for other show times !%>';return true" title="<%! Search for other show times !%>" /></a>
+						<a href="<tmpl_var recurl>"><img src="bilder/sum_rec.gif" width="58" height="22" border="0" alt="<%! Record !%>" onmouseover="window.status='<%! Record !%>';return true" title="<%! Record !%>" /></a>
+					</tmpl_if>
+				</td>
+
+				<td class="col_right"></td>
+			</tr>
+
+		</tmpl_if>
+	</tmpl_loop>
+</tmpl_loop>
+
+			<tr class="footer">
+				<td class="col_left"></td>
+				<td class="col_center" colspan="4"></td>
+				<td class="col_right"></td>
+			</tr>
+		</table>
+	</form>
+</body>
+</html>