From 96a0c8db655393b17d29663077d4fa9cbf0a623a Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 17 Nov 2024 16:46:52 +1100 Subject: [PATCH 1/3] Update logic --- links/templates/links/collection_detail.html | 38 ++--- links/templates/links/collection_list.html | 41 +++--- new_theme/static/css/dist/styles.css | 137 ++++++++++++++++++- 3 files changed, 175 insertions(+), 41 deletions(-) diff --git a/links/templates/links/collection_detail.html b/links/templates/links/collection_detail.html index 24a2bae..abe9548 100644 --- a/links/templates/links/collection_detail.html +++ b/links/templates/links/collection_detail.html @@ -35,48 +35,54 @@ -
-
-

{{ collection.name }}

+
+ +
+

{{ collection.name }}

{% if collection.description %}

{{ collection.description }}

{% endif %}
-
+ + +
+ - + class="inline-flex items-center px-3 py-2 sm:px-4 sm:py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50"> + - {% trans "Edit Collection" %} + + +
diff --git a/links/templates/links/collection_list.html b/links/templates/links/collection_list.html index d6eda56..e2f7fe6 100644 --- a/links/templates/links/collection_list.html +++ b/links/templates/links/collection_list.html @@ -3,12 +3,12 @@ {% load static %} {% block content %} -
-
-

{% trans "Image Collections" %}

+
+ -
+
{% for collection in collections %}
- +
-
+
{% with images=collection.images.all|slice:":4" %} {% for image in images %} -
+
{{ image.title }}
{% empty %}
- + -

{% trans "No images yet" %}

+

{% trans "No images yet" %}

{% endfor %} {% endwith %} @@ -45,33 +46,33 @@
-
-

+
+

{{ collection.name }}

-

+

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

{% if collection.description %} -

{{ collection.description }}

+

{{ collection.description }}

{% endif %}
-
+
- +
{% empty %} -
+
diff --git a/links/templates/links/help.html b/links/templates/links/help.html index d3b621d..6aeb174 100644 --- a/links/templates/links/help.html +++ b/links/templates/links/help.html @@ -213,6 +213,145 @@ curl -X POST http://localhost:8000/api/newsletters \ }' ``` +## Collection API Usage + +GoLinks provides RESTful APIs for managing image collections. Here are the available endpoints and their usage: + +### List Collections + +Retrieve a paginated list of all collections: +``` +GET /api/collections +GET /api/collections?page=2 +GET /api/collections?page_size=20 +``` +Response example: +```json +{ + "count": 10, + "next": "http://localhost:8000/api/collections?page=2", + "previous": null, + "results": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "name": "My Collection", + "description": "A collection of images", + "image_count": 5, + "created_at": "2024-01-01T00:00:00Z" + }, + // ... more collections + ] +} +``` + +### Create a Collection + +Create a new image collection: +``` +POST /api/collections +Content-Type: application/json + +{ + "name": "My Collection", + "description": "A collection of images" +} +``` +Response example: +```json +{ + "status": "success", + "message": "Collection created successfully", + "data": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "name": "My Collection", + "description": "A collection of images", + "image_count": 0, + "created_at": "2024-01-01T00:00:00Z" + } +} +``` + +### Upload Images to Collection + +Upload one or multiple images to a collection: +``` +POST /api/collections/{collection_id}/upload_images +Content-Type: multipart/form-data + +file: image1.jpg +file: image2.jpg +``` +Response example: +```json +{ + "status": "success", + "message": "Successfully uploaded 2 images", + "data": [ + { + "id": "550e8400-e29b-41d4-a716-446655440001", + "title": "image1.jpg", + "content_type": "image/jpeg", + "size": 1024000, + "url": "https://your-r2-domain.com/images/...", + "created_at": "2024-01-01T00:00:00Z" + }, + { + "id": "550e8400-e29b-41d4-a716-446655440002", + "title": "image2.jpg", + "content_type": "image/jpeg", + "size": 2048000, + "url": "https://your-r2-domain.com/images/...", + "created_at": "2024-01-01T00:00:00Z" + } + ] +} +``` + +### Delete an Image + +Delete a specific image from a collection: +``` +DELETE /api/images/{image_id} +``` +Response example: +```json +{ + "status": "success", + "message": "Image deleted successfully" +} +``` + +### Delete a Collection + +Delete a collection and all its images: +``` +DELETE /api/collections/{collection_id} +``` +Response example: +```json +{ + "status": "success", + "message": "Collection deleted successfully" +} +``` + +### Error Responses + +In case of errors, the API will return appropriate status codes and error messages: +```json +{ + "status": "error", + "message": "Error description here" +} +``` + +Common status codes: +- 200: Success +- 201: Created +- 400: Bad Request +- 404: Not Found +- 500: Internal Server Error + {% endfilter %}
From 1b533040f1ca92e5ba9d5c55b42ba0da92c62191 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 17 Nov 2024 17:02:18 +1100 Subject: [PATCH 3/3] Update logic --- links/templates/links/collection_list.html | 120 +++++++++++---------- new_theme/static/css/dist/styles.css | 23 ++++ 2 files changed, 86 insertions(+), 57 deletions(-) diff --git a/links/templates/links/collection_list.html b/links/templates/links/collection_list.html index 93a0c94..27c747d 100644 --- a/links/templates/links/collection_list.html +++ b/links/templates/links/collection_list.html @@ -18,65 +18,71 @@
{% for collection in collections %} -
- - -
-
- {% with images=collection.images.all|slice:":4" %} - {% for image in images %} -
- {{ image.title }} -
- {% empty %} -
- - - -

{% trans "No images yet" %}

-
- {% endfor %} - {% endwith %} +
{% empty %} diff --git a/new_theme/static/css/dist/styles.css b/new_theme/static/css/dist/styles.css index e826792..71d1cf1 100644 --- a/new_theme/static/css/dist/styles.css +++ b/new_theme/static/css/dist/styles.css @@ -793,6 +793,13 @@ video { -webkit-line-clamp: 3; } +.line-clamp-1 { + overflow: hidden; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; +} + .block { display: block; } @@ -869,6 +876,14 @@ video { height: 2rem; } +.h-\[160px\] { + height: 160px; +} + +.h-\[280px\] { + height: 280px; +} + .w-12 { width: 3rem; } @@ -2235,6 +2250,14 @@ video { height: 1.25rem; } + .sm\:h-\[200px\] { + height: 200px; + } + + .sm\:h-\[320px\] { + height: 320px; + } + .sm\:w-10 { width: 2.5rem; }