freshrss-kagi-summarizer/extension.php

35 lines
1.1 KiB
PHP

<?php
class KagiSummarizerExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
$this->registerHook('entry_before_display', [$this, 'addSummarizeButton']);
//Minz_View::appendScript($this->getFileUrl('script.js', 'js'), false, false, false);
//Minz_View::appendStyle($this->getFileUrl('style.css', 'css'));
//Minz_View::appendScript(_url('kagiSummarizer', 'jsVars', false, true, false);
//$this->registerController('kagiSummarizer');
//$this->registerViews();
}
public function handleConfigureAction() {
$this->registerTranslates();
if (Minz_Request::isPost()) {
$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;
FreshRSS_Context::$user_conf->save();
}
}
public function addSummarizeButton(FreshRSS_Entry $entry): FreshRSS_Entry {
$entry->_content('<h1>Hello World</h1>' . $entry->_content());
return $entry;
}
}