From f1dfaaa142155c3ea70532964eee8b64e0fd0c6a Mon Sep 17 00:00:00 2001 From: Michelle LaMar Date: Mon, 7 Nov 2005 05:42:21 +0000 Subject: [PATCH] Added RSS feed template to Collaboration. Created help for new template. Added internationalization for template labels, tooltips and help. Modified upgrade script to add new column to Collaboration table and add new template. --- docs/changelog/6.x.x.txt | 1 + docs/upgrades/upgrade_6.7.8-6.8.0.pl | 55 +++++++++++++++ lib/WebGUI/Asset/Wobject/Collaboration.pm | 64 +++++++++--------- lib/WebGUI/Help/Asset_Collaboration.pm | 18 +++++ .../i18n/English/Asset_Collaboration.pm | 67 +++++++++++++++++++ 5 files changed, 174 insertions(+), 31 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 861a35206..152e839fd 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -11,6 +11,7 @@ migration.txt for details. - Added automated code testing framework. - Added code skeletons for the various plugins WebGUI supports. + - Added template to Collaboration RSS feeds. 6.7.7 diff --git a/docs/upgrades/upgrade_6.7.8-6.8.0.pl b/docs/upgrades/upgrade_6.7.8-6.8.0.pl index 514a48885..629cc69ff 100644 --- a/docs/upgrades/upgrade_6.7.8-6.8.0.pl +++ b/docs/upgrades/upgrade_6.7.8-6.8.0.pl @@ -26,8 +26,62 @@ addTimeZonesToUserPreferences(); # the new DateTime system uses Params::Validate, which will only validate integers # up to 2^32 as SCALARs. :( removeUnneededFiles(); +updateCollaboration(); finish(); +#------------------------------------------------- +sub updateCollaboration { +print "\tAdding collaboration/rss template\n" unless ($quiet); +my $template = < + + +<tmpl_var title> + + + + +<tmpl_var title> + + + + + + + + +STOP +# Get Template folder +my $templateFolder = WebGUI::Asset->newByUrl('templates'); +# Add Collaboration/RSS folder beneath +my $rssFolder = $templateFolder->addChild({ + title=>"Collaboration/RSS", + menuTitle=>"Collaboration/RSS", + url=>"templates/collaboration/rss", + className=>"WebGUI::Asset::Wobject::Folder" + }); +$rssFolder->commit; +# Place the Collaboration/RSS folder beneath the +# Collaboration/Thread folder +my $threadFolder = WebGUI::Asset->newByUrl('templates/collaboration/thread'); +my $threadRank = $threadFolder->getRank; +$rssFolder->setRank($threadRank + 1); + +$rssFolder->addChild({ + className=>"WebGUI::Asset::Template", + template=>$template, + namespace=>"Collaboration/RSS", + title=>'Default Forum RSS', + menuTitle=>'Default Forum RSS', + ownerUserId=>'3', + groupIdView=>'7', + groupIdEdit=>'4', + isHidden=>1 + }, 'PBtmpl0000000000000142' +); + +} + #------------------------------------------------- sub addTimeZonesToUserPreferences { print "\tDropping time offsets in favor of time zones.\n" unless ($quiet); @@ -54,6 +108,7 @@ sub start { ); WebGUI::Session::open("../..",$configFile); WebGUI::Session::refreshUserInfo(3); + WebGUI::SQL->write("ALTER TABLE Collaboration ADD COLUMN rssTemplateId varchar(22) binary NOT NULL default 'PBtmpl0000000000000142' after notificationTemplateId"); WebGUI::SQL->write("insert into webguiVersion values (".quote($toVersion).",'upgrade',".time().")"); } diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index d2838c107..7d7c76a5b 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -359,6 +359,10 @@ sub definition { fieldType=>"selectList", defaultValue=>'dateUpdated' }, + rssTemplateId =>{ + fieldType=>"template", + defaultValue=>'PBtmpl0000000000000142' + }, notificationTemplateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000027' @@ -463,6 +467,13 @@ sub getEditForm { -label=>WebGUI::International::get('notification template', 'Asset_Collaboration'), -hoverHelp=>WebGUI::International::get('notification template description', 'Asset_Collaboration'), ); + $tabform->getTab("display")->template( + -name=>"rssTemplateId", + -value=>$self->getValue("rssTemplateId"), + -namespace=>"Collaboration/RSS", + -label=>WebGUI::International::get('rss template', 'Asset_Collaboration'), + -hoverHelp=>WebGUI::International::get('rss template description', 'Asset_Collaboration'), + ); $tabform->getTab("security")->group( -name=>"moderateGroupId", -label=>WebGUI::International::get('who moderates', 'Asset_Collaboration'), @@ -703,7 +714,7 @@ sub getUnsubscribeUrl { =head2 incrementReplies ( lastPostDate, lastPostId ) -Increments this forum's reply counter. +Increments the reply counter for this forum. =head3 lastPostDate @@ -1125,17 +1136,19 @@ sub www_view { # print out RSS 2.0 feed describing the items visible on the first page sub www_viewRSS { my $self = shift; + my %var; + $self->logView() if ($session{setting}{passiveProfilingEnabled}); - my $encTitle = _xml_encode($self->get("title")); - my $encDescription = _xml_encode($self->get("description")); - my $encUrl = _xml_encode($self->getUrl); - my $xml = qq~ - - -$encTitle -$encUrl -$encDescription -~; + # Set the required channel variables + $var{'title'} = _xml_encode($self->get("title")); + $var{'link'} = _xml_encode($self->getUrl); + $var{'description'} = _xml_encode($self->get("description")); + # Set some of the optional channel variables + $var{'generator'} = "WebGUI ".$WebGUI::VERSION; + $var{'lastBuildDate'} = _xml_encode(_get_rfc822_date($self->get("dateUpdated"))); + $var{'webMaster'} = $WebGUI::Session::session{setting}{companyEmail}; + $var{'docs'} = "http://blogs.law.harvard.edu/tech/rss"; + my $sth = WebGUI::SQL->read("select asset.assetId, asset.className, max(assetData.revisionDate) from Thread left join asset on Thread.assetId=asset.assetId @@ -1150,30 +1163,21 @@ sub www_viewRSS { my $i = 1; while (my ($id, $class, $version) = $sth->array) { my $post = WebGUI::Asset::Wobject::Collaboration->new($id, $class, $version); + my $encUrl = _xml_encode(WebGUI::URL::getSiteURL().$post->getUrl); - my $encUrl = _xml_encode(WebGUI::URL::getSiteURL().$post->getUrl); - my $encTitle = _xml_encode($post->get("title")); - my $encPubDate = _xml_encode(_get_rfc822_date($post->get("dateUpdated"))); - my $encDescription = _xml_encode($post->get("synopsis")); - $xml .= qq~ - -$encTitle -$encUrl -$encDescription -$encUrl -$encPubDate - -~; + push(@{$var{'item_loop'}}, { + title => _xml_encode($post->get("title")), + link => $encUrl, + description => _xml_encode($post->get("synopsis")), + guid => $encUrl, + pubDate => _xml_encode(_get_rfc822_date($post->get("dateUpdated"))) + }); $i++; last if ($i == $self->get("threadsPerPage")); } - $xml .=qq~ - - -~; WebGUI::HTTP::setMimeType("text/xml"); - return $xml; + return $self->processTemplate(\%var,$self->get("rssTemplateId")); } @@ -1181,5 +1185,3 @@ sub www_viewRSS { 1; - - diff --git a/lib/WebGUI/Help/Asset_Collaboration.pm b/lib/WebGUI/Help/Asset_Collaboration.pm index 36e666a1f..72baa6eb2 100644 --- a/lib/WebGUI/Help/Asset_Collaboration.pm +++ b/lib/WebGUI/Help/Asset_Collaboration.pm @@ -35,6 +35,11 @@ our $HELP = { description => 'notification template description', namespace => 'Asset_Collaboration', }, + { + title => 'rss template', + description => 'rss template description', + namespace => 'Asset_Collaboration', + }, { title => 'who moderates', description => 'who moderates description', @@ -191,6 +196,19 @@ our $HELP = { ] }, + 'collaboration rss template' => { + title => 'collaboration rss template title', + body => 'collaboration rss template body', + fields => [ + ], + related => [ + { + tag => 'collaboration post list template variables', + namespace => 'Asset_Collaboration', + }, + ] + }, + }; 1; diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index dd896956e..216dc685b 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -433,6 +433,11 @@ our $I18N = { lastUpdated => 1109698614, }, + 'rss template' => { + message => q|RSS Template|, + lastUpdated => 1109698614, + }, + 'who moderates' => { message => q|Who can moderate?|, lastUpdated => 1109698614, @@ -847,6 +852,10 @@ properties listed below:

