]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #525 from ArthurHoaro/plugins/feeds-markdown2
authorArthur <arthur@hoa.ro>
Sat, 9 Apr 2016 14:35:41 +0000 (16:35 +0200)
committerArthur <arthur@hoa.ro>
Sat, 9 Apr 2016 14:35:41 +0000 (16:35 +0200)
Process feeds content with Markdown

application/Url.php
index.php
tests/Url/UrlTest.php
tpl/tagcloud.html

index a4ac2e73cad2537ab28cd6bb604356bd311d14d7..af38c4d9155ed4eb856691c941f26f11714b77be 100644 (file)
@@ -118,13 +118,43 @@ class Url
      */
     public function __construct($url)
     {
-        $this->parts = parse_url(trim($url));
+        $url = self::cleanupUnparsedUrl(trim($url));
+        $this->parts = parse_url($url);
 
         if (!empty($url) && empty($this->parts['scheme'])) {
             $this->parts['scheme'] = 'http';
         }
     }
 
+    /**
+     * Clean up URL before it's parsed.
+     * ie. handle urlencode, url prefixes, etc.
+     *
+     * @param string $url URL to clean.
+     *
+     * @return string cleaned URL.
+     */
+    protected static function cleanupUnparsedUrl($url)
+    {
+        return self::removeFirefoxAboutReader($url);
+    }
+
+    /**
+     * Remove Firefox Reader prefix if it's present.
+     *
+     * @param string $input url
+     *
+     * @return string cleaned url
+     */
+    protected static function removeFirefoxAboutReader($input)
+    {
+        $firefoxPrefix = 'about://reader?url=';
+        if (startsWith($input, $firefoxPrefix)) {
+            return urldecode(ltrim($input, $firefoxPrefix));
+        }
+        return $input;
+    }
+    
     /**
      * Returns a string representation of this URL
      */
index dfc00fbd6c5d437ef8e074494e7443f7f0067673..735615ff7b084326aef7dc8dfee611021b73fe3a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1015,11 +1015,16 @@ function renderPage()
             return strcasecmp($a, $b);
         });
 
-        $tagList=array();
-        foreach($tags as $key=>$value)
-        // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
-        {
-            $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
+        $tagList = array();
+        foreach($tags as $key => $value) {
+            // Tag font size scaling:
+            //   default 15 and 30 logarithm bases affect scaling,
+            //   22 and 6 are arbitrary font sizes for max and min sizes.
+            $size = log($value, 15) / log($maxcount, 30) * 2.2 + 0.8;
+            $tagList[$key] = array(
+                'count' => $value,
+                'size' => number_format($size, 2, '.', ''),
+            );
         }
 
         $data = array(
index 425327ed02b37b7f1ccb638208ddf404ed7b16d5..a64a73eae183e82672e3647c8a8249cdfa26c189 100644 (file)
@@ -128,6 +128,13 @@ class UrlTest extends PHPUnit_Framework_TestCase
             self::$baseUrl.'?my=stuff&is=kept#again',
             $url->cleanup()
         );
+
+        // test firefox reader url
+        $url = new Url(
+            'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept')
+        );
+        $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup());
+
     }
 
     /**
index 5891cd258498bd14b750940f868f8615842daa63..e449f2939fe095ca1138b4c4f02a6d64289ae83d 100644 (file)
@@ -12,8 +12,8 @@
 
     <div id="cloudtag">
         {loop="tags"}
-            <span class="count">{$value.count}</span>
-            <a href="?searchtags={$key|urlencode}" style="font-size:{$value.size}pt;">{$key}</a>
+            <span class="count">{$value.count}</span><a
+                href="?searchtags={$key|urlencode}" style="font-size:{$value.size}em;">{$key}</a>
             {loop="$value.tag_plugin"}
                 {$value}
             {/loop}