Aklapper has uploaded a new change for review. https://gerrit.wikimedia.org/r/113461
Change subject: Remove Sitemap extension from Git. Was removed from server already. Also see bug 33406. ...................................................................... Remove Sitemap extension from Git. Was removed from server already. Also see bug 33406. Change-Id: I09d4cbee32462163bca2dd43596992938542abf5 --- D extensions/Sitemap/Config.pm D extensions/Sitemap/Extension.pm D extensions/Sitemap/lib/Constants.pm D extensions/Sitemap/lib/Util.pm D extensions/Sitemap/robots.txt D extensions/Sitemap/template/en/default/hook/global/header-additional_header.html.tmpl D extensions/Sitemap/template/en/default/hook/global/messages-messages.html.tmpl 7 files changed, 0 insertions(+), 438 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/bugzilla/modifications refs/changes/61/113461/1 diff --git a/extensions/Sitemap/Config.pm b/extensions/Sitemap/Config.pm deleted file mode 100644 index 2467b59..0000000 --- a/extensions/Sitemap/Config.pm +++ /dev/null @@ -1,35 +0,0 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Sitemap Bugzilla Extension. -# -# The Initial Developer of the Original Code is Everything Solved, Inc. -# Portions created by the Initial Developer are Copyright (C) 2010 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Max Kanat-Alexander <[email protected]> - -package Bugzilla::Extension::Sitemap; -use strict; - -use constant NAME => 'Sitemap'; - -use constant REQUIRED_MODULES => [ - { - package => 'Search-Sitemap', - module => 'Search::Sitemap', - version => 0, - } -]; - -__PACKAGE__->NAME; diff --git a/extensions/Sitemap/Extension.pm b/extensions/Sitemap/Extension.pm deleted file mode 100644 index 65cd7dd..0000000 --- a/extensions/Sitemap/Extension.pm +++ /dev/null @@ -1,173 +0,0 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Sitemap Bugzilla Extension. -# -# The Initial Developer of the Original Code is Everything Solved, Inc. -# Portions created by the Initial Developer are Copyright (C) 2010 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Max Kanat-Alexander <[email protected]> - -package Bugzilla::Extension::Sitemap; -use strict; -use base qw(Bugzilla::Extension); - -our $VERSION = '1.0'; - -use Bugzilla::Extension::Sitemap::Constants; -use Bugzilla::Extension::Sitemap::Util; -use Bugzilla::Constants qw(bz_locations); -use Bugzilla::Util qw(correct_urlbase get_text); - -use DateTime; -use File::Copy; -use IO::File; - -######### -# Pages # -######### - -sub template_before_process { - my ($self, $args) = @_; - my ($vars, $file) = @$args{qw(vars file)}; - - return if !$file eq 'global/header.html.tmpl'; - return unless (exists $vars->{bug} or exists $vars->{bugs}); - my $bugs = exists $vars->{bugs} ? $vars->{bugs} : [$vars->{bug}]; - return if !ref $bugs eq 'ARRAY'; - - foreach my $bug (@$bugs) { - if (!bug_is_ok_to_index($bug)) { - $vars->{sitemap_noindex} = 1; - last; - } - } -} - -sub page_before_template { - my ($self, $args) = @_; - my $page = $args->{page_id}; - - if ($page =~ m{^sitemap/sitemap\.}) { - _page_sitemap(); - } -} - -sub _page_sitemap { - my $map = generate_sitemap(); - print Bugzilla->cgi->header('text/xml'); - print $map->xml; - exit; -} - -################ -# Installation # -################ - -sub install_before_final_checks { - my ($self) = @_; - if (!correct_urlbase()) { - print STDERR get_text('sitemap_no_urlbase'), "\n"; - return; - } - if (Bugzilla->params->{'requirelogin'}) { - print STDERR get_text('sitemap_requirelogin'), "\n"; - return; - } - $self->_fix_robots_txt(); - _do_ping(); -} - -sub _fix_robots_txt { - my ($self) = @_; - my $cgi_path = bz_locations()->{'cgi_path'}; - my $robots_file = "$cgi_path/robots.txt"; - my $current = new IO::File("$cgi_path/robots.txt", 'r'); - if (!$current) { - warn "$robots_file: $!"; - return; - } - - my $current_contents; - { local $/; $current_contents = <$current> } - $current->close(); - - return if $current_contents =~ m{^Allow: \/\*show_bug\.cgi}ms; - my $backup_name = "$cgi_path/robots.txt.old"; - print get_text('sitemap_fixing_robots', { current => $robots_file, - backup => $backup_name }), "\n"; - rename $robots_file, $backup_name or die "backup failed: $!"; - my $new_file = $self->package_dir . '/robots.txt'; - copy($new_file, $robots_file) or die "$new_file -> $robots_file: $!"; -} - -sub _do_ping { - my $done_filename = bz_locations()->{'datadir'} . '/sitemaps_done'; - if (-e $done_filename) { - my $done = new IO::File($done_filename, 'r'); - if ($done) { - my $done_content = <$done>; - chomp($done_content); - $done->close(); - return if $done_content eq correct_urlbase(); - } - else { - warn "$done_filename: $!"; - } - } - - print get_text('sitemap_pinging'), "\n"; - - require Search::Sitemap::Ping; - my $url = correct_urlbase() . SITEMAP_URL; - my $ping = Search::Sitemap::Ping->new($url); - my $failures = 0; - foreach my $engine ($ping->engines) { - $engine->add_trigger('success', \&_ping_success); - $engine->add_trigger('failure', sub { _ping_failure(\$failures, @_) }); - } - $ping->submit(); - - if ($failures) { - print get_text('sitemap_some_failures'), "\n\n"; - } - else { - print get_text('sitemap_no_failures', { done_file => $done_filename }), - "\n\n"; - my $done = new IO::File($done_filename, '>') or die "$done_filename: $!"; - print $done correct_urlbase(); - } -} - -sub _ping_success { - my ($engine) = @_; - _ping_message($engine, 'sitemap_ok'); -} - -sub _ping_failure { - my ($failures, $engine) = @_; - $$failures++; - _ping_message($engine, 'sitemap_failed'); -} - -sub _ping_message { - my ($engine, $message) = @_; - my $type = ref $engine; - $type =~ /::(\w+)$/; - my $name = $1; - my $result = get_text($message, { engine => $name }); - $name = sprintf('%10s', $name); - print "$name$result\n"; -} -__PACKAGE__->NAME; diff --git a/extensions/Sitemap/lib/Constants.pm b/extensions/Sitemap/lib/Constants.pm deleted file mode 100644 index ad37589..0000000 --- a/extensions/Sitemap/lib/Constants.pm +++ /dev/null @@ -1,42 +0,0 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Sitemap Bugzilla Extension. -# -# The Initial Developer of the Original Code is Everything Solved, Inc. -# Portions created by the Initial Developer are Copyright (C) 2010 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Max Kanat-Alexander <[email protected]> - -package Bugzilla::Extension::Sitemap::Constants; -use strict; -use base qw(Exporter); -our @EXPORT = qw( - SITEMAP_MAX - SITEMAP_DELAY - SITEMAP_URL -); - -# This is the largest number of entries that can be in a sitemap, -# per the sitemaps.org standard. -use constant SITEMAP_MAX => 50_000; - -# We only show bugs that are 12 hours old, because if somebody -# files a bug that's a security bug but doesn't protect it, we -# want to give them time to fix that. -use constant SITEMAP_DELAY => 12; - -use constant SITEMAP_URL => 'page.cgi?id=sitemap/sitemap.xml'; - -1; diff --git a/extensions/Sitemap/lib/Util.pm b/extensions/Sitemap/lib/Util.pm deleted file mode 100644 index 37e2936..0000000 --- a/extensions/Sitemap/lib/Util.pm +++ /dev/null @@ -1,99 +0,0 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Sitemap Bugzilla Extension. -# -# The Initial Developer of the Original Code is Everything Solved, Inc. -# Portions created by the Initial Developer are Copyright (C) 2010 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Max Kanat-Alexander <[email protected]> - -package Bugzilla::Extension::Sitemap::Util; -use strict; -use base qw(Exporter); -our @EXPORT = qw(generate_sitemap bug_is_ok_to_index); - -use Bugzilla::Extension::Sitemap::Constants; -use Bugzilla::Util qw(correct_urlbase datetime_from); - -use Scalar::Util qw(blessed); - -# Instead of doing "use Search::Sitemap", we "require" it when we need it. -# This is because Search::Sitemap uses Moose, and we don't want it -# slowing down normal mod_cgi page loads. - -sub too_young_date { - my $hours_ago = DateTime->now(time_zone => Bugzilla->local_timezone); - $hours_ago->subtract(hours => SITEMAP_DELAY); - return $hours_ago; -} - -sub bug_is_ok_to_index { - my ($bug) = @_; - return 1 unless blessed($bug) && $bug->isa('Bugzilla::Bug'); - my $creation_ts = datetime_from($bug->creation_ts); - return ($creation_ts lt too_young_date()) ? 1 : 0; -} - -# We put two things in the Sitemap: a list of Browse links for products, -# and links to bugs. -sub generate_sitemap { - require Search::Sitemap; - - # Sitemaps must never contain private data. - Bugzilla->logout_request(); - my $user = Bugzilla->user; - my $products = $user->get_accessible_products; - - my $num_bugs = SITEMAP_MAX - scalar(@$products); - # We do this date math outside of the database because databases - # usually do better with a straight comparison value. - my $hours_ago = too_young_date(); - my $since = $hours_ago->ymd . ' ' . $hours_ago->hms; - - # We don't use Bugzilla::Bug objects, because this could be a tremendous - # amount of data, and we only want a little. Also, we only display - # bugs that are not in any group. We show the last $num_bugs - # most-recently-updated bugs. - my $dbh = Bugzilla->dbh; - my $bug_data = $dbh->selectall_arrayref( - 'SELECT bugs.bug_id, bugs.delta_ts - FROM bugs - LEFT JOIN bug_group_map ON bugs.bug_id = bug_group_map.bug_id - WHERE bug_group_map.bug_id IS NULL AND creation_ts < ? - ORDER BY delta_ts DESC ' - . $dbh->sql_limit($num_bugs), undef, $hours_ago); - - my $bug_url = correct_urlbase() . 'show_bug.cgi?id='; - my $product_url = correct_urlbase() . 'describecomponents.cgi?product='; - my $map = Search::Sitemap->new(); - foreach my $product (@$products) { - $map->add( - loc => $product_url . $product->name, - changefreq => 'daily', - priority => '0.4', - ); - } - foreach my $bug_row (@$bug_data) { - my ($id, $delta_ts) = @$bug_row; - $map->add( - loc => $bug_url . $id, - lastmod => datetime_from($delta_ts, 'UTC')->iso8601 . 'Z', - ); - } - - return $map; -} - -1; diff --git a/extensions/Sitemap/robots.txt b/extensions/Sitemap/robots.txt deleted file mode 100644 index 75b83b7..0000000 --- a/extensions/Sitemap/robots.txt +++ /dev/null @@ -1,8 +0,0 @@ -User-agent: * -Disallow: /*.cgi -Disallow: /*show_bug.cgi*ctype=* -Allow: / -Allow: /*index.cgi -Allow: /*show_bug.cgi -Allow: /*describecomponents.cgi -Allow: /*page.cgi diff --git a/extensions/Sitemap/template/en/default/hook/global/header-additional_header.html.tmpl b/extensions/Sitemap/template/en/default/hook/global/header-additional_header.html.tmpl deleted file mode 100644 index 682f609..0000000 --- a/extensions/Sitemap/template/en/default/hook/global/header-additional_header.html.tmpl +++ /dev/null @@ -1,23 +0,0 @@ -[%# The contents of this file are subject to the Mozilla Public - # License Version 1.1 (the "License"); you may not use this file - # except in compliance with the License. You may obtain a copy of - # the License at http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS - # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - # implied. See the License for the specific language governing - # rights and limitations under the License. - # - # The Initial Developer of the Original Code is Everything Solved, Inc. - # Portions created by Everything Solved are Copyright (C) 2010 - # Everything Solved. All Rights Reserved. - # - # The Original Code is the Bugzilla Sitemap Extension. - # - # Contributor(s): - # Max Kanat-Alexander <[email protected]> - #%] - -[% SET meta_robots = ['noarchive'] %] -[% meta_robots.push('noindex') IF sitemap_noindex %] -<meta name="robots" content="[% meta_robots.join(',') FILTER html %]"> diff --git a/extensions/Sitemap/template/en/default/hook/global/messages-messages.html.tmpl b/extensions/Sitemap/template/en/default/hook/global/messages-messages.html.tmpl deleted file mode 100644 index f2fb5cb..0000000 --- a/extensions/Sitemap/template/en/default/hook/global/messages-messages.html.tmpl +++ /dev/null @@ -1,58 +0,0 @@ -[%# The contents of this file are subject to the Mozilla Public - # License Version 1.1 (the "License"); you may not use this file - # except in compliance with the License. You may obtain a copy of - # the License at http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS - # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - # implied. See the License for the specific language governing - # rights and limitations under the License. - # - # The Initial Developer of the Original Code is Everything Solved, Inc. - # Portions created by Everything Solved are Copyright (C) 2010 - # Everything Solved. All Rights Reserved. - # - # The Original Code is the Bugzilla Sitemap Extension. - # - # Contributor(s): - # Max Kanat-Alexander <[email protected]> - #%] - -[% IF message_tag == "sitemap_fixing_robots" %] - Replacing [% current FILTER html %]. (The old version will be saved - as "[% backup FILTER html %]". You can delete the old version if you - do not need its contents.) - -[% ELSIF message_tag == "sitemap_pinging" %] - Pinging search engines to let them know about our sitemap: - -[% ELSIF message_tag == "sitemap_requirelogin" %] - Not updating search engines with your sitemap, because you have the - "requirelogin" parameter turned on, and so search engines will not be - able to access your sitemap. - -[% ELSIF message_tag == "sitemap_no_urlbase" %] - You have not yet set the "urlbase" parameter. We cannot update - search engines and inform them about your sitemap without a - urlbase. Please set the "urlbase" parameter and re-run - checksetup.pl. - -[% ELSIF message_tag == "sitemap_ok" %] - : OK - -[% ELSIF message_tag == "sitemap_failed" %] - : FAILED - -[% ELSIF message_tag == "sitemap_some_failures" %] - There were some failures while submitting the sitemap to certain - search engines. If you wait a few minutes and run checksetup again, - we will attempt to submit your sitemap again. - -[% ELSIF message_tag == "sitemap_no_failures" %] - Sitemap submission to search engines complete! Submission will - NOT be done again by checksetup.pl unless you change your - "urlbase", "sslbase", or "ssl_redirect" parameters. If you do change - any of those parameters, you should re-run checksetup.pl, and it will - re-submit your sitemap. - -[% END %] -- To view, visit https://gerrit.wikimedia.org/r/113461 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I09d4cbee32462163bca2dd43596992938542abf5 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/bugzilla/modifications Gerrit-Branch: master Gerrit-Owner: Aklapper <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
