Merge pull request #1065 from annando/master

Refreshing of the network page only when the page is at the beginning
This commit is contained in:
tobiasd 2014-08-07 08:42:25 +02:00
commit cf0ebd952f
11 changed files with 89 additions and 72 deletions

View file

@ -595,7 +595,7 @@ function bb_RemovePictureLinks($match) {
$ch = @curl_init($match[1]); $ch = @curl_init($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
@curl_exec($ch); @curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);
@ -643,7 +643,7 @@ function bb_CleanPictureLinksSub($match) {
$ch = @curl_init($match[1]); $ch = @curl_init($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true); @curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
@curl_exec($ch); @curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);
@ -1069,25 +1069,26 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
if($saved_image) if($saved_image)
$Text = bb_replace_images($Text, $saved_image); $Text = bb_replace_images($Text, $saved_image);
// Clean up the HTML by loading and saving the HTML with the DOM // Clean up the HTML by loading and saving the HTML with the DOM.
// Only do it when it has to be done - for performance reasons // Bad structured html can break a whole page.
// Update: Now it is done every time - since bad structured html can break a whole page // For performance reasons do it only with ativated item cache or at export.
//if (!$tryoembed) { if (!$tryoembed OR (get_itemcachepath() != "")) {
// $doc = new DOMDocument(); $doc = new DOMDocument();
// $doc->preserveWhiteSpace = false; $doc->preserveWhiteSpace = false;
// $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8"); //$Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
// $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'; $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
// @$doc->loadHTML($doctype."<html><body>".$Text."</body></html>"); $encoding = '<?xml encoding="UTF-8">';
@$doc->loadHTML($encoding.$doctype."<html><body>".$Text."</body></html>");
$doc->encoding = 'UTF-8';
$Text = $doc->saveHTML();
$Text = str_replace(array("<html><body>", "</body></html>", $doctype, $encoding), array("", "", "", ""), $Text);
// $Text = $doc->saveHTML(); $Text = str_replace('<br></li>','</li>', $Text);
// $Text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $Text);
// $Text = str_replace('<br></li>','</li>', $Text); //$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
}
// $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
//}
// Clean up some useless linebreaks in lists // Clean up some useless linebreaks in lists
//$Text = str_replace('<br /><ul','<ul ', $Text); //$Text = str_replace('<br /><ul','<ul ', $Text);

View file

@ -405,7 +405,7 @@ intval($params['uid']), LOGGER_DEBUG);
$textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
$body))),ENT_QUOTES,'UTF-8')); $body))),ENT_QUOTES,'UTF-8'));
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
"<br />\n",$body)))); "<br />\n",$body))),ENT_QUOTES,'UTF-8');
$datarray = array(); $datarray = array();
$datarray['banner'] = $banner; $datarray['banner'] = $banner;

View file

