]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #422 from annando/master
authorfriendica <info@friendica.com>
Thu, 2 Aug 2012 10:47:02 +0000 (03:47 -0700)
committerfriendica <info@friendica.com>
Thu, 2 Aug 2012 10:47:02 +0000 (03:47 -0700)
Speed improvements, better diaspora export

database.sql
include/bb2diaspora.php
include/bbcode.php
include/markdownify/markdownify.php
include/network.php
mod/parse_url.php
mods/readme.txt [new file with mode: 0644]
update.php
view/theme/diabook/style-profile.css
view/theme/diabook/style.css

index 80ce05ba0cc998f619df3b0149ba94f515e7637e..fa4f1bd58b15d92595e74a19e3766aed51dbf079 100644 (file)
@@ -570,6 +570,9 @@ CREATE TABLE IF NOT EXISTS `item` (
   KEY `moderated` (`moderated`),
   KEY `spam` (`spam`),
   KEY `author-name` (`author-name`),
+  KEY `uid_commented` (`uid`, `commented`),
+  KEY `uid_created` (`uid`, `created`),
+  KEY `uid_unseen` (`uid`, `unseen`),
   FULLTEXT KEY `title` (`title`),
   FULLTEXT KEY `body` (`body`),
   FULLTEXT KEY `allow_cid` (`allow_cid`),
index b95dee8f3b4b67541c9052b1cdba9cbcea83ec05..9ede42f6c7a66fab7597566296584d4e3968c3fc 100644 (file)
@@ -202,9 +202,9 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
        // the following was added on 10-January-2012 due to an inability of Diaspora's
        // new javascript markdown processor to handle links with images as the link "text"
        // It is not optimal and may be removed if this ability is restored in the future
-       if ($fordiaspora)
-               $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism",
-                                       "[url]$1[/url]\n[img]$2[/img]", $Text);
+       //if ($fordiaspora)
+       //      $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism",
+       //                              "[url]$1[/url]\n[img]$2[/img]", $Text);
 
        // Convert it to HTML - don't try oembed
        $Text = bbcode($Text, $preserve_nl, false);
index 9ece3c3deca1c23fae7e7c6ab7df1c1354915450..d83cd35814a9f582c8b117d3b097f4026fe228d5 100644 (file)
@@ -224,6 +224,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        // Check for list text
        $Text = str_replace("[*]", "<li>", $Text);
 
+       // Check for style sheet commands
+       $Text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism","<span style=\"$1;\">$2</span>",$Text);
+
+       // Check for CSS classes
+       $Text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism","<span class=\"$1\">$2</span>",$Text);
+
        // handle nested lists
        $endlessloop = 0;
 
index 7bbf1cbbed60c9047ff793bac8c104c4cdb97f27..0d4429a01336e10d9ce17ab43170201ae874bef1 100644 (file)
@@ -686,6 +686,10 @@ class Markdownify {
         #  [1]: mailto:mail@example.com Title
         $tag['href'] = 'mailto:'.$bufferDecoded;
       }
+
+      $this->out('['.$buffer.']('.$tag['href'].' "'.$tag['title'].'")', true);
+
+/*
       # [This link][id]
       foreach ($this->stack['a'] as $tag2) {
         if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) {
@@ -699,6 +703,7 @@ class Markdownify {
       }
 
       $this->out('['.$buffer.']['.$tag['linkID'].']', true);
+*/
     }
   }
   /**
@@ -737,7 +742,7 @@ class Markdownify {
 
 // ![Alt text](/path/to/img.jpg "Optional title")
     if ($this->parser->tagAttributes['title'] != "")
-      $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].'"'.$this->parser->tagAttributes['title'].'")', true);
+      $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].' "'.$this->parser->tagAttributes['title'].'")', true);
     else
       $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].')', true);
 
index a95dde535c9fa967156b28806f9c508b9ed1b064..0fff5c7cc9eea0993682da0810cc2748b4819e11 100644 (file)
@@ -802,7 +802,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
        $s = htmlspecialchars_decode($s);
 
        $matches = null;
-       $c = preg_match_all('/\[img\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
+       $c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
        if($c) {
                require_once('include/Photo.php');
                foreach($matches as $mtch) {
@@ -823,6 +823,12 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
                                $scaled = $mtch[1];
                        $i = fetch_url($scaled);
 
+                       $cache = get_config('system','itemcache');
+                       if (($cache != '') and is_dir($cache)) {
+                               $cachefile = $cache."/".hash("md5", $scaled);
+                               file_put_contents($cachefile, $i);
+                       }
+
                        // guess mimetype from headers or filename
                        $type = guess_image_type($mtch[1],true);
                        
index 5dd7de750b112b8b8f79aa094a79835e05833c1a..ea05055f0cefc69b461c29b5e009786320bcc2b8 100644 (file)
@@ -176,6 +176,9 @@ function parseurl_getsiteinfo($url) {
                 }
         } else {
                $src = completeurl($siteinfo["image"], $url);
+
+               unset($siteinfo["image"]);
+
                $photodata = getimagesize($src);
 
                if (($photodata[0] > 10) and ($photodata[1] > 10))
@@ -292,8 +295,7 @@ function parse_url_content(&$a) {
        $siteinfo = parseurl_getsiteinfo($url);
 
        if($siteinfo["title"] == "") {
-               echo print_r($siteinfo, true);
-               //echo sprintf($template,$url,$url,'') . $str_tags;
+               echo sprintf($template,$url,$url,'') . $str_tags;
                killme();
        } else {
                $text = $siteinfo["text"];
@@ -302,7 +304,7 @@ function parse_url_content(&$a) {
 
        $image = "";
 
-        if($siteinfo["image"] != ""){
+        if(sizeof($siteinfo["images"]) > 0){
             /*
               Execute below code only if image is present in siteinfo
              */
diff --git a/mods/readme.txt b/mods/readme.txt
new file mode 100644 (file)
index 0000000..9e79f84
--- /dev/null
@@ -0,0 +1,5 @@
+Site speed can be improved when the following indexes are set. They cannot be set through the update script because on large sites they will block the site for several minutes.
+
+CREATE INDEX `uid_commented` ON `item` (`uid`, `commented`);
+CREATE INDEX `uid_created` ON `item` (`uid`, `created`);
+CREATE INDEX `uid_unseen` ON `item` (`uid`, `unseen`);
index 9442f825bb34fb3cefe53f8241f51115b9b0ea75..19e6cf3bdf78c06eae128ee1f383eb4f902d3492 100644 (file)
@@ -1343,4 +1343,3 @@ function update_1153() {
        if(!$r) return UPDATE_FAILED;
        return UPDATE_SUCCESS;
 }
-
index 63b2eb544a4121e675aae1ab559fefd0453e798b..927549fa33f7bd48a53cd1c106eafcf1cdb1fb45 100644 (file)
@@ -2549,4 +2549,9 @@ list-style-type: disc;
 #photos-upload-newalbum-div {
         float: left;
         width: 175px;
-}
\ No newline at end of file
+}
+
+.item-image-preview {
+  float: left;
+  margin-right: 10px;
+}
index 68bfd5d3a9213a0750b8b37460c941898497ab06..286559b859b9906a3fefc177bee882fe5da0c498 100644 (file)
@@ -2906,4 +2906,4 @@ list-style-type: disc;
 #photos-upload-newalbum-div {
         float: left;
         width: 175px;
-}
\ No newline at end of file
+}