added localhost to settings template

main
Michael Murtaugh 1 week ago
parent 43eb40b7ee
commit 4cc904534a

@ -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)

@ -1,19 +0,0 @@
{% load static %}
<!doctype html>
<html lang=en>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no">
<title>xpub call 2025</title>
<style>
</style>
</head>
<body>
<img src="{{creature.image.url}}">
<p>{{creature.caption}}</p>
</body>
</html>

@ -2,5 +2,6 @@
{% block content %}
<img src="{{object.image.url}}">
<img src="{% url 'creature_frame' object.id %}">
<p>{{object.caption}}</p>
{% endblock %}

@ -4,7 +4,7 @@
<h2>Creatures</h2>
<ul>
{% for creature in page_obj %}
<li><a href="{% url 'walk' creature.id %}">{{ creature.caption }}</a></li>
<li><a href="{% url 'creature_detail' creature.id %}">{{ creature.caption }}</a></li>
{% endfor %}
</ul>

@ -1,57 +0,0 @@
{% load static %}
{% block extrahead %}
<link rel="stylesheet" href="{% static 'call/statement.css' %}">
{% endblock %}
{% block content %}
<img src="{{creature.image.url}}" class="creature" style="display: none">
<canvas class="creature"></canvas>
<!-- <p>{{creature.caption}}</p> -->
<!-- <div class="bubble mini top">awesome!</div>
<div class="bubble right">I can get you a thumb by three o'clock</div>
<div class="bubble medium bottom">I'm not into the whole China thing, man</div>
<div class="bubble grow left">This is such a travesty</div>
<div class="bubble shadow large bottom">Ik moet nu eerst even een gerestaureerde drol hebben!</div> -->
<div class="bubble shadow large top"><textarea placeholder="Your messsage" autofocus id="caption"></textarea></div>
<p>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.</p>
<div id="info">
<p>Application deadlines:</p>
<p>
March 4, 2024 (non-EU + EU)<br>
May 8, 2024 (EU)<br>
</p>
<p>Open days:</p>
<p>
<a href="mailto:pzi.coordinators@hr.nl?subject=XPUB Open Day (online)&amp;body=Hello, I will join the online open day on the February 6th on 10:00 CET or 16:00 CET" target="_blank">February 6, 2024</a> (online)<br>
<a href="https://www.pzwart.nl/blog/2023/10/10/open-day/" target="_blank">February 15, 2025</a> (IRL)<br>
</p>
<p>
<br>
<button id="apply">Apply</button>
</p>
</div>
<p>CSS Speech bubbles from <a href="https://codepen.io/josfabre/pen/EBMWwW">Jos Faber</a>.</p>
<script>
// Get canvas context
const ctx = document.querySelector("canvas.creature").getContext("2d");
// Load image
const image = new Image();
image.onload = () => {
// Draw the image into the canvas
ctx.drawImage(image, 0, 0, 64);
};
image.src = document.querySelector("img.creature").src;
</script>
{% endblock %}

@ -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/<int:pk>/s/", Statement.as_view(), name="statement"),
# path("creatures/<int:pk>/w/", Walk.as_view(), name="walk"),
path("creatures/", CreatureList.as_view(), name="creature_list"),
path("creatures/<int:pk>/", CreatureDetail.as_view(), name="creature_detail"),
path("creatures/<int:pk>/s/", Statement.as_view(), name="statement"),
path("creatures/<int:pk>/w/", Walk.as_view(), name="walk"),
path("creatures/<int:creature_id>/frame/", creature_frame, name="creature_frame"),
path('', views.index)
]

@ -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

@ -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/'

Loading…
Cancel
Save