Skip to content

Commit

Permalink
Merge pull request #5 from giannistolou/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
giannistolou authored Aug 16, 2022
2 parents e967235 + 5cf8258 commit 5c799f5
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 56 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/uploadsfiles
USER root

# set environment variables
Expand Down
4 changes: 2 additions & 2 deletions bookCafe/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
MEDIA_URL = '/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploadsfiles')
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
BASE_DIR / "dist",
Expand Down
2 changes: 2 additions & 0 deletions bookCafe/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
path('', include('findBookCafe.urls')),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

handler404 = 'findBookCafe.views.page404'
handler500 = 'findBookCafe.views.page500'
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
command: gunicorn bookCafe.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_volume:/home/app/web/staticfiles
- uploads_volume:/home/app/web/uploadsfiles
- ./db.sqlite3:/home/app/web/db.sqlite3
expose:
- 8000
Expand All @@ -17,6 +18,7 @@ services:
build: ./nginx
volumes:
- static_volume:/home/app/web/staticfiles
- uploads_volume:/home/app/web/uploadsfiles
depends_on:
- web
hostname: cafe-book-nginx
Expand All @@ -26,6 +28,7 @@ services:

volumes:
static_volume:
uploads_volume:

networks:
nginx:
Expand Down
3 changes: 3 additions & 0 deletions findBookCafe/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cProfile import label
from random import choices
from django.db import models
from django_quill.fields import QuillField
Expand Down Expand Up @@ -36,6 +37,7 @@ class Shop(models.Model):
type = models.CharField(choices=CAFE_TYPES_OPTIONS, max_length=3, default=CAFE_TYPES_OPTIONS[0])
thumbnail = models.ImageField(upload_to ='uploads/', null = True)
name = models.CharField(max_length=300)
name_en = models.CharField(max_length=300)
latitude = models.FloatField(max_length=100)
longitude = models.FloatField(max_length=100)
address = models.CharField(max_length=300)
Expand All @@ -46,6 +48,7 @@ class Shop(models.Model):
tripadvisor = models.URLField(max_length=300, blank=True)
googleMaps = models.URLField(max_length=300, blank=True)
isBookShop = models.BooleanField()
isAccessibleForPeopleWithDisabilities = models.BooleanField(default=False)
isCoffeeAllowed = models.BooleanField(default=True)
hasLunch = models.BooleanField(default=False)
internetQuality = models.CharField(choices=INTERNET_CHOICE, max_length=1, default=INTERNET_CHOICE[2])
Expand Down
20 changes: 20 additions & 0 deletions findBookCafe/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
{% load static %} {% include "commonHead.html" %}
<link rel="stylesheet" href="{% static 'style/page404.css' %}" />
<title>404 error</title>
<link rel="stylesheet" href="{% static 'style/cafes.css' %}" />
<script src="{% static 'bundle.js' %}" async></script>
</head>

<body>
{% include "header.html" %}
<main class="mdc-top-app-bar--fixed-adjust">
<div class="page404">
<h1>404</h1>
<p>Η σελίδα δεν βρέθηκε</p>
<a href="/" class="mdc-button mdc-button--raised">Αρχική</a>
</div>
</main>
</body>
</html>
18 changes: 4 additions & 14 deletions findBookCafe/templates/cafe.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
<html>
<head>
{% load static %}
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% load static %} {% include "commonHead.html" %}
<title>{{cafe.name}}</title>
<link rel="stylesheet" href="{% static 'style/cafe.css' %}" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
<script src="{% static 'bundle.js' %}" async></script>
</head>

Expand All @@ -24,7 +13,7 @@
<div class="imgCnt">
<h1 class="name">{{cafe.name}}</h1>
<img
src="/{{cafe.thumbnail}}"
src="https://cafe.book-community.com/media/{{cafe.thumbnail}}"
alt="thumbnail {{cafe.name}}"
/>
</div>
Expand Down Expand Up @@ -69,5 +58,6 @@ <h1 class="name">{{cafe.name}}</h1>
{{cafe.description.html | safe}}
</section>
</main>
{% include "footer.html" %}
</body>
</html>
2 changes: 2 additions & 0 deletions findBookCafe/templates/cafeIcons.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
<span class="material-symbols-sharp icon"> power </span>
{% else %}
<span class="material-symbols-sharp icon"> power_off </span>
{% endif %} {% if cafe.isAccessibleForPeopleWithDisabilities %}
<span class="material-symbols-sharp icon"> accessible </span>
{% endif %}
</div>
14 changes: 3 additions & 11 deletions findBookCafe/templates/cafes.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<html>
<head>
{% load static %}
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% load static %} {% include "commonHead.html" %}
<title>Βρες την καφετέρια που σου ταιριάζει</title>
<link rel="stylesheet" href="{% static 'style/cafes.css' %}" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
<script src="{% static 'bundle.js' %}" async></script>
</head>

