From b4589ee3d02ede62e762275875a6e24752f1fc3d Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Mon, 8 Sep 2025 21:00:53 +0200 Subject: [PATCH 1/3] feat(Memos): add livestats and config support for Memos app Implement livestats functionality to display memo count and add config support for API access. Enable enhanced app features in app.json. --- Memos/Memos.php | 53 ++++++++++++++++++++++++++++++++++++++- Memos/app.json | 2 +- Memos/config.blade.php | 15 +++++++++++ Memos/livestats.blade.php | 6 +++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Memos/config.blade.php create mode 100644 Memos/livestats.blade.php diff --git a/Memos/Memos.php b/Memos/Memos.php index 71fc9472c7..ff3b802fc8 100644 --- a/Memos/Memos.php +++ b/Memos/Memos.php @@ -2,6 +2,57 @@ namespace App\SupportedApps\Memos; -class Memos extends \App\SupportedApps +class Memos extends \App\SupportedApps implements \App\EnhancedApps { + + public $config; + + public function __construct() {} + + public function test() + { + $test = parent::appTest( + $this->url('api/v1/auth/sessions/current'), + $this->attrs() + ); + echo $test->status; + } + + public function livestats() + { + $status = 'inactive'; + $res = parent::execute( + $this->url('api/v1/memos'), + $this->attrs() + ); + $details = json_decode($res->getBody()); + + $data = []; + + if ($details) { + $status = 'active'; + $data['memo_count'] = count($details->memos); + } + + return parent::getLiveStats($status, $data); + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url) . $endpoint; + return $api_url; + } + + + public function attrs() + { + $access_token = $this->config->access_token; + $attrs = [ + "headers" => [ + "content-type" => "application/json", + "Authorization" => "Bearer " . $access_token, + ], + ]; + return $attrs; + } } diff --git a/Memos/app.json b/Memos/app.json index 52d228a642..81a8f601e9 100644 --- a/Memos/app.json +++ b/Memos/app.json @@ -4,7 +4,7 @@ "website": "https://github.com/usememos/memos", "license": "MIT License", "description": "A privacy-first, lightweight note-taking service. Easily capture and share your great thoughts.", - "enhanced": false, + "enhanced": true, "tile_background": "light", "icon": "memos.png" } \ No newline at end of file diff --git a/Memos/config.blade.php b/Memos/config.blade.php new file mode 100644 index 0000000000..59969d7030 --- /dev/null +++ b/Memos/config.blade.php @@ -0,0 +1,15 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')

+
+
+ + {!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!} +
+
+ + {!! Form::text('config[access_token]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'access_token', 'class' => 'form-control config-item')) !!} +
+
+ +
+
+ diff --git a/Memos/livestats.blade.php b/Memos/livestats.blade.php new file mode 100644 index 0000000000..4d50c9bf1a --- /dev/null +++ b/Memos/livestats.blade.php @@ -0,0 +1,6 @@ + \ No newline at end of file From 4355c5af0e9ed2f7d7ff3136c007594c0cd94004 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Wed, 10 Sep 2025 20:20:57 +0200 Subject: [PATCH 2/3] style(Memos): improve code formatting and readability --- Memos/Memos.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Memos/Memos.php b/Memos/Memos.php index ff3b802fc8..695cf789c4 100644 --- a/Memos/Memos.php +++ b/Memos/Memos.php @@ -4,10 +4,11 @@ class Memos extends \App\SupportedApps implements \App\EnhancedApps { - public $config; - public function __construct() {} + public function __construct() { + + } public function test() { From 4d63f0734025e9b0d5a576f406de8a5a2d3707f4 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Sat, 13 Sep 2025 17:26:56 +0200 Subject: [PATCH 3/3] style: remove empty line in Memos constructor --- Memos/Memos.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Memos/Memos.php b/Memos/Memos.php index 695cf789c4..1c2a28a31e 100644 --- a/Memos/Memos.php +++ b/Memos/Memos.php @@ -7,7 +7,6 @@ class Memos extends \App\SupportedApps implements \App\EnhancedApps public $config; public function __construct() { - } public function test()