message => q|The template used to generate emails for users who have subscribed to this Asset.|, lastUpdated => 1119070429, }, + 'rss template description' => { + message => q|The template used to generate the xml for an rss feed based on this Asset.|, + lastUpdated => 1119070429, + }, 'who moderates description' => { message => q|The group that will moderate posts to this Asset, if moderation is enabled.|, @@ -1258,6 +1267,64 @@ A URL for sorting and displaying the list of posts by their ratings. }, + 'collaboration rss template title' => { + message => q|Collaboration RSS Template|, + lastUpdated => 1114467745, + }, + + 'collaboration rss template body' => { + message => q|The Collaboration RSS template is available to allow configuration of the XML produced as an RSS feed for a collaboration. To produce a valid rss feed, this template must adhere to the RSS 2.0 Specification. These variables are available in the Collaboration RSS Template:

+ +

+title
+The title of the rss feed (comes from the collaboration title). + +

+link
+The url to the collaboration. + +

+description
+The description of the rss feed (comes from the collaboration description). + +

+generator
+The program used to generate the rss feed, i.e. WebGUI plus version information. (optional field) +

+webMaster
+The email address of the person responsible for the technical issues relating to this rss feed. (optional field) +

+docs
+The url of documentation about the format of this file, RSS 2.0 (optional field) +

+lastBuildDate
+The date that this feed was last updated. (optional field) + +

+item_loop
+Loops over the posts to be transmitted in this RSS feed. +

+title
+The title of the item (post). +

+link
+The url to the full text of the item. +

+description
+A synopsis of the item. +

+guid
+A unique identifier for this item. +

+pubDate
+The date the item was published. +

+ + |, + lastUpdated => 1114467741, + }, + + }; 1;