Merge remote-tracking branch 'remotes/upstream/master'

* remotes/upstream/master:
  parse_url: Fixed a problem in the detection if there was an image or not. Additionally removed some test content.
  rev update
  Changed markdown to enable diaspora postings with images that contain links
  bbcode: two new bbcode elements (style, class) for CSS
  Moving the index creation commands into a readme file due to the fact that creating of these indexes is really slow.
  network: Caching of images
  scale_external_images: Fix: Hadn't looked for pictures in the format [img=XxY]
  Further performance improvements
  Speed improvements in the database
This commit is contained in:
Simon L'nu 2012-08-02 12:46:36 -04:00
commit 9433d229ed
12 changed files with 57 additions and 26 deletions

View file

@ -11,7 +11,7 @@ require_once('include/cache.php');
require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('library/Mobile_Detect/Mobile_Detect.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.0.1421' ); define ( 'FRIENDICA_VERSION', '3.0.1422' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1154 ); define ( 'DB_UPDATE_VERSION', 1154 );

View file

@ -570,6 +570,9 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `moderated` (`moderated`), KEY `moderated` (`moderated`),
KEY `spam` (`spam`), KEY `spam` (`spam`),
KEY `author-name` (`author-name`), 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 `title` (`title`),
FULLTEXT KEY `body` (`body`), FULLTEXT KEY `body` (`body`),
FULLTEXT KEY `allow_cid` (`allow_cid`), FULLTEXT KEY `allow_cid` (`allow_cid`),

View 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 // 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" // 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 // It is not optimal and may be removed if this ability is restored in the future
if ($fordiaspora) //if ($fordiaspora)
$Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism", // $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism",
"[url]$1[/url]\n[img]$2[/img]", $Text); // "[url]$1[/url]\n[img]$2[/img]", $Text);
// Convert it to HTML - don't try oembed // Convert it to HTML - don't try oembed
$Text = bbcode($Text, $preserve_nl, false); $Text = bbcode($Text, $preserve_nl, false);

View file

@ -224,6 +224,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Check for list text // Check for list text
$Text = str_replace("[*]", "<li>", $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 // handle nested lists
$endlessloop = 0; $endlessloop = 0;

View file

@ -686,6 +686,10 @@ class Markdownify {
# [1]: mailto:mail@example.com Title # [1]: mailto:mail@example.com Title
$tag['href'] = 'mailto:'.$bufferDecoded; $tag['href'] = 'mailto:'.$bufferDecoded;
} }
$this->out('['.$buffer.']('.$tag['href'].' "'.$tag['title'].'")', true);
/*
# [This link][id] # [This link][id]
foreach ($this->stack['a'] as $tag2) { foreach ($this->stack['a'] as $tag2) {
if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) { if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) {
@ -699,6 +703,7 @@ class Markdownify {
} }
$this->out('['.$buffer.']['.$tag['linkID'].']', true); $this->out('['.$buffer.']['.$tag['linkID'].']', true);
*/
} }
} }
/** /**

View file

@ -802,7 +802,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$s = htmlspecialchars_decode($s); $s = htmlspecialchars_decode($s);
$matches = null; $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) { if($c) {
require_once('include/Photo.php'); require_once('include/Photo.php');
foreach($matches as $mtch) { foreach($matches as $mtch) {
@ -823,6 +823,12 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$scaled = $mtch[1]; $scaled = $mtch[1];
$i = fetch_url($scaled); $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 // guess mimetype from headers or filename
$type = guess_image_type($mtch[1],true); $type = guess_image_type($mtch[1],true);

View file

@ -176,6 +176,9 @@ function parseurl_getsiteinfo($url) {
} }
} else { } else {
$src = completeurl($siteinfo["image"], $url); $src = completeurl($siteinfo["image"], $url);
unset($siteinfo["image"]);
$photodata = getimagesize($src); $photodata = getimagesize($src);
if (($photodata[0] > 10) and ($photodata[1] > 10)) if (($photodata[0] > 10) and ($photodata[1] > 10))
@ -292,8 +295,7 @@ function parse_url_content(&$a) {
$siteinfo = parseurl_getsiteinfo($url); $siteinfo = parseurl_getsiteinfo($url);
if($siteinfo["title"] == "") { if($siteinfo["title"] == "") {
echo print_r($siteinfo, true); echo sprintf($template,$url,$url,'') . $str_tags;
//echo sprintf($template,$url,$url,'') . $str_tags;
killme(); killme();
} else { } else {
$text = $siteinfo["text"]; $text = $siteinfo["text"];
@ -302,7 +304,7 @@ function parse_url_content(&$a) {
$image = ""; $image = "";
if($siteinfo["image"] != ""){ if(sizeof($siteinfo["images"]) > 0){
/* /*
Execute below code only if image is present in siteinfo Execute below code only if image is present in siteinfo
*/ */

