2023-09-25 11:49:34 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class KagiSummarizerExtension extends Minz_Extension {
|
|
|
|
public function init() {
|
|
|
|
$this->registerTranslates();
|
2023-09-25 13:08:57 -05:00
|
|
|
$this->registerHook('entry_before_display', [$this, 'addSummarizeButton']);
|
2023-09-25 13:30:27 -05:00
|
|
|
Minz_View::appendScript($this->getFileUrl('script.js', 'js'), false, false, false);
|
2023-09-25 11:51:14 -05:00
|
|
|
//Minz_View::appendStyle($this->getFileUrl('style.css', 'css'));
|
2023-09-25 11:49:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function handleConfigureAction() {
|
|
|
|
$this->registerTranslates();
|
|
|
|
|
|
|
|
if (Minz_Request::isPost()) {
|
2023-09-25 12:38:33 -05:00
|
|
|
$kagi_token = Minz_Request::param('kagi_token', '');
|
|
|
|
$prefix = 'https://kagi.com/search?token=';
|
|
|
|
if (substr($kagi_token, 0, strlen($prefix)) == $prefix) {
|
|
|
|
$kagi_token = substr($kagi_token, strlen($prefix));
|
|
|
|
}
|
|
|
|
FreshRSS_Context::$user_conf->kagi_token = $kagi_token;
|
2023-09-25 11:49:34 -05:00
|
|
|
FreshRSS_Context::$user_conf->save();
|
|
|
|
}
|
2023-09-25 11:52:51 -05:00
|
|
|
}
|
2023-09-25 13:05:04 -05:00
|
|
|
|
|
|
|
public function addSummarizeButton(FreshRSS_Entry $entry): FreshRSS_Entry {
|
2023-09-25 13:24:33 -05:00
|
|
|
$this->registerTranslates();
|
|
|
|
|
2023-09-25 13:40:11 -05:00
|
|
|
$entry->_content('<p class="kagi-summary"><a class="btn" onClick="documentReady(); return false;" href="#">' . _t('ext.kagiSummarizer.ui.summarize_button') . '</a></p>' . $entry->content());
|
2023-09-25 13:05:04 -05:00
|
|
|
return $entry;
|
|
|
|
}
|
2023-09-25 11:49:34 -05:00
|
|
|
}
|