@ -35,7 +35,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
} }
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
if(intval($timeout)) { if(intval($timeout)) {
@ -72,7 +72,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
$base = $s; $base = $s;
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code']; $http_code = $curl_info['http_code'];
// logger('fetch_url:' . $http_code . ' data: ' . $s); logger('fetch_url '.$url.': '.$http_code." ".$s, LOGGER_DATA);
$header = ''; $header = '';
// Pull out multiple headers, e.g. proxy and continuation headers // Pull out multiple headers, e.g. proxy and continuation headers
@ -134,7 +134,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params); curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
if(intval($timeout)) { if(intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
@ -1163,8 +1163,7 @@ function original_url($url, $depth=1, $fetchbody = false) {
curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
$header = curl_exec($ch); $header = curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);

View file

@ -21,6 +21,7 @@
var src = null; var src = null;
var prev = null; var prev = null;
var livetime = null; var livetime = null;
var force_update = false;
var msie = false; var msie = false;
var stopped = false; var stopped = false;
var totStopped = false; var totStopped = false;
@ -301,11 +302,16 @@
prev = 'live-' + src; prev = 'live-' + src;
in_progress = true; in_progress = true;
if ($(document).scrollTop() == 0)
force_update = true;
var udargs = ((netargs.length) ? '/' + netargs : ''); var udargs = ((netargs.length) ? '/' + netargs : '');
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0); var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0) + '&force=' + ((force_update) ? 1 : 0);
$.get(update_url,function(data) { $.get(update_url,function(data) {
in_progress = false; in_progress = false;
force_update = false;
// $('.collapsed-comments',data).each(function() { // $('.collapsed-comments',data).each(function() {
// var ident = $(this).attr('id'); // var ident = $(this).attr('id');
// var is_hidden = $('#' + ident).is(':hidden'); // var is_hidden = $('#' + ident).is(':hidden');
@ -414,6 +420,7 @@
$('#like-rotator-' + ident.toString()).show(); $('#like-rotator-' + ident.toString()).show();
$.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate ); $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
liking = 1; liking = 1;
force_update = true;
} }
function dosubthread(ident) { function dosubthread(ident) {
@ -505,6 +512,7 @@
commentClose(tarea,id); commentClose(tarea,id);
if(timer) clearTimeout(timer); if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10); timer = setTimeout(NavUpdate,10);
force_update = true;
} }
if(data.reload) { if(data.reload) {
window.location.href=data.reload; window.location.href=data.reload;
@ -637,6 +645,7 @@ function notifyMarkAll() {
$.get('notify/mark/all', function(data) { $.get('notify/mark/all', function(data) {
if(timer) clearTimeout(timer); if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,1000); timer = setTimeout(NavUpdate,1000);
force_update = true;
}); });
} }

View file

@ -77,9 +77,12 @@ function item_post(&$a) {
$thr_parent = ''; $thr_parent = '';
$parid = 0; $parid = 0;
$r = false; $r = false;
$objecttype = null;
if($parent || $parent_uri) { if($parent || $parent_uri) {
$objecttype = ACTIVITY_OBJ_COMMENT;
if(! x($_REQUEST,'type')) if(! x($_REQUEST,'type'))
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
@ -195,6 +198,7 @@ function item_post(&$a) {
$location = $orig_post['location']; $location = $orig_post['location'];
$coord = $orig_post['coord']; $coord = $orig_post['coord'];
$verb = $orig_post['verb']; $verb = $orig_post['verb'];
$objecttype = $orig_post['object-type'];
$emailcc = $orig_post['emailcc']; $emailcc = $orig_post['emailcc'];
$app = $orig_post['app']; $app = $orig_post['app'];
$categories = $orig_post['file']; $categories = $orig_post['file'];
@ -425,6 +429,9 @@ function item_post(&$a) {
if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) { if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[2]; $images = $match[2];
if(count($images)) { if(count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE;
foreach($images as $image) { foreach($images as $image) {
if(! stristr($image,$a->get_baseurl() . '/photo/')) if(! stristr($image,$a->get_baseurl() . '/photo/'))
continue; continue;
@ -494,6 +501,7 @@ function item_post(&$a) {
$bookmark = 0; $bookmark = 0;
if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) { if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) {
$objecttype = ACTIVITY_OBJ_BOOKMARK;
$bookmark = 1; $bookmark = 1;
} }
@ -509,6 +517,20 @@ function item_post(&$a) {
$body = scale_external_images($body,false); $body = scale_external_images($body,false);
// Setting the object type if not defined before
if (!$objecttype) {
$objecttype = ACTIVITY_OBJ_NOTE; // Default value
require_once("include/plaintext.php");
$objectdata = get_attached_data($body);
if ($post["type"] == "link")
$objecttype = ACTIVITY_OBJ_BOOKMARK;
elseif ($post["type"] == "video")
$objecttype = ACTIVITY_OBJ_VIDEO;
elseif ($post["type"] == "photo")
$objecttype = ACTIVITY_OBJ_IMAGE;
}
/** /**
* Look for any tags and linkify them * Look for any tags and linkify them
@ -641,6 +663,7 @@ function item_post(&$a) {
$datarray['file'] = $categories; $datarray['file'] = $categories;
$datarray['inform'] = $inform; $datarray['inform'] = $inform;
$datarray['verb'] = $verb; $datarray['verb'] = $verb;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow; $datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow; $datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny; $datarray['deny_cid'] = $str_contact_deny;
@ -728,8 +751,8 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` ) `tag`, `inform`, `verb`, `object-type`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` )
VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )", VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )",
dbesc($datarray['guid']), dbesc($datarray['guid']),
intval($datarray['uid']), intval($datarray['uid']),
dbesc($datarray['type']), dbesc($datarray['type']),
@ -758,6 +781,7 @@ function item_post(&$a) {
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc($datarray['inform']), dbesc($datarray['inform']),
dbesc($datarray['verb']), dbesc($datarray['verb']),
dbesc($datarray['object-type']),
dbesc($datarray['postopts']), dbesc($datarray['postopts']),
dbesc($datarray['allow_cid']), dbesc($datarray['allow_cid']),
dbesc($datarray['allow_gid']), dbesc($datarray['allow_gid']),
@ -911,10 +935,6 @@ function item_post(&$a) {
call_hooks('post_local_end', $datarray); call_hooks('post_local_end', $datarray);
// if no auto update is enabled, then disable it temporarily
if (get_pconfig($profile_uid, "system", "no_auto_update") == 1)
set_pconfig($profile_uid, "system", "no_auto_update", -1);
if(strlen($emailcc) && $profile_uid == local_user()) { if(strlen($emailcc) && $profile_uid == local_user()) {
$erecips = explode(',', $emailcc); $erecips = explode(',', $emailcc);
if(count($erecips)) { if(count($erecips)) {

View file

@ -136,10 +136,6 @@ function like_content(&$a) {
// Save the author information for the unlike in case we need to relay to Diaspora // Save the author information for the unlike in case we need to relay to Diaspora
store_diaspora_like_retract_sig($activity, $item, $like_item, $contact); store_diaspora_like_retract_sig($activity, $item, $like_item, $contact);
// if no auto update is enabled, then disable it temporarily
if (get_pconfig($owner_uid, "system", "no_auto_update") == 1)
set_pconfig($owner_uid, "system", "no_auto_update", -1);
// proc_run('php',"include/notifier.php","like","$post_id"); // $post_id isn't defined here! // proc_run('php',"include/notifier.php","like","$post_id"); // $post_id isn't defined here!
$like_item_id = $like_item['id']; $like_item_id = $like_item['id'];
proc_run('php',"include/notifier.php","like","$like_item_id"); proc_run('php',"include/notifier.php","like","$like_item_id");
@ -222,10 +218,6 @@ EOT;
// Save the author information for the like in case we need to relay to Diaspora // Save the author information for the like in case we need to relay to Diaspora
store_diaspora_like_sig($activity, $post_type, $contact, $post_id); store_diaspora_like_sig($activity, $post_type, $contact, $post_id);
// if no auto update is enabled, then disable it temporarily
if (get_pconfig($owner_uid, "system", "no_auto_update") == 1)
set_pconfig($owner_uid, "system", "no_auto_update", -1);
$arr['id'] = $post_id; $arr['id'] = $post_id;
call_hooks('post_local_end', $arr); call_hooks('post_local_end', $arr);

View file

@ -71,8 +71,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch,CURLOPT_USERAGENT,' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
$header = curl_exec($ch); $header = curl_exec($ch);
$curl_info = @curl_getinfo($ch); $curl_info = @curl_getinfo($ch);

View file

@ -886,7 +886,7 @@ function settings_content(&$a) {
'$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''),
'$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''), '$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''),
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''), '$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
'$no_auto_update' => array('no_auto_update', t("Disable automatic network update"), $no_auto_update, ''), '$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, 'When disabled, the network page is updated all the time, which could be confusing while reading.'),
'$theme_config' => $theme_config, '$theme_config' => $theme_config,
)); ));

View file

@ -13,12 +13,9 @@ function update_network_content(&$a) {
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
echo (($_GET['msie'] == 1) ? '<div>' : '<section>'); echo (($_GET['msie'] == 1) ? '<div>' : '<section>');
$no_auto_update = get_pconfig($profile_uid, "system", "no_auto_update"); if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET['force'] == 1))
if ($no_auto_update <= 0) {
$text = network_content($a,$profile_uid); $text = network_content($a,$profile_uid);
if ($no_auto_update < 0) else
set_pconfig($profile_uid, "system", "no_auto_update", 1);
} else
$text = ""; $text = "";
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";

View file

@ -13,10 +13,10 @@
{{include file="field_themeselect.tpl" field=$mobile_theme}} {{include file="field_themeselect.tpl" field=$mobile_theme}}
{{include file="field_input.tpl" field=$itemspage_mobile_network}} {{include file="field_input.tpl" field=$itemspage_mobile_network}}
{{include file="field_input.tpl" field=$ajaxint}} {{include file="field_input.tpl" field=$ajaxint}}
{{include file="field_checkbox.tpl" field=$no_auto_update}}
{{include file="field_checkbox.tpl" field=$nosmile}} {{include file="field_checkbox.tpl" field=$nosmile}}
{{include file="field_checkbox.tpl" field=$noinfo}} {{include file="field_checkbox.tpl" field=$noinfo}}
{{include file="field_checkbox.tpl" field=$infinite_scroll}} {{include file="field_checkbox.tpl" field=$infinite_scroll}}
{{include file="field_checkbox.tpl" field=$no_auto_update}}
<div class="settings-submit-wrapper" > <div class="settings-submit-wrapper" >