Эх сурвалжийг харах

add option to show a "share on network" inside the button or just a icon

Fernando Ribeiro 9 жил өмнө
parent
commit
6ee5d4ce45

+ 2 - 2
conf/default.php

@@ -8,6 +8,6 @@
 //$conf['fixme']    = 'FIXME';
 
 
-$conf['networks']   = 'Twitter Facebook Google+ Linkedin Pinterest Tumblr Reddit';
+$conf['networks']   = 'twitter facebook googleplus linkedin pinterest tumblr reddit';
 
-$conf['display']    = 'name';
+$conf['display']    = 'text';

+ 2 - 2
conf/metadata.php

@@ -8,6 +8,6 @@
 //$meta['fixme'] = array('string');
 
 
-$meta['networks']   = array('string', '_pattern' => '/^[a-zA-Z\+\s]*$/');
+$meta['networks']   = array('string', '_pattern' => '/^[a-zA-Z\s]*$/');
 
-$meta['display']    = array('multichoice','_choices' => array('name', 'text', 'icon'));
+$meta['display']    = array('multichoice','_choices' => array('text', 'icon'));

+ 1 - 1
lang/en/lang.php

@@ -13,7 +13,7 @@
 
 $lang['twitter_text']    = 'Tweet this';
 $lang['facebook_text']   = 'Share on Facebook';
-$lang['google+_text']    = 'Plus on Google+';
+$lang['googleplus_text'] = 'Plus on Google+';
 $lang['linkedin_text']   = 'Share on LinkedIn';
 $lang['pinterest_text']  = 'Pin on Pinterest';
 $lang['tumblr_text']     = 'Share on Tumblr';

+ 2 - 2
lang/en/settings.php

@@ -9,6 +9,6 @@
 // $lang['fixme'] = 'FIXME';
 
 $lang['networks']   = 'List of your favorite social buttons, space separated and in order of appearance.';
-$lang['networks']  .= ' Valid names are: twitter facebook google+ linkedin pinterest tumblr reddit';
+$lang['networks']  .= ' Valid names are: twitter facebook googleplus linkedin pinterest tumblr reddit';
 
-$lang['display']    = 'Display options: share on network, the name of network or just the icon';
+$lang['display']    = 'Display options: show a "share on network" text or just the icon';

+ 20 - 0
lang/pt/lang.php

@@ -0,0 +1,20 @@
+<?php
+/**
+ * Portuguese language file for lsb plugin
+ *
+ * @author Fernando Ribeiro <pinguim.ribeiro@gmail.com>
+ */
+
+// menu entry for admin plugins
+// $lang['menu'] = 'Your menu entry';
+
+// custom language strings for the plugin
+// $lang['fixme'] = 'FIXME';
+
+$lang['twitter_text']    = 'Tweetar isto';
+$lang['facebook_text']   = 'Partilhar no Facebook';
+$lang['googleplus_text'] = 'Mais on Google+';
+$lang['linkedin_text']   = 'Partilhar no LinkedIn';
+$lang['pinterest_text']  = 'Pin no Pinterest';
+$lang['tumblr_text']     = 'Partilhar no Tumblr';
+$lang['reddit_text']     = 'Partilhar no Reddit';

+ 1 - 1
lang/pt/settings.php

@@ -1,6 +1,6 @@
 <?php
 /**
- * english language file for lsb plugin
+ * Portuguese language file for lsb plugin
  *
  * @author Fernando Ribeiro <pinguim.ribeiro@gmail.com>
  */

+ 4 - 3
style.css

@@ -6,13 +6,14 @@
 }
 
 .lsb-item {
-    display: inline;
+    display: inline-block;
     margin: .25em;
+    line-height: 24px;
 }
 
 .lsb-link {
     font-size: .75em;
-    padding: 0.75em .75em .75em 2.5em;
+    padding: .5em .5em .5em 2.25em;
     background-color: #f5f5f5;
     border-radius: 2px;
     box-shadow: 0 0 .5em #999;
@@ -38,7 +39,7 @@
     background-image: url("http://www.facebook.com/favicon.ico");
 }
 
