Fix HEAD link issues with RssFeed with exporting.

Refactor the module so that getting the feed url will return
the static URL when exporting.
This commit is contained in:
Colin Kuskie 2009-04-27 19:16:38 +00:00
parent 142518035d
commit 553b1d03d7
3 changed files with 75 additions and 31 deletions

View file

@ -7,6 +7,7 @@
- fixed #10047: SQLReport Debug doesn't catch when bind variables are incorrect
- fixed #10260: WebGUI::Asset::Wobject::Gallery.pm default search date misfunction
- fixed #10238: Edit Calendar Event not working when proxy cache disabled
- Fixed a bug in the RssFeed aspect that would cause the wrong HEAD links to be made for the feeds when exporting.
7.7.4
- rfe: Extend DateTime for Week-Nrs (#9151)

View file

@ -220,7 +220,7 @@ sub exportAssetCollateral {
$reportSession->output->print('<br />');
}
foreach my $ext (qw( rss atom )) {
foreach my $ext (qw( rss atom rdf )) {
my $dest = Path::Class::File->new($filedir, $filenameBase . '.' . $ext);
# tell the user which asset we're exporting.
@ -313,95 +313,136 @@ sub getRssFeedItems {
#-------------------------------------------------------------------
=head2 _getFeedUrl ($extension)
Generic method for returning the URL for a type of feed. If the special scratch variable
isExporting is true, the static url (url based vs asset function based) will be returned
instead.
=head3 $extension
The kind of feed that is requested. Valid extensions are "rss", "atom" or "rdf".
=cut
sub _getFeedUrl {
my $self = shift;
my $extension = shift;
if ( $self->session->scratch->get('isExporting') ) {
return $self->_getStaticFeedUrl($extension);
}
return $self->getUrl("func=view\u$extension");
}
#-------------------------------------------------------------------
=head2 _getStaticFeedUrl ($extension)
Generic method for returning the static URL for a type of feed.
=head3 $extension
The kind of feed that is requested. Valid extensions are "rss", "atom" or "rdf".
=cut
sub _getStaticFeedUrl {
my $self = shift;
my $extension = shift;
my $url = $self->get("url") . '.' . $extension;
$url = $self->session->url->gateway($url);
if ($self->get("encryptPage")) {
$url = $self->session->url->getSiteURL . $url;
$url =~ s/^http:/https:/;
}
return $url;
}
#-------------------------------------------------------------------
=head2 getAtomFeedUrl ()
Returns $self->getUrl('func=viewAtom').
Returns the URL for this asset's feed in Atom format. If the special scratch variable
isExporting is true, the static url (url based vs asset function based) will be returned
instead.
=cut
sub getAtomFeedUrl {
shift->getUrl("func=viewAtom");
my $self = shift;
return $self->_getFeedUrl('atom');
}
#-------------------------------------------------------------------
=head2 getRdfFeedUrl ()
Returns $self->getUrl('func=viewRdf').
Returns the URL for this asset's feed in RDF format. If the special scratch variable
isExporting is true, the static url (url based vs asset function based) will be returned
instead.
=cut
sub getRdfFeedUrl {
shift->getUrl("func=viewRdf");
my $self = shift;
return $self->_getFeedUrl('rdf');
}
#-------------------------------------------------------------------
=head2 getRssFeedUrl ()
Returns $self->getUrl('func=viewRss').
Returns the URL for this asset's feed in RSS 2.0 format. If the special scratch variable
isExporting is true, the static url (url based vs asset function based) will be returned
instead.
=cut
sub getRssFeedUrl {
shift->getUrl("func=viewRss");
my $self = shift;
return $self->_getFeedUrl('rss');
}
#-------------------------------------------------------------------
=head2 getStaticAtomFeedUrl ()
Returns the current asset's URL with .atom concatenated onto it.
Returns the URL to use when exporting for this asset's feed in Atom format.
=cut
sub getStaticAtomFeedUrl {
my $self = shift;
my $url = $self->get("url") . '.atom';
$url = $self->session->url->gateway($url);
if ($self->get("encryptPage")) {
$url = $self->session->url->getSiteURL . $url;
$url =~ s/^http:/https:/;
}
return $url;
return $self->_getStaticFeedUrl('atom');
}
#-------------------------------------------------------------------
=head2 getStaticRdfFeedUrl ()
Returns the current asset's URL with .rdf concatenated onto it.
Returns the URL to use when exporting for this asset's feed in RDF format.
=cut
sub getStaticRdfFeedUrl {
my $self = shift;
my $url = $self->get("url") . '.rdf';
$url = $self->session->url->gateway($url);
if ($self->get("encryptPage")) {
$url = $self->session->url->getSiteURL . $url;
$url =~ s/^http:/https:/;
}
return $url;
return $self->_getStaticFeedUrl('rdf');
}
#-------------------------------------------------------------------
=head2 getStaticRssFeedUrl ()
Returns the current asset's URL with .rss concatenated onto it.
Returns the URL to use when exporting for this asset's feed in RSS 2.0 format.
=cut
sub getStaticRssFeedUrl {
my $self = shift;
my $url = $self->get("url") . '.rss';
$url = $self->session->url->gateway($url);
if ($self->get("encryptPage")) {
$url = $self->session->url->getSiteURL . $url;
$url =~ s/^http:/https:/;
}
return $url;
return $self->_getStaticFeedUrl('rss');
}
#-------------------------------------------------------------------

View file

@ -157,6 +157,7 @@ cmp_bag(
[qw/
shawshank.rss shawshank
shawshank.atom
shawshank.rdf
/],
'exportAssetCollateral: feed files exported, index.html file'
);
@ -172,6 +173,7 @@ cmp_bag(
[qw/
shawshank.html.rss
shawshank.html.atom
shawshank.html.rdf
/],
'exportAssetCollateral: feed files exported, shawshank.html file'
);