Skip to content
Permalink
Browse files

social 0.10: twittervia fix, @ allowed, og:desc newlines stripped

  • Loading branch information...
onli committed Aug 16, 2016
1 parent b4716db commit 7921a9c93160475d4ba566d21cce547b891d1145
@@ -1,3 +1,8 @@
0.10:
* Strip newlines from description
* Fix unfilled language variable TWITTERVIA_DESC
* Work with and without @ in the twittervia username

0.9:
* Add option to set a fallback image for
twitter and facebook tags
@@ -12,7 +12,7 @@
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW', 'Auf Übersichtsseiten anzeigen');
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW_DESC', 'Zeige die Sharebuttons auch auf Übersichtsseiten (wie z.B. der Startseite).');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA', 'Twittererwähnung');
@define('PLUGIN_EVENT_SOCIAL_TWITTER_DESC', 'Twittername, der am Ende des Tweets angehängtwerden soll ("none" deaktiviert dies).');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA_DESC', 'Twittername, der am Ende des Tweets angehängt werden soll ("none" deaktiviert dies).');
@define('PLUGIN_EVENT_SOCIAL_LANG_DESC', 'Sprache der Sharebuttons.');
@define('PLUGIN_EVENT_SOCIAL_BACKEND', 'Backend für Zähler');
@define('PLUGIN_EVENT_SOCIAL_BACKEND_DESC', 'URL für ein Shariff-Backend, mit dem einige der Buttons (u.a. Facebook) anzeigen wie oft der Artikel geteilt wurde. "none" deaktiviert den Zähler. Standard: "https://onli.columba.uberspace.de/s9y_shariff"');
@@ -12,7 +12,7 @@
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW', 'Show on overview pages');
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW_DESC', 'Also show the share buttons on overview pages (like i.e. the front page).');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA', 'Twitter mention');
@define('PLUGIN_EVENT_SOCIAL_TWITTER_DESC', 'Username of the twitter user that shall be mentioned (set to "none" to disable.');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA_DESC', 'Username of the twitter user that shall be mentioned (set to "none" to disable.');
@define('PLUGIN_EVENT_SOCIAL_LANG_DESC', 'Language of the share buttons');
@define('PLUGIN_EVENT_SOCIAL_BACKEND', 'Backend for share counter');
@define('PLUGIN_EVENT_SOCIAL_BACKEND_DESC', 'URL to a shariff backend, that provides some buttons (like Facebook) with a share counter. Set to "none" to deacivate. Default: "https://onli.columba.uberspace.de/s9y_shariff"');
@@ -12,7 +12,7 @@
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW', 'Auf Übersichtsseiten anzeigen');
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW_DESC', 'Zeige die Sharebuttons auch auf Übersichtsseiten (wie z.B. der Startseite).');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA', 'Twittererwähnung');
@define('PLUGIN_EVENT_SOCIAL_TWITTER_DESC', 'Twittername, der am Ende des Tweets angehängtwerden soll ("none" deaktiviert dies).');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA_DESC', 'Twittername, der am Ende des Tweets angehängt werden soll ("none" deaktiviert dies).');
@define('PLUGIN_EVENT_SOCIAL_LANG_DESC', 'Sprache der Sharebuttons.');
@define('PLUGIN_EVENT_SOCIAL_BACKEND', 'Backend für Zähler');
@define('PLUGIN_EVENT_SOCIAL_BACKEND_DESC', 'URL für ein Shariff-Backend, mit dem einige der Buttons (u.a. Facebook) anzeigen wie oft der Artikel geteilt wurde. "none" deaktiviert den Zähler. Standard: "https://onli.columba.uberspace.de/s9y_shariff"');
@@ -12,7 +12,7 @@
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW', 'Show on overview pages');
@define('PLUGIN_EVENT_SOCIAL_OVERVIEW_DESC', 'Also show the share buttons on overview pages (like i.e. the front page.');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA', 'Twitter mention');
@define('PLUGIN_EVENT_SOCIAL_TWITTER_DESC', 'Username of the twitter user that shall be mentioned (set to "none" to disable.');
@define('PLUGIN_EVENT_SOCIAL_TWITTERVIA_DESC', 'Username of the twitter user that shall be mentioned (set to "none" to disable.');
@define('PLUGIN_EVENT_SOCIAL_LANG_DESC', 'Language of the share buttons');
@define('PLUGIN_EVENT_SOCIAL_BACKEND', 'Backend for share counter');
@define('PLUGIN_EVENT_SOCIAL_BACKEND_DESC', 'URL to a shariff backend, that provides some buttons (like Facebook) with a share counter. Set to "none" to deacivate. Default: "https://onli.columba.uberspace.de/s9y_shariff"');
@@ -16,7 +16,7 @@ function introspect(&$propbag) {
$propbag->add('description', PLUGIN_EVENT_SOCIAL_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'onli, Matthias Mees');
$propbag->add('version', '0.9');
$propbag->add('version', '0.10');
$propbag->add('requirements', array(
'serendipity' => '2.0'
));
@@ -106,7 +106,7 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
}
$twitter_via = $this->get_config('twitter_via', 'none');
if ($twitter_via != 'none') {
$twitter_via_tag = ' data-twitter-via="' . $twitter_via .'"';
$twitter_via_tag = ' data-twitter-via="' . str_replace('@', '', $twitter_via) .'"';
}
$backend = $this->get_config('backend', 'https://onli.columba.uberspace.de/s9y_shariff/');
if ($backend != 'none') {
@@ -148,7 +148,8 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
echo '<!--serendipity_event_shariff-->' . "\n";
echo '<meta name="twitter:card" content="summary" />' . "\n";
echo '<meta property="og:title" content="' . serendipity_specialchars($entry['title']) . '" />' . "\n";
echo '<meta property="og:description" content="' . substr(strip_tags($entry['body']), 0, 200) . '..." />' . "\n";
# /\s+/: multiple newline and whitespaces
echo '<meta property="og:description" content="' . trim(preg_replace('/\s+/', ' ', substr(strip_tags($entry['body']), 0, 200))) . '..." />' . "\n";
echo '<meta property="og:type" content="article" />' . "\n";
echo '<meta property="og:site_name" content="' . $serendipity['blogTitle'] . '" />' . "\n";
echo '<meta property="og:url" content="'. $blogURL . serendipity_specialchars($_SERVER['REQUEST_URI']) . '" />' . "\n";
@@ -168,6 +169,7 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
echo '<meta property="og:image" content="' . $social_image . '" />' . "\n";
}
}
break;
default:
return false;
}

0 comments on commit 7921a9c

Please sign in to comment.
You can’t perform that action at this time.