Web-Feed
Structr offers in-built support for web feeds. This article will provide detailed information on how to integrate feeds into an existing instance.
Data Types
A web feed is reduced to certain components that can be represented within the database.
Name | Description
– | –
DataFeed | The built-in type DataFeed is used to specify the source of a web feed. Once created, Structr is able to pull FeedItem entries from that source.
FeedItem | Contains information about a specific entry from a web feed. Furthermore relations to the feed entries’ content and enclosures are provided in the form of FeedItemContent and FeedItemEnclosure.
FeedItemContent | Represents the information found within the <content>
-tag of a web feed item and relates to a FeedItem.
FeedItemEnclosure | Represents the information found within the <enclosure>
-tag of a web feed item and relates to a FeedItem.
Configuring the web feed component
- Stop the Structr instance using
sudo service structr-ui stop
. - Set up the CronService within structr.conf to run the
UpdateFeedTask
periodically . See below for an example configuration. - Restart the instance using
sudo service structr-ui start
.
#### Specifying the feed update task for the CronService
CronService.tasks = org.structr.feed.cron.UpdateFeedTask
#### Setting up the execution interval in enhanced cron time format <minute> <hour> <day of the month> <month of the year> <day of the week> <year>
# In this example the web feed will be updated every 5 minutes
org.structr.feed.cron.UpdateFeedTask.cronExpression = 5 * * * * *
Setting up feeds
Create at least one DataFeed entry and specify the necessary attributes. Fore more details regarding this process refer to the DataFeed article.
Accessing the feed data
Once the CronService has executed the UpdateFeedTask
at least once, the feed data will be saved as FeedItem entries within the database and can be queried using the data types described above.
Hint
To automatically make newly created FeedItem entries visible to all users, add a custom onCreate
Callback-Function that sets the visibleToPublicUsers
and visibleToAuthenticatedUsers
attributes to true
.