Skip to content

Commit

Permalink
Merge branch 'master' into oalders/remove-coderwall
Browse files Browse the repository at this point in the history
  • Loading branch information
ranguard committed Mar 30, 2016
2 parents ebe6e4b + 2f74d11 commit 2bee22e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/MetaCPAN/Middleware/Static.pm
Expand Up @@ -91,9 +91,9 @@ sub wrap {
mount '/static' => sub {
my $res = $static_app->(@_);
push @{ $res->[1] }, (
'Cache-Control' => "max-age=${hour_ttl}",
'Cache-Control' => "max-age=${day_ttl}",

'Surrogate-Control' => "max-age=${hour_ttl}",
'Surrogate-Control' => "max-age=${year_ttl}",
'Surrogate-Key' => 'assets',
);
$res;
Expand Down
16 changes: 10 additions & 6 deletions root/static/js/cpan.js
Expand Up @@ -102,6 +102,11 @@ function toggleWhatsnew() {
}
}

function setFavTitle(button) {
button.attr('title', button.hasClass('active') ? 'Remove from favorite' : 'Add to favorite');
return;
}

$(document).ready(function() {

// User customisations
Expand Down Expand Up @@ -349,11 +354,7 @@ $(document).ready(function() {
}, 1000);
});

if ($(".inline").find("button").hasClass("active")) {
$(".favorite").attr("title", "Remove from favorite");
} else {
$(".favorite").attr("title", "Add to favorite");
}
setFavTitle($('.inline').find('button'));

$('.dropdown-toggle').dropdown();

Expand Down Expand Up @@ -502,7 +503,9 @@ function showUserData(fav_data) {
// On the page... make it deltable and styled as 'active'
if (MetaCPAN.favs_to_check[distribution]) {
$('#' + distribution + '-fav input[name="remove"]').val(1);
$('#' + distribution + '-fav button').addClass('active');
var button = $('#' + distribution + '-fav button');
button.addClass('active');
setFavTitle(button);
}

});
Expand Down Expand Up @@ -534,6 +537,7 @@ function favDistribution(form) {
success: function() {
var button = form.find('button');
button.toggleClass('active');
setFavTitle(button);
var counter = button.find('span');
var count = counter.text();
if (button.hasClass('active')) {
Expand Down
2 changes: 1 addition & 1 deletion t/fastly_headers.t
Expand Up @@ -11,7 +11,7 @@ test_psgi app, sub {
is( $res->code, 200, 'code 200' );
is( $res->header('Set-Cookie'), undef, 'No cookie' );
is( $res->header('Surrogate-Control'),
'max-age=3600', 'Image Surrogate-Control' );
'max-age=31536000', 'Image Surrogate-Control as a year' );
}
};

Expand Down

0 comments on commit 2bee22e

Please sign in to comment.