From 9eec1ec34fe00dcb27b8a06a5d60f293afa49f97 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Thu, 19 Dec 2024 17:07:32 +1100 Subject: [PATCH] Add tags to image collection --- data/db.sqlite3 | Bin 331776 -> 335872 bytes links/forms.py | 3 +- links/migrations/0028_imagecollection_tags.py | 18 +++++ links/models.py | 1 + links/templates/links/collection_detail.html | 27 ++++++- links/templates/links/collection_form.html | 70 +++++++++++++++++- links/templates/links/collection_list.html | 46 +++++++++--- new_theme/static/css/dist/styles.css | 48 ++++++++++++ 8 files changed, 197 insertions(+), 16 deletions(-) create mode 100644 links/migrations/0028_imagecollection_tags.py diff --git a/data/db.sqlite3 b/data/db.sqlite3 index 140ec139ea38d5015bf6b3a7f73fc4364ac5f597..81c688a306c7150847dc68fb8e25488cb2d306a1 100644 GIT binary patch delta 1638 zcmb7EU2NM_6t=H@{gW>DCMYG-kS5oy3$0dTJ9g|ul-AN7hEP{DI+Y4Rnl?^J(`Bt% zB>FOzg7(0Wwh^=|O=y$}@eE{IUiUPH_5x36QxQWvAf7gaco`Dn+6hYpR4tZ#bno?d z&iTG`?(x~})Y+S#ie!2u;pA;E?__n?%@~f; zd?!`!rH2NAn!~uREU8Bt3L;NsL zVukIEgf@Sa+q~*3P-M-7|T_?1 z=}n*Ag58t@?J)oRYtZzj>v@Y-vD}mXg>L$%_w?(b(gufA{+&l1*;*)zY2RnxohED* z9D-5go~$-8t6;Ew-0%-LFbYCOmqC?WJpgA~7bF<)fSIHXcrLNUElKHmlB%5OsvO&u zZKu{=+0D6zohiIotE~0pKGs-^_mf&56r!SM{#Try3XDXKyHwza^0-B2KrTsexHXU9 zHcKz~AB=?WF!&Ds1^HxgKY+kEFbt-d4DnR&*!)0yTez>`wOV&1@H7< zx=h(3hPsC43I?WDCYDx)=6V)J=B6eV(<}9u{6R8i3P#3OCdO6gp z`66VDtV~VyOf8HI%}lr3>N6c*z{bk&!NBjao#z6RIRE4Z0rlzJ;Y=#qbM7-u2>?3l zJxENj&4GED1B(HSFTu_P^qB_(!*m4)7Lm;g1^4*3O<-Xukm2O$XW$p%%jQ1D&Bs;G z`I+MZM?aqhhb0ICeIUuf!t;qCY;vJM(Dr@~)>IZIMz_s{0#1xfhN;sha
-

{{ collection.name }}

{% if collection.description %} -

{{ collection.description }}

+
+

{% trans "Description" %}

+

{{ collection.description }}

+
{% endif %} + + +
+
+ {% for tag in collection.tags.all %} + + {{ tag.name }} + + {% empty %} + {% trans "No tags" %} + {% endfor %} +
+
@@ -319,6 +334,14 @@ {% block extra_js %} + + +{% endblock %} diff --git a/links/templates/links/collection_list.html b/links/templates/links/collection_list.html index 6a10ee8..657c648 100644 --- a/links/templates/links/collection_list.html +++ b/links/templates/links/collection_list.html @@ -49,17 +49,17 @@
-

- {{ collection.name }} -

-

- {{ collection.images.count }} {% trans "images" %} -

- {% if collection.description %} -

- {{ collection.description }} +

+

{{ collection.name }}

+ {% if collection.description %} +

{{ collection.description }}

+ {% endif %} + + +

+ {{ collection.images.count }} {% trans "images" %}

- {% endif %} +
@@ -142,6 +142,32 @@ function deleteCollection(collectionId) { }); } } + +document.addEventListener('DOMContentLoaded', function() { + const colors = [ + 'bg-blue-50 hover:bg-blue-100 text-blue-700', + 'bg-green-50 hover:bg-green-100 text-green-700', + 'bg-yellow-50 hover:bg-yellow-100 text-yellow-700', + 'bg-red-50 hover:bg-red-100 text-red-700', + 'bg-indigo-50 hover:bg-indigo-100 text-indigo-700', + 'bg-purple-50 hover:bg-purple-100 text-purple-700', + 'bg-pink-50 hover:bg-pink-100 text-pink-700', + 'bg-cyan-50 hover:bg-cyan-100 text-cyan-700', + 'bg-orange-50 hover:bg-orange-100 text-orange-700', + 'bg-teal-50 hover:bg-teal-100 text-teal-700', + 'bg-lime-50 hover:bg-lime-100 text-lime-700', + 'bg-emerald-50 hover:bg-emerald-100 text-emerald-700', + 'bg-sky-50 hover:bg-sky-100 text-sky-700', + 'bg-violet-50 hover:bg-violet-100 text-violet-700', + 'bg-rose-50 hover:bg-rose-100 text-rose-700', + 'bg-amber-50 hover:bg-amber-100 text-amber-700' + ]; + + document.querySelectorAll('.tag-card').forEach(tag => { + const randomColor = colors[Math.floor(Math.random() * colors.length)]; + tag.classList.add(...randomColor.split(' ')); + }); +}); {% endblock %} {% endblock %} diff --git a/new_theme/static/css/dist/styles.css b/new_theme/static/css/dist/styles.css index 3450973..40a1531 100644 --- a/new_theme/static/css/dist/styles.css +++ b/new_theme/static/css/dist/styles.css @@ -795,6 +795,14 @@ video { margin-top: 2rem; } +.-ml-4 { + margin-left: -1rem; +} + +.mb-3 { + margin-bottom: 0.75rem; +} + .line-clamp-1 { overflow: hidden; display: -webkit-box; @@ -916,6 +924,14 @@ video { min-height: 100vh; } +.min-h-0 { + min-height: 0px; +} + +.min-h-\[120px\] { + min-height: 120px; +} + .w-12 { width: 3rem; } @@ -1046,6 +1062,10 @@ video { user-select: all; } +.resize-y { + resize: vertical; +} + .resize { resize: both; } @@ -1120,6 +1140,10 @@ video { gap: 1.5rem; } +.gap-3 { + gap: 0.75rem; +} + .gap-x-4 { -moz-column-gap: 1rem; column-gap: 1rem; @@ -1248,6 +1272,10 @@ video { border-radius: 0.375rem; } +.rounded-xl { + border-radius: 0.75rem; +} + .rounded-l-md { border-top-left-radius: 0.375rem; border-bottom-left-radius: 0.375rem; @@ -1514,6 +1542,18 @@ video { background-color: rgb(245 243 255 / var(--tw-bg-opacity)); } +.bg-black\/50 { + background-color: rgb(0 0 0 / 0.5); +} + +.bg-black\/75 { + background-color: rgb(0 0 0 / 0.75); +} + +.bg-gray-900\/75 { + background-color: rgb(17 24 39 / 0.75); +} + .bg-opacity-20 { --tw-bg-opacity: 0.2; } @@ -1792,6 +1832,10 @@ video { line-height: 1.25; } +.leading-relaxed { + line-height: 1.625; +} + .tracking-normal { letter-spacing: 0em; } @@ -2898,4 +2942,8 @@ video { .xl\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } + + .xl\:grid-cols-5 { + grid-template-columns: repeat(5, minmax(0, 1fr)); + } }