Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1462475: remove zone-related code
Browse files Browse the repository at this point in the history
  • Loading branch information
escattone committed Jul 11, 2018
1 parent ba61ca7 commit 5c8c135
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 1,197 deletions.
1 change: 0 additions & 1 deletion kuma/landing/views.py
Expand Up @@ -87,7 +87,6 @@ def promote_buttons(request):
Disallow: /*$translate
Disallow: /*$locales
Disallow: /*$json
Disallow: /*$styles
Disallow: /*$toc
Disallow: /*$move
Disallow: /*$quick-review
Expand Down
66 changes: 0 additions & 66 deletions kuma/settings/common.py
Expand Up @@ -749,72 +749,6 @@ def pipeline_one_scss(slug, **kwargs):
'output_filename': 'build/styles/wiki-compat-tables.css',
'template_name': 'pipeline/javascript-array.jinja',
},
'zone-addons': {
'source_filenames': (
'styles/zone-addons.scss',
),
'output_filename': 'build/styles/zone-addons.css',
},
'zone-apps': {
'source_filenames': (
'styles/zone-apps.scss',
),
'output_filename': 'build/styles/zone-apps.css',
},
'zone-archive': {
'source_filenames': (
'styles/zone-archive.scss',
),
'output_filename': 'build/styles/zone-archive.css',
},
'zone-b2g': {
'source_filenames': (
'styles/zone-b2g.scss',
),
'output_filename': 'build/styles/zone-b2g.css',
},
'zone-connect': {
'source_filenames': (
'styles/zone-connect.scss',
),
'output_filename': 'build/styles/zone-connect.css',
},
'zone-firefox': {
'source_filenames': (
'styles/zone-firefox.scss',
),
'output_filename': 'build/styles/zone-firefox.css',
},
'zone-games': {
'source_filenames': (
'styles/zone-games.scss',
),
'output_filename': 'build/styles/zone-games.css',
},
'zone-learn': {
'source_filenames': (
'styles/zone-learn.scss',
),
'output_filename': 'build/styles/zone-learn.css',
},
'zone-marketplace': {
'source_filenames': (
'styles/zone-marketplace.scss',
),
'output_filename': 'build/styles/zone-marketplace.css',
},
'zone-ten': {
'source_filenames': (
'styles/zone-ten.scss',
),
'output_filename': 'build/styles/zone-ten.css',
},
'zones': {
'source_filenames': (
'styles/zones.scss',
),
'output_filename': 'build/styles/zones.css',
},
'users': {
'source_filenames': (
'styles/users.scss',
Expand Down
50 changes: 0 additions & 50 deletions kuma/static/js/wiki-skinny.js
Expand Up @@ -16,56 +16,6 @@
$quickLinks.find('.toggleable').mozTogglers();
})();

/*
Set up the zone subnav accordion
*/
$('.subnav').each(function() {
var $subnav = $(this);
var $subnavList = $subnav.find(' > ol');
var minHeightFn = $('.zone-landing-header-preview-base').length ? setMinHeight : noop;

if (!$subnavList.length) {
return; // Exit if the subnav isn't set up properly
}

// Set the list items as togglers where needed
setupTogglers($subnavList.find('li'));

// Make them toggleable!
$subnavList.find('.toggleable').mozTogglers({
slideCallback: minHeightFn
});

// Try to find the current page in the list, if found, open it
// Need to keep track of the elements we've found so they aren't found twice
var used = [];
var $selected = $subnavList.find('a[href$="' + doc.location.pathname + '"]');
$selected.each(function() {
var self = this;
var $togglers = $(this).parents('.toggleable').find('.toggler');

$togglers.each(function() {
if ($.contains($(this).parent('li').get(0), self) && used.indexOf(this) === -1) {
$(this).trigger('mdn:click');
used.push(this);
}
});
}).parent().addClass('current');

// Mark this is an accordion so the togglers open/close properly
$subnavList.addClass('accordion');

function noop(){}
function setMinHeight() {
if ($('.zone-landing-header-preview-base').css('position') === 'absolute') {
$('.wiki-main-content').css('min-height', $subnav.height());
}
}

minHeightFn();
});


/*
Subscribe / unsubscribe to an article
*/
Expand Down
50 changes: 0 additions & 50 deletions kuma/static/js/wiki.js
Expand Up @@ -16,56 +16,6 @@
$quickLinks.find('.toggleable').mozTogglers();
})();

