Skip to content

Commit ece131b

Browse files
lucaslraLucas Araujo
andauthored
feat: add Readeck integration with live stats and config (#866)
* feat: add Readeck integration with live stats and config Add support for Readeck application including live stats display for bookmarks count and configuration options for API key and URL override * style: fix constructor formatting in Readeck class * refactor: remove empty constructor from Readeck class --------- Co-authored-by: Lucas Araujo <[email protected]>
1 parent 4f59693 commit ece131b

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

Readeck/Readeck.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace App\SupportedApps\Readeck;
4+
5+
class Readeck extends \App\SupportedApps implements \App\EnhancedApps
6+
{
7+
public $config;
8+
9+
public function __construct() {
10+
}
11+
12+
public function test()
13+
{
14+
$test = parent::appTest($this->url("api/contacts"));
15+
echo $test->status;
16+
}
17+
18+
public function livestats()
19+
{
20+
$status = 'inactive';
21+
$res = parent::execute(
22+
$this->url('api/bookmarks?is_archived=false'),
23+
$this->attrs()
24+
);
25+
26+
$details = json_decode($res->getBody());
27+
28+
$data = [];
29+
30+
if ($details) {
31+
$status = 'active';
32+
$data["bookmarks_count"] = count($details);
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+
public function attrs()
45+
{
46+
$apikey = $this->config->apikey;
47+
$attrs = [
48+
"headers" => [
49+
"content-type" => "application/json",
50+
"Authorization" => "Bearer " . $apikey,
51+
],
52+
];
53+
return $attrs;
54+
}
55+
}

Readeck/app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"appid": "9ebfa3a7bc09302c2d7c55713d121bf073c9cc63",
3+
"name": "Readeck",
4+
"website": "https://readeck.org/",
5+
"license": "GNU Affero General Public License v3.0",
6+
"description": "Readeck is a simple web application that lets you save the precious readable content of web pages you like and want to keep forever.\r\nSee it as a bookmark manager and a read later tool.",
7+
"enhanced": true,
8+
"tile_background": "dark",
9+
"icon": "readeck.png"
10+
}

Readeck/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>{{ __('app.apps.apikey') }}</label>
9+
{!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', '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+

Readeck/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+
<span class="title">Bookmarks</span>
4+
<strong>{!! $bookmarks_count !!}</strong>
5+
</li>
6+
</ul>

Readeck/readeck.png

3.95 KB
Loading

0 commit comments

Comments
 (0)