Files
Cloud-CMS/modules/mastodon.xml

202 lines
8.8 KiB
XML
Raw Normal View History

2025-12-02 10:32:59 -05:00
<!--
~ Copyright (C) 2024 Xibo Signage Ltd
~
~ Xibo - Digital Signage - https://xibosignage.com
~
~ This file is part of Xibo.
~
~ Xibo is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ any later version.
~
~ Xibo is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with Xibo. If not, see <http://www.gnu.org/licenses/>.
-->
<module>
<id>core-mastodon</id>
<name>Mastodon</name>
<author>Core</author>
<description>Mastodon</description>
<icon>fab fa-mastodon</icon>
<class>\Xibo\Widget\MastodonProvider</class>
<type>mastodon</type>
<dataType>social-media</dataType>
<dataCacheKey>%hashtag%_%numItems%_%searchOn%_%onlyMedia%_%serverUrl%_%userName%</dataCacheKey>
<fallbackData>1</fallbackData>
<schemaVersion>1</schemaVersion>
<assignable>1</assignable>
<regionSpecific>1</regionSpecific>
<renderAs>html</renderAs>
<defaultDuration>60</defaultDuration>
<settings>
<property id="defaultServerUrl" type="text">
<title>Default Server URL</title>
<helpText>The default URL for the mastodon instance.</helpText>
<default>https://mastodon.social</default>
</property>
<property id="cachePeriodImages" type="number">
<title>Cache Period for Images</title>
<helpText>Please enter the number of hours you would like to cache mastodon images.</helpText>
<default>24</default>
</property>
<property id="cachePeriod" type="number">
<title>Cache Period</title>
<helpText>Please enter the number of seconds you would like to cache mastodon search results.</helpText>
<default>3600</default>
</property>
</settings>
<properties>
<property id="hashtag" type="text">
<title>Hashtag</title>
<helpText>Test your search by using a Hashtag to return results from the mastodon URL provided in the module settings.</helpText>
<default></default>
</property>
<property id="searchOn" type="dropdown" mode="single">
<title>Search on</title>
<helpText>Show only local/remote server posts.</helpText>
<default>all</default>
<options>
<option name="all">All known servers</option>
<option name="local">Local server</option>
<option name="remote">Remote servers</option>
</options>
</property>
<property id="serverUrl" type="text">
<title>Server</title>
<helpText>Leave empty to use the one from settings.</helpText>
<default></default>
</property>
<property id="userName" type="text">
<title>Username</title>
<helpText>Provide Mastodon username to get public statuses from the account.</helpText>
<default></default>
</property>
<property id="numItems" type="number">
<title>Count</title>
<helpText>The number of posts to return (default = 15).</helpText>
<default>15</default>
<rule>
<test type="or" message="When duration is per item then number of items must be 1 or higher">
<condition type="gte">1</condition>
<condition field="durationIsPerItem" type="eq">0</condition>
</test>
</rule>
</property>
<property id="onlyMedia" type="checkbox">
<title>Only posts with attached media?</title>
<helpText>Return only posts which included attached media.</helpText>
<default>0</default>
</property>
<property id="durationIsPerItem" type="checkbox">
<title>Duration is per item</title>
<helpText>The duration specified is per item otherwise it is per feed.</helpText>
<default>0</default>
</property>
<property id="removeMentions" type="checkbox">
<title>Remove Mentions?</title>
<helpText>Should mentions (@someone) be removed from the Mastodon Post?</helpText>
<default>0</default>
</property>
<property id="removeHashtags" type="checkbox">
<title>Remove Hashtags?</title>
<helpText>Should Hashtags (#something) be removed from the Mastodon Post?</helpText>
<default>0</default>
</property>
<property id="removeUrls" type="checkbox">
<title>Remove URLs?</title>
<helpText>Should URLs be removed from the Mastodon Post? Most URLs do not compliment digital signage.</helpText>
<default>1</default>
</property>
</properties>
<onParseData><![CDATA[
// item - element to be parsed
// properties - object containing the values to be evaluated/used
if(properties.removeMentions == 1) {
item.text = item.text.replace(/@[^\s]+/g, '');
}
if(properties.removeHashtags == 1) {
item.text = item.text.replace(/#[^\s]+/g, '');
}
if(properties.removeUrls == 1) {
item.text = item.text.replace(/(https?:\/\/)?(www\.)?[-a-zA-Z0-9()@:%_\+.~#?&//=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g, '');
}
if(properties.dateFormat) {
item.date = moment(item.date).format(properties.dateFormat);
}
// Return the parsed item
return item;
]]></onParseData>
<sampleData><![CDATA[
[{
"date": "2000-01-01T01:00:30+00:00",
"text": "This is a sample mastodon text",
"location": "Mastodon location",
"photo": "[[assetId=mastodonContentPhoto]]",
"user": "@mastodon_user",
"screenName": "Mastodon user",
"userProfileImage": "[[assetId=mastodonProfilePhoto]]",
"userProfileImageMini": "[[assetId=mastodonProfilePhotoMini]]",
"userProfileImageBigger": "[[assetId=mastodonProfilePhotoBigger]]"
},
{
"date": "2000-01-01T01:00:30+00:00",
"text": "This is a sample mastodon text",
"location": "Mastodon location",
"photo": "[[assetId=mastodonContentPhoto]]",
"user": "@mastodon_user",
"screenName": "Mastodon user",
"userProfileImage": "[[assetId=mastodonProfilePhoto]]",
"userProfileImageMini": "[[assetId=mastodonProfilePhotoMini]]",
"userProfileImageBigger": "[[assetId=mastodonProfilePhotoBigger]]"
},
{
"date": "2000-01-01T01:00:30+00:00",
"text": "This is a sample mastodon text",
"location": "Mastodon location",
"photo": "[[assetId=mastodonContentPhoto]]",
"user": "@mastodon_user",
"screenName": "Mastodon user",
"userProfileImage": "[[assetId=mastodonProfilePhoto]]",
"userProfileImageMini": "[[assetId=mastodonProfilePhotoMini]]",
"userProfileImageBigger": "[[assetId=mastodonProfilePhotoBigger]]"
},
{
"date": "2000-01-01T01:00:30+00:00",
"text": "This is a sample mastodon text",
"location": "Mastodon location",
"photo": "[[assetId=mastodonContentPhoto]]",
"user": "@mastodon_user",
"screenName": "Mastodon user",
"userProfileImage": "[[assetId=mastodonProfilePhoto]]",
"userProfileImageMini": "[[assetId=mastodonProfilePhotoMini]]",
"userProfileImageBigger": "[[assetId=mastodonProfilePhotoBigger]]"
},
{
"date": "2000-01-01T01:00:30+00:00",
"text": "This is a sample mastodon text",
"location": "Mastodon location",
"photo": "[[assetId=mastodonContentPhoto]]",
"user": "@mastodon_user",
"screenName": "Mastodon user",
"userProfileImage": "[[assetId=mastodonProfilePhoto]]",
"userProfileImageMini": "[[assetId=mastodonProfilePhotoMini]]",
"userProfileImageBigger": "[[assetId=mastodonProfilePhotoBigger]]"
}]
]]></sampleData>
<preview></preview>
<assets>
<asset id="mastodonLogo" alias="providerLogo" type="path" mimeType="image/png" path="/modules/assets/mastodon_blue.png"></asset>
<asset id="mastodonLogoWhite" alias="providerLogoWhite" type="path" mimeType="image/png" path="/modules/assets/mastodon_white.png"></asset>
<asset id="mastodonContentPhoto" type="path" mimeType="image/png" path="/modules/assets/mastodon_content_photo.jpg" cmsOnly="true"></asset>
<asset id="mastodonProfilePhoto" type="path" mimeType="image/png" path="/modules/assets/mastodon_profile_photo.jpg" cmsOnly="true"></asset>
<asset id="mastodonProfilePhotoMini" type="path" mimeType="image/png" path="/modules/assets/mastodon_profile_photo_mini.jpg" cmsOnly="true"></asset>
<asset id="mastodonProfilePhotoBigger" type="path" mimeType="image/png" path="/modules/assets/mastodon_profile_photo_bigger.jpg" cmsOnly="true"></asset>
</assets>
</module>