Compare commits

..

5 Commits

Author SHA1 Message Date
root
ff4e0b2325 disable Xframe middleware 2023-08-09 09:46:34 +00:00
root
b729ea7b51 text/slider fixes 2023-08-09 09:46:19 +00:00
root
25c4714072 fix upcoming events 2023-08-09 09:46:04 +00:00
root
f46154ddfd gallery tweaks and url preview headers 2023-08-09 09:45:13 +00:00
root
2b129a8596 tweaks 2019-07-29 11:09:50 +00:00
13 changed files with 133 additions and 28 deletions

View File

@ -55,7 +55,7 @@ MIDDLEWARE = [
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
#'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'camp.urls'
@ -63,7 +63,9 @@ ROOT_URLCONF = 'camp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [
os.path.join(BASE_DIR, 'camp', 'templates')
],
'APP_DIRS': False,
'OPTIONS': {
'context_processors': [

View File

@ -0,0 +1,4 @@
.slider1 {
display: none;
}

View File

@ -66,7 +66,7 @@ a:focus, a:hover {
}
.index-text p {
text-align: justify;
//text-align: justify;
}
.title-bar-right {

View File

@ -1386,7 +1386,8 @@
} else {
// if adaptiveHeight is true and next height is different from current height, animate to the new height
if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
// fails with slow connections
//slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
}
// if carousel and not infinite loop
if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) {
@ -1432,6 +1433,9 @@
}
}
if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
if (!slider.working) {
el.redrawSlider()
}
};
/**

View File

@ -143,10 +143,25 @@ class Content(models.Model):
def typefilter(self):
return self.type
def admin_thumbnail_(self):
src = None
if self.photo:
src = self.photo.get_thumbnail_url()
if self.image:
if self.image.startswith('http') or self.image.startswith('/'):
src = self.image
else:
src = settings.IMAGE_PREFIX + self.image
if src:
return mark_safe(u'<a href="{}"><img src="{}"></a>'.format(self.get_absolute_url(), src))
@property
def image_url(self):
if self.photo:
return self.photo.get_display_url()
url = self.photo.image.url
if not url.lower().endswith('.gif'):
url = self.photo.get_display_url()
return url
if self.image:
if self.image.startswith('http') or self.image.startswith('/'):
return self.image

View File

@ -1,13 +1,14 @@
{% load available_content%}
{% load available_content static %}
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% block head %}
<title>Studio CAMP</title>
{% endblock %}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "css/jquery.bxslider.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
@ -49,14 +50,36 @@
<script src="{% static "js/foundation.js" %}"></script>
<script src="{% static "js/app.js" %}"></script>
<script src="{% static "js/what-input.js" %}"></script>
<script src="{% static "js/jquery.bxslider.js" %}"></script>
<script src="{% static "js/jquery.bxslider.js" %}?2"></script>
<script type="text/javascript">
$(document).ready(function(){
slider = $('.slider1').bxSlider({
var startSlide = 0;
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
startSlide = parseInt(document.location.hash.slice(1)) - 1
}
function loadSlideshow() {
$('a.original-link').bind('touchstart MSPointerDown pointerdown', function(event) {
event.stopPropagation()
});
$('a.original-link').on({
mousedown: function(event) {
event.stopPropagation()
},
})
slider = $('.slider1').show().bxSlider({
startSlide: startSlide,
preloadImages: 'all',
adaptiveHeight : true,
pager : false,
});
var images = $('.slider1 img'), count = images.length;
images.on({load: function(event) {
setTimeout(function() {
slider.resize()
slider.redrawSlider()
}, 100)
}})
document.querySelectorAll('.select-image').forEach(function(a) {
a.onclick = function(event) {
event.preventDefault();
@ -64,12 +87,21 @@
document.location.hash = '#' + this.dataset.id;
};
});
/*
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
var slide = parseInt(document.location.hash.slice(1))
if (slide) {
slider.goToSlide(slide - 1)
slider.resize()
slider.redrawSlider()
setTimeout(function() {
slider.resize()
slider.redrawSlider()
}, 2000)
}
}
*/
$(document).keydown(function(e){
if (e.keyCode == 39) // Right arrow
@ -82,8 +114,9 @@
slider && slider.goToPrevSlide();
return false;
}
});
});
});
}
$(document).ready(loadSlideshow);
</script>
{% block end %}
{% endblock %}

View File

@ -0,0 +1,7 @@
<title>{{ content.title }} - Studio CAMP</title>
<meta name="title" content="{{ content.title }}"/>
<meta property="og:title" content="{{ content.title }}"/>
<meta content="https://studio.camp{{ content.image_url }}" name="thumbnail"/>
<meta content="https://studio.camp{{ content.image_url }}" name="image_src"/>
<meta property="og:image" content="https://studio.camp{{ content.image_url }}"/>

View File

@ -1,4 +1,7 @@
{% extends 'base.html' %}
{% block head %}
{% include "content-header.html" %}
{% endblock %}
{% block content %}
{% include "edit.html" %}

View File

