The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ
Old, Django based sources of the site gergely.polonkai.eu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
1.4 KiB

from django.db.models import Count
from taggit.models import Tag
from math import floor
from operator import itemgetter
from django.conf import settings
import os
from random import choice
def randomheader(request):
header_file = choice(filter(
lambda x: os.path.isfile(
settings.HEADER_DIR + os.path.sep + x
),
os.listdir(settings.HEADER_DIR)
))
return {'header': header_file}
def tagcloud(request):
tagcloud = []
tagcloudlist = Tag.objects.annotate(
ct = Count('taggit_taggeditem_items')
).order_by('-ct')
if (len(tagcloudlist) > 0):
tmax = tagcloudlist[0].ct
tmin = 1
if (tmax == tmin):
tmax += 1
for cloudelement in tagcloudlist:
tagcount = cloudelement.ct
if (tagcount >= tmin):
size = int(floor((5.0 * (tagcount - tmin)) / (tmax - tmin)))
tagcloud.append({
'name': cloudelement.name,
'slug': cloudelement.slug,
'size': size
})
tagcloud.sort(key = itemgetter('name'))
return {'tagcloud': tagcloud}
def viewname(request):
if hasattr(request, 'view_name'):
return {
'view_name': request.view_name,
}
else:
return {}