Expand Down Expand Up @@ -82,5 +73,6 @@
</div>
{% include "cafesList.html" %}
</main>
{% include "footer.html" %}
</body>
</html>
7 changes: 5 additions & 2 deletions findBookCafe/templates/cafesList.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
{%for cafe in cafes%}
<div class="cafe">
<div class="imgCnt">
<img src="/{{cafe.thumbnail}}" />
<img
src="https://cafe.book-community.com/media/{{cafe.thumbnail}}"
alt="{{cafe.name}}"
/>
</div>
<div class="content">
{% include "cafeIcons.html" %}
<span class="location"
>{{cafe.region.name}}, {{cafe.region.city.name}}</span
>
<a
href="cafes/{{cafe.name}}-{{cafe.id}}"
href="cafes/{{cafe.name_en}}-{{cafe.id}}"
class="mdc-button mdc-button--raised"
>{{cafe.name}}</a
>
Expand Down
23 changes: 23 additions & 0 deletions findBookCafe/templates/commonHead.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load static %}
<meta charset="UTF-8" />
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📖</text></svg>"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
<script
defer
data-domain="cafe.book-community.com"
src="https://plausible.io/js/plausible.js"
></script>
<link rel="stylesheet" href="{% static 'style/footer.css' %}" />
70 changes: 70 additions & 0 deletions findBookCafe/templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div class="cookie-banner" style="display: none">
<p>
Χρησιμοποιούμε cookies για την υπηρεσία του newsletter, για περισσότερα
διάβασε την
<a href="https://book-community.com/privacy-policy.html"
>πολιτική απορρήτου</a
>
</p>
<div class="options">
<button class="decline" onclick="closeCookieBanner()">Απόρριψη</button>
<button class="accept" onclick="acceptCookies()">Αποδοχή</button>
</div>
</div>

<section class="newsletter">
<div class="container">
<div class="title">Κάνε εγγραφή στο newsletter μας</div>
<div class="subtitle">
Για να μαθαίνεις την πορεία του project και ενδιαφέροντα θέματα γύρω
από το βιβλίο!
</div>

<div id="newsletterProblem" style="display: none">
<p style="text-align: center">
Αποδεχτείτε τα cookies για να κάνετε εγγραφή στο newsletter
</p>
<button class="btnCookie" onclick="acceptCookies()">
Αποδοχή cookies
</button>
</div>
<form class="form">
<iframe
title="newsletter iframe"
frameborder="0"
scrolling="no"
></iframe>
</form>
</div>
</section>

<script>
var cookieBanner = document.querySelector(".cookie-banner");
var decline = document.querySelector(".decline");
var accept = document.querySelector(".accept");
var iframes = document.querySelectorAll("iframe");
var newsletterProblem = document.querySelector("#newsletterProblem");

if (localStorage.getItem("cookieSeen") != "shown") {
cookieBanner.style.display = "flex";
newsletterProblem.style.display = "flex";
} else {
acceptCookies();
}

function closeCookieBanner() {
cookieBanner.style.animation = "cookieHide 1s";
setTimeout(() => {
cookieBanner.style.display = "none";
}, 1000);
}

function acceptCookies() {
closeCookieBanner();
newsletterProblem.style.display = "none";
localStorage.setItem("cookieSeen", "shown");
iframes.forEach((el) => {
el.src = "https://bookcommunitygr.substack.com/embed";
});
}
</script>
4 changes: 2 additions & 2 deletions findBookCafe/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
>
<a
href="/map"
class="mdc-button material-icons mdc-top-app-bar__action-item mdc-icon-button material-symbols-sharp"
class="mdc-button material-icons mdc-top-app-bar__action-item mdc-icon-button"
aria-label="Bookmark this page"
>
explore
<span class="material-symbols-sharp"> explore </span>
</a>
</section>
</div>
Expand Down
6 changes: 3 additions & 3 deletions findBookCafe/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

<head>
{% load static %}
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% include "commonHead.html" %}
<title>Book Cafe</title>
<link rel="stylesheet" href="{% static 'style/index.css' %}" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<script src="{% static 'bundle.js' %}" async></script>
</head>

Expand Down Expand Up @@ -44,6 +43,7 @@ <h1 class="app-page-title homepage-version">
</div>
</section>
</main>
{% include "footer.html" %}
</body>

</html>
14 changes: 3 additions & 11 deletions findBookCafe/templates/libraries.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<html>
<head>
{% load static %}
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% load static %} {% include "commonHead.html" %}
<title>Βρες την βιβλιοθήκη που σου ταιριάζει</title>
<link rel="stylesheet" href="{% static 'style/cafes.css' %}" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
<script src="{% static 'bundle.js' %}" async></script>
</head>

Expand Down Expand Up @@ -82,5 +73,6 @@
</div>
{% include "cafesList.html" %}
</main>
{% include "footer.html" %}
</body>
</html>
10 changes: 2 additions & 8 deletions findBookCafe/templates/map.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
<!DOCTYPE html>
<html>
<head>
{% load static %}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Βρες την καφετέρια που σου ταιριάζει</title>
{% load static %} {% include "commonHead.html" %}
<link rel="stylesheet" href="{% static 'style/theme.css' %}" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200"
/>
<title>Display a map on a webpage</title>
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
Expand Down
15 changes: 13 additions & 2 deletions findBookCafe/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from django.shortcuts import render
from django.http import Http404
from .models import Shop
import environ
env = environ.Env()
# Create your views here.

def page404(request, exception):
return render(request, '404.html')

def page500(exception):
return render('404.html', exception)

def index(request):
return render(request, 'index.html')

Expand All @@ -12,7 +20,10 @@ def cafes(request):

def cafe(request, cafe):
id = cafe.split('-')[-1]
cafe = Shop.objects.get(id=id)
try:
cafe = Shop.objects.get(id=id)
except:
raise Http404
return render(request, 'cafe.html', {'cafe': cafe})

def libraries(request):
Expand All @@ -27,5 +38,5 @@ def map(request):
if shop.type == 'LIB':
shop_type = 'Βιβλιοθήκη'
data.append({'name': shop.name, 'id': shop.id, 'directions':shop.googleMaps, 'shopType': shop_type, 'type': "Feature", 'properties': {'iconSize': [60, 60]},
'geometry':{'type': "Point",'coordinates': [shop.latitude, shop.longitude]}})
'geometry':{'type': "Point",'coordinates': [shop.longitude, shop.latitude]}})
return render(request, 'map.html', {'shops': data, 'map_api': env('MAP_BOX_API')})
Loading

0 comments on commit 5c799f5

Please sign in to comment.