Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| blocks:app-note:rss-feed [2024-03-14 09:27] – [The example block] mattias | blocks:app-note:rss-feed [2024-03-14 13:10] (current) – mattias | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====Use RSS in Blocks===== | =====Use RSS in Blocks===== | ||
| - | This application note exemplifies how to use a feed script to parse a RSS feed and use child replication in blocks to publish the content on a spot. | + | This application note assumes previous experience with blocks, it exemplifies how to use a feed script to parse an RSS feed and use child replication in blocks to publish the content on a spot. |
| - | [[https:// | + | [[https:// |
| - | ====Installation==== | + | |
| - | This zip contains an exported block and the feed script file and its typescript source file. | + | |
| + | ====Installation==== | ||
| - | * Make sure you have the latest script dependencies from https:// | + | * Make sure you have the latest script dependencies from https:// |
| - | * Copy the RSS.ts and _RSS.js from the script/ | + | * Enable the script by copying |
| * Restart blocks. This will enable the script and the script will write an example configuration file in scripts/ | * Restart blocks. This will enable the script and the script will write an example configuration file in scripts/ | ||
| - | * Rename the example file Rss.config.example.json to Rss.config.json | + | * Rename the example file Rss.config.example.json to Rss.config.json |
| - | * Create a task with a do statement bound the the callable | + | * Create a task with a do statement bound the scripts |
| - | * Run the task to consider | + | * Run the task to restart the script and use the sample |
| * Download the example block from here: {{ : | * Download the example block from here: {{ : | ||
| - | * Import the example block into the editor using the import | + | * Import the example block into the editor using the Block/ |
| - | * Open the block in the editor | + | * Test by open the block in for editing |
| + | |||
| + | You should expect something like this in the preview: | ||
| + | {{: | ||
| + | |||
| + | :!: Please note, if working with feeds on spots, it is the spot that downloads any images, not the server, hence the spot must be able to access any images. | ||
| + | |||
| Line 24: | Line 30: | ||
| ====The example block==== | ====The example block==== | ||
| - | The example block uses child replication to replicate one slide per feed item in a slideshow. | + | The example block uses child replication to replicate one slide per feed item in a slideshow. |
| - | The block uses a spot parameter named //feed// to parametrize the property paths to accomodate | + | The block uses a spot parameter named //feed// to parametrize the property paths to accomodate |
| If no such parameter has been configured on the spot itself with a value it will fall back to the //Formal Value// used in the block itself : | If no such parameter has been configured on the spot itself with a value it will fall back to the //Formal Value// used in the block itself : | ||
| Line 37: | Line 43: | ||
| ====Configure the script==== | ====Configure the script==== | ||
| ===Configuration file=== | ===Configuration file=== | ||
| - | This feedscript can use a configuration file // | + | This feedscript can use an optional |
| In the example configuration we can see an entry where a preferred image size has been indicated. This setting only works for feeds that contain what's in RSS called a < | In the example configuration we can see an entry where a preferred image size has been indicated. This setting only works for feeds that contain what's in RSS called a < | ||
| - | Use the //maxAge// to control for how long we want to show the article in the feed, and use the maxLength | + | Use the //maxAge// to control for how long we want to show the article in the feed, and use the maxLength |
| Exampel configuration: | Exampel configuration: | ||
| Line 69: | Line 75: | ||
| - | ===Configure with task=== | + | ===Configure |
| - | As an option configure feeds in runtime using a callable on the script as in this example: | + | Feeds can be configured |
| {{: | {{: | ||
| - | The options are basically the same but will only be added if a task has been setup to be triggered at startup | + | The options are basically the same as with the config file method, |
| - | If using task to configure feeds one may want to remove the config file. | + | If using the task to configure feeds one may want to remove the config file if present. |
| ===Reinitialize the script=== | ===Reinitialize the script=== | ||
| - | The feed script exposes a second callable that merely | + | The feed script exposes a second callable that merely |
| ====Styling==== | ====Styling==== | ||
| - | In the example block we use a CSS trick to be able to add ellipsis | + | In the example block we use a CSS trick to be able to add ellipses |
| - | The ellipsis css rule: | + | The ellipsis css rule used here: |
| < | < | ||
| .rss .multi-line-ellipsis { | .rss .multi-line-ellipsis { | ||
| Line 92: | Line 98: | ||
| } | } | ||
| </ | </ | ||
| + | |||