Skip to content

Commit

Permalink
(#517) Add button to set the current page as the cover thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Jan 4, 2022
1 parent 40bcfa0 commit 7048a73
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
2 changes: 2 additions & 0 deletions public/js/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Reader.initializeAll = function () {
});
$(document).on("click.edit_metadata", "#edit-archive", () => LRR.openInNewTab(`./edit?id=${Reader.id}`));
$(document).on("click.add_category", "#add-category", () => Server.addArchiveToCategory(Reader.id, $("#category").val()));
$(document).on("click.set_thumbnail", "#set-thumbnail", () => Server.callAPI(`/api/archives/${Reader.id}/thumbnail?page=${Reader.currentPage + 1}`,
"PUT", `Successfully set page ${Reader.currentPage + 1} as the thumbnail!`, "Error updating thumbnail!", null));

$(document).on("click.thumbnail", ".quick-thumbnail", (e) => {
LRR.closeOverlay();
Expand Down
4 changes: 2 additions & 2 deletions templates/reader.html.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@

<h2>Admin Options</h2>

<input class="stdbtn" type='button' id="regenerate-thumbnail" value="Regenerate Archive Thumbnail"
disabled title="Coming back soon!" />
<input class="stdbtn" type='button' id="set-thumbnail" value="Set this Page as Thumbnail"
title="Set the currently opened page as the thumbnail for this archive." />
<br>
<input id="regenerate-cache" class='stdbtn' type='button' value='Clean Archive Cache' />
<br>
Expand Down
49 changes: 43 additions & 6 deletions tools/Documentation/api-documentation/archive-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,31 @@ ID of the Archive to process.

{% swagger baseUrl="http://lrr.tvc-16.science" path="/api/archives/:id/thumbnail" method="get" summary="Get Archive Thumbnail" %}
{% swagger-description %}
Get the Thumbnail image for a given Archive. This endpoint will queue generation of the thumbnail in the background if it doesn't already exist, and return a placeholder image.
Get a Thumbnail image for a given Archive. This endpoint will queue generation of the thumbnail in the background if it doesn't already exist, and return a placeholder image.
If you want to get the background job ID instead of the placeholder, you can use the `no_fallback` query parameter.
{% endswagger-description %}

{% swagger-parameter name="id" type="string" required="true" in="path" %}
ID of the Archive to process.
{% endswagger-parameter %}
{% swagger-parameter name="page" type="int" required="false" in="query" %}
Specify which page you want to get a thumbnail for. Defaults to the cover, aka page 1.
{% endswagger-parameter %}
{% swagger-parameter name="no_fallback" type="boolean" required="false" in="query" %}
Disables the placeholder image and returns a JSON if the thumbnail is queued for extraction. This parameter does nothing if the image already exists.
{% endswagger-parameter %}

{% swagger-response status="202" description="The thumbnail is queued for extraction. Use `/api/minion/:jobid` to track when your thumbnail is ready." %}
```javascript
{
"operation": "______",
"error": "No archive ID specified.",
"success": 0
"job": 2429,
"operation": "serve_thumbnail",
"success": 1
}
```
{% endswagger-response %}

{% swagger-response status="200" description="" %}
{% swagger-response status="200" description="If the thumbnail was already extracted, you get it directly." %}
{% tabs %}
{% tab title="2810d5e0a8d027ecefebca6237031a0fa7b91eb3.jpg" %}
```
Expand All @@ -182,7 +185,7 @@ Disables the placeholder image and returns a JSON if the thumbnail is queued for
{% swagger-response status="400" description="" %}
```javascript
{
"operation": "______",
"operation": "serve_thumbnail",
"error": "No archive ID specified.",
"success": 0
}
Expand Down Expand Up @@ -363,6 +366,40 @@ Current page to update the reading progress to. **Must** be a positive integer,
{% endswagger-response %}
{% endswagger %}

{% swagger baseUrl="http://lrr.tvc-16.science" path="/api/archives/:id/thumbnail" method="put" summary="🔑Update Thumbnail" %}
{% swagger-description %}
Update the cover thumbnail for the given Archive.
You can specify a page number to use as the thumbnail, or you can use the default thumbnail.
{% endswagger-description %}

{% swagger-parameter name="id" type="string" required="true" in="path" %}
ID of the Archive to process.
{% endswagger-parameter %}
{% swagger-parameter name="page" type="int" required="false" in="path" %}
Page you want to make the thumbnail out of. Defaults to 1.
{% endswagger-parameter %}

{% swagger-response status="200" description="" %}
```javascript
{
"operation": "update_thumbnail",
"success": 1,
"new_thumbnail": "/mnt//lrr/content/thumb/95/9595845d952e8141feeba375767248b960979bc2.jpg"
}
```
{% endswagger-response %}

{% swagger-response status="400" description="" %}
```javascript
{
"operation": "update_thumbnail",
"error": "No archive ID specified.",
"success": 0
}
```
{% endswagger-response %}
{% endswagger %}

{% swagger baseUrl="http://lrr.tvc-16.science" path="/api/archives/:id/metadata" method="put" summary="🔑Update Archive Metadata" %}
{% swagger-description %}
Update tags and title for the given Archive. Data supplied to the server through this method will **overwrite** the previous data.
Expand Down

0 comments on commit 7048a73

Please sign in to comment.