Skip to content

New RSS component #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 5, 2024
83 changes: 83 additions & 0 deletions examples/official-site/sqlpage/migrations/37_rss.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- Documentation for the RSS component
INSERT INTO component (name, description, icon, introduced_in_version) VALUES (
'rss',
'Produces a data flow in the RSS format. To use this component, you must first returning an HTTP header with the "application/rss+xml" content type (see http_header component). Next, you must use the shell-empty component to avoid that SQLPage generates HTML code. TIPS: If you don''t want change the page shell, you can also use the _sqlpage_embed URL parameter.',
'rss',
'0.20.0'
);

INSERT INTO parameter (component,name,description,type,top_level,optional) VALUES (
'rss',
'title',
'Defines the title of the channel.',
'TEXT',
TRUE,
FALSE
),(
'rss',
'link',
'Defines the hyperlink to the channel.',
'URL',
TRUE,
FALSE
),(
'rss',
'description',
'Describes the channel.',
'TEXT',
TRUE,
FALSE
),(
'rss',
'title',
'Defines the title of the item.',
'TEXT',
FALSE,
FALSE
),(
'rss',
'link',
'Defines the hyperlink to the item',
'URL',
FALSE,
FALSE
),(
'rss',
'description',
'Describes the item',
'TEXT',
FALSE,
FALSE
),(
'rss',
'pubdate',
'Indicates when the item was published (RFC-822 date-time).',
'TEXT',
FALSE,
TRUE
);

-- Insert example(s) for the component
INSERT INTO example (component, description)
VALUES (
'rss',
'
### An RSS chanel about SQLPage latest news.

```sql
select
''rss'' as component,
''SQLPage blog'' as title,
''https://sql.ophir.dev/blog.sql'' as link,
''latest news about SQLpage'' as description;
select
''Hello everyone !'' as title,
''https://sql.ophir.dev/blog.sql?post=Come%20see%20me%20build%20twitter%20live%20on%20stage%20in%20Prague'' as link,
''If some of you european SQLPagers are around Prague this december, I will be giving a talk about SQLPage at pgconf.eu on December 14th.'' as description;
select
''3 solutions to the 3 layer problem'' as title,
''https://sql.ophir.dev/blog.sql?post=3%20solutions%20to%20the%203%20layer%20problem'' as link,
''Some interesting questions emerged from the article Repeating yourself.'' as description,
''Mon, 04 Dec 2023 00:00:00 GMT'' as pubdate;
```
');
17 changes: 17 additions & 0 deletions sqlpage/templates/rss.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{{title}}</title>
<link>{{link}}</link>
<description>{{description}}</description>
{{#each_row}}
<item>
<title>{{title}}</title>
<link>{{link}}</link>
<description><![CDATA[{{description}}]]></description>
{{~#if pubdate}}<pubDate>{{pubdate}}</pubDate>{{/if}}
</item>
{{/each_row}}
</channel>
</rss>