/*
Set up the zone subnav accordion
*/
$('.subnav').each(function() {
var $subnav = $(this);
var $subnavList = $subnav.find(' > ol');
var minHeightFn = $('.zone-landing-header-preview-base').length ? setMinHeight : noop;

if (!$subnavList.length) {
return; // Exit if the subnav isn't set up properly
}

// Set the list items as togglers where needed
setupTogglers($subnavList.find('li'));

// Make them toggleable!
$subnavList.find('.toggleable').mozTogglers({
slideCallback: minHeightFn
});

// Try to find the current page in the list, if found, open it
// Need to keep track of the elements we've found so they aren't found twice
var used = [];
var $selected = $subnavList.find('a[href$="' + doc.location.pathname + '"]');
$selected.each(function() {
var self = this;
var $togglers = $(this).parents('.toggleable').find('.toggler');

$togglers.each(function() {
if ($.contains($(this).parent('li').get(0), self) && used.indexOf(this) === -1) {
$(this).trigger('mdn:click');
used.push(this);
}
});
}).parent().addClass('current');

// Mark this is an accordion so the togglers open/close properly
$subnavList.addClass('accordion');

function noop(){}
function setMinHeight() {
if ($('.zone-landing-header-preview-base').css('position') === 'absolute') {
$('.wiki-main-content').css('min-height', $subnav.height());
}
}

minHeightFn();
});


/*
Subscribe / unsubscribe to an article
*/
Expand Down
7 changes: 1 addition & 6 deletions kuma/wiki/admin.py
Expand Up @@ -24,7 +24,7 @@
from .decorators import check_readonly
from .forms import RevisionAkismetSubmissionAdminForm
from .models import (Document, DocumentDeletionLog, DocumentSpamAttempt,
DocumentTag, DocumentZone, EditorToolbar, Revision,
DocumentTag, EditorToolbar, Revision,
RevisionAkismetSubmission, RevisionIP)


Expand Down Expand Up @@ -378,11 +378,6 @@ class DocumentTagAdmin(admin.ModelAdmin):
ordering = ('name',)


@admin.register(DocumentZone)
class DocumentZoneAdmin(admin.ModelAdmin):
raw_id_fields = ('document',)