5
mods/readme.txt Normal file
View file

@ -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`);

View file

@ -1343,4 +1343,3 @@ function update_1153() {
if(!$r) return UPDATE_FAILED; if(!$r) return UPDATE_FAILED;
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }

View file

@ -6,9 +6,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 3.0.1421\n" "Project-Id-Version: 3.0.1422\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-07-31 10:00-0700\n" "POT-Creation-Date: 2012-08-01 10:00-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -37,7 +37,7 @@ msgstr ""
#: ../../mod/crepair.php:115 ../../mod/wall_attach.php:44 #: ../../mod/crepair.php:115 ../../mod/wall_attach.php:44
#: ../../mod/fsuggest.php:78 ../../mod/events.php:140 ../../mod/api.php:26 #: ../../mod/fsuggest.php:78 ../../mod/events.php:140 ../../mod/api.php:26
#: ../../mod/api.php:31 ../../mod/photos.php:116 ../../mod/photos.php:938 #: ../../mod/api.php:31 ../../mod/photos.php:116 ../../mod/photos.php:938
#: ../../mod/editpost.php:10 ../../mod/install.php:151 ../../mod/poke.php:109 #: ../../mod/editpost.php:10 ../../mod/install.php:151 ../../mod/poke.php:135
#: ../../mod/notifications.php:66 ../../mod/contacts.php:139 #: ../../mod/notifications.php:66 ../../mod/contacts.php:139
#: ../../mod/settings.php:86 ../../mod/settings.php:519 #: ../../mod/settings.php:86 ../../mod/settings.php:519
#: ../../mod/settings.php:524 ../../mod/manage.php:86 ../../mod/network.php:6 #: ../../mod/settings.php:524 ../../mod/manage.php:86 ../../mod/network.php:6
@ -51,7 +51,7 @@ msgstr ""
#: ../../mod/profile_photo.php:166 ../../mod/message.php:38 #: ../../mod/profile_photo.php:166 ../../mod/message.php:38
#: ../../mod/message.php:168 ../../mod/allfriends.php:9 #: ../../mod/message.php:168 ../../mod/allfriends.php:9
#: ../../mod/nogroup.php:25 ../../mod/wall_upload.php:53 #: ../../mod/nogroup.php:25 ../../mod/wall_upload.php:53
#: ../../mod/follow.php:9 ../../mod/display.php:138 ../../mod/profiles.php:7 #: ../../mod/follow.php:9 ../../mod/display.php:130 ../../mod/profiles.php:7
#: ../../mod/profiles.php:408 ../../mod/delegate.php:6 #: ../../mod/profiles.php:408 ../../mod/delegate.php:6
#: ../../mod/suggest.php:28 ../../mod/invite.php:13 ../../mod/invite.php:81 #: ../../mod/suggest.php:28 ../../mod/invite.php:13 ../../mod/invite.php:81
#: ../../mod/dfrn_confirm.php:53 ../../addon/facebook/facebook.php:510 #: ../../mod/dfrn_confirm.php:53 ../../addon/facebook/facebook.php:510
@ -127,7 +127,7 @@ msgstr ""
#: ../../mod/photos.php:1285 ../../mod/photos.php:1325 #: ../../mod/photos.php:1285 ../../mod/photos.php:1325
#: ../../mod/photos.php:1365 ../../mod/photos.php:1396 #: ../../mod/photos.php:1365 ../../mod/photos.php:1396
#: ../../mod/install.php:246 ../../mod/install.php:284 #: ../../mod/install.php:246 ../../mod/install.php:284
#: ../../mod/localtime.php:45 ../../mod/poke.php:169 ../../mod/content.php:691 #: ../../mod/localtime.php:45 ../../mod/poke.php:199 ../../mod/content.php:691
#: ../../mod/contacts.php:341 ../../mod/settings.php:537 #: ../../mod/contacts.php:341 ../../mod/settings.php:537
#: ../../mod/settings.php:691 ../../mod/settings.php:752 #: ../../mod/settings.php:691 ../../mod/settings.php:752
#: ../../mod/settings.php:958 ../../mod/group.php:85 ../../mod/message.php:294 #: ../../mod/settings.php:958 ../../mod/group.php:85 ../../mod/message.php:294
@ -1222,23 +1222,23 @@ msgstr ""
msgid "Please select your timezone:" msgid "Please select your timezone:"
msgstr "" msgstr ""
#: ../../mod/poke.php:163 #: ../../mod/poke.php:192
msgid "Poke/Prod" msgid "Poke/Prod"
msgstr "" msgstr ""
#: ../../mod/poke.php:164 #: ../../mod/poke.php:193
msgid "poke, prod or do other things to somebody" msgid "poke, prod or do other things to somebody"
msgstr "" msgstr ""
#: ../../mod/poke.php:165 #: ../../mod/poke.php:194
msgid "Recipient" msgid "Recipient"
msgstr "" msgstr ""
#: ../../mod/poke.php:166 #: ../../mod/poke.php:195
msgid "Choose what you wish to do to recipient" msgid "Choose what you wish to do to recipient"
msgstr "" msgstr ""
#: ../../mod/poke.php:168 #: ../../mod/poke.php:198
msgid "Make this post private" msgid "Make this post private"
msgstr "" msgstr ""
@ -2986,8 +2986,8 @@ msgid "%1$s doesn't like %2$s's %3$s"
msgstr "" msgstr ""
#: ../../mod/notice.php:15 ../../mod/viewsrc.php:15 ../../mod/admin.php:159 #: ../../mod/notice.php:15 ../../mod/viewsrc.php:15 ../../mod/admin.php:159
#: ../../mod/admin.php:705 ../../mod/admin.php:904 ../../mod/display.php:37 #: ../../mod/admin.php:705 ../../mod/admin.php:904 ../../mod/display.php:29
#: ../../mod/display.php:142 ../../include/items.php:3692 #: ../../mod/display.php:134 ../../include/items.php:3692
msgid "Item not found." msgid "Item not found."
msgstr "" msgstr ""
@ -3811,7 +3811,7 @@ msgstr ""
msgid "Requested profile is not available." msgid "Requested profile is not available."
msgstr "" msgstr ""
#: ../../mod/profile.php:141 ../../mod/display.php:75 #: ../../mod/profile.php:141 ../../mod/display.php:67
msgid "Access to this profile has been restricted." msgid "Access to this profile has been restricted."
msgstr "" msgstr ""
@ -3898,7 +3898,7 @@ msgstr ""
msgid "link" msgid "link"
msgstr "" msgstr ""
#: ../../mod/display.php:135 #: ../../mod/display.php:127
msgid "Item has been removed." msgid "Item has been removed."
msgstr "" msgstr ""

View file

@ -2550,3 +2550,8 @@ list-style-type: disc;
float: left; float: left;
width: 175px; width: 175px;
} }
.item-image-preview {
float: left;
margin-right: 10px;
}