Skip to content

Commit 3a09b21

Browse files
lucaslraLucas Araujo
andauthored
feat(Tachidesk): add livestats and config support for Tachidesk app (#872)
* 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 * Fixed tachidesk logo size * refactor: remove unused Log import and debug statement --------- Co-authored-by: Lucas Araujo <[email protected]>
1 parent 0c39521 commit 3a09b21

File tree

5 files changed

+92
-10
lines changed

5 files changed

+92
-10
lines changed

Tachidesk/Tachidesk.php

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

33
namespace App\SupportedApps\Tachidesk;
44

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

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

2.3 KB
Loading

0 commit comments

Comments
 (0)