Skip to content

Rss feed subscription #1230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 12, 2014
50 changes: 42 additions & 8 deletions lib/MetaCPAN/Web/Controller/Feed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ sub author : Chained('index') PathPart Args(1) {

my $author_cv = $c->model('API::Author')->get($author);
my $releases_cv = $c->model('API::Release')->latest_by_author($author);
my $data = {
author => $author_cv->recv,
releases =>
[ map { $_->{fields} } @{ $releases_cv->recv->{hits}{hits} } ],
};
my $release_data
= [ map { $_->{fields} } @{ $releases_cv->recv->{hits}{hits} } ];
my $author_info = $author_cv->recv;
my $faves_cv
= $c->model('API::Favorite')->by_user( $author_info->{user} );
my $faves_data
= [ map { $_->{fields} } @{ $faves_cv->recv->{hits}{hits} } ];

$c->stash->{feed} = $self->build_feed(
title => "Recent CPAN uploads by $data->{author}->{name} - MetaCPAN",
entries => $data->{releases}
title => "Recent CPAN activity of $author - MetaCPAN",
entries => [
sort { $b->{date} cmp $a->{date} }
@{ $self->_format_release_entries($release_data) },
@{ $self->_format_favorite_entries( $author, $faves_data ) }
],
);
}

Expand All @@ -98,7 +104,7 @@ sub build_entry {
my $e = XML::Feed::Entry->new('RSS');
$e->title( $entry->{name} );
$e->link(
$entry->{link} // join( '/',
$entry->{link} ||= join( '/',
'http://metacpan.org', 'release',
$entry->{author}, $entry->{name} )
);
Expand All @@ -120,6 +126,34 @@ sub build_feed {
return $feed->as_xml;
}

sub _format_release_entries {
my ( $self, $releases ) = @_;
my @release_data;
foreach my $item ( @{$releases} ) {
$item->{link} = join( '/',
'https://metacpan.org', 'release',
$item->{author}, $item->{name} );
$item->{name} = "$item->{author} has released $item->{name}";
push( @release_data, $item );
}
return \@release_data;
}

sub _format_favorite_entries {
my ( $self, $author, $data ) = @_;
my @fav_data;
foreach my $fav ( @{$data} ) {
$fav->{abstract}
= "$author ++ed $fav->{distribution} from $fav->{author}";
$fav->{author} = $author;
$fav->{link} = join( '/',
'https://metacpan.org', 'release', $fav->{distribution} );
$fav->{name} = "$author ++ed $fav->{distribution}";
push( @fav_data, $fav );
}
return \@fav_data;
}

sub end : Private {
my ( $self, $c ) = @_;
$c->res->content_type('application/rss+xml; charset=UTF-8');
Expand Down
7 changes: 7 additions & 0 deletions root/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@
</li>
</ul>
<!-- End left content -->

<div class="content">
<div id="feed_subscription" class="page-header">
<p>Activity for <% author.name %> (<% author.pauseid %>)</p>
<i class="fa fa-rss fa-2x">
<a href="/feed/author/<% author.pauseid %>"></a>
</i>
</div>
<div class="visible-xs inline-author-pic"><% INCLUDE inc/author-pic.html author = author %></div>
<% INCLUDE inc/release-table.html releases = aggregated, header = 1, tablesorter = 1, table_id = "author_releases" %>
<% INCLUDE inc/favorite-table.html favorites = faves, author = 1 tablesorter = 1 %>
Expand Down
5 changes: 5 additions & 0 deletions root/inc/release-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<span class="glyphicon glyphicon-star black"></span>Rate this distribution
</a>
</li>
<li>
<a href="/feed/distribution/<% release.distribution %>">
<i class="fa fa-rss-square fa-fw black" id="rss-subscription"></i>Subscribe this distribution
</a>
</li>
<li>
<form action="/search">
<input type="hidden" name="q" value="dist:<% release.distribution %>">
Expand Down
2 changes: 1 addition & 1 deletion root/pod.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<% INCLUDE inc/breadcrumbs.html plussers_div = plusser_authors%>

<ul class="nav nav-list slidepanel" id="pod-navlist" itemscope itemtype="http://schema.org/SoftwareApplication">
<ul class="nav nav-list slidepanel" itemscope itemtype="http://schema.org/SoftwareApplication">
<li class="visible-xs">
<% INCLUDE mobile/toolbar-search-form.html %>
</li>
Expand Down
6 changes: 6 additions & 0 deletions root/recent.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
%>

<div class="content">
<div id="feed_subscription" class="page-header">
<p>Recent Uploads</p>
<i class="fa fa-rss fa-2x">
<a href="/feed/recent"></a>
</i>
</div>
<%-
MoY = [undef, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
DoW = [undef, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
Expand Down
4 changes: 4 additions & 0 deletions root/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,8 @@ div.qtip-github table th {

.news_feed {
float: right;
}

#icon-rss {
background: url('/static/icons/icon-rss.png');
}
Binary file added root/static/icons/icon-rss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added root/static/icons/rss_feed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion root/static/less/account.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
padding-left: 0px !important;
}


#account-profile {
.form-group:after {
clear: both !important;
Expand Down
26 changes: 26 additions & 0 deletions root/static/less/author.less
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,29 @@
}
}
}

#feed_subscription {
&.page-header {
margin: 0 0 5px;
font-weight: bold;
margin-left: 5px;
}

p {
font-size: 16px;
display: inline;
}

a {
display: inline;
width: 20px;
height: 20px;
padding-right: 20px;
float: right;
}

.fa {
float: right;
margin-right: -15px;
}
}
10 changes: 5 additions & 5 deletions root/static/less/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
font-size: 14px;
line-height: 20px;
margin-bottom: 0;
padding: 4px 12px;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;



