From eb102f2bea3dcb62b19fb9f97cd8f8947d7b0615 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Sat, 17 Jan 2015 12:08:48 +0000 Subject: [PATCH] 02_RSS.pm: improved frontpage for RSS git-svn-id: https://svn.fhem.de/fhem/trunk@7597 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/02_RSS.pm | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 745f89068..c91e970ba 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 02_RSS.pm: improved frontpage for RSS - bugfix: FB_CALLMONITOR regognize "user:" as login prompt for remote telnet connection (phonebook) - changed: 73_km200.pm: DoNotPoll includes top-down hierarchy diff --git a/fhem/FHEM/02_RSS.pm b/fhem/FHEM/02_RSS.pm index f15a04f46..c596ba1c9 100644 --- a/fhem/FHEM/02_RSS.pm +++ b/fhem/FHEM/02_RSS.pm @@ -172,15 +172,20 @@ sub RSS_Overview { my ($name, $url); - my $html= "\n"; + my $html= RSS_HTMLHead("RSS RSS_Overview") . "\n"; foreach my $def (sort keys %defs) { if($defs{$def}{TYPE} eq "RSS") { $name= $defs{$def}{NAME}; $url= RSS_getURL($defs{$def}{fhem}{hostname}); - $html.= " $name
\n"; + $html.= "$name
\n\n

\n"; } } - $html.=""; + $html.="\n" . RSS_HTMLTail(); return ("text/html; charset=utf-8", $html); } @@ -246,6 +251,27 @@ RSS_getScript() { return $scripts; } +sub +RSS_HTMLHead($$) { + my ($title,$refresh) = @_; + + my $doctype= ''; + my $xmlns= 'xmlns="http://www.w3.org/1999/xhtml"'; + my $r= defined($refresh) ? "\n" : ""; + # css and js header output should be coded only in one place + my $cssTemplate = "\n"; + my $css= sprintf($cssTemplate, "pgm2/style.css"); + $css.= sprintf($cssTemplate, "pgm2/jquery-ui.min.css"); + map { $css.= sprintf($cssTemplate, $_); } + split(" ", AttrVal($FW_wname, "CssFiles", "")); + my $scripts= RSS_getScript(); + my $code= "$doctype\n\n\n$title\n$r$css$scripts\n"; +} + +sub +RSS_HTMLTail() { + return ""; +} sub RSS_returnHTML($) { @@ -256,11 +282,9 @@ RSS_returnHTML($) { my $img= "$url/rss/$name.$type"; my $refresh= AttrVal($name, 'refresh', 60); my $areas= AttrVal($name, 'areas', ""); - my $mime = ($type eq 'png')? 'image/png' : 'image/jpeg'; - my $doctype= ''; - my $xmlns= 'xmlns="http://www.w3.org/1999/xhtml"'; - my $scripts= RSS_getScript(); - my $code= "$doctype\n\n\n$name\n\n$scripts\n\n\n\n$areas\n\n\n"; + my $code= RSS_HTMLHead($name, $refresh) . + "\n\n\n$areas\n\n\n" . + RSS_HTMLTail(); return ("text/html; charset=utf-8", $code); }