Skip to content

Commit 6e722b3

Browse files
authored
Merge pull request #959 from memeLab/change-profile-page-layout
Change profile page layout
2 parents dbc4735 + 8653a55 commit 6e722b3

58 files changed

Lines changed: 10171 additions & 975 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/blog/static/css/blog.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#blog-area,
33
#clipping-area,
44
#posts-area{
5-
max-width: 600px;
5+
max-width: 100%;
66
margin: 0 auto;
77
}
88
.post{
@@ -31,7 +31,7 @@
3131
/* Post Detail Page */
3232
#post,
3333
#post-area{
34-
max-width: 600px;
34+
max-width: 100%;
3535
margin: 1.5em auto;
3636
}
3737
#post{

src/config/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def debug(_):
154154

155155
PAGE_SIZE = 20
156156
MODAL_PAGE_SIZE = 40
157+
OBJECT_MODAL_PAGE_SIZE = 16
157158

158159
REST_FRAMEWORK = {
159160
"DEFAULT_RENDERER_CLASSES": [

src/core/admin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class MarkerAdmin(BaseMarkerObjectAdmin):
131131
]
132132

133133
def image_preview(self, obj):
134-
return format_html(obj.as_html_thumbnail(), "")
134+
return format_html(obj.as_html(height=64, width=64, thumbnail=True), "")
135135

136136

137137
@admin.action(description="Generate spritesheets for selected GIF objects")
@@ -215,7 +215,7 @@ class ObjectAdmin(BaseMarkerObjectAdmin):
215215
actions = [generate_spritesheets, "populate_dimensions"]
216216

217217
def image_preview(self, obj):
218-
return format_html(obj.as_html_thumbnail(), "")
218+
return format_html(obj.as_html(height=64, width=64), "")
219219

220220
def has_spritesheet(self, obj):
221221
return bool(obj.spritesheet_file and obj.spritesheet_metadata)
@@ -294,13 +294,13 @@ def exhibits_count(self, obj):
294294
exhibits_count.short_description = "Exhibits Count"
295295

296296
def marker_preview(self, obj):
297-
return format_html(obj.marker.as_html_thumbnail(), "")
297+
return format_html(obj.marker.as_html(height=64, width=64, thumbnail=True), "")
298298

299299
marker_preview.short_description = "Marker"
300300
marker_preview.allow_tags = True
301301

302302
def augmented_preview(self, obj):
303-
return format_html(obj.augmented.as_html_thumbnail(), "")
303+
return format_html(obj.augmented.as_html(height=64, width=64), "")
304304

305305
augmented_preview.short_description = "Augmented Object"
306306
augmented_preview.allow_tags = True
@@ -391,4 +391,4 @@ def _owner(self, obj):
391391
return format_html(HTML_LINK, link, obj.owner.user.username)
392392

393393
def preview(self, obj):
394-
return format_html(obj.as_html_thumbnail().replace(obj.title, ""), "")
394+
return format_html(obj.as_html(), "")
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{# Three-dot action menu component.
2+
Variables:
3+
- element: the model instance
4+
- element_type: string like "marker", "object", "artwork", "sound", "ar-exhibit", "mr-exhibit"
5+
- can_edit: boolean
6+
- can_delete: boolean
7+
- has_preview: boolean (only markers and artworks)
8+
- edit_reason: string explaining why edit is disabled (optional)
9+
- delete_reason: string explaining why delete is disabled (optional)
10+
#}
11+
<div class="action-menu-container">
12+
<button type="button"
13+
class="action-menu-trigger"
14+
aria-label="{{ _('Actions') }}">
15+
<svg width="20" height="20" viewBox="0 0 16 16" fill="currentColor">
16+
<circle cx="8" cy="3" r="1.5" /><circle cx="8" cy="8" r="1.5" /><circle cx="8" cy="13" r="1.5" />
17+
</svg>
18+
</button>
19+
<div class="action-menu-dropdown">
20+
{% if element_type == "ar-exhibit" or element_type == "mr-exhibit" %}
21+
{% set edit_url = url('edit-' ~ element_type) ~ '?id=' ~ element.id %}
22+
{% else %}
23+
{% set edit_url = url('edit-' ~ element_type) ~ '?id=' ~ element.id %}
24+
{% endif %}
25+
<a class="action-menu-item{% if not can_edit %} disabled{% endif %}"
26+
{% if can_edit %} href="{{ edit_url }}" {% else %} href="#" data-disabled="true" data-reason="{{ edit_reason }}" {% endif %}>
27+
{{ _("Edit") }}
28+
</a>
29+
{% if has_preview %}
30+
{% if element_type == "marker" %}
31+
{% set preview_url = url('marker-preview') ~ '?id=' ~ element.id %}
32+
{% elif element_type == "artwork" %}
33+
{% set preview_url = url('artwork-preview') ~ '?id=' ~ element.id %}
34+
{% endif %}
35+
<a class="action-menu-item" href="{{ preview_url }}">{{ _("Preview") }}</a>
36+
{% endif %}
37+
{% set delete_url = url('delete-content') ~ '?content_type=' ~ element_type ~ '&id=' ~ element.id %}
38+
<a class="action-menu-item action-menu-delete{% if not can_delete %} disabled{% endif %}"
39+
{% if can_delete %} href="{{ delete_url }}" data-confirm="{{ _('Are you sure you want to delete this item?') }}" {% else %} href="#" data-disabled="true" data-reason="{{ delete_reason }}" {% endif %}>
40+
{{ _("Delete") }}
41+
</a>
42+
</div>
43+
</div>

src/core/jinja2/core/components/item-list.jinja2

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@
66
{% for element in repository_list %}
77
<div {% if element_type != "ar-exhibit" and element_type != "mr-exhibit" and htmx != "false" %} hx-get="/api/v1/{{ element_type }}s/{{ element.id }}/?format=modal" hx-target="#modal" hx-trigger="click" class="repository-item trigger-modal" {% else %} class="repository-item" {% endif %}
88
id="{{ element_type }}-{{ element.id }}">
9-
{{ element.as_html_thumbnail(editable=editable) | safe }}
9+
{% if element_type == "marker" %}
10+
{% with marker=element %}
11+
{% include "core/templates/marker_thumbnail.jinja2" %}
12+
{% endwith %}
13+
{% elif element_type == "object" %}
14+
{% with object=element %}
15+
{% include "core/templates/object_thumbnail.jinja2" %}
16+
{% endwith %}
17+
{% elif element_type == "sound" %}
18+
{% with sound=element %}
19+
{% include "core/templates/sound_thumbnail.jinja2" %}
20+
{% endwith %}
21+
{% elif element_type == "artwork" %}
22+
{% with artwork=element %}
23+
{% include "core/templates/artwork_thumbnail.jinja2" %}
24+
{% endwith %}
25+
{% elif element_type == "ar-exhibit" or element_type == "mr-exhibit" %}
26+
{% with exhibit=element %}
27+
{% include "core/templates/exhibit_thumbnail.jinja2" %}
28+
{% endwith %}
29+
{% endif %}
1030
</div>
1131
{% endfor %}
1232
</section>

src/core/jinja2/core/exhibit_create_ar.jinja2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<section class="create-exhibit">
44
{# FIXME: maybe this can be improved #}
55
<link rel="stylesheet" href="{{ static ('css/marker-creation.css') }}">
6+
<link rel="stylesheet" href="{{ static ('css/repository-list.css') }}">
67
<link rel="stylesheet" href="{{ static ('css/label.css') }}">
78
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
89
<link rel="stylesheet"
@@ -37,7 +38,6 @@
3738
<div id="artwork-modal" class="tab">
3839
<h4 class="modal-title">{{ _("Select Artworks") }}</h4>
3940
{% if artworks %}
40-
<p class="gallery-title">{{ _("Choose from your repository") }}</p>
4141
{% with repository_list = artworks, element_type="artwork", htmx="false", selected=selected_artworks %}
4242
{% include "core/components/item-list.jinja2" %}
4343
{% endwith %}
@@ -103,7 +103,7 @@
103103
104104
selected_artworks.split(",").forEach(function(id){
105105
artworks[id] = id
106-
$("#artwork-"+id).css("border-bottom","3px solid #a6a6a6");
106+
$("#artwork-"+id).css("border-bottom","3px solid #05f7ae");
107107
});
108108
109109
}
@@ -126,7 +126,7 @@
126126
else
127127
console.error("Unknown item type: " + item_type);
128128
}else{
129-
$(this).css("border-bottom","3px solid #a6a6a6");
129+
$(this).css("border-bottom","3px solid #05f7ae");
130130
if (item_type === "artwork")
131131
artworks[item_id] = item_id;
132132
else

src/core/jinja2/core/exhibit_create_mr.jinja2

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<section class="create-exhibit">
44
{# FIXME: maybe this can be improved #}
55
<link rel="stylesheet" href="{{ static ('css/marker-creation.css') }}">
6+
<link rel="stylesheet" href="{{ static ('css/repository-list.css') }}">
67
<link rel="stylesheet" href="{{ static ('css/label.css') }}">
78
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
89
<link rel="stylesheet"
@@ -38,29 +39,23 @@
3839
{{ form.visible_fields()[4] .errors }}
3940
<div id="form-modal" class="modal">
4041
<div id="object-modal" class="tab">
41-
<h4 class="modal-title">{{ _("Select Objects") }}</h4>
42-
<div id="navigation-buttons"
43-
style="display: flex;
44-
justify-content: space-between;
45-
margin-bottom: 15px">
46-
<button style="width:2.5em;
47-
font-size: larger;
48-
margin:0"
42+
<div class="modal-nav-header">
43+
<button class="modal-nav-btn"
4944
id="previous-button-objects"
5045
hx-get="/elements/"
5146
hx-vals='js:{page: get_page_objects(-1), element_type: "object"}'
5247
hx-target="#repo-object"
5348
hx-swap="outerHTML">
5449
<
5550
</button>
56-
<button style="width:2.5em;
57-
font-size: larger;
58-
margin:0"
51+
<h4 class="modal-title">{{ _("Select Objects") }}</h4>
52+
<button class="modal-nav-btn"
5953
id="next-button-objects"
6054
hx-get="/elements/"
6155
hx-vals='js:{page: get_page_objects(1), element_type: "object"}'
6256
hx-target="#repo-object"
63-
hx-swap="outerHTML">></button>
57+
hx-swap="outerHTML"
58+
{% if total_object_pages <= 1 %}disabled="disabled"{% endif %}>></button>
6459
</div>
6560
{% with repository_list = objects, element_type="object", htmx="false" %}
6661
{% include "core/components/item-list.jinja2" %}
@@ -73,29 +68,23 @@
7368
onclick="validateSubmit()">{{ _("Okay") }}</a>
7469
</div>
7570
<div id="sound-modal" class="tab">
76-
<h4 class="modal-title">{{ _("Select Sounds") }}</h4>
77-
<div id="navigation-buttons"
78-
style="display: flex;
79-
justify-content: space-between;
80-
margin-bottom: 15px">
81-
<button style="width:2.5em;
82-
font-size: larger;
83-
margin:0"
71+
<div class="modal-nav-header">
72+
<button class="modal-nav-btn"
8473
id="previous-button-sounds"
8574
hx-get="/elements/"
8675
hx-vals='js:{page: get_page_sounds(-1), element_type: "sound"}'
8776
hx-target="#repo-sound"
8877
hx-swap="outerHTML">
8978
<
9079
</button>
91-
<button style="width:2.5em;
92-
font-size: larger;
93-
margin:0"
80+
<h4 class="modal-title">{{ _("Select Sounds") }}</h4>
81+
<button class="modal-nav-btn"
9482
id="next-button-sounds"
9583
hx-get="/elements/"
9684
hx-vals='js:{page: get_page_sounds(1), element_type: "sound"}'
9785
hx-target="#repo-sound"
98-
hx-swap="outerHTML">></button>
86+
hx-swap="outerHTML"
87+
{% if total_sound_pages <= 1 %}disabled="disabled"{% endif %}>></button>
9988
</div>
10089
{% with repository_list = sounds, element_type="sound", htmx="false" %}
10190
{% include "core/components/item-list.jinja2" %}
@@ -214,12 +203,12 @@
214203
215204
selected_objects.split(",").forEach(function(id){
216205
augmenteds[id] = id
217-
$("#object-"+id).css("border-bottom","3px solid #a6a6a6");
206+
$("#object-"+id).css("border-bottom","3px solid #05f7ae");
218207
});
219208
220209
selected_sounds.split(",").forEach(function(id){
221210
sounds[id] = id
222-
$("#sound-"+id).css("border-bottom","3px solid #a6a6a6");
211+
$("#sound-"+id).css("border-bottom","3px solid #05f7ae");
223212
});
224213
225214
}
@@ -245,7 +234,7 @@
245234
else
246235
console.error("Unknown item type: " + item_type);
247236
}else{
248-
$(this).css("border-bottom","3px solid #a6a6a6");
237+
$(this).css("border-bottom","3px solid #05f7ae");
249238
if (item_type === "object")
250239
augmenteds[item_id] = item_id;
251240
else if (item_type === "sound")

src/core/jinja2/core/exhibit_select.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends '/core/arviewer.jinja2' %}
1+
{% extends '/core/focused_layout.jinja2' %}
22
{% block content %}
33
{# FIXME: maybe this can be improved #}
44
<link rel="stylesheet" href="{{ static ('css/signup.css') }}">

src/core/jinja2/core/arviewer.jinja2 renamed to src/core/jinja2/core/focused_layout.jinja2

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@
2323
{% block extra_css %}{% endblock %}
2424
{% block extra_js %}{% endblock %}
2525
</head>
26-
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
27-
integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8="
28-
crossorigin="anonymous"></script>
29-
<script src="{{ static('js/bowser.js') }}"></script>
30-
<script src="{{ static('js/detect.js') }}"></script>
31-
<script src="{{ static('js/safari-only-warning.js') }}"></script>
32-
{# <script src="{{ static('js/main.js') }}"></script> #}
3326
<body class="colorful">
3427
{% if content is defined %}
3528
<section>

src/core/jinja2/core/header.jinja2

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@
77
</div>
88
<div class="aside">
99
{% if request.user.is_authenticated %}
10-
<div class="welcome">
11-
<p>
12-
{{ _("Welcome, ") }}<a href="{{ url('profile') }}">{{ request.user.username }}</a>
13-
</p>
10+
<div class="user-menu-wrapper">
11+
<span class="welcome-text">{{ _("Welcome,") }}</span>
12+
<button id="user-menu-btn" type="button" class="user-menu-button">{{ request.user.username }} ▾</button>
13+
<div id="user-menu-list" class="user-menu-list">
14+
<a href="{{ url('profile') }}" class="user-menu-option">{{ _("My Creations") }}</a>
15+
<a href="{{ url('edit-profile') }}" class="user-menu-option">{{ _("Edit profile") }}</a>
16+
<form id="logout-form"
17+
method="post"
18+
action="{{ url('logout') }}"
19+
style="margin:0">
20+
{{ csrf_input }}
21+
<button type="submit" class="user-menu-option">{{ _("Log out") }}</button>
22+
</form>
23+
</div>
1424
</div>
1525
{% else %}
1626
<div class="signup-btn">
@@ -24,3 +34,21 @@
2434
</div>
2535
</div>
2636
</div>
37+
<script>
38+
(function() {
39+
const btn = document.getElementById('user-menu-btn');
40+
const list = document.getElementById('user-menu-list');
41+
if (!btn || !list) return;
42+
43+
btn.addEventListener('click', function(e) {
44+
e.stopPropagation();
45+
list.classList.toggle('show');
46+
});
47+
48+
document.addEventListener('click', function(e) {
49+
if (!list.contains(e.target) && e.target !== btn) {
50+
list.classList.remove('show');
51+
}
52+
});
53+
})();
54+
</script>

0 commit comments

Comments
 (0)