-
Notifications
You must be signed in to change notification settings - Fork 3
/
extension.php
executable file
·51 lines (45 loc) · 1.58 KB
/
extension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
class ArticleSummaryExtension extends Minz_Extension
{
protected array $csp_policies = [
'default-src' => '*',
];
public function init()
{
$this->registerHook('entry_before_display', array($this, 'addSummaryButton'));
$this->registerController('ArticleSummary');
Minz_View::appendStyle($this->getFileUrl('style.css', 'css'));
Minz_View::appendScript($this->getFileUrl('axios.js', 'js'));
Minz_View::appendScript($this->getFileUrl('marked.js', 'js'));
Minz_View::appendScript($this->getFileUrl('script.js', 'js'));
}
public function addSummaryButton($entry)
{
$url_summary = Minz_Url::display(array(
'c' => 'ArticleSummary',
'a' => 'summarize',
'params' => array(
'id' => $entry->id()
)
));
$entry->_content(
'<div class="oai-summary-wrap">'
. '<button data-request="' . $url_summary . '" class="oai-summary-btn"></button>'
. '<div class="oai-summary-content"></div>'
. '</div>'
. $entry->content()
);
return $entry;
}
public function handleConfigureAction()
{
if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->oai_url = Minz_Request::param('oai_url', '');
FreshRSS_Context::$user_conf->oai_key = Minz_Request::param('oai_key', '');
FreshRSS_Context::$user_conf->oai_model = Minz_Request::param('oai_model', '');
FreshRSS_Context::$user_conf->oai_prompt = Minz_Request::param('oai_prompt', '');
FreshRSS_Context::$user_conf->oai_provider = Minz_Request::param('oai_provider', '');
FreshRSS_Context::$user_conf->save();
}
}
}