diff options
author | 2025-03-02 19:32:33 -0800 | |
---|---|---|
committer | 2025-03-02 19:32:33 -0800 | |
commit | 8b16dd20f6544af3eedf286e23c0d34ab525736c (patch) | |
tree | ec284e22a046c4c8e9626e3fa64a000a2747bf84 /bridges/QwenBlogBridge.php | |
parent | b183aa798af48af556496c42780d6e844172cf44 (diff) | |
parent | 00a24e2f694a319a5e6cb070dddfff2dae892378 (diff) | |
download | rss-bridge-master.tar.gz rss-bridge-master.tar.zst rss-bridge-master.zip |
Diffstat (limited to 'bridges/QwenBlogBridge.php')
-rw-r--r-- | bridges/QwenBlogBridge.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bridges/QwenBlogBridge.php b/bridges/QwenBlogBridge.php new file mode 100644 index 00000000..2af3f401 --- /dev/null +++ b/bridges/QwenBlogBridge.php @@ -0,0 +1,49 @@ +<?php + +class QwenBlogBridge extends FeedExpander +{ + const NAME = 'Qwen Blog'; + const URI = 'https://qwenlm.github.io/blog/'; + const DESCRIPTION = 'Fetch the latest items from Qwen'; + const MAINTAINER = 'sqrtminusone'; + const CACHE_TIMEOUT = 3600; + + const PARAMETERS = [ + '' => [ + 'limit' => [ + 'name' => 'Limit', + 'type' => 'number', + 'required' => true, + 'defaultValue' => 10 + ], + ] + ]; + + public function collectData() + { + $this->collectExpandableDatas(self::URI . 'index.xml', $this->getInput('limit')); + } + + protected function parseItem(array $item) + { + $dom = getSimpleHTMLDOM($item['uri']); + $content = $dom->find('div.post-content', 0); + if ($content == null) { + return $item; + } + + // Fix code blocks + foreach ($dom->find('pre.chroma') as $code_block) { + // Somehow there are tags in <pre>?? + $code_block_html = str_get_html($code_block->plaintext); + $code = ''; + foreach ($code_block_html->find('span.line') as $line) { + $code .= $line->plaintext . "\n"; + } + $code_block->outertext = '<pre>' . $code . '</pre>'; + } + + $item['content'] = $content; + return $item; + } +} |