From 4da27f6a4b78decc89fbabe9a22e02fd9c733b39 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 8 Aug 2024 10:15:38 +0100 Subject: [PATCH] Add support for social media cards (#8441) * Initial Commit * Fix Twitter description * Improve image preview name Thanks @simonbaird * Add control panel UI for social media cards --- core/language/en-GB/ControlPanel.multids | 6 ++++ core/templates/social-metadata.tid | 38 ++++++++++++++++++++++++ core/ui/ControlPanel/SocialCard.tid | 22 ++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 core/templates/social-metadata.tid create mode 100644 core/ui/ControlPanel/SocialCard.tid diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index 772949c0d..a1b164c5c 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -198,6 +198,12 @@ Settings/TitleLinks/Yes/Description: Display tiddler titles as links Settings/MissingLinks/Caption: Wiki Links Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet Settings/MissingLinks/Description: Enable links to missing tiddlers +SocialCard/Caption: Social Media Card +SocialCard/Domain/Prompt: Domain name to display for the link (for example, ''tiddlywiki.com'') +SocialCard/Hint: This information is used by social and messaging services to display a preview card for links to this TiddlyWiki when hosted online +SocialCard/PreviewUrl/Prompt: Full URL to preview image for this TiddlyWiki +SocialCard/PreviewUrl/Preview: Preview image: +SocialCard/Url/Prompt: Full URL of this TiddlyWiki StoryTiddler/Caption: Story Tiddler StoryTiddler/Hint: This rule cascade is used to dynamically choose the template for displaying a tiddler in the story river. StoryView/Caption: Story View diff --git a/core/templates/social-metadata.tid b/core/templates/social-metadata.tid new file mode 100644 index 000000000..6f9dc11bc --- /dev/null +++ b/core/templates/social-metadata.tid @@ -0,0 +1,38 @@ +title: $:/core/templates/social-metadata +tags: $:/tags/RawMarkupWikified + +\procedure meta-plain(name,source,name-attribute:"name") +\whitespace trim +<%if [has[text]] %> + <meta <$text text=<>/>="<$text text=<>/>" content="<$text text={{{ [get[text]encodehtml[]] }}}/>"> + <$text text={{{ [charcode[10]] }}}/> +<%endif%> +\end meta-plain + +\procedure meta-wikified(name,source,name-attribute:"name") +\whitespace trim +<%if [has[text]] %> + <$wikify name="html" text={{{ [get[text]] }}} output="text"> + <meta <$text text=<>/>="<$text text=<>/>" content="<$text text={{{ [encodehtml[]] }}}/>"> + <$text text={{{ [charcode[10]] }}}/> + +<%endif%> +\end meta-wikified + +\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock conditional commentinline commentblock +<> + + +<> +<> +<> +<> +<> + + +<> +<> +<> +<> +<> +<> diff --git a/core/ui/ControlPanel/SocialCard.tid b/core/ui/ControlPanel/SocialCard.tid new file mode 100644 index 000000000..591c6550f --- /dev/null +++ b/core/ui/ControlPanel/SocialCard.tid @@ -0,0 +1,22 @@ +title: $:/core/ui/ControlPanel/SocialCard +tags: $:/tags/ControlPanel/Advanced +caption: {{$:/language/ControlPanel/SocialCard/Caption}} + +\define lingo-base() $:/language/ControlPanel/ + +<> + +|<$link to="$:/SiteTitle"><> |<$edit-text tiddler="$:/SiteTitle" default="" tag="input"/> | +|<$link to="$:/SiteSubtitle"><> |<$edit-text tiddler="$:/SiteSubtitle" default="" tag="input"/> | +|<$link to="$:/SiteDomain"><> |<$edit-text tiddler="$:/SiteDomain" default="" tag="input"/> | +|<$link to="$:/SiteUrl"><> |<$edit-text tiddler="$:/SiteUrl" default="" tag="input"/> | +|<$link to="$:/SitePreviewUrl"><> |<$edit-text tiddler="$:/SitePreviewUrl" default="" tag="input"/> | + +<%if [[$:/SitePreviewUrl]get[text]else[]!is[blank]] %> +
+
+<> +
+ +
+<%endif%> \ No newline at end of file