@admin.register(DocumentSpamAttempt)
class DocumentSpamAttemptAdmin(admin.ModelAdmin):
list_display = [
Expand Down
40 changes: 7 additions & 33 deletions kuma/wiki/jinja2/wiki/document.html
@@ -1,7 +1,7 @@
{% extends "wiki/base.html" %}
{% block title %}{{ page_title(document.title + seo_parent_title) }}{% endblock %}

{% from "wiki/includes/document_macros.html" import build_document_crumbs, get_document_quick_links, get_document_subnav, document_watch, contributor_links with context %}
{% from "wiki/includes/document_macros.html" import build_document_crumbs, get_document_quick_links, document_watch, contributor_links with context %}
{% from "wiki/includes/buttons.html" import get_document_buttons with context %}
{% from "wiki/includes/approvals.html" import get_approvals_html with context %}

Expand All @@ -20,11 +20,7 @@
{% set approvals_html = get_approvals_html(document, request.user) %}
{% endif %}

{% set nearest_zone = document.nearest_zone %}
{% set is_zone = nearest_zone %}
{% set is_zone_root = document.is_zone_root %}

{% set show_left = zone_subnav_html or quick_links_html or approvals_html %}
{% set show_left = quick_links_html or approvals_html %}

{% set buttons = get_document_buttons(document, help_link, other_translations) %}
{% set crumbs = build_document_crumbs(document) %}
Expand All @@ -43,20 +39,13 @@
{%- endif -%}
{% endblock %}

{% block bodyclass %}document {% if is_zone %}zone{% endif %} {% if is_zone_root %}zone-landing{% endif %}{% endblock %}
{% block bodyclass %}document{% endblock %}
{% block body_attributes %}data-slug="{{ document.slug }}" contextmenu="edit-history-menu" data-search-url="{{ search_url }}"{% endblock body_attributes %}

{% block main_content_id %}document-main{% endblock %}

{% block site_css %}
{{ super() }}
{% if nearest_zone %}
{% if nearest_zone.css_slug %}
{% stylesheet 'zone-' + nearest_zone.css_slug %}
{% else %}
{% stylesheet 'zones' %}
{% endif %}
{% endif %}
{% endblock %}

{% block extrahead %}
Expand Down Expand Up @@ -118,14 +107,6 @@
</div>

<div class="document-title">
{% if is_zone_root %}
<!-- zone image -->
<span class="zone-parent"></span>
{% elif is_zone %}
<!-- zone image, link to zone root -->
<a class="zone-parent" href="{{ nearest_zone.document.get_absolute_url() }}">{{ nearest_zone.document.title }}</a>
{% endif %}

<h1>{{ document.title }}</h1>
</div>
</div>
Expand All @@ -144,7 +125,7 @@ <h1>{{ document.title }}</h1>

{% block content %}

<div class="wiki-main-content" {% if not is_zone %}id="document-main"{% endif %}><div class="center">
<div class="wiki-main-content" id="document-main"><div class="center">
<!-- start the main content container -->
<div id="wiki-column-container" class="{% if show_left %}wiki-left-present{% else %}wiki-left-closed wiki-left-none{% endif %}">

Expand Down Expand Up @@ -271,18 +252,11 @@ <h2 class="offscreen">{{ _('Document Tags and Contributors') }}</h2>
</div>

{% if show_left %}
<!-- quick links and zone subnav strip -->
<!-- quick links and approvals strip -->
<div id="wiki-left" class="column-strip wiki-column">

{% if not is_zone_root %}
<!-- crumbs -->
{{ crumbs }}
{% endif %}

{% if zone_subnav_html %}
<!-- zone subnav -->
{{ get_document_subnav(zone_subnav_html) }}
{% endif %}
<!-- crumbs -->
{{ crumbs }}

{% if quick_links_html %}
<!-- quick links -->
Expand Down
7 changes: 0 additions & 7 deletions kuma/wiki/jinja2/wiki/includes/buttons.html
Expand Up @@ -101,13 +101,6 @@
<li><a href="{{ url('wiki.delete_document', document.slug) }}" rel="nofollow">{{ _('Delete this article') }}</a></li>
{% endif %}

{% set zone_links = document_zone_management_links(request.user, document) %}
{% if zone_links['change'] %}
<li><a target="_blank" href="{{ zone_links['change'] }}" rel="nofollow">{{ _('Manage content zone') }}</a></li>
{% endif %}
{% if zone_links['add'] %}
<li><a target="_blank" href="{{ zone_links['add'] }}" rel="nofollow">{{ _('Convert to content zone') }}</a></li>
{% endif %}
<li class="page-print"><a href="#" onclick="return window.print();">{{ _('Print this article') }}</a></li>
</ul>
</div>
Expand Down
8 changes: 0 additions & 8 deletions kuma/wiki/jinja2/wiki/includes/document_macros.html
Expand Up @@ -18,14 +18,6 @@
{% endif %}
{%- endmacro %}

{% macro get_document_subnav(html) %}
<nav class="zone-subnav-container" role="navigation">
<div class="subnav" id="Subnav">
{{ html|safe }}
</div>
</nav>&nbsp;
{%- endmacro %}

{% macro get_document_quick_links(html) %}
<div class="quick-links" id="quick-links">
<div class="quick-links-head">{{ _('Related Topics') }}</div>
Expand Down
52 changes: 0 additions & 52 deletions kuma/wiki/jobs.py
@@ -1,6 +1,5 @@
import collections
import random
import time

from django.conf import settings
from django.contrib.auth import get_user_model
Expand All @@ -9,57 +8,6 @@
from kuma.users.templatetags.jinja_helpers import gravatar_url


class DocumentNearestZoneJob(KumaJob):
# Allow up to three minutes to refresh the cache before assuming
# the task has failed and allowing another to be enqueued.
refresh_timeout = 180

def expiry(self, *args, **kwargs):
# Spread the cache expiration times across a random
# number of days from 1 to 10 (in units of seconds).
seconds_per_day = 24 * 60 * 60
return time.time() + random.randint(1 * seconds_per_day,
10 * seconds_per_day)

def fetch(self, pk):
"""
Find the nearest DocumentZone, if there is one, starting from this
document and going upwards via topic parents.
"""
from .models import Document, DocumentZone

# Using "admin_objects" here to get around the
# filter that excludes deleted documents.
get_parent_id = (Document.admin_objects
.values_list('parent_topic', flat=True)
.get)
while pk:
try:
return DocumentZone.objects.select_related('document').get(document=pk)
except DocumentZone.DoesNotExist:
pk = get_parent_id(pk=pk)

return self.empty()


class DocumentZoneURLRemapsJob(KumaJob):
lifetime = 60 * 60 * 3
refresh_timeout = 60

def fetch(self, locale):
from .models import DocumentZone
zones = (DocumentZone.objects.filter(document__locale=locale,
url_root__isnull=False)
.exclude(url_root=''))
remaps = [('/docs/%s' % zone.document.slug, '/%s' % zone.url_root)
for zone in zones]
return remaps

def empty(self):
# the empty result needs to be an empty list instead of None
return []


class DocumentContributorsJob(KumaJob):
"""
Given a wiki document returns a list of contributors that have recently
Expand Down

0 comments on commit 5c8c135

Please sign in to comment.