<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from common import *

def advanced_search(request):
    data = {"mode":"search", "genres":GENRE_LIST}
    
    return render_to_response("advanced_search.html", data, context_instance=RequestContext(request))

def article_directory(request):
    data = {}
    data["sort"] = request.GET.get("sort", "category")
    if request.GET.get("sort") == "date":
        data["articles"] = Article.objects.defer("content", "css").filter(published=True, page=1).order_by("-date", "title")
        return render_to_response("article_directory.html", data, context_instance=RequestContext(request))
    else:
        data["articles"] = Article.objects.defer("content", "css").filter(published=True, page=1).order_by("category", "title")
        return render_to_response("article_directory.html", data, context_instance=RequestContext(request))
    
def article_view(request, id):
    id = int(id)
    data = {"id":id}
    data["article"] = get_object_or_404(Article, pk=id)
    data["title"] = data["article"].title
    return render_to_response("article_view.html", data, context_instance=RequestContext(request))

def browse(request, letter="*", category="ZZT", page=1):
    data = {"mode":"browse", "category":category}
    
    if category == "ZZT":
        if request.GET.get("view") == "list":
            data["letter"] = letter if letter != "1" else "#"
            data["files"] = File.objects.filter(category=category, letter=letter).order_by("title")
            return render_to_response("browse_list.html", data, context_instance=RequestContext(request))
        else:
            data["page"] = int(request.GET.get("page", page))
            data["letter"] = letter if letter != "1" else "#"
            data["files"] = File.objects.filter(category=category, letter=letter).order_by("title")[(data["page"]-1)*PAGE_SIZE:data["page"]*PAGE_SIZE]
            data["count"] = File.objects.filter(category=category, letter=letter).count()
            data["pages"] = int(1.0 * math.ceil(data["count"] / PAGE_SIZE))
            data["page_range"] = range(1, data["pages"] + 1)
            data["prev"] = max(1,data["page"] - 1)
            data["next"] = min(data["pages"],data["page"] + 1)
            return render_to_response("browse.html", data, context_instance=RequestContext(request))<commit_msg>Fixed off by one error on file listing page counts.<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from common import *

def advanced_search(request):
    data = {"mode":"search", "genres":GENRE_LIST}
    
    return render_to_response("advanced_search.html", data, context_instance=RequestContext(request))

def article_directory(request):
    data = {}
    data["sort"] = request.GET.get("sort", "category")
    if request.GET.get("sort") == "date":
        data["articles"] = Article.objects.defer("content", "css").filter(published=True, page=1).order_by("-date", "title")
        return render_to_response("article_directory.html", data, context_instance=RequestContext(request))
    else:
        data["articles"] = Article.objects.defer("content", "css").filter(published=True, page=1).order_by("category", "title")
        return render_to_response("article_directory.html", data, context_instance=RequestContext(request))
    
def article_view(request, id):
    id = int(id)
    data = {"id":id}
    data["article"] = get_object_or_404(Article, pk=id)
    data["title"] = data["article"].title
    return render_to_response("article_view.html", data, context_instance=RequestContext(request))

def browse(request, letter="*", category="ZZT", page=1):
    data = {"mode":"browse", "category":category}
    
    if category == "ZZT":
        if request.GET.get("view") == "list":
            data["letter"] = letter if letter != "1" else "#"
            data["files"] = File.objects.filter(category=category, letter=letter).order_by("title")
            return render_to_response("browse_list.html", data, context_instance=RequestContext(request))
        else:
            data["page"] = int(request.GET.get("page", page))
            data["letter"] = letter if letter != "1" else "#"
            data["files"] = File.objects.filter(category=category, letter=letter).order_by("title")[(data["page"]-1)*PAGE_SIZE:data["page"]*PAGE_SIZE]
            data["count"] = File.objects.filter(category=category, letter=letter).count()
            data["pages"] = int(math.ceil(1.0 * data["count"] / PAGE_SIZE))
            data["page_range"] = range(1, data["pages"] + 1)
            data["prev"] = max(1,data["page"] - 1)
            data["next"] = min(data["pages"],data["page"] + 1)
            return render_to_response("browse.html", data, context_instance=RequestContext(request))
{'fraction_non_alphanumeric': 0.17125822368421054, 'fraction_numerical': 0.0069901315789473685, 'mean_word_length': 4.1264488935721815, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2833034', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1435, 'n_words': 264}