[Slim-Checkins] r10805 - in /trunk/server: Plugins/Podcast/
Plugins/Podcast/HTML/
Plugins/Podcast/HTML/EN/ Plugins/Podcast/HTML/EN/plugins/
Plugins/Podcast/HTML/EN/plugins/Podcast/
Plugins/Podcast/HTML/EN/plugins/Podcast/settings/ Slim/Web/
dsully at svn.slimdevices.com
dsully at svn.slimdevices.com
Thu Nov 30 16:52:25 PST 2006
Author: dsully
Date: Thu Nov 30 16:52:25 2006
New Revision: 10805
URL: http://svn.slimdevices.com?rev=10805&view=rev
Log:
Bug: N/A
Description: Convert the Podcast plugin. Add array capability for CGI parameters.
Added:
trunk/server/Plugins/Podcast/HTML/
trunk/server/Plugins/Podcast/HTML/EN/
trunk/server/Plugins/Podcast/HTML/EN/plugins/
trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/
trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/
trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html (with props)
trunk/server/Plugins/Podcast/Settings.pm (with props)
Modified:
trunk/server/Plugins/Podcast/Plugin.pm
trunk/server/Slim/Web/HTTP.pm
Added: trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html
URL: http://svn.slimdevices.com/trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html?rev=10805&view=auto
==============================================================================
--- trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html (added)
+++ trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html Thu Nov 30 16:52:25 2006
@@ -1,0 +1,33 @@
+[% PROCESS settings/header.html %]
+
+ <div class="settingSection">
+ <div class="prefHead">[% "PLUGIN_PODCAST" | string | upper %]</div>
+ <div class="prefDesc">[% "PODCAST_GROUP_DESC" | string %]</div>
+
+ <table border="0" cellspacing="7" cellpadding="7">
+
+ <tr>
+ <td><label for="new_feed" class="stdlabel">[% "SETUP_PLUGIN_PODCAST_ADD_FEED" | string %]</label></td>
+
+ <td><input type="text" class="stdedit" name="plugin_podcast_feeds" id="new_feed" value="" size="60" /></td>
+ </tr>
+
+ <tr></tr>
+ <tr></tr>
+ <tr><td><label>[% "SETUP_PLUGIN_PODCAST_EXISTING_FEEDS" | string %]</label></td><td></td></tr>
+
+ [% FOREACH pref = prefs %]
+
+ <tr>
+ <td><label for="plugin_podcast_feeds" class="stdlabel">[% pref.1 %]</label></td>
+
+ <td><input type="text" class="stdedit" name="plugin_podcast_feeds" id="plugin_podcast_feeds" value="[% pref.0 %]" size="60" /></td>
+
+ </tr>
+
+ [% END %]
+
+ </table>
+ </div>
+
+[% PROCESS settings/footer.html %]
Propchange: trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html
------------------------------------------------------------------------------
svn:keywords = Id Author LastChangedDate LastChangedBy
Propchange: trunk/server/Plugins/Podcast/HTML/EN/plugins/Podcast/settings/basic.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: trunk/server/Plugins/Podcast/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Plugins/Podcast/Plugin.pm?rev=10805&r1=10804&r2=10805&view=diff
==============================================================================
--- trunk/server/Plugins/Podcast/Plugin.pm (original)
+++ trunk/server/Plugins/Podcast/Plugin.pm Thu Nov 30 16:52:25 2006
@@ -13,6 +13,8 @@
use HTML::Entities;
use XML::Simple;
+
+use Plugins::Podcast::Settings;
use Slim::Formats::XML;
use Slim::Utils::Cache;
@@ -55,6 +57,8 @@
$log->info("Initializing.");
+ Plugins::Podcast::Settings->new;
+
Slim::Buttons::Common::addMode('PLUGIN.Podcast', getFunctions(), \&setMode);
my @feedURLPrefs = Slim::Utils::Prefs::getArray("plugin_podcast_feeds");
@@ -79,22 +83,22 @@
# No prefs set or we've had a version change and they weren't modified,
# so we'll use the defaults
- if (scalar(@feedURLPrefs) == 0 ||
- (!$feedsModified && (!$version || $version != FEEDS_VERSION))) {
+ if (scalar(@feedURLPrefs) == 0 || (!$feedsModified && (!$version || $version != FEEDS_VERSION))) {
+
# use defaults
# set the prefs so the web interface will work.
revertToDefaults();
+
} else {
+
# use prefs
- my $i = 0;
- while ($i < scalar(@feedNamePrefs)) {
+ for (my $i = 0; $i < scalar(@feedNamePrefs); $i++) {
push @feeds, {
name => $feedNamePrefs[$i],
value => $feedURLPrefs[$i],
type => 'link',
};
- $i++;
}
}
@@ -110,11 +114,6 @@
$log->debug('');
}
- # feed_names should reflect current names
- %feed_names = ();
-
- map { $feed_names{$_->{'value'} } = $_->{'name'}} @feeds;
-
updateOPMLCache( \@feeds );
}
@@ -128,11 +127,6 @@
Slim::Utils::Prefs::set('plugin_podcast_names', \@names);
Slim::Utils::Prefs::set('plugin_podcast_feeds_version', FEEDS_VERSION);
- # feed_names should reflect current names
- %feed_names = ();
-
- map { $feed_names{$_->{'value'}} = $_->{'name'} } @feeds;
-
updateOPMLCache( \@feeds );
}
@@ -245,8 +239,14 @@
# Update the hashref of podcast feeds for use with the web UI
sub updateOPMLCache {
my $feeds = shift;
+
+ # feed_names should reflect current names
+ %feed_names = ();
+
+ map { $feed_names{$_->{'value'}} = $_->{'name'} } @feeds;
my $outline = [];
+
for my $item ( @{$feeds} ) {
push @{$outline}, {
'name' => $item->{'name'},
@@ -268,62 +268,6 @@
$cache->set( 'podcasts_opml', $opml, '10days' );
}
-# for configuring via web interface
-sub setupGroup {
- my %Group = (
- PrefOrder => [
- 'plugin_podcast_reset',
- 'plugin_podcast_feeds',
- ],
- GroupHead => 'PLUGIN_PODCAST',
- GroupDesc => 'PODCAST_GROUP_DESC',
- GroupLine => 1,
- GroupSub => 1,
- Suppress_PrefSub => 1,
- Suppress_PrefLine => 1,
- );
-
- my %Prefs = (
- plugin_podcast_reset => {
- 'onChange' => sub {
- Slim::Utils::Prefs::set("plugin_podcast_feeds_modified", undef);
- Slim::Utils::Prefs::set("plugin_podcast_feeds_version", undef);
- revertToDefaults();
- },
- 'inputTemplate' => 'setup_input_submit.html',
- 'changeIntro' => 'PODCAST_RESETTING',
- 'ChangeButton' => 'PODCAST_RESET_BUTTON',
- 'dontSet' => 1,
- 'changeMsg' => '',
- },
-
- plugin_podcast_feeds => {
- 'isArray' => 1,
- 'arrayAddExtra' => 1,
- 'arrayDeleteNull' => 1,
- 'arrayDeleteValue' => '',
- 'arrayBasicValue' => 0,
- 'PrefSize' => 'large',
- 'inputTemplate' => 'setup_input_array_txt.html',
- 'PrefInTable' => 1,
- 'showTextExtValue' => 1,
- 'externalValue' => sub {
- my ($client, $value, $key) = @_;
-
- if ($key =~ /^(\D*)(\d+)$/ && ($2 < scalar(@feeds))) {
- return $feeds[$2]->{'name'};
- }
-
- return '';
- },
- 'onChange' => \&updateFeedNames,
- 'changeMsg' => 'PODCAST_FEEDS_CHANGE',
- },
- );
-
- return (\%Group, \%Prefs);
-}
-
sub updateFeedNames {
my @feedURLPrefs = Slim::Utils::Prefs::getArray("plugin_podcast_feeds");
my @feedNamePrefs = ();
@@ -336,80 +280,73 @@
# case 1: we're reverting to default
if (scalar(@feedURLPrefs) == 0) {
+
revertToDefaults();
- } else {
- # case 2: url list edited
-
- my $i = 0;
- while ($i < scalar(@feedURLPrefs)) {
-
- my $url = $feedURLPrefs[$i];
- my $name = $feed_names{$url};
-
- if ($name && $name !~ /^http\:/) {
-
- # no change
- $feedNamePrefs[$i] = $name;
-
- } elsif ($url =~ /^http\:/) {
-
- # does a synchronous get
- my $xml = Slim::Formats::XML->getFeedSync($url);
-
- if ($xml && exists $xml->{'channel'}->{'title'}) {
-
- # here for podcasts and RSS
- $feedNamePrefs[$i] = Slim::Formats::XML::unescapeAndTrim($xml->{'channel'}->{'title'});
-
- } elsif ($xml && exists $xml->{'head'}->{'title'}) {
-
- # here for OPML
- $feedNamePrefs[$i] = Slim::Formats::XML::unescapeAndTrim($xml->{'head'}->{'title'});
-
- } else {
- # use url as title since we have nothing else
- $feedNamePrefs[$i] = $url;
- }
+ return;
+ }
+
+ # case 2: url list edited
+ my $i = 0;
+ while ($i < scalar(@feedURLPrefs)) {
+
+ my $url = $feedURLPrefs[$i];
+ my $name = $feed_names{$url};
+
+ if ($name && $name !~ /^http\:/) {
+
+ # no change
+ $feedNamePrefs[$i] = $name;
+
+ } elsif ($url =~ /^http\:/) {
+
+ # does a synchronous get
+ my $xml = Slim::Formats::XML->getFeedSync($url);
+
+ if ($xml && exists $xml->{'channel'}->{'title'}) {
+
+ # here for podcasts and RSS
+ $feedNamePrefs[$i] = Slim::Formats::XML::unescapeAndTrim($xml->{'channel'}->{'title'});
+
+ } elsif ($xml && exists $xml->{'head'}->{'title'}) {
+
+ # here for OPML
+ $feedNamePrefs[$i] = Slim::Formats::XML::unescapeAndTrim($xml->{'head'}->{'title'});
} else {
# use url as title since we have nothing else
$feedNamePrefs[$i] = $url;
}
- $i++;
+ } else {
+ # use url as title since we have nothing else
+ $feedNamePrefs[$i] = $url;
}
- # if names array contains more than urls, delete the extras
- while ($feedNamePrefs[$i]) {
- delete $feedNamePrefs[$i];
- $i++;
- }
-
- # save updated names to prefs
- Slim::Utils::Prefs::set('plugin_podcast_names', \@feedNamePrefs);
-
- # runtime list must reflect changes
- @feeds = ();
- $i = 0;
-
- while ($i < scalar(@feedNamePrefs)) {
-
- push @feeds, {
- name => $feedNamePrefs[$i],
- value => $feedURLPrefs[$i]
- };
-
- $i++;
- }
-
- # feed_names should reflect current names
- %feed_names = ();
-
- map { $feed_names{$_->{'value'}} = $_->{'name'} } @feeds;
-
- updateOPMLCache( \@feeds );
- }
-
+ $i++;
+ }
+
+ # if names array contains more than urls, delete the extras
+ while ($feedNamePrefs[$i]) {
+ delete $feedNamePrefs[$i];
+ $i++;
+ }
+
+ # save updated names to prefs
+ Slim::Utils::Prefs::set('plugin_podcast_names', \@feedNamePrefs);
+
+ # runtime list must reflect changes
+ @feeds = ();
+
+ for (my $i = 0; $i < scalar(@feedNamePrefs); $i++) {
+
+ push @feeds, {
+ name => $feedNamePrefs[$i],
+ value => $feedURLPrefs[$i],
+ type => 'link',
+ };
+ }
+
+ updateOPMLCache( \@feeds );
}
sub strings { return q!
@@ -461,6 +398,13 @@
ES Reinicializar Podcasts por defecto
FR Rétablir la liste des podcasts par défaut
NL Herstel default podcasts
+
+SETUP_PLUGIN_PODCAST_ADD_FEED
+ EN Add a new feed:
+
+
+SETUP_PLUGIN_PODCAST_EXISTING_FEEDS
+ EN Existing feeds:
!};
1;
Added: trunk/server/Plugins/Podcast/Settings.pm
URL: http://svn.slimdevices.com/trunk/server/Plugins/Podcast/Settings.pm?rev=10805&view=auto
==============================================================================
--- trunk/server/Plugins/Podcast/Settings.pm (added)
+++ trunk/server/Plugins/Podcast/Settings.pm Thu Nov 30 16:52:25 2006
@@ -1,0 +1,45 @@
+package Plugins::Podcast::Settings;
+
+# SlimServer Copyright (C) 2001-2006 Slim Devices Inc.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2.
+
+use strict;
+use base qw(Slim::Web::Settings);
+
+sub name {
+ return 'PLUGIN_PODCAST';
+}
+
+sub page {
+ return 'plugins/Podcast/settings/basic.html';
+}
+
+sub handler {
+ my ($class, $client, $params) = @_;
+
+ if ($params->{'submit'}) {
+
+ # Remove empty feeds.
+ my @feeds = grep { $_ ne '' } @{$params->{'plugin_podcast_feeds'}};
+
+ Slim::Utils::Prefs::set('plugin_podcast_feeds', \@feeds);
+
+ Plugins::Podcast::Plugin::updateFeedNames();
+ }
+
+ my @feeds = Slim::Utils::Prefs::getArray('plugin_podcast_feeds');
+ my @names = Slim::Utils::Prefs::getArray('plugin_podcast_names');
+
+ for (my $i = 0; $i < @feeds; $i++) {
+
+ push @{$params->{'prefs'}}, [ $feeds[$i], $names[$i] ];
+ }
+
+ return $class->SUPER::handler($client, $params);
+}
+
+1;
+
+__END__
Propchange: trunk/server/Plugins/Podcast/Settings.pm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/server/Plugins/Podcast/Settings.pm
------------------------------------------------------------------------------
svn:keywords = Id Author LastChangedDate LastChangedBy
Propchange: trunk/server/Plugins/Podcast/Settings.pm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/server/Slim/Web/HTTP.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/HTTP.pm?rev=10805&r1=10804&r2=10805&view=diff
==============================================================================
--- trunk/server/Slim/Web/HTTP.pm (original)
+++ trunk/server/Slim/Web/HTTP.pm Thu Nov 30 16:52:25 2006
@@ -395,7 +395,22 @@
$value = Slim::Utils::Unicode::utf8encode_locale($value);
}
- $params->{$name} = $value;
+ # Ick. It sure would be nice to use
+ # CGI or CGI::Lite
+ if (ref($params->{$name}) eq 'ARRAY') {
+
+ push @{$params->{$name}}, $value;
+
+ } elsif (exists $params->{$name}) {
+
+ my $old = delete $params->{$name};
+
+ @{$params->{$name}} = ($old, $value);
+
+ } else {
+
+ $params->{$name} = $value;
+ }
$log->info("HTTP parameter $name = $value");
More information about the checkins
mailing list