-.ico-google {
+.ico-googleplus {
     background-image: url("https://ssl.gstatic.com/s2/oz/images/faviconr2.ico");
 }
 

+ 20 - 20
syntax/button.php

@@ -36,13 +36,8 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
      */
     public function connectTo($mode) {
         $this->Lexer->addSpecialPattern('~~LSB\b.*?~~',$mode,'plugin_lsb_button');
-//        $this->Lexer->addEntryPattern('<FIXME>',$mode,'plugin_lsb_button');
     }
 
-//    public function postConnect() {
-//        $this->Lexer->addExitPattern('</FIXME>','plugin_lsb_button');
-//    }
-
     /**
      * Handle matches of the lsb syntax
      *
@@ -77,7 +72,7 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
         $renderer->doc .= '<ul class="lsb">';
 
         // validation list of available social networks
-        $protected = array('twitter', 'facebook', 'google+', 'linkedin', 'pinterest', 'tumblr', 'reddit');
+        $protected = array('twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'tumblr', 'reddit');
 
 
         foreach ($data as $network) {
@@ -91,10 +86,10 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
     }
 
     /**
-     * Render xhtml output for facebook share button
+     * Render xhtml output for share buttons
      *
-     * @param string $network The social network to render the button to
-     * @return string Xhtml code for button.
+     * @param string    $network    The social network to render the button to
+     * @return string   Xhtml code for button.
      */
     protected function lsb_button ($network) {
         global $ID;
@@ -109,29 +104,29 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
         // see: https://github.com/cferdinandi/social-sharing
         // <a href="https://twitter.com/intent/tweet?text=YOUR-TITLE&url=YOUR-URL&via=TWITTER-HANDLE">Tweet</a>
         // <a href="https://www.facebook.com/sharer/sharer.php?u=YOUR-URL">Share on Facebook</a>
-        // <a href="https://plus.google.com/share?url=YOUR-URL">Plus on Google+</a>
+        // <a href="https://plus.google.com/share?url=YOUR-URL">Plus on googleplus</a>
         // <a href="https://www.linkedin.com/shareArticle?mini=true&url=YOUR-URL&title=YOUR-TITLE&summary=YOUR-SUMMARY&source=YOUR-URL">Share on LinkedIn</a>
         // <a href="https://pinterest.com/pin/create/button/?url=YOUR-URL&description=YOUR-DESCRIPTION&media=YOUR-IMAGE-SRC">Pin on Pinterest</a>
         // <a href="https://vk.com/share.php?url=YOUR-URL&title=YOUR-TITLE&description=YOUR-DESCRIPTION&image=YOUR-IMAGE-SRC&noparse=true">Share on VK</a>
         // <a href="https://www.xing-share.com/app/user?op=share;sc_p=xing-share;url=YOUR-URL">Share on Xing</a>
         // <a href="http://www.tumblr.com/share/link?url=YOUR-URL&description=YOUR-DESCRIPTION">Share on Tumblr</a>
         // <a href="http://www.reddit.com/submit?url=YOUR_URL&title=YOUR_TITLE">Share on Reddit</a>
- 
+
         switch ($network) {
             case 'twitter':
-                $href = 'https://twitter.com/intent/tweet?url=' . $url . '&text='. $title .'&via=TWITTER-HANDLE';
+                $href = 'https://twitter.com/intent/tweet?url=' . $url . '&text='. $title;
                 break;
             case 'facebook':
                 $href = 'http://www.facebook.com/sharer.php?u='. $url;
                 break;
-            case 'google+':
+            case 'googleplus':
                 $href = 'https://plus.google.com/share?url='. $url;
                 break;
             case 'linkedin':
-                $href = 'href="https://www.linkedin.com/shareArticle?url='. $url .'&title=' . $title . '&summary=' . $abstract . '&mini=true&source=' . $url;
+                $href = 'https://www.linkedin.com/shareArticle?url='. $url .'&title=' . $title . '&summary=' . $abstract . '&mini=true&source=' . $url;
                 break;
             case 'pinterest':
-                $href = 'https://pinterest.com/pin/create/button/?url='. $url .'&description=' . $abstract . '&media=YOUR-IMAGE-SRC';
+                $href = 'https://pinterest.com/pin/create/button/?url='. $url .'&description=' . $abstract;
                 break;
             case 'tumblr':
                 $href = 'http://www.tumblr.com/share/link?url='. $url .'&description=' . $abstract;
@@ -148,15 +143,20 @@ class syntax_plugin_lsb_button extends DokuWiki_Syntax_Plugin {
         return $xhtml;
     }
 
-
+    /**
+     * Returns the thext to display in share button
+     *
+     * @param string    $network    The social network to get the text to
+     * @return string   text for button or empty string to show just the icon.
+     */
     protected function lsb_getText($network) {
 
         $display = $this->getConf('display');
-        if ($display == 'name') {
-            return $network;
-        } elseif ($display == 'text') {
-            return $this->getLang($network.'_text');
+
+        if ($display == 'text') {
+            return $this->getLang($network . '_text');
         } else {
+            // no text, just the icon
             return '';
         }
     }