Created random header image code
This commit is contained in:
parent
a99ca61159
commit
414ff5b4a4
@ -2,6 +2,13 @@ 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):
|
||||
tagcloudlist = Tag.objects.annotate(ct=Count('taggit_taggeditem_items')).order_by('-ct')
|
@ -131,6 +131,7 @@ INSTALLED_APPS = (
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
'blog',
|
||||
'basics',
|
||||
)
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
@ -170,5 +171,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
"django.core.context_processors.static",
|
||||
"django.core.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
'gergelypolonkai_django.taghelper.tagcloud',
|
||||
'gergelypolonkai_django.helper.tagcloud',
|
||||
'gergelypolonkai_django.helper.randomheader',
|
||||
)
|
||||
|
||||
HEADER_DIR = SITE_ROOT + os.path.sep + "static" + os.path.sep + "images" + os.path.sep + "header"
|
||||
|
BIN
gergelypolonkai_django/static/images/header/header_1.png
Normal file
BIN
gergelypolonkai_django/static/images/header/header_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
gergelypolonkai_django/static/images/header/header_2.png
Normal file
BIN
gergelypolonkai_django/static/images/header/header_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
gergelypolonkai_django/static/images/header/header_3.png
Normal file
BIN
gergelypolonkai_django/static/images/header/header_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
gergelypolonkai_django/static/images/header/header_4.png
Normal file
BIN
gergelypolonkai_django/static/images/header/header_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
@ -18,7 +18,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="content-wrapper">
|
||||
<div id="header" style="background-image: url('{% static "images/random_header.jpg" %}');">
|
||||
<div id="header" style="background-image: url('{% static "images/header/"|add:header %}');">
|
||||
<div id="picture">
|
||||
<img src="{% static "images/profile.png" %}" alt="" />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user