@ -1,5 +1,7 @@
{% extends 'base.html' %}
{% block head %}
{% include "content-header.html" %}
{% endblock %}
{% block content %}
{% include "featured.html" %}

View File

@ -13,11 +13,11 @@
<ul class="slider1">
{% for photo in gallery.public %}
<li id="slide-{{photo.slug}}">
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}">
<img src="{{ photo.get_display_url }}" alt="{{ photo.title }}" loading="lazy">
<p>
{{ photo.caption|safe }}
{% if photo.caption %}<br>{%endif%}
<a href="{{ photo.image.url }}" target="_blank" >Link to original file</a>
<a href="{{ photo.image.url }}" class="original-link" target="_blank" >Link to original file</a>
</p>
</li>

View File

@ -10,7 +10,7 @@
<p>
{{ object.caption|safe }}
{% if object.caption %}<br>{%endif%}
<a href="{{ object.image.url }}" target="_blank" >Link to original file</a>
<a href="{{ object.image.url }}" class="original-link" target="_blank" >Link to original file</a>
</p>
<ul>
{% for gallery in object.public_galleries %}

View File

@ -1,5 +1,6 @@
from django import template
from django.urls import reverse
from django.utils.html import mark_safe
from ..models import Content
@ -18,3 +19,27 @@ def available_content():
type.upper()
])
return sections
@register.filter
def admin_thumbnail(row):
from photologue.models import Photo
p = None
if 'for="id_photos_' in row.get('label_for'):
try:
p = Photo.objects.get(pk=row['option_value'])
except:
pass
elif 'for="id_related_content_' in row.get('label_for'):
try:
p = Content.objects.get(pk=row['option_value'])
except:
pass
else:
print(row)
if p:
try:
return mark_safe(p.admin_thumbnail() + ' ')
except:
pass
return ''

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import datetime
from datetime import datetime, timedelta
import re
from django.conf import settings
@ -9,6 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import EmailMessage
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q, Count
from django.db.models.functions import Coalesce
from django.http import HttpResponse, Http404
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
@ -23,14 +24,24 @@ from . import forms
ITEMS_PER_PAGE = 30
def get_events(base):
now = datetime.now() - timedelta(hours=24)
now = datetime.now().date()
upcoming_events = base.filter(datestart__gte=now).order_by('datestart')[:12]
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now)[:12]
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now))
#past_events.annotate(datesort=Coalesce('dateend', 'datestart')).order_by('-datesort')[:12]
past_events = past_events.order_by('-datestart')[:12]
#past_events = list(past_events)
#past_events.sort(key=lambda event: event.dateend if event.dateend else event.datestart, reverse=True)
return upcoming_events, ongoing_events, past_events
def index(request):
now = datetime.now()
display_events = ['news', 'events']
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
base = base.filter(published=True)
upcoming_events = base.filter(datestart__gte=now)[:12]
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now)[:12]
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now))[:12]
upcoming_events, ongoing_events, past_events = get_events(base)
homepage = Content.objects.filter(type__name='homepage').order_by('-datestart')[:1]
context = {
@ -73,7 +84,7 @@ def section_index(request, section, max_length=10):
def content_years(content):
years = [
year['year'].year
for year in content.annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
for year in content.exclude(datestart=None).annotate(year=TruncYear('datestart')).values('year').annotate(count=Count('shortname')).order_by('-year')
]
return years
@ -81,9 +92,10 @@ def filter_by_years(content, year):
years = content_years(content)
if year.isdigit():
year = int(year)
else:
elif years:
year = years[0]
content = content.filter(datestart__gte='%s-01-01' % year, datestart__lt='%s-01-01' % (year+1))
if year:
content = content.filter(datestart__gte='%04d-01-01' % year, datestart__lt='%04d-01-01' % (year+1))
return {
'content': content,
'year': year,
@ -124,7 +136,6 @@ def section_list(request, section):
return render(request, 'results.html', context)
def event(request):
now = datetime.now()
display_events = ['events', 'news']
featured = Content.objects.filter(type__name='events', featured=True).order_by('-datestart')[:1]
base = Content.objects.filter(type__name__in=display_events).order_by('-datestart')
@ -132,9 +143,7 @@ def event(request):
if featured:
base = base.exclude(pk=featured[0].pk)
upcoming_events = base.filter(datestart__gt=now).order_by('-datestart')
ongoing_events = base.filter(datestart__lt=now, dateend__gte=now).order_by('-datestart')
past_events = base.filter(Q(dateend__lt=now) | Q(dateend=None, datestart__lt=now)).order_by('-datestart')[:10]
upcoming_events, ongoing_events, past_events = get_events(base)
context = {
'upcoming_events': upcoming_events,
@ -150,6 +159,7 @@ def get_related_content(types, current=None, max_length=10):
latest_content_list = Content.objects.filter(type__name__in=types).order_by('-datestart')
if current:
latest_content_list = latest_content_list.exclude(pk=current.pk)
latest_content_list = latest_content_list.exclude(pk__in=current.related_content.all())
latest_content_list = latest_content_list.filter(published=True)
more = latest_content_list.count() > max_length
latest_content_list = latest_content_list[:max_length]