From 952eba9625c5222e1eee77f711ecb3996998bafb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 25 Apr 2012 02:20:45 -0500 Subject: Clean up mirrorlist generation form a bit Rename template since it really isn't an index of mirrors at all, and convert the form to use multiple checkboxes for both ftp/http and ipv4/ipv6 selection. Signed-off-by: Dan McGee --- mirrors/views.py | 18 ++++++++++-- sitestatic/archweb.css | 10 +++++++ templates/mirrors/index.html | 44 ------------------------------ templates/mirrors/mirrorlist_generate.html | 44 ++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 47 deletions(-) delete mode 100644 templates/mirrors/index.html create mode 100644 templates/mirrors/mirrorlist_generate.html diff --git a/mirrors/views.py b/mirrors/views.py index 349c17d1..6c08f712 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -2,6 +2,7 @@ from operator import attrgetter, itemgetter from django import forms +from django.forms.widgets import CheckboxSelectMultiple from django.core.serializers.json import DjangoJSONEncoder from django.db.models import Q from django.http import Http404, HttpResponse @@ -19,9 +20,11 @@ class MirrorlistForm(forms.Form): country = forms.MultipleChoiceField(required=False) - protocol = forms.MultipleChoiceField(required=False) + protocol = forms.MultipleChoiceField(required=False, + widget=CheckboxSelectMultiple) ip_version = forms.MultipleChoiceField(required=False, - label="IP version", choices=(('4','IPv4'), ('6','IPv6'))) + label="IP version", choices=(('4','IPv4'), ('6','IPv6')), + widget=CheckboxSelectMultiple) use_mirror_status = forms.BooleanField(required=False) def __init__(self, *args, **kwargs): @@ -47,6 +50,15 @@ def get_countries(self): countries = [(code, COUNTRY_LOOKUP[code]) for code in country_codes] return sorted(countries, key=itemgetter(1)) + def as_div(self): + "Returns this form rendered as HTML s." + return self._html_output( + normal_row = u'%(label)s %(field)s%(help_text)s', + error_row = u'%s', + row_ender = '', + help_text_html = u' %s', + errors_on_separate_row = True) + @csrf_exempt def generate_mirrorlist(request): @@ -63,7 +75,7 @@ def generate_mirrorlist(request): else: form = MirrorlistForm() - return direct_to_template(request, 'mirrors/index.html', + return direct_to_template(request, 'mirrors/mirrorlist_generate.html', {'mirrorlist_form': form}) diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css index fdc356ff..407156f8 100644 --- a/sitestatic/archweb.css +++ b/sitestatic/archweb.css @@ -802,6 +802,16 @@ table td.country { white-space: normal; } +form#list-generator div ul { + list-style: none; + display: inline; + padding-left: 0; +} + + form#list-generator div ul li { + display: inline; + } + /* dev/TU biographies */ div#arch-bio-toc { width: 75%; diff --git a/templates/mirrors/index.html b/templates/mirrors/index.html deleted file mode 100644 index 49907b8f..00000000 --- a/templates/mirrors/index.html +++ /dev/null @@ -1,44 +0,0 @@ -{% extends "base.html" %} -{% load package_extras %} -{% block title %}Arch Linux - Pacman Mirrorlist Generator{% endblock %} - -{% block content %} -
- -

Pacman Mirrorlist Generator

- -

This page generates the most up-to-date mirrorlist possible for Arch - Linux. The data used here comes straight from the developers' internal - mirror database used to track mirror availability and tiering. There are - two main options: get a mirrorlist with every available mirror, or get a - mirrorlist tailored to your geography.

- -

Mirrorlist with all available mirrors

- -

An up-to-date mirrorlist is available containing all currently active - mirrors, optionally filtering by protocol. These URLs requires no GET or - POST parameters so they can be fetched from the command line if desired.

- -

- -

Customized by country mirrorlist

- -

The following form can generate a custom up-to-date - pacman mirrorlist based on geography and - desired protocol(s). Simply replace the contents of - /etc/pacman.d/mirrorlist with your generated list. - Additionally, the mirror status data can be incorporated into the generated - mirror list and used to pre-order the mirrors.

- -
- {{ mirrorlist_form.as_p }} -

-
-
-{% endblock %} - diff --git a/templates/mirrors/mirrorlist_generate.html b/templates/mirrors/mirrorlist_generate.html new file mode 100644 index 00000000..e6f5e28c --- /dev/null +++ b/templates/mirrors/mirrorlist_generate.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} +{% load package_extras %} +{% block title %}Arch Linux - Pacman Mirrorlist Generator{% endblock %} + +{% block content %} +
+ +

Pacman Mirrorlist Generator

+ +

This page generates the most up-to-date mirrorlist possible for Arch + Linux. The data used here comes straight from the developers' internal + mirror database used to track mirror availability and tiering. There are + two main options: get a mirrorlist with every available mirror, or get a + mirrorlist tailored to your geography.

+ +

Mirrorlist with all available mirrors

+ +

An up-to-date mirrorlist is available containing all currently active + mirrors, optionally filtering by protocol. These URLs requires no GET or + POST parameters so they can be fetched from the command line if desired.

+ +

+ +

Customized by country mirrorlist

+ +

The following form can generate a custom up-to-date + pacman mirrorlist based on geography and + desired protocol(s). Simply replace the contents of + /etc/pacman.d/mirrorlist with your generated list. + Additionally, the mirror status data can be incorporated into the generated + mirror list and used to pre-order the mirrors.

+ +
+ {{ mirrorlist_form.as_div }} +

+
+
+{% endblock %} + -- cgit v1.2.3-54-g00ecf