diff options
-rw-r--r-- | packages/urls.py | 1 | ||||
-rw-r--r-- | packages/utils.py | 2 | ||||
-rw-r--r-- | packages/views/display.py | 2 | ||||
-rw-r--r-- | packages/views/search.py | 42 | ||||
-rw-r--r-- | sitemaps.py | 20 | ||||
-rw-r--r-- | sitestatic/archweb.css | 52 | ||||
-rw-r--r-- | sitestatic/konami.min.js | 4 | ||||
-rw-r--r-- | sitestatic/konami.pack.js | 1 | ||||
-rw-r--r-- | templates/news/paginator.html | 10 | ||||
-rw-r--r-- | templates/packages/search.html | 3 | ||||
-rw-r--r-- | templates/packages/search_paginator.html | 8 | ||||
-rw-r--r-- | templates/public/index.html | 19 | ||||
-rw-r--r-- | templates/releng/result_list.html | 2 | ||||
-rw-r--r-- | todolists/views.py | 3 |
14 files changed, 62 insertions, 107 deletions
diff --git a/packages/urls.py b/packages/urls.py index 9a151b4b..4e2e2638 100644 --- a/packages/urls.py +++ b/packages/urls.py @@ -24,7 +24,6 @@ urlpatterns = patterns('packages.views', (r'^update/$', 'update'), (r'^$', SearchListView.as_view(), {}, 'packages-search'), - (r'^(?P<page>\d+)/$', SearchListView.as_view()), (r'^search/json/$', 'search_json'), (r'^differences/$', 'arch_differences', {}, 'packages-differences'), diff --git a/packages/utils.py b/packages/utils.py index 49aeb8ce..ef6311eb 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -79,7 +79,7 @@ def get_split_packages_info(): pkgnames = Package.objects.values('pkgname') split_pkgs = Package.objects.exclude(pkgname=F('pkgbase')).exclude( pkgbase__in=pkgnames).values('pkgbase', 'repo', 'arch').annotate( - last_update=Max('last_update')) + last_update=Max('last_update')).order_by().distinct() all_arches = Arch.objects.in_bulk({s['arch'] for s in split_pkgs}) all_repos = Repo.objects.in_bulk({s['repo'] for s in split_pkgs}) for split in split_pkgs: diff --git a/packages/views/display.py b/packages/views/display.py index 497c8d48..fcf8fdea 100644 --- a/packages/views/display.py +++ b/packages/views/display.py @@ -104,6 +104,8 @@ def redirect_agnostic(request, name, repo, arch): def redirect_to_search(request, name, repo, arch): + if request.GET.get('q'): + name = request.GET.get('q') pkg_data = [ ('arch', arch.lower()), ('repo', repo.lower()), diff --git a/packages/views/search.py b/packages/views/search.py index 9cb5f38d..0362602e 100644 --- a/packages/views/search.py +++ b/packages/views/search.py @@ -1,6 +1,4 @@ -from datetime import datetime import json -from pytz import utc from django import forms from django.contrib.auth.models import User @@ -14,26 +12,6 @@ from ..models import PackageRelation from ..utils import attach_maintainers, PackageJSONEncoder -def coerce_limit_value(value): - if not value: - return None - if value == 'all': - # negative value indicates show all results - return -1 - value = int(value) - if value < 0: - raise ValueError - return value - -class LimitTypedChoiceField(forms.TypedChoiceField): - def valid_value(self, value): - try: - coerce_limit_value(value) - return True - except (ValueError, TypeError): - return False - - class PackageSearchForm(forms.Form): repo = forms.MultipleChoiceField(required=False) arch = forms.MultipleChoiceField(required=False) @@ -46,11 +24,6 @@ class PackageSearchForm(forms.Form): flagged = forms.ChoiceField( choices=[('', 'All')] + make_choice(['Flagged', 'Not Flagged']), required=False) - limit = LimitTypedChoiceField( - choices=make_choice([50, 100, 250]) + [('all', 'All')], - coerce=coerce_limit_value, - required=False, - initial=50) def __init__(self, *args, **kwargs): show_staging = kwargs.pop('show_staging', False) @@ -119,6 +92,7 @@ def parse_form(form, packages): class SearchListView(ListView): template_name = "packages/search.html" + paginate_by = 100 sort_fields = ("arch", "repo", "pkgname", "pkgbase", "compressed_size", "installed_size", "build_date", "last_update", "flag_date") @@ -145,19 +119,11 @@ class SearchListView(ListView): # Form had errors so don't return any results return Package.objects.none() - def get_paginate_by(self, queryset): - limit = 50 - if self.form.is_valid(): - asked_limit = self.form.cleaned_data['limit'] - if asked_limit and asked_limit < 0: - limit = None - elif asked_limit: - limit = asked_limit - return limit - def get_context_data(self, **kwargs): context = super(SearchListView, self).get_context_data(**kwargs) - context['current_query'] = self.request.GET.urlencode() + query_params = self.request.GET.copy() + query_params.pop('page', None) + context['current_query'] = query_params.urlencode() context['search_form'] = self.form return context diff --git a/sitemaps.py b/sitemaps.py index b079d8b7..d206a1b6 100644 --- a/sitemaps.py +++ b/sitemaps.py @@ -11,17 +11,27 @@ from releng.models import Release class PackagesSitemap(Sitemap): - changefreq = "weekly" - priority = "0.5" - def items(self): - return Package.objects.normal().filter(repo__staging=False).only( + return Package.objects.normal().only( 'pkgname', 'last_update', 'files_last_update', - 'repo__name', 'arch__name').order_by() + 'repo__name', 'repo__testing', 'repo__staging', + 'arch__name').order_by() def lastmod(self, obj): return obj.last_update + def changefreq(self, obj): + if obj.repo.testing or obj.repo.staging: + return "daily" + return "weekly" + + def priority(self, obj): + if obj.repo.testing: + return "0.4" + if obj.repo.staging: + return "0.1" + return "0.5" + class PackageFilesSitemap(PackagesSitemap): changefreq = "weekly" diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css index dcc964ee..a0dfb2ec 100644 --- a/sitestatic/archweb.css +++ b/sitestatic/archweb.css @@ -1002,19 +1002,30 @@ ul.admin-actions { padding-left: 1.5em; } -/* todo lists (public and private) */ -.todo-table .complete { +/* colored yes/no type values */ +.todo-table .complete, +.signoff-yes, +#key-status .signed-yes, +#releng-result .success-yes, +#release-list .available-yes { color: green; } -.todo-table .incomplete { +.todo-table .incomplete, +.signoff-no, +#key-status .signed-no, +#releng-result .success-no, +#release-list .available-no { color: red; } -.todo-table .inprogress { +.todo-table .inprogress, +.signoff-bad { color: darkorange; } + +/* todo lists (public and private) */ .todo-info { margin: 0; color: #999; } @@ -1036,18 +1047,9 @@ ul.signoff-list { } .signoff-yes { - color: green; font-weight: bold; } -.signoff-no { - color: red; -} - -.signoff-bad { - color: darkorange; -} - .signoff-disabled { color: gray; } @@ -1071,30 +1073,6 @@ ul.signoff-list { position: relative; top: -0.9em; } -#releng-result .success-yes { - color: green; -} - -#releng-result .success-no { - color: red; -} - -#release-list .available-yes { - color: green; -} - -#release-list .available-no { - color: red; -} - -#key-status .signed-yes { - color: green; -} - -#key-status .signed-no { - color: red; -} - /* highlight current website in the navbar */ #archnavbar.anb-home ul li#anb-home a, #archnavbar.anb-packages ul li#anb-packages a, diff --git a/sitestatic/konami.min.js b/sitestatic/konami.min.js new file mode 100644 index 00000000..f69ca4ff --- /dev/null +++ b/sitestatic/konami.min.js @@ -0,0 +1,4 @@ +var Konami=function(t){var e={addEvent:function(t,e,n,i){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&(t["e"+e+n]=n,t[e+n]=function(){t["e"+e+n](window.event,i)},t.attachEvent("on"+e,t[e+n]))},input:"",pattern:"3838404037393739666513",load:function(t){this.addEvent(document,"keydown",function(n,i){return i&&(e=i),e.input+=n?n.keyCode:event.keyCode,e.input.length>e.pattern.length&&(e.input=e.input.substr(e.input.length-e.pattern.length)),e.input==e.pattern?(e.code(t),e.input="",void 0):void 0},this),this.iphone.load(t)},code:function(t){window.location=t},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:!1,capture:!1,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(t){e.code(t)},load:function(t){this.orig_keys=this.keys,e.addEvent(document,"touchmove",function(t){if(1==t.touches.length&&e.iphone.capture===!0){var n=t.touches[0] + e.iphone.stop_x=n.pageX,e.iphone.stop_y=n.pageY,e.iphone.tap=!1,e.iphone.capture=!1,e.iphone.check_direction()}}),e.addEvent(document,"touchend",function(){e.iphone.tap===!0&&e.iphone.check_direction(t)},!1),e.addEvent(document,"touchstart",function(t){e.iphone.start_x=t.changedTouches[0].pageX,e.iphone.start_y=t.changedTouches[0].pageY,e.iphone.tap=!0,e.iphone.capture=!0})},check_direction:function(t){var e=Math.abs(this.start_x-this.stop_x),n=Math.abs(this.start_y-this.stop_y),i=0>this.start_x-this.stop_x?"RIGHT":"LEFT",o=0>this.start_y-this.stop_y?"DOWN":"UP",s=e>n?i:o + s=this.tap===!0?"TAP":s,s==this.keys[0]&&(this.keys=this.keys.slice(1,this.keys.length)),0==this.keys.length&&(this.keys=this.orig_keys,this.code(t))}}} +return"string"==typeof t&&e.load(t),"function"==typeof t&&(e.code=t,e.load()),e} diff --git a/sitestatic/konami.pack.js b/sitestatic/konami.pack.js deleted file mode 100644 index bff279f9..00000000 --- a/sitestatic/konami.pack.js +++ /dev/null @@ -1 +0,0 @@ -(function(){"use strict";var a=Function("return this")(),b=function(){var a={addEvent:function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event,d)},a.attachEvent("on"+b,a[b+c]))},input:"",pattern:"3838404037393739666513",load:function(b){this.addEvent(document,"keydown",function(c,d){return d&&(a=d),a.input+=c?c.keyCode:event.keyCode,a.input.length>a.pattern.length&&(a.input=a.input.substr(a.input.length-a.pattern.length)),a.input==a.pattern?(a.code(b),a.input="",void 0):void 0},this),this.iphone.load(b)},code:function(a){window.location=a},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:!1,capture:!1,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){this.orig_keys=this.keys,a.addEvent(document,"touchmove",function(b){if(1==b.touches.length&&1==a.iphone.capture){var c=b.touches[0];a.iphone.stop_x=c.pageX,a.iphone.stop_y=c.pageY,a.iphone.tap=!1,a.iphone.capture=!1,a.iphone.check_direction()}}),a.addEvent(document,"touchend",function(){1==a.iphone.tap&&a.iphone.check_direction(b)},!1),a.addEvent(document,"touchstart",function(b){a.iphone.start_x=b.changedTouches[0].pageX,a.iphone.start_y=b.changedTouches[0].pageY,a.iphone.tap=!0,a.iphone.capture=!0})},check_direction:function(a){x_magnitude=Math.abs(this.start_x-this.stop_x),y_magnitude=Math.abs(this.start_y-this.stop_y),x=0>this.start_x-this.stop_x?"RIGHT":"LEFT",y=0>this.start_y-this.stop_y?"DOWN":"UP",result=x_magnitude>y_magnitude?x:y,result=1==this.tap?"TAP":result,result==this.keys[0]&&(this.keys=this.keys.slice(1,this.keys.length)),0==this.keys.length&&(this.keys=this.orig_keys,this.code(a))}}};return a};"undefined"!=typeof module?module.exports=b:a.Konami=b})(); diff --git a/templates/news/paginator.html b/templates/news/paginator.html index fbd0546b..57fbeb15 100644 --- a/templates/news/paginator.html +++ b/templates/news/paginator.html @@ -1,20 +1,20 @@ {% if is_paginated %} <div class="pagination"> - <p>{{paginator.count}} news items, viewing page {{page_obj.number}} of {{paginator.num_pages}}.</p> + <p>{{ paginator.count }} news items, viewing page {{ page_obj.number }} of {{ paginator.num_pages }}.</p> <p class="news-nav"> {% if page_obj.has_previous %} - <a class="prev" href="?page={{page_obj.previous_page_number}}" + <a class="prev" href="?page={{ page_obj.previous_page_number }}" title="Go to previous page">< Prev</a> {% endif %} {% for num in paginator.page_range %} {% ifequal num page_obj.number %} - <span>{{num}}</span> + <span>{{ num }}</span> {% else %} - <a href="?page={{num}}" title="Go to page {{num}}">{{num}}</a> + <a href="?page={{ num }}" title="Go to page {{ num }}">{{ num }}</a> {% endifequal %} {% endfor %} {% if page_obj.has_next %} - <a class="next" href="?page={{page_obj.next_page_number}}" + <a class="next" href="?page={{ page_obj.next_page_number }}" title="Go to next page">Next ></a> {% endif %} </p> diff --git a/templates/packages/search.html b/templates/packages/search.html index a5d52d6c..bf1eecd9 100644 --- a/templates/packages/search.html +++ b/templates/packages/search.html @@ -36,9 +36,6 @@ <div>{{ search_form.flagged.errors }} <label for="id_flagged" title="Limit results based on out-of-date status"> Flagged</label>{{ search_form.flagged }}</div> - <div>{{ search_form.limit.errors }} - <label for="id_limit" title="Select the number of results to display per page"> - Per Page</label>{{ search_form.limit }}</div> <div ><label> </label><input title="Search for packages using this criteria" type="submit" value="Search" /></div> </fieldset> diff --git a/templates/packages/search_paginator.html b/templates/packages/search_paginator.html index 362b7cb3..3c368b82 100644 --- a/templates/packages/search_paginator.html +++ b/templates/packages/search_paginator.html @@ -1,12 +1,12 @@ <div class="pkglist-stats"> {% if is_paginated %} - <p>{{paginator.count}} packages found. - Page {{page_obj.number}} of {{paginator.num_pages}}.</p> + <p>{{ paginator.count }} packages found. + Page {{ page_obj.number }} of {{ paginator.num_pages }}.</p> <div class="pkglist-nav"> <span class="prev"> {% if page_obj.has_previous %} - <a href="/packages/{{page_obj.previous_page_number}}/?{{current_query}}" + <a href="?page={{ page_obj.previous_page_number }}&{{ current_query }}" title="Go to previous page">< Prev</a> {% else %} < Prev @@ -14,7 +14,7 @@ </span> <span class="next"> {% if page_obj.has_next %} - <a href="/packages/{{page_obj.next_page_number}}/?{{current_query}}" + <a href="?page={{ page_obj.next_page_number }}&{{ current_query }}" title="Go to next page">Next ></a> {% else %} Next > diff --git a/templates/public/index.html b/templates/public/index.html index 3f88c183..abdb0277 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -211,10 +211,8 @@ <div id="konami" style="display:none;"></div> {% load cdn %}{% jquery %} -<script type="text/javascript" src="{% static "bootstrap-typeahead.min.js" %}"></script> -<script type="text/javascript" src="{% static "konami.pack.js" %}"></script> <script type="text/javascript"> -$(document).ready(function() { +function setupTypeahead() { $('#pkgsearch-field').typeahead({ source: function(query, callback) { $.getJSON('/opensearch/packages/suggest', {q: query}, function(data) { @@ -226,10 +224,9 @@ $(document).ready(function() { menu: '<ul class="pkgsearch-typeahead"></ul>', items: 10 }).attr('autocomplete', 'off'); -}); -$(document).ready(function() { - var konami = new Konami(); - konami.code = function() { +} +function setupKonami() { + var konami = new Konami(function() { $('#konami').html('<img src="{% static "vector_tux.png" %}" alt=""/>'); setTimeout(function() { $('#konami').fadeIn(500); @@ -237,9 +234,11 @@ $(document).ready(function() { $('#konami').click(function() { $('#konami').fadeOut(500); }); - }; - konami.iphone.code = konami.code; - konami.load(); + }); +} +$(document).ready(function() { + $.ajax({ url: "{% static "bootstrap-typeahead.min.js" %}", cache: true, dataType: "script", success: setupTypeahead }); + $.ajax({ url: "{% static "konami.min.js" %}", cache: true, dataType: "script", success: setupKonami }); }); </script> {% endblock %} diff --git a/templates/releng/result_list.html b/templates/releng/result_list.html index 12bf39db..67e5934d 100644 --- a/templates/releng/result_list.html +++ b/templates/releng/result_list.html @@ -5,7 +5,7 @@ <div class="box"> <h2>Results for: {% if option %}{{ option.verbose_name|title }}: {{ value }}{% endif %} - {{ iso_name|default:"" }} + {% if iso_name %}{{ iso_name|default:"" }}{% endif %} </h2> <p><a href="{% url 'releng-test-overview' %}">Go back to testing results</a></p> diff --git a/todolists/views.py b/todolists/views.py index 9935987b..36a0d97d 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -219,7 +219,8 @@ def send_todolist_emails(todo_list, new_packages): def public_list(request): - todo_lists = Todolist.objects.incomplete().defer('raw') + todo_lists = Todolist.objects.incomplete().defer( + 'raw').order_by('-created') # total hackjob, but it makes this a lot less query-intensive. all_pkgs = [tp for tl in todo_lists for tp in tl.packages()] attach_maintainers(all_pkgs) |