Skip to content

Commit f6e39af

Browse files
authored
Merge pull request #3380 from metacpan/leo/disable_favs
Remove favourite function - causing traffic
2 parents d248df3 + d24c29f commit f6e39af

File tree

4 files changed

+1
-96
lines changed

4 files changed

+1
-96
lines changed

lib/MetaCPAN/Web/Model/ReleaseInfo.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ sub _fetch {
7575
sub {
7676
my ($dist) = @_;
7777
return (
78-
[ favorites => $self->_favorite->by_dist($dist) ],
7978
[ plussers => $self->_favorite->find_plussers($dist) ],
8079
[ versions => $self->_release->versions($dist) ],
8180
[ distribution => $self->_distribution->get($dist) ],

root/inc/favorite.tx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
<div id="[% $release.distribution %]-fav" class="show-logged-in">
2-
<form action="/account/favorite/add" style="display: inline" method="POST">
3-
<input type="hidden" name="remove" value="0">
4-
<input type="hidden" name="release" value="[% $release.name %]">
5-
<input type="hidden" name="author" value="[% $release.author %]">
6-
<input type="hidden" name="distribution" value="[% $release.distribution %]">
7-
<button type="submit" class="favorite[% if $favorites { %] highlight[% } %]"><span>[% $favorites %]</span> ++</button>
8-
</form>
9-
</div>
10-
<div class="show-logged-out">
11-
<button class="fav-not-logged-in favorite[% if $favorites { %] highlight[% } %]"><span>[% $favorites %]</span> ++</button>
12-
</div>
1+
132
%% if $github && $repository.url {
143
<div class="star-rating">
154
<a href="[% $repository.url %]" target="_blank" class="btn btn-primary" title="View on GitHub">

root/static/js/cpan.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ require('bootstrap/js/dropdown.js');
1313
require('bootstrap/js/modal.js');
1414
require('bootstrap/js/tooltip.js');
1515

16-
function setFavTitle(button) {
17-
button.setAttribute('title', button.classList.contains('active') ? 'Remove from favorites' : 'Add to favorites');
18-
}
1916

2017
async function processUserData() {
2118
let user_data;
@@ -52,20 +49,6 @@ async function processUserData() {
5249
document.querySelector('.logged-in-icon').replaceWith(avatar);
5350
}
5451

55-
// process users current favs
56-
for (const fav of user_data.faves) {
57-
const distribution = fav.distribution;
58-
59-
// On the page... make it deltable and styled as 'active'
60-
const fav_display = document.querySelector(`#${distribution}-fav`);
61-
62-
if (fav_display) {
63-
fav_display.querySelector('input[name="remove"]').value = 1;
64-
var button = fav_display.querySelector('button');
65-
button.classList.add('active');
66-
setFavTitle(button);
67-
}
68-
}
6952
}
7053

7154
function set_page_size(selector, storage_name) {
@@ -172,10 +155,6 @@ for (const el of document.querySelectorAll('.ellipsis')) {
172155

173156
createAnchors(document.querySelectorAll('.anchors'));
174157

175-
for (const favButton of document.querySelectorAll('.breadcrumbs .favorite')) {
176-
setFavTitle(favButton);
177-
}
178-
179158
jQuery('.dropdown-toggle').dropdown(); // bootstrap
180159

181160
const toc = document.querySelector(".content .toc")
@@ -224,54 +203,6 @@ if (changes) {
224203
});
225204
}
226205

227-
for (const favForm of document.querySelectorAll('form[action="/account/favorite/add"]')) {
228-
favForm.addEventListener('submit', async e => {
229-
e.preventDefault();
230-
const formData = new FormData(favForm);
231-
const response = await fetch(favForm.action, {
232-
method: favForm.method,
233-
headers: {
234-
'Accept': 'application/json',
235-
},
236-
body: formData,
237-
});
238-
if (!response.ok) {
239-
alert("Error adding favorite!");
240-
}
241-
242-
const button = favForm.querySelector('button');
243-
button.classList.toggle('active');
244-
setFavTitle(button);
245-
const counter = button.querySelector('span');
246-
const count = counter.innerText;
247-
if (button.classList.contains('active')) {
248-
counter.innerText = count ? parseInt(count, 10) + 1 : 1;
249-
// now added let users remove
250-
favForm.querySelector('input[name="remove"]').value = 1;
251-
if (!count)
252-
button.classList.toggle('highlight');
253-
}
254-
else {
255-
// can't delete what's already deleted
256-
favForm.querySelector('input[name="remove"]').value = 0;
257-
258-
counter.textContent = parseInt(count, 10) - 1;
259-
260-
if (counter.textContent == 0) {
261-
counter.textContent = '';
262-
button.classList.toggle('highlight');
263-
}
264-
}
265-
});
266-
}
267-
268-
for (const favButton of document.querySelectorAll('.fav-not-logged-in')) {
269-
favButton.addEventListener('click', e => {
270-
e.preventDefault();
271-
alert('Please sign in to add favorites');
272-
});
273-
}
274-
275206
for (const sel of document.querySelectorAll('.select-navigator')) {
276207
sel.addEventListener('change', () => {
277208
document.location.href = sel.value;

t/controller/shared/release-info.t

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ my $rt_prefix = $model->RT_URL_PREFIX;
1616

1717
# Not all tests apply to all releases.
1818
my @optional = qw(
19-
favorited
2019
home_page
2120
repository
2221
issues
@@ -70,7 +69,6 @@ test_psgi app, sub {
7069
home_page => 0,
7170
reviews => 0,
7271
repository => 0,
73-
favorited => 0
7472
},
7573
);
7674

@@ -127,18 +125,6 @@ test_psgi app, sub {
127125
# TODO: latest version (should be where we already are)
128126
# TODO: author
129127

130-
# not in release-info.html but should be shown on both:
131-
132-
my $favs = '//*[contains-token(@class, "favorite")]';
133-
$tx->like( $favs, qr/\+\+$/, 'tag for favorites (++)' );
134-
135-
optional_test favorited => sub {
136-
ok(
137-
$tx->find_value("$favs/span") > 0,
138-
"$req_uri has been marked as favorite"
139-
);
140-
};
141-
142128
# Info about a release (either the one we're looking at or the one the module belongs to)
143129

144130
# TODO: Download

0 commit comments

Comments
 (0)