New short summary view for vdradmin-am-3.4.4

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

Commit Message

Joachim Banzhaf (compuserve) April 28, 2006, 5:55 p.m. UTC
  Am Freitag, 28. April 2006 13:16 schrieb Joachim Banzhaf (compuserve):
> 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:

now there are three.
apply this one to a clean vdradmin-am-3.4.4/ with patch -p1 </path/to/patch

> 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.

done.

> 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.

I gave up on background color and use images now.
Put the images in the template/default/bilder directory.

The other items are still open...

Joachim Banzhaf
  

Patch

Dateien vdradmin-am-3.4.4.orig/template/default/bilder/elapsed.gif und vdradmin-am-3.4.4/template/default/bilder/elapsed.gif sind verschieden.
Dateien vdradmin-am-3.4.4.orig/template/default/bilder/remaining.gif und vdradmin-am-3.4.4/template/default/bilder/remaining.gif sind verschieden.
diff -Nur -x '*.orig' -x '*~' -x '*.patch' -x '*.at' -x '*.done' -x '*.conf' -x '*.pid' vdradmin-am-3.4.4.orig/template/default/navigation.html vdradmin-am-3.4.4/template/default/navigation.html
--- vdradmin-am-3.4.4.orig/template/default/navigation.html	2006-03-11 06:41:12.000000000 +0100
+++ vdradmin-am-3.4.4/template/default/navigation.html	2006-04-27 18:24:44.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>
diff -Nur -x '*.orig' -x '*~' -x '*.patch' -x '*.at' -x '*.done' -x '*.conf' -x '*.pid' vdradmin-am-3.4.4.orig/template/default/prog_summary2.html vdradmin-am-3.4.4/template/default/prog_summary2.html
--- vdradmin-am-3.4.4.orig/template/default/prog_summary2.html	1970-01-01 01:00:00.000000000 +0100
+++ vdradmin-am-3.4.4/template/default/prog_summary2.html	2006-04-28 18:34:19.000000000 +0200
@@ -0,0 +1,116 @@ 
+<!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"><h2>Uhrzeit</h2></td>
+				<td class="col_center"><h2>Sendung</h2></td>
+				<td class="col_center"><h2>Sender</h2></td>
+				<td class="col_center"><h2>Steuerung</h2></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 width="100">
+					<div>
+						<tmpl_if start><tmpl_var start>-<tmpl_var stop></tmpl_if>
+					</div>
+					<tmpl_if stream_live_on>
+						<a href="<tmpl_var streamurl>" title="<%! Stream !%>">
+							<table height="8px" width="70px" border="1" cellspacing="0" cellpadding="0">
+								<tr>
+									<td class="elapsed" width="<tmpl_var percent>%">&nbsp;</td>
+									<td class="remaining">&nbsp;</td>
+								</tr>
+							</table>
+						</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>
diff -Nur -x '*.orig' -x '*~' -x '*.patch' -x '*.at' -x '*.done' -x '*.conf' -x '*.pid' vdradmin-am-3.4.4.orig/template/default/prog_summary.html vdradmin-am-3.4.4/template/default/prog_summary.html
--- vdradmin-am-3.4.4.orig/template/default/prog_summary.html	2006-02-27 12:44:36.000000000 +0100
+++ vdradmin-am-3.4.4/template/default/prog_summary.html	2006-04-27 18:24:44.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>
diff -Nur -x '*.orig' -x '*~' -x '*.patch' -x '*.at' -x '*.done' -x '*.conf' -x '*.pid' vdradmin-am-3.4.4.orig/template/default/style.css vdradmin-am-3.4.4/template/default/style.css
--- vdradmin-am-3.4.4.orig/template/default/style.css	2006-03-13 12:03:31.000000000 +0100
+++ vdradmin-am-3.4.4/template/default/style.css	2006-04-28 18:49:35.000000000 +0200
@@ -68,6 +68,9 @@ 
 .col_edit, .col_delete, .col_checkbox { text-align: center; width: 30px; max-width: 30px; }
 #rec_list .col_date, #rec_list .col_time { width: 76px; }
 
+#prog_summary2 .elapsed   { font-size: 3px; background-image: url("bilder/elapsed.gif"); }
+#prog_summary2 .remaining { font-size: 3px; background-image: url("bilder/remaining.gif"); }
+
 #heading { height: 39px; }
 #heading tr, #heading td { vertical-align: middle; }
 #heading .col_left { min-width: 15px; width: 15px; background-image: url("bilder/nav_button_back_start.gif"); }
diff -Nur -x '*.orig' -x '*~' -x '*.patch' -x '*.at' -x '*.done' -x '*.conf' -x '*.pid' vdradmin-am-3.4.4.orig/vdradmind.pl vdradmin-am-3.4.4/vdradmind.pl
--- vdradmin-am-3.4.4.orig/vdradmind.pl	2006-04-06 12:57:26.000000000 +0200
+++ vdradmin-am-3.4.4/vdradmind.pl	2006-04-27 18:24:44.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);