&:hover,
&:focus {
background-color: #e6e6e6;
text-decoration: none;
background-image: none;
background-color: #e6e6e6;
text-decoration: none;
background-image: none;
}
}

Expand Down
5 changes: 3 additions & 2 deletions root/static/less/nav-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ul.nav-list.box-right {

.nav > li {
line-height: 20px;
width: inherit;
}

.nav-list > li > a,
Expand Down Expand Up @@ -100,6 +101,6 @@ ul.nav-list.box-right {
line-height: 25px;
}

#pod-navlist li {
.left-toolbar li {
width: 180px;
}
}
1 change: 1 addition & 0 deletions root/static/less/responsive.less
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@

.home input.home-search-input {
position: relative;
right: 5px;
width: 93%;
font-size: 1.4em;
}
Expand Down
88 changes: 49 additions & 39 deletions root/static/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
@screen-sm-min: (@screen-xs + 1);

h1, .h1, h2, .h2, h3, .h3 {
line-height: 35px;
line-height: 35px;
}

.black {
color: @black;
color: @black;
}

.border-radius(@radius) {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}

.collapse .navbar-collapse {
Expand All @@ -61,10 +61,15 @@ h1, .h1, h2, .h2, h3, .h3 {

input#search-input {
font-size: 16px;
height: 30px;
}

.home {
padding: 40px 0 50px;
}

.home .btn {
font-size: 1.2em;
font-size: 1.2em;
}

.home input {
Expand Down Expand Up @@ -125,80 +130,85 @@ body {
}

#map {
margin-right: 200px !important;
margin-right: 200px !important;
}

#map img {
max-width: none;
}

.smaller {
font-size: 1.0em;
line-height: 2.5em;
font-size: 1.0em;
line-height: 2.5em;
}

.btn.btn-slidepanel {
border-radius: 2px;
padding: 1px 4px 5px 4px;
margin-top: 3px;
border-radius: 2px;
padding: 1px 4px 5px 4px;
margin-top: 3px;
}

.table.tablesorter th {
padding-right: 20px;
padding-right: 20px;
}

.container-top {
padding: 0 10px 10px 10px;
padding: 0 10px 10px 10px;
}

.head-small-logo {
width: 200px;
width: 200px;
}

.main-content {
margin-bottom: 60px;
margin-top: 25px;
line-height: 20px;
margin-bottom: 60px;
margin-top: 25px;
line-height: 20px;
}

#lab {
margin-top: -25px;
margin-bottom: 50px;
margin-top: -25px;
margin-bottom: 50px;
}

.tool-bar-form {
margin-top: 2px;
margin-bottom: 10px;
height: 30px;
width: 165px !important;
margin-top: 2px;
margin-bottom: 10px;
height: 30px;
width: 165px !important;
}

li button.dependencies-graph {
padding: 0;
font-size: inherit;
background: none !important;
background-image: none;
border: none;
color: @linkColor !important;
padding: 0;
font-size: inherit;
background: none !important;
background-image: none;
border: none;
color: @linkColor !important;
}

.top-content {
padding-bottom: 10px;
padding-bottom: 10px;
}

.row-fluid {
padding-bottom: 10px;
padding-bottom: 10px;
}

.footer {
.sponsor-logo {
border: none;
float: right;
width: 90%;
padding: 0px;
}
.sponsor-logo {
border: none;
float: right;
width: 90%;
padding: 0px;
}
}

.ui-tooltip-titlebar {
height: 25px !important;
height: 25px !important;
}

#rss-subscription {
width: 1.2em;
font-size: 1.1em;
}
Loading