Merge branch 'website'
This commit is contained in:
commit
d046770191
19 changed files with 318 additions and 2 deletions
|
|
@ -116,6 +116,7 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATICFILES_DIRS = [BASE_DIR / "static"]
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
|
|
|
|||
73
websiteapp/static/css/styles.css
Normal file
73
websiteapp/static/css/styles.css
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
@font-face {
|
||||
font-family: 'CynthoBold';
|
||||
src:
|
||||
url('/static/font/CynthoNextBold.otf') format('opentype');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'CynthoRegular';
|
||||
src:
|
||||
url('/static/font/CynthoNextRegular.otf') format('opentype');
|
||||
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* This sets the font color for all text */
|
||||
body {
|
||||
background-color:rgba(250, 184, 0);
|
||||
color: #006cab;
|
||||
font-size: 20px;
|
||||
font-family: "CynthoRegular", sans-serif;;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: rgba(0, 108, 171);
|
||||
color: rgba(250, 184, 0);
|
||||
font-size: 20px;
|
||||
font-family: "CynthoRegular", sans-serif;
|
||||
font-weight: bold;
|
||||
padding: 25px 25px;
|
||||
border: none; /* removes default border */
|
||||
border-radius: 5px; /* rounded corners */
|
||||
cursor: pointer; /* pointer on hover */
|
||||
align-items: center; /* aligns vertically */
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#map {
|
||||
height: 550px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 80%;
|
||||
height: 300px;
|
||||
padding: 12px;
|
||||
box-sizing: border-box;
|
||||
border: 4px solid rgba(0, 108, 171);
|
||||
border-radius: 5px;
|
||||
background-color: rgb(255, 199, 44);
|
||||
font-size: 18px;
|
||||
color: #006cab;
|
||||
resize: none;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
display: flex; /* places buttons side-by-side */
|
||||
justify-content: center; /* centers them horizontally */ /* aligns vertically */
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
img {
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
}
|
||||
BIN
websiteapp/static/font/CynthoNextBold.otf
Normal file
BIN
websiteapp/static/font/CynthoNextBold.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextExtraBold.otf
Normal file
BIN
websiteapp/static/font/CynthoNextExtraBold.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextExtraLight.otf
Normal file
BIN
websiteapp/static/font/CynthoNextExtraLight.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextLight.otf
Normal file
BIN
websiteapp/static/font/CynthoNextLight.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextMedium.otf
Normal file
BIN
websiteapp/static/font/CynthoNextMedium.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextRegular.otf
Normal file
BIN
websiteapp/static/font/CynthoNextRegular.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextSemiBold.otf
Normal file
BIN
websiteapp/static/font/CynthoNextSemiBold.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/font/CynthoNextThin.otf
Normal file
BIN
websiteapp/static/font/CynthoNextThin.otf
Normal file
Binary file not shown.
BIN
websiteapp/static/img/drawing.png
Normal file
BIN
websiteapp/static/img/drawing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
33
websiteapp/templates/websiteapp/base.html
Normal file
33
websiteapp/templates/websiteapp/base.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<!-- Link your custom CSS -->
|
||||
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
|
||||
|
||||
<title>GREGGORDINATES</title>
|
||||
|
||||
<!-- Global CSS -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br>
|
||||
<br>
|
||||
<h1 style="color:#ffffff ; margin-top: 20px; margin-bottom: 10px;
|
||||
letter-spacing: 1.5px;" >
|
||||
GREGGordinates
|
||||
</h1>
|
||||
<p> "Everything is relative to greggs, and only that is absolute." </p>
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- Global JS -->
|
||||
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
29
websiteapp/templates/websiteapp/decode.html
Normal file
29
websiteapp/templates/websiteapp/decode.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{% extends 'websiteapp/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<br><br>
|
||||
<h3>What's your cool GREGGordinates :3</h3>
|
||||
<textarea id="greggordinates" name="greggordinates" rows="4" cols="50">
|
||||
|
||||
</textarea>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
<div class="btn-group">
|
||||
<a href="{% url 'landing_page' %}">
|
||||
<button>
|
||||
←
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'encode_result' %}">
|
||||
<button onclick="saveAndGo()">
|
||||
Get lame location :/
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
7
websiteapp/templates/websiteapp/decode_result.html
Normal file
7
websiteapp/templates/websiteapp/decode_result.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{% extends 'websiteapp/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p> Landing Page </p>
|
||||
|
||||
{% endblock %}
|
||||
80
websiteapp/templates/websiteapp/encode.html
Normal file
80
websiteapp/templates/websiteapp/encode.html
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{% extends 'websiteapp/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p id="result"></p>
|
||||
|
||||
<br>
|
||||
|
||||
<div id="map" data-mode=""></div>
|
||||
|
||||
<input
|
||||
type="hidden"
|
||||
data-map-markers=""
|
||||
value=""
|
||||
name="map-geojson-data"
|
||||
id="mapData"
|
||||
/>
|
||||
|
||||
|
||||
<p id="coords">Click on the map to choose your lame location</p>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Initialize map
|
||||
const map = L.map('map').setView([54.5, -3], 6);
|
||||
|
||||
// Add OpenStreetMap tiles
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
let marker;
|
||||
|
||||
// When the user clicks the map
|
||||
map.on('click', function (e) {
|
||||
const lat = e.latlng.lat.toFixed(6);
|
||||
const lng = e.latlng.lng.toFixed(6);
|
||||
|
||||
// Remove existing marker (if any)
|
||||
if (marker) map.removeLayer(marker);
|
||||
|
||||
// Add marker at clicked location
|
||||
marker = L.marker([lat, lng]).addTo(map);
|
||||
|
||||
// Show coordinates
|
||||
document.getElementById('coords').textContent = `Coordinates: ${lat}, ${lng}`;
|
||||
|
||||
// Save coordinates in hidden input as JSON
|
||||
const geoData = JSON.stringify({ lat: lat, lng: lng });
|
||||
document.getElementById('mapData').value = geoData;
|
||||
|
||||
console.log("Saved to hidden input:", geoData);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div class="btn-group">
|
||||
<a href="{% url 'landing_page' %}">
|
||||
<button>
|
||||
←
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'encode_result' %}">
|
||||
<button onclick="saveAndGo()">
|
||||
GREGG IT!
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
||||
<!-- pass coordinates to django and directs to result page -->
|
||||
|
||||
{% endblock %}
|
||||
7
websiteapp/templates/websiteapp/encode_result.html
Normal file
7
websiteapp/templates/websiteapp/encode_result.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{% extends 'websiteapp/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p> encode result </p>
|
||||
|
||||
{% endblock %}
|
||||
37
websiteapp/templates/websiteapp/landing_page.html
Normal file
37
websiteapp/templates/websiteapp/landing_page.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{% extends 'websiteapp/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<img src="{% static 'img/drawing.png' %}" alt="Cute map drawing">
|
||||
|
||||
<div class="btn-group">
|
||||
<a href="{% url 'encode' %}">
|
||||
<button>Encode</button>
|
||||
</a>
|
||||
<a href="{% url 'decode' %}">
|
||||
<button>Decode</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.btn-group {
|
||||
display: flex; /* places buttons side-by-side */
|
||||
justify-content: center; /* centers them horizontally */
|
||||
align-items: center; /* aligns vertically */
|
||||
gap: 30px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
padding: 120px 120px;
|
||||
}
|
||||
|
||||
.btn-group button {
|
||||
padding: 40px 40px;
|
||||
font-size:25px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -1 +1,10 @@
|
|||
urlpatterns = []
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.landing_page, name='landing_page'),
|
||||
path('encode', views.encode_view, name='encode'),
|
||||
path('encode/result', views.encode_result_view, name='encode_result'),
|
||||
path('decode', views.decode_view, name='decode'),
|
||||
path('decode/result', views.decode_result_view, name='decode_result'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,43 @@
|
|||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from engine import encode, decode, format_location, parse_location
|
||||
|
||||
def hello_world(request: HttpRequest) -> HttpResponse:
|
||||
return render(request, 'websiteapp/hello_world.html', {
|
||||
"content": "hi!",
|
||||
})
|
||||
|
||||
def landing_page(request: HttpRequest) -> HttpResponse:
|
||||
return render(request, 'websiteapp/landing_page.html', {})
|
||||
|
||||
def encode_view(request: HttpRequest) -> HttpResponse:
|
||||
return render(request, 'websiteapp/encode.html', {})
|
||||
|
||||
def encode_result_view(request: HttpRequest) -> HttpResponse:
|
||||
lat, lon = request.GET.get('lat', None), request.GET.get('lon', None)
|
||||
|
||||
if lat is None or lon is None:
|
||||
# TODO: do some nice error display
|
||||
return render(request, 'websiteapp/encode_result.html', {"result": "error"})
|
||||
|
||||
result = encode((lat, lon))
|
||||
result_str = format_location(result)
|
||||
|
||||
return render(request, 'websiteapp/encode_result.html', {"result": result_str})
|
||||
|
||||
def decode_view(request: HttpRequest) -> HttpResponse:
|
||||
return render(request, 'websiteapp/decode.html', {})
|
||||
|
||||
def decode_result_view(request: HttpRequest) -> HttpResponse:
|
||||
loc_str = request.GET.get('loc', None)
|
||||
if loc_str is None:
|
||||
# TODO: do some nice error display
|
||||
result = "error"
|
||||
|
||||
else:
|
||||
loc = parse_location(loc_str)
|
||||
(lon, lat) = decode(loc)
|
||||
result = f"{lon},{lat}"
|
||||
|
||||
return render(request, 'websiteapp/decode_result.html', {"result": result})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue