Compare commits

...

2 Commits

5 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
$kagi_token = FreshRSS_Context::$user_conf->kagi_token; $kagi_token = FreshRSS_Context::$user_conf->kagi_token;
$kagi_language = FreshRSS_Context::$user_conf->kagi_language; $kagi_language = FreshRSS_Context::$user_conf->kagi_language;
$kagi_custom_css = FreshRSS_Context::$user_conf->kagi_custom_css;
function printLanguageOption($lang, $selected) { function printLanguageOption($lang, $selected) {
echo '<option ' . ($selected == $lang ? 'selected ' : '') . 'value="'. $lang . '">' echo '<option ' . ($selected == $lang ? 'selected ' : '') . 'value="'. $lang . '">'
. _t('ext.kagiSummarizer.configure.lang.' . strtolower($lang == '' ? 'default' : $lang)) . _t('ext.kagiSummarizer.configure.lang.' . strtolower($lang == '' ? 'default' : $lang))
@ -54,6 +55,13 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group">
<label class="group-name" for="kagi_custom_css"><?php echo _t('ext.kagiSummarizer.configure.kagi_custom_css'); ?></label>
<div class="group-controls">
<input type="text" name="kagi_custom_css" id="kagi_custom_css" value="<?php echo $kagi_custom_css; ?>">
<p><small><?php echo _t('ext.kagiSummarizer.configure.kagi_custom_css_help'); ?></small></p>
</div>
</div>
<div class="form-group form-actions"> <div class="form-group form-actions">
<div class="group-controls"> <div class="group-controls">
<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button> <button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>

View File

@ -20,12 +20,14 @@ class KagiSummarizerExtension extends Minz_Extension {
} }
FreshRSS_Context::$user_conf->kagi_token = $kagi_token; FreshRSS_Context::$user_conf->kagi_token = $kagi_token;
FreshRSS_Context::$user_conf->kagi_language = Minz_Request::param('kagi_language', ''); FreshRSS_Context::$user_conf->kagi_language = Minz_Request::param('kagi_language', '');
FreshRSS_Context::$user_conf->kagi_custom_css = Minz_Request::param('kagi_custom_css', '');
FreshRSS_Context::$user_conf->save(); FreshRSS_Context::$user_conf->save();
} }
} }
public function addSummarizeButton(FreshRSS_Entry $entry): FreshRSS_Entry { public function addSummarizeButton(FreshRSS_Entry $entry): FreshRSS_Entry {
$this->registerTranslates(); $this->registerTranslates();
$custom_css = FreshRSS_Context::$user_conf->kagi_custom_css;
$url_summary = Minz_Url::display(array( $url_summary = Minz_Url::display(array(
'c' => 'kagiSummarizer', 'c' => 'kagiSummarizer',
'a' => 'summarize', 'a' => 'summarize',
@ -46,7 +48,7 @@ class KagiSummarizerExtension extends Minz_Extension {
. '<a class="btn" href="' . $url_key_moments . '">' . '<a class="btn" href="' . $url_key_moments . '">'
. _t('ext.kagiSummarizer.ui.key_moments_button') . '</a>' . _t('ext.kagiSummarizer.ui.key_moments_button') . '</a>'
. '<p class="kagi-status hidden alert"></p>' . '<p class="kagi-status hidden alert"></p>'
. '<blockquote class="kagi-content hidden"></blockquote></div>' . '<blockquote class="kagi-content hidden" data-css="' . $custom_css . '"></blockquote></div>'
. $entry->content()); . $entry->content());
return $entry; return $entry;
} }

View File

@ -6,6 +6,8 @@ return array(
'kagi_token' => 'Kagi Token', 'kagi_token' => 'Kagi Token',
'kagi_token_help' => 'Copy and paste the "Session Link" from your <a href="https://kagi.com/settings?p=user_details" target="_blank">Kagi Account</a> settings.', 'kagi_token_help' => 'Copy and paste the "Session Link" from your <a href="https://kagi.com/settings?p=user_details" target="_blank">Kagi Account</a> settings.',
'kagi_language' => 'Output Language', 'kagi_language' => 'Output Language',
'kagi_custom_css' => 'Custom CSS',
'kagi_custom_css_help' => 'Applied to the summary container element.',
'lang' => array( 'lang' => array(
'default' => 'Default', 'default' => 'Default',
'bg' => 'Bulgarian', 'bg' => 'Bulgarian',

View File

@ -2,7 +2,7 @@
"name": "Kagi Summarizer", "name": "Kagi Summarizer",
"author": "Rudis Muiznieks", "author": "Rudis Muiznieks",
"description": "Add buttons to summarize articles with the Kagi Universal Summarizer.", "description": "Add buttons to summarize articles with the Kagi Universal Summarizer.",
"version": 0.2, "version": 0.3,
"entrypoint": "KagiSummarizer", "entrypoint": "KagiSummarizer",
"type": "user" "type": "user"
} }

View File

@ -22,6 +22,7 @@ function configureSummarizeButtons() {
function setKagiState(container, statusType, statusMsg, summaryText) { function setKagiState(container, statusType, statusMsg, summaryText) {
var kstatus = container.querySelector('.kagi-status'); var kstatus = container.querySelector('.kagi-status');
var content = container.querySelector('.kagi-content'); var content = container.querySelector('.kagi-content');
content.style.cssText = content.dataset.css;
switch(statusType) { switch(statusType) {
case 0: case 0: