gradient for the current week
This commit is contained in:
parent
b433230191
commit
f02023b079
3 changed files with 18 additions and 3 deletions
|
|
@ -312,11 +312,12 @@ class Week(models.Model):
|
||||||
items, _ = Item.public(monday)
|
items, _ = Item.public(monday)
|
||||||
return items.order_by('published')
|
return items.order_by('published')
|
||||||
|
|
||||||
@property
|
def background(self, now=None):
|
||||||
def background(self):
|
|
||||||
if self.use_hue:
|
if self.use_hue:
|
||||||
colors = []
|
colors = []
|
||||||
for item in self.items():
|
for item in self.items():
|
||||||
|
if now and item.published > now:
|
||||||
|
continue
|
||||||
color = item.get_hue(update=True)
|
color = item.get_hue(update=True)
|
||||||
if color:
|
if color:
|
||||||
if not colors:
|
if not colors:
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ def index(request):
|
||||||
now = get_now()
|
now = get_now()
|
||||||
else:
|
else:
|
||||||
now = None
|
now = None
|
||||||
|
monday = get_monday(now)
|
||||||
week, archive = models.Item.public(now)
|
week, archive = models.Item.public(now)
|
||||||
if archive and archive.exists():
|
if archive and archive.exists():
|
||||||
context['archive'] = '/_%s/' % get_monday(get_now() - timedelta(days=7))
|
context['archive'] = '/_%s/' % get_monday(get_now() - timedelta(days=7))
|
||||||
|
|
@ -75,6 +76,9 @@ def index(request):
|
||||||
context["break"] = week
|
context["break"] = week
|
||||||
else:
|
else:
|
||||||
context['items'] = week
|
context['items'] = week
|
||||||
|
extra = models.Week.objects.filter(monday=monday, is_break=False).first()
|
||||||
|
if extra:
|
||||||
|
context['week_background'] = extra.background(now)
|
||||||
if now:
|
if now:
|
||||||
context['now'] = now
|
context['now'] = now
|
||||||
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
||||||
|
|
@ -109,7 +113,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
||||||
if extra:
|
if extra:
|
||||||
context['week_title'] = extra.title
|
context['week_title'] = extra.title
|
||||||
context['week_byline'] = extra.byline
|
context['week_byline'] = extra.byline
|
||||||
context['week_background'] = extra.background
|
context['week_background'] = extra.background()
|
||||||
elif week:
|
elif week:
|
||||||
week = int(week)
|
week = int(week)
|
||||||
year = int(year)
|
year = int(year)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,16 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link rel="alternate" type="application/atom+xml" title="{{ settings.SITENAME }}" href="/atom.xml" />
|
<link rel="alternate" type="application/atom+xml" title="{{ settings.SITENAME }}" href="/atom.xml" />
|
||||||
<title>{{ settings.SITENAME }}</title>
|
<title>{{ settings.SITENAME }}</title>
|
||||||
|
{% if week_background %}
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: {{ week_background }};
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
window.useHue = true;
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="index">
|
<div class="index">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue