Skip to content

Commit c4ea7e3

Browse files
authoredMay 26, 2023
Merge pull request #32 from isaacte/isaacte
Added RDFA support on books and authors
2 parents 5e05fb1 + 51a8041 commit c4ea7e3

File tree

5 files changed

+147
-122
lines changed

5 files changed

+147
-122
lines changed
 

‎Base/templates/Base/author.html

+21-14
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
{% block title %}Index{% endblock %}
55

66
{% block content %}
7-
<h1>{{ author.name }}</h1>
8-
<div class="row">
9-
<div class="col-sm-12 col-md-6 col-lg-3 my-2">
10-
{% if author.image %}
11-
<img class="img-fluid" src="{{ author.image }}">
12-
{% else %}
13-
<img class="img-fluid" src="{% static 'images/person-dummy.jpg' %}">
14-
{% endif %}
7+
<span vocab="https://schema.org/" typeof="Person">
8+
<h1><span property="name">{{ author.name }}</span></h1>
9+
<div class="row">
10+
<div class="col-sm-12 col-md-6 col-lg-3 my-2">
11+
{% if author.image %}
12+
<img class="img-fluid" src="{{ author.image }}">
13+
<span property="image" content="{{ author.image }}"></span>
14+
{% else %}
15+
<img class="img-fluid" src="{% static 'images/person-dummy.jpg' %}">
16+
{% endif %}
17+
</div>
18+
<div class="col-sm-12 col-md-6 col-lg-9 my-2">
19+
<h2>Biography</h2>
20+
<hr class="review-separator">
21+
<p>{% if author.biography %}
22+
<span property="description">{{ author.biography }}</span>
23+
{% else %}
24+
We are sorry, at the moment, this author does not have a biography.
25+
{% endif %}</p>
26+
</div>
1527
</div>
16-
<div class="col-sm-12 col-md-6 col-lg-9 my-2">
17-
<h2>Biography</h2>
18-
<hr class="review-separator">
19-
<p>{% if author.biography %}{{ author.biography }}{% else %}We are sorry, at the moment, this author does not have a biography.{% endif %}</p>
20-
</div>
21-
</div>
28+
</span>
2229
{% endblock %}

‎Base/templates/Base/book.html

+123-101
Original file line numberDiff line numberDiff line change
@@ -3,120 +3,142 @@
33
{% block title %}{{ book.title }}{% endblock %}
44

55
{% block content %}
6-
<h1>{{ book.title }}</h1>
7-
<div class="row">
8-
<div class="col-sm-12 col-md-6 col-lg-4 my-2">
9-
{% if not book.image %}
10-
<img class="img-fluid" src="../../static/images/NoCover.jpeg">
11-
{% else %}
12-
<img class="img-fluid" src="{{ book.image }}">
13-
{% endif %}
14-
<div class="d-grid gap-2">
15-
{% if not read_by_user %}
16-
<button type="button" id="read-button" class="btn btn-primary my-2">Mark as read</button>
6+
<span vocab="https://schema.org/" typeof="Book">
7+
<h1>
8+
<span rel="name">{{ book.title }}</span>
9+
</h1>
10+
<div class="row">
11+
<div class="col-sm-12 col-md-6 col-lg-4 my-2">
12+
{% if not book.image %}
13+
<img class="img-fluid" src="../../static/images/NoCover.jpeg">
1714
{% else %}
18-
<button type="button" id="read-button" class="btn my-2 btn-success" data-bs-toggle="modal" data-bs-target="#read-button-backdrop">Read</button>
15+
<span property="image" content="{{ book.image }}"></span>
16+
<img class="img-fluid" src="{{ book.image }}">
1917
{% endif %}
20-
21-
<!-- Modal -->
22-
<div class="modal fade" id="read-button-backdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
23-
<div class="modal-dialog">
24-
<div class="modal-content">
25-
<div class="modal-header">
26-
<h1 class="modal-title fs-5" id="staticBackdropLabel">Are you sure you want to remove the book from your reading list?</h1>
27-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
28-
</div>
29-
<!-- <div class="modal-body">
30-
...
31-
</div> -->
32-
<div class="modal-footer">
33-
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">No</button>
34-
<button type="button" id="remove-book-button" class="btn btn-primary" data-bs-dismiss="modal">Yes</button>
18+
<div class="d-grid gap-2">
19+
{% if not read_by_user %}
20+
<button type="button" id="read-button" class="btn btn-primary my-2">Mark as read</button>
21+
{% else %}
22+
<button type="button" id="read-button" class="btn my-2 btn-success" data-bs-toggle="modal" data-bs-target="#read-button-backdrop">Read</button>
23+
{% endif %}
24+
25+
<!-- Modal -->
26+
<div class="modal fade" id="read-button-backdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
27+
<div class="modal-dialog">
28+
<div class="modal-content">
29+
<div class="modal-header">
30+
<h1 class="modal-title fs-5" id="staticBackdropLabel">Are you sure you want to remove the book from your reading list?</h1>
31+
<button typse="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
32+
</div>
33+
<!-- <div class="modal-body">
34+
...
35+
</div> -->
36+
<div class="modal-footer">
37+
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">No</button>
38+
<button type="button" id="remove-book-button" class="btn btn-primary" data-bs-dismiss="modal">Yes</button>
39+
</div>
40+
</div>
3541
</div>
3642
</div>
37-
</div>
38-
</div>
39-
</div>
43+
</div>
4044

