Skip to content

Commit ce4c378

Browse files
author
Lucas Araujo
committed
feat: add Readeck integration with live stats and configuration
Add new Readeck application integration including: - Live stats display for bookmarks count - Configuration page for API settings - App metadata and icon - PHP class for API interaction
1 parent ff057fe commit ce4c378

5 files changed

Lines changed: 92 additions & 0 deletions

File tree

Readeck/Readeck.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace App\SupportedApps\Readeck;
4+
5+
class Readeck extends \App\SupportedApps implements \App\EnhancedApps
6+
{
7+
8+
public $config;
9+
10+
//protected $login_first = true; // Uncomment if api requests need to be authed first
11+
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
12+
13+
public function __construct()
14+
{
15+
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
16+
}
17+
18+
public function test()
19+
{
20+
$test = parent::appTest($this->url("api/contacts"));
21+
echo $test->status;
22+
}
23+
24+
public function livestats()
25+
{
26+
$status = 'inactive';
27+
$res = parent::execute(
28+
$this->url('api/bookmarks?is_archived=false'),
29+
$this->attrs()
30+
);
31+
32+
$details = json_decode($res->getBody());
33+
34+
$data = [];
35+
36+
if ($details) {
37+
$status = 'active';
38+
$data["bookmarks_count"] = count($details);
39+
}
40+
41+
return parent::getLiveStats($status, $data);
42+
}
43+
44+
public function url($endpoint)
45+
{
46+
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
47+
return $api_url;
48+
}
49+
50+
public function attrs()
51+
{
52+
$apikey = $this->config->apikey;
53+
$attrs = [
54+
"headers" => [
55+
"content-type" => "application/json",
56+
"Authorization" => "Bearer " . $apikey,
57+
],
58+
];
59+
return $attrs;
60+
}
61+
}

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)