diff --git a/README.md b/README.md index ad6ef77..c06cacf 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,18 @@ This is code for the XPUB 2025 call. ## Dependencies +To run locally, clone the repo (call2025), and cd into the call2025: + + python3 -m venv venv + source venv/bin/activate pip install django pillow pyyaml click + mkdir db + cp call2025/settings.template.py call2025/settings.py + ./manage.py migrate + ./manage.py runserver + + ## Key files * Stylesheets: [index.css](call/static/call/index.css) + [guestbook](call/static/call/guestbook.css) diff --git a/call/templates/call/creature.html b/call/templates/call/creature.html deleted file mode 100644 index b5435a0..0000000 --- a/call/templates/call/creature.html +++ /dev/null @@ -1,19 +0,0 @@ -{% load static %} - - - - -xpub call 2025 - - - - - - - -

{{creature.caption}}

- - - - \ No newline at end of file diff --git a/call/templates/call/creature_detail.html b/call/templates/call/creature_detail.html index f38af06..fda1389 100644 --- a/call/templates/call/creature_detail.html +++ b/call/templates/call/creature_detail.html @@ -2,5 +2,6 @@ {% block content %} +

{{object.caption}}

{% endblock %} \ No newline at end of file diff --git a/call/templates/call/creature_list.html b/call/templates/call/creature_list.html index 7c33a38..ea07a64 100644 --- a/call/templates/call/creature_list.html +++ b/call/templates/call/creature_list.html @@ -4,7 +4,7 @@

Creatures

diff --git a/call/templates/call/statement.html b/call/templates/call/statement.html deleted file mode 100644 index 2cb0b95..0000000 --- a/call/templates/call/statement.html +++ /dev/null @@ -1,57 +0,0 @@ -{% load static %} -{% block extrahead %} - -{% endblock %} - -{% block content %} - - - - - - - - - -
- - -

The Master Experimental Publishing at the Piet Zwart Institute in Rotterdam (NL) is a two-year master focused on the acts of making things public and creating publics in the age of post-digital networks.

-
-

Application deadlines:

-

- March 4, 2024 (non-EU + EU)
- May 8, 2024 (EU)
-

-

Open days:

-

- February 6, 2024 (online)
- February 15, 2025 (IRL)
-

-

-
- -

-
- -

CSS Speech bubbles from Jos Faber.

- - - - -{% endblock %} diff --git a/call/urls.py b/call/urls.py index f66a895..2476cac 100644 --- a/call/urls.py +++ b/call/urls.py @@ -17,12 +17,14 @@ Including another URLconf from django.contrib import admin from django.urls import path, include from call import views -from .views import Guestbook, CreatureDetail, Statement, Walk +from .views import Guestbook, CreatureList, CreatureDetail, creature_frame urlpatterns = [ path("guestbook/", Guestbook.as_view(), name="guestbook"), + # path("creatures//s/", Statement.as_view(), name="statement"), + # path("creatures//w/", Walk.as_view(), name="walk"), + path("creatures/", CreatureList.as_view(), name="creature_list"), path("creatures//", CreatureDetail.as_view(), name="creature_detail"), - path("creatures//s/", Statement.as_view(), name="statement"), - path("creatures//w/", Walk.as_view(), name="walk"), + path("creatures//frame/", creature_frame, name="creature_frame"), path('', views.index) ] diff --git a/call/views.py b/call/views.py index 3d2dd1b..621330f 100644 --- a/call/views.py +++ b/call/views.py @@ -1,12 +1,14 @@ -from django.shortcuts import render, HttpResponseRedirect +from django.shortcuts import render, get_object_or_404, HttpResponse, HttpResponseRedirect from call.forms import CreatureForm from django.views import generic from .models import Creature from django.urls import reverse +# from io import StringIO +from PIL import Image -# Create your views here. def index(request): + """ Main page of call, with 2bitcharactergenerator, receives POST to save a new creature """ if request.method == "POST": print ("post", request.POST) print ("files", request.FILES) @@ -25,18 +27,28 @@ def index(request): return render(request, "call/index.html", {"form": form}) class Guestbook(generic.ListView): + """ public guestbook page """ paginate_by = 20 model=Creature template_name = "call/guestbook.html" queryset = Creature.objects.filter(published=True) -class CreatureDetail(generic.DetailView): - model = Creature +class CreatureList(generic.ListView): + """ public guestbook page """ + paginate_by = 20 + model=Creature + template_name = "call/creature_list.html" + queryset = Creature.objects.filter(published=True) -class Statement(generic.DetailView): +class CreatureDetail(generic.DetailView): + """ Generates Pixelated PNG of creature """ model = Creature - template_name = "call/statement.html" + template_name = "call/creature_detail.html" -class Walk(generic.DetailView): - model = Creature - template_name = "call/walk.html" +def creature_frame (request, creature_id): + """ Generates Pixelated PNG of creature """ + creature = get_object_or_404(Creature, pk=creature_id) + im = Image.open(creature.image.path) + response = HttpResponse(content_type="image/png") + im.save(response, "PNG") + return response diff --git a/call2025/settings.template.py b/call2025/settings.template.py index 16031fd..8ae4c50 100644 --- a/call2025/settings.template.py +++ b/call2025/settings.template.py @@ -24,9 +24,12 @@ SECRET_KEY = 'django-insecure-nn7mvrgu6de^%z&6t1usgaji_*59z*v+230tluec-h4fw*n(%i # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +DEPLOY = True -ALLOWED_HOSTS = ['xpub.nl'] - +if DEPLOY: + ALLOWED_HOSTS = ['xpub.nl'] +else: + ALLOWED_HOSTS = ['localhost'] # Application definition @@ -117,7 +120,6 @@ USE_TZ = True # https://docs.djangoproject.com/en/5.1/howto/static-files/ # -DEPLOY = True if DEPLOY: STATIC_URL = '/2025/call/static/'