Skip to content

Commit 3c67938

Browse files
author
Lucas Araujo
committed
feat(Tachidesk): add livestats and config support for Tachidesk app
Implement livestats functionality to display active series and unread chapters Add config page with URL override and category selection Update app description and enable enhanced features
1 parent ff057fe commit 3c67938

File tree

5 files changed

+95
-10
lines changed

5 files changed

+95
-10
lines changed

Tachidesk/Tachidesk.php

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,70 @@
22

33
namespace App\SupportedApps\Tachidesk;
44

5-
class Tachidesk extends \App\SupportedApps
5+
use Log;
6+
7+
class Tachidesk extends \App\SupportedApps implements \App\EnhancedApps
68
{
9+
public $config;
10+
11+
public function __construct() {
12+
}
13+
14+
public function test()
15+
{
16+
$test = parent::appTest($this->url('api/v1/settings/about'));
17+
echo $test->status;
18+
}
19+
20+
public function livestats()
21+
{
22+
$status = 'inactive';
23+
24+
$category = $this->getCategory();
25+
Log::info('Tachidesk: livestats: category: ' . $category);
26+
27+
$res = parent::execute($this->url('api/v1/category/' . $category));
28+
$details = json_decode($res->getBody());
29+
30+
if ($details) {
31+
$status = 'active';
32+
$data = [
33+
"unread_chapters_count" => $this->getChapterCount($details),
34+
"active_series_count" => count($details),
35+
];
36+
}
37+
38+
return parent::getLiveStats($status, $data);
39+
}
40+
41+
public function url($endpoint)
42+
{
43+
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
44+
return $api_url;
45+
}
46+
47+
private function getChapterCount($categoryDetails)
48+
{
49+
$chapterCount = 0;
50+
foreach ($categoryDetails as $series) {
51+
$chapterCount += $series->unreadCount ?? 0;
52+
}
53+
return $chapterCount;
54+
}
55+
56+
private function getCategory()
57+
{
58+
if (isset($this->config->category)) {
59+
$res = parent::execute($this->url('api/v1/category'));
60+
$resData = json_decode($res->getBody());
61+
$collectedResponse = collect($resData);
62+
63+
$filteredResponse = $collectedResponse->whereIn('name', [$this->config->category]);
64+
if ($filteredResponse->count() > 0) {
65+
return $filteredResponse->first()->id;
66+
}
67+
}
68+
69+
return '0';
70+
}
771
}

Tachidesk/app.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"appid": "1de00f5662a5c44f3d23b50f9e13232cdd64f667",
3-
"name": "Tachidesk",
4-
"website": "https://github.com/Suwayomi/Tachidesk-Server",
5-
"license": "Mozilla Public License 2.0",
6-
"description": "A free and open source manga reader server that runs extensions built for Tachiyomi.\r\nTachidesk is an independent Tachiyomi compatible software and is not a Fork of Tachiyomi.",
7-
"enhanced": false,
8-
"tile_background": "dark",
9-
"icon": "tachidesk.png"
10-
}
2+
"appid": "1de00f5662a5c44f3d23b50f9e13232cdd64f667",
3+
"name": "Tachidesk",
4+
"website": "https://github.com/Suwayomi/Tachidesk-Sorayomi",
5+
"license": "Mozilla Public License 2.0",
6+
"description": "A free and open source manga reader based on Flutter to read manga from a Suwayomi-Server instance.",
7+
"enhanced": true,
8+
"tile_background": "dark",
9+
"icon": "tachidesk.png"
10+
}

Tachidesk/config.blade.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
2+
<div class="items">
3+
<div class="input">
4+
<label>{{ strtoupper(__('app.url')) }}</label>
5+
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
6+
</div>
7+
<div class="input">
8+
<label>Category ({{ __('app.optional') }})</label>
9+
{!! Form::text('config[category]', null, array('placeholder' => 'Default', 'data-config' => 'category', 'class' => 'form-control config-item')) !!}
10+
</div>
11+
<div class="input">
12+
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
13+
</div>
14+
</div>
15+

Tachidesk/livestats.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<ul class="livestats">
2+
<li>
3+
<strong style="font-size: 0.8em;">Active Series: {!! $active_series_count !!}</strong>
4+
<strong style="font-size: 0.7em; padding-top: 0.5em;">Unread Chapters: {!! $unread_chapters_count !!}</strong>
5+
</li>
6+
</ul>

Tachidesk/tachidesk.png

88.4 KB
Loading

0 commit comments

Comments
 (0)