41-
<table class="table">
42-
<tbody>
43-
<tr>
44-
<th scope="col">Authors</th>
45-
<td id="authors-field">
46-
{% if authors %}
47-
{% for author in authors %}
48-
<a class="link-secondary" href="{% url 'author' author_id=author.author.openlibrary_key %}">{{ author.author.name }}</a>{% if not forloop.last %}, {% endif %}
45+
<table class="table">
46+
<tbody>
47+
<tr>
48+
<th scope="col">Authors</th>
49+
<td id="authors-field">
50+
{% if authors %}
51+
{% for author in authors %}
52+
{% url 'author' author_id=author.author.openlibrary_key as author_url%}
53+
<a class="link-secondary" href="{{ author_url }}">
54+
<div property="author" typeof="Person">
55+
<span property="name">{{ author.author.name }}</span>
56+
<span property="url" content="{{ author_url }}"></span>
57+
</div>
58+
</a>{% if not forloop.last %}, {% endif %}
59+
{% endfor %}
60+
{% else %}
61+
No authors
62+
{% endif %}
63+
</td>
64+
</tr>
65+
{% if genres %}
66+
<tr>
67+
<th scope="row">Genres</th>
68+
<td id="genres-field" rel="genre">
69+
{% for genre in genres %}
70+
<a class="link-secondary" href="{% url 'subject' genre.literary_genre.clean_name %}"><span rel="genre" content="{% url 'subject' genre.literary_genre.clean_name %}">{{ genre.literary_genre.name }}</span></a>{% if not forloop.last %}, {% endif %}
4971
{% endfor %}
72+
</td>
73+
</tr>
74+
{% endif %}
75+
</tbody>
76+
</table>
77+
</div>
78+
<div class="col-sm-12 col-md-6 col-lg-8 my-2">
79+
<h2>Summary</h2>
80+
<hr class="review- separator">
81+
<p>{% if book.summary %}
82+
<span property="abstract">{{ book.summary }}</span>
83+
{% else %}We are sorry, at the moment, this book does not have summary.
84+
{% endif %}</p>
85+
<!-- Nuevo apartado para mostrar las reviews -->
86+
<div>
87+
<h2>Reviews</h2>
88+
{% if reviews %}
89+
<div rel="aggregateRating" typeof="AggregateRating">
90+
<h3><span property="ratingValue">Average rating: {{ book.qualification }}</span>(<span property="reviewCount">{{ book.review_set.all.count }}</span> reviews)</h3>
91+
</div>
92+
{% endif %}
93+
<hr class="review-separator">
94+
<h4>Leave a Review</h4>
95+
{% if user.is_authenticated %}
96+
{% block review_form %}
97+
{% if not user_review_exists %}
98+
<a href="{% url 'create_review' book.openlibrary_key %}" class="btn btn-primary">Write a review</a>
5099
{% else %}
51-
No authors
100+
<p>Yoy have already reviewed this book:</p>
101+
<a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit review</a>
102+
<a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete review</a>
52103
{% endif %}
53-
</td>
54-
</tr>
55-
{% if genres %}
56-
<tr>
57-
<th scope="row">Genres</th>
58-
<td id="genres-field">
59-
{% for genre in genres %}
60-
<a class="link-secondary" href="{% url 'subject' genre.literary_genre.clean_name %}">{{ genre.literary_genre.name }}</a>{% if not forloop.last %}, {% endif %}
61-
{% endfor %}
62-
</td>
63-
</tr>
104+
{% endblock %}
105+
{% else %}
106+
<p>Please <a href="{% url 'register' %}">register</a> or <a href="{% url 'login' %}">log in</a> to leave a review.</p>
64107
{% endif %}
65-
</tbody>
66-
</table>
67-
</div>
68-
<div class="col-sm-12 col-md-6 col-lg-8 my-2">
69-
<h2>Summary</h2>
70-
<hr class="review-separator">
71-
<p>{% if book.summary %}{{ book.summary }}{% else %}We are sorry, at the moment, this book does not have summary.{% endif %}</p>
72-
<!-- Nuevo apartado para mostrar las reviews -->
73-
<div>
74-
<h2>Reviews</h2>
75-
<hr class="review-separator">
76-
<h4>Leave a Review</h4>
77-
{% if user.is_authenticated %}
78-
{% block review_form %}
79-
{% if not user_review_exists %}
80-
<a href="{% url 'create_review' book.openlibrary_key %}" class="btn btn-primary">Write a review</a>
81-
{% else %}
82-
<p>Yoy have already reviewed this book:</p>
83-
<a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit review</a>
84-
<a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete review</a>
85-
{% endif %}
86-
{% endblock %}
87-
{% else %}
88-
<p>Please <a href="{% url 'register' %}">register</a> or <a href="{% url 'login' %}">log in</a> to leave a review.</p>
89-
{% endif %}
90-
<hr class="review-separator">
91-
{% if reviews %}
92-
<div class="review-list">
93-
{% for review in reviews %}
94-
<div class="review">
95-
<div class="review-header">
96-
<div class="review-info">{{ review.user }} - {{review.date}}</div>
97-
<div class="review-rating">
98-
{% for _ in "x"|rjust:review.qualification|make_list %}
99-
<i class="fas fa-star"></i>
100-
{% endfor %}
108+
<hr class="review-separator">
109+
{% if reviews %}
110+
<div class="review-list">
111+
{% for review in reviews %}
112+
<div class="review" rel="review" typeof="Review">
113+
<div class="review-header">
114+
<div class="review-info"><span property="author" typeof="Person"><span property="name">{{ review.user.username }}</span></span> - <span property="publishDate" content="{{ review.date|date:"c" }}"></span>{{review.date}}</div>
115+
<div class="review-rating">
116+
{% for _ in "x"|rjust:review.qualification|make_list %}
117+
<i class="fas fa-star"></i>
118+
{% endfor %}
119+
<span property="worstRating" content="1"></span>
120+
<span property="ratingValue" content="{{ review.qualification }}"></span>
121+
<span property="bestRating" content="5"></span>
122+
</div>
101123
</div>
124+
<div class="review-comment"><span property="description">{{ review.comment }}</span></div>
125+
{% if user.is_authenticated and user == review.user %}
126+
<div class="review-actions">
127+
<a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit</a>
128+
<a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete</a>
129+
</div>
130+
{% endif %}
131+
<hr class="review-separator">
102132
</div>
103-
<div class="review-comment">{{ review.comment }}</div>
104-
{% if user.is_authenticated and user == review.user %}
105-
<div class="review-actions">
106-
<a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit</a>
107-
<a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete</a>
108-
</div>
109-
{% endif %}
110-
<hr class="review-separator">
111-
</div>
112-
{% endfor %}
113-
</div>
114-
{% else %}
115-
<p>No reviews available for this book.</p>
116-
{% endif %}
133+
{% endfor %}
134+
</div>
135+
{% else %}
136+
<p>No reviews available for this book.</p>
137+
{% endif %}
138+
</div>
117139
</div>
118140
</div>
119-
</div>
141+
</span>
120142
{% endblock %}
121143
{% block js %}
122144
<script>

‎ReadMore/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
DEBUG=(int, 0),
2424
)
2525

26-
#Read .env.local file
26+
#Read .env file
2727
environ.Env.read_env(BASE_DIR / '.env')
2828

2929

‎docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- db
1717
restart: always
1818
env_file:
19-
- .env.local
19+
- .env
2020
db:
2121
image: postgres
2222
volumes:

‎fly.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ kill_timeout = "5s"
1717
[env]
1818
PORT = "8000"
1919

20-
[[mounts]]
21-
source = "read_more_files"
22-
destination = "/media"
23-
2420
[[services]]
2521
protocol = "tcp"
2622
internal_port = 8000
@@ -41,4 +37,4 @@ kill_timeout = "5s"
4137

4238
[[statics]]
4339
guest_path = "/code/static"
44-
url_prefix = "/static/"
40+
url_prefix = "/static/"

0 commit comments

Comments
 (0)
Please sign in to comment.