From 2b69571cbf97d3b62dff1fa3849f714272e5f893 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Fri, 15 Jun 2018 22:55:00 +0200 Subject: [PATCH 1/7] Frio: add addon_hooks to head.tpl --- view/theme/frio/templates/head.tpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index 31b7175ba..f4bcabdae 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -68,6 +68,12 @@ + +{{if is_array($addon_hooks)}} +{{foreach $addon_hooks as $addon_hook}} + +{{/foreach}} +{{/if}} From c651641856622459174e25e72abb7f0f7501b806 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 15 Jun 2018 20:50:31 -0400 Subject: [PATCH 2/7] Fix PHP 7.2 Warning in Model\Contact --- src/Model/Contact.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index e504849f7..f354f89c7 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1070,9 +1070,11 @@ class Contact extends BaseObject 'limit' => [$a->pager['start'], $a->pager['itemspage']]]; $r = Item::select(local_user(), [], $condition, $params); - $o = conversation($a, dba::inArray($r), 'contact-posts', false); + $items = dba::inArray($r); + + $o = conversation($a, $items, 'contact-posts', false); - $o .= alt_pager($a, count($r)); + $o .= alt_pager($a, count($items)); return $o; } From d2da5d63c78f03dca145d9d1c4d30712ce817bc6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jun 2018 07:26:09 +0000 Subject: [PATCH 3/7] Fix for PR 5199: Corrected check for empty object --- src/Protocol/PortableContact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 2dcc04740..719148a8e 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -1009,7 +1009,7 @@ class PortableContact // Maybe the page is unencrypted only? $xmlobj = @simplexml_load_string($serverret["body"], 'SimpleXMLElement', 0, "http://docs.oasis-open.org/ns/xri/xrd-1.0"); - if (!$serverret["success"] || ($serverret["body"] == "") || (empty($xmlobj) == 0) || !is_object($xmlobj)) { + if (!$serverret["success"] || ($serverret["body"] == "") || empty($xmlobj) || !is_object($xmlobj)) { $server_url = str_replace("https://", "http://", $server_url); // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital @@ -1025,7 +1025,7 @@ class PortableContact $xmlobj = @simplexml_load_string($serverret["body"], 'SimpleXMLElement', 0, "http://docs.oasis-open.org/ns/xri/xrd-1.0"); } - if (!$serverret["success"] || ($serverret["body"] == "") || (empty($xmlobj) == 0) || !is_object($xmlobj)) { + if (!$serverret["success"] || ($serverret["body"] == "") || empty($xmlobj) || !is_object($xmlobj)) { // Workaround for bad configured servers (known nginx problem) if (!in_array($serverret["debug"]["http_code"], ["403", "404"])) { $failure = true; From a2fc1be187fef508e304cb90279cb995b765787c Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 16 Jun 2018 13:05:33 +0200 Subject: [PATCH 4/7] fix scroll position in stream while ajax update --- composer.json | 3 +- composer.lock | 109 ++++++++++++++++++++++++++++- mod/update_community.php | 4 -- mod/update_display.php | 3 - mod/update_network.php | 4 -- mod/update_notes.php | 4 -- mod/update_profile.php | 4 -- view/js/main.js | 57 ++++++++------- view/templates/head.tpl | 1 + view/theme/frio/templates/head.tpl | 1 + 10 files changed, 142 insertions(+), 48 deletions(-) diff --git a/composer.json b/composer.json index 9668b9341..941464e70 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "npm-asset/jquery-datetimepicker": "^2.4.0", "npm-asset/jgrowl": "^1.4", "npm-asset/fullcalendar": "^3.0.1", - "npm-asset/cropperjs": "1.2.2" + "npm-asset/cropperjs": "1.2.2", + "npm-asset/imagesloaded": "4.1.4" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index dd2665ebb..7ba8fc1cf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "ab5a551aff0505691c4836d063fc5171", + "content-hash": "4fcae78061a3eb72f91e4fa81e53af56", "packages": [ { "name": "asika/simple-console", @@ -770,6 +770,49 @@ ], "time": "2018-01-03T13:39:39+00:00" }, + { + "name": "npm-asset/ev-emitter", + "version": "1.1.1", + "dist": { + "type": "tar", + "url": "https://registry.npmjs.org/ev-emitter/-/ev-emitter-1.1.1.tgz", + "reference": null, + "shasum": "8f18b0ce5c76a5d18017f71c0a795c65b9138f2a" + }, + "type": "npm-asset-library", + "extra": { + "npm-asset-bugs": { + "url": "https://github.com/metafizzy/ev-emitter/issues" + }, + "npm-asset-main": "ev-emitter.js", + "npm-asset-directories": { + "test": "test" + }, + "npm-asset-repository": { + "type": "git", + "url": "git+https://github.com/metafizzy/ev-emitter.git" + }, + "npm-asset-scripts": { + "test": "mocha test/test" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David DeSandro" + } + ], + "description": "lil' event emitter", + "homepage": "https://github.com/metafizzy/ev-emitter#readme", + "keywords": [ + "emitter", + "event", + "pubsub" + ], + "time": "2017-07-06T13:46:38+00:00" + }, { "name": "npm-asset/fullcalendar", "version": "3.8.2", @@ -882,6 +925,70 @@ ], "time": "2018-01-30T23:49:01+00:00" }, + { + "name": "npm-asset/imagesloaded", + "version": "4.1.4", + "dist": { + "type": "tar", + "url": "https://registry.npmjs.org/imagesloaded/-/imagesloaded-4.1.4.tgz", + "reference": null, + "shasum": "1376efcd162bb768c34c3727ac89cc04051f3cc7" + }, + "require": { + "npm-asset/ev-emitter": ">=1.0.0,<2.0.0" + }, + "require-dev": { + "npm-asset/chalk": ">=1.1.1,<2.0.0", + "npm-asset/cheerio": ">=0.19.0,<0.20.0", + "npm-asset/gulp": ">=3.9.0,<4.0.0", + "npm-asset/gulp-jshint": ">=1.11.2,<2.0.0", + "npm-asset/gulp-json-lint": ">=0.1.0,<0.2.0", + "npm-asset/gulp-rename": ">=1.2.2,<2.0.0", + "npm-asset/gulp-replace": ">=0.5.4,<0.6.0", + "npm-asset/gulp-requirejs-optimize": "dev-github:metafizzy/gulp-requirejs-optimize", + "npm-asset/gulp-uglify": ">=1.4.2,<2.0.0", + "npm-asset/gulp-util": ">=3.0.7,<4.0.0", + "npm-asset/highlight.js": ">=8.9.1,<9.0.0", + "npm-asset/marked": ">=0.3.5,<0.4.0", + "npm-asset/minimist": ">=1.2.0,<2.0.0", + "npm-asset/transfob": ">=1.0.0,<2.0.0" + }, + "type": "npm-asset-library", + "extra": { + "npm-asset-bugs": { + "url": "https://github.com/desandro/imagesloaded/issues" + }, + "npm-asset-main": "imagesloaded.js", + "npm-asset-directories": { + "test": "test" + }, + "npm-asset-repository": { + "type": "git", + "url": "git://github.com/desandro/imagesloaded.git" + }, + "npm-asset-scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David DeSandro" + } + ], + "description": "JavaScript is all like _You images done yet or what?_", + "homepage": "https://github.com/desandro/imagesloaded", + "keywords": [ + "dom", + "images", + "jquery-plugin", + "loaded", + "ui" + ], + "time": "2018-01-02T16:56:03+00:00" + }, { "name": "npm-asset/jgrowl", "version": "1.4.6", diff --git a/mod/update_community.php b/mod/update_community.php index d64ea5d70..088da0143 100644 --- a/mod/update_community.php +++ b/mod/update_community.php @@ -19,10 +19,6 @@ function update_community_content(App $a) { $text = ''; } - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = ""; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; diff --git a/mod/update_display.php b/mod/update_display.php index 48df9797d..4b6d26cb7 100644 --- a/mod/update_display.php +++ b/mod/update_display.php @@ -19,9 +19,6 @@ function update_display_content(App $a) echo "
"; $text = display_content($a, true, $profile_uid); - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = ""; diff --git a/mod/update_network.php b/mod/update_network.php index 962701627..6c02e4a8f 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -25,10 +25,6 @@ function update_network_content(App $a) $text = ""; } - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = ""; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; diff --git a/mod/update_notes.php b/mod/update_notes.php index 892e71d78..7db60e78e 100644 --- a/mod/update_notes.php +++ b/mod/update_notes.php @@ -32,10 +32,6 @@ function update_notes_content(App $a) { $text = notes_content($a, $profile_uid); - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = ""; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; diff --git a/mod/update_profile.php b/mod/update_profile.php index 1a05130e0..984fd7949 100644 --- a/mod/update_profile.php +++ b/mod/update_profile.php @@ -31,10 +31,6 @@ function update_profile_content(App $a) { $text = profile_content($a, $profile_uid); - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = ""; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; diff --git a/view/js/main.js b/view/js/main.js index b5043601c..4c55546aa 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -418,6 +418,9 @@ function liveUpdate(src) { if ($(document).scrollTop() == 0) { force_update = true; } + + var orgHeight = $("section").height(); + var udargs = ((netargs.length) ? '/' + netargs : ''); var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&force=' + ((force_update) ? 1 : 0) + '&item=' + update_item; @@ -426,42 +429,42 @@ function liveUpdate(src) { force_update = false; update_item = 0; - // add a new thread - $('.toplevel_item',data).each(function() { - var ident = $(this).attr('id'); + $('.wall-item-body', data).imagesLoaded(function() { + // add a new thread + $('.toplevel_item',data).each(function() { + var ident = $(this).attr('id'); - if ($('#' + ident).length == 0 && profile_page == 1) { - $('img',this).each(function() { - $(this).attr('src',$(this).attr('dst')); - }); - $('#' + prev).after($(this)); - } else { - // Find out if the hidden comments are open, so we can keep it that way - // if a new comment has been posted - var id = $('.hide-comments-total', this).attr('id'); - if (typeof id != 'undefined') { - id = id.split('-')[3]; - var commentsOpen = $("#collapsed-comments-" + id).is(":visible"); - } + // Add new top-level item. + if ($('#' + ident).length == 0 && profile_page == 1) { + $('#' + prev).after($(this)); - $('img',this).each(function() { - $(this).attr('src',$(this).attr('dst')); - }); - $('html').height($('html').height()); - $('#' + ident).replaceWith($(this)); + // Replace already existing thread. + } else { + // Find out if the hidden comments are open, so we can keep it that way + // if a new comment has been posted + var id = $('.hide-comments-total', this).attr('id'); + if (typeof id != 'undefined') { + id = id.split('-')[3]; + var commentsOpen = $("#collapsed-comments-" + id).is(":visible"); + } - if (typeof id != 'undefined') { - if (commentsOpen) { - showHideComments(id); + $('#' + ident).replaceWith($(this)); + + if (typeof id != 'undefined') { + if (commentsOpen) { + showHideComments(id); + } } } - $('html').height('auto'); - } - prev = ident; + prev = ident; + }); }); callAddonHooks("postprocess_liveupdate"); + // Update the scroll position. + $(window).scrollTop($(window).scrollTop() + $("section").height() - orgHeight); + $('.like-rotator').hide(); if (commentBusy) { commentBusy = false; diff --git a/view/templates/head.tpl b/view/templates/head.tpl index b3dfbc1f4..aadbfcd8e 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -42,6 +42,7 @@ + diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index f4bcabdae..ef1cd810b 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -66,6 +66,7 @@ + From d0ea208d042617d0e3cb37b953dcef1f3e95af63 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Sat, 16 Jun 2018 13:38:32 +0200 Subject: [PATCH 5/7] main.js - move some code of liveUpdate() into updateConvItems() for readability --- view/js/main.js | 84 ++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/view/js/main.js b/view/js/main.js index 4c55546aa..88cfe89ee 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -395,6 +395,47 @@ function NavUpdate() { timer = setTimeout(NavUpdate, updateInterval); } +function updateConvItems(data) { + // add a new thread + $('.toplevel_item',data).each(function() { + var ident = $(this).attr('id'); + + // Add new top-level item. + if ($('#' + ident).length == 0 && profile_page == 1) { + $('#' + prev).after($(this)); + + // Replace already existing thread. + } else { + // Find out if the hidden comments are open, so we can keep it that way + // if a new comment has been posted + var id = $('.hide-comments-total', this).attr('id'); + if (typeof id != 'undefined') { + id = id.split('-')[3]; + var commentsOpen = $("#collapsed-comments-" + id).is(":visible"); + } + + $('#' + ident).replaceWith($(this)); + + if (typeof id != 'undefined') { + if (commentsOpen) { + showHideComments(id); + } + } + } + prev = ident; + }); + + $('.like-rotator').hide(); + if (commentBusy) { + commentBusy = false; + $('body').css('cursor', 'auto'); + } + /* autocomplete @nicknames */ + $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl"); + /* autocomplete bbcode */ + $(".comment-edit-form textarea").bbco_autocomplete('bbcode'); +} + function liveUpdate(src) { if ((src == null) || stopped || !profile_uid) { $('.like-rotator').hide(); return; @@ -430,51 +471,14 @@ function liveUpdate(src) { update_item = 0; $('.wall-item-body', data).imagesLoaded(function() { - // add a new thread - $('.toplevel_item',data).each(function() { - var ident = $(this).attr('id'); + updateConvItems(data); - // Add new top-level item. - if ($('#' + ident).length == 0 && profile_page == 1) { - $('#' + prev).after($(this)); - - // Replace already existing thread. - } else { - // Find out if the hidden comments are open, so we can keep it that way - // if a new comment has been posted - var id = $('.hide-comments-total', this).attr('id'); - if (typeof id != 'undefined') { - id = id.split('-')[3]; - var commentsOpen = $("#collapsed-comments-" + id).is(":visible"); - } - - $('#' + ident).replaceWith($(this)); - - if (typeof id != 'undefined') { - if (commentsOpen) { - showHideComments(id); - } - } - } - prev = ident; - }); + // Update the scroll position. + $(window).scrollTop($(window).scrollTop() + $("section").height() - orgHeight); }); callAddonHooks("postprocess_liveupdate"); - // Update the scroll position. - $(window).scrollTop($(window).scrollTop() + $("section").height() - orgHeight); - - $('.like-rotator').hide(); - if (commentBusy) { - commentBusy = false; - $('body').css('cursor', 'auto'); - } - /* autocomplete @nicknames */ - $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl"); - /* autocomplete bbcode */ - $(".comment-edit-form textarea").bbco_autocomplete('bbcode'); - }); } From 1a8d3c460e061383346e3fedcdc9230e1fe267bb Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Sat, 16 Jun 2018 13:50:56 +0200 Subject: [PATCH 6/7] add class "wall-item-body" to all themes --- view/theme/quattro/templates/search_item.tpl | 2 +- view/theme/quattro/templates/wall_thread.tpl | 2 +- view/theme/vier/templates/search_item.tpl | 2 +- view/theme/vier/templates/wall_thread.tpl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index 649ad341f..cf79b24c0 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -23,7 +23,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body}} +
{{$item.body}}
diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 89832403f..79bf1d6b6 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -60,7 +60,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body}} + {{$item.body}}
diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index f056b0f7a..c1383ba43 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -30,7 +30,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body}} +
{{$item.body}}
diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index d1588bde3..6c636d53b 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -67,7 +67,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body}} + {{$item.body}}
From a54fea313ff93b43ae0c691df2a8cf9c8c363006 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Jun 2018 11:52:28 +0000 Subject: [PATCH 7/7] More indentions --- mod/ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/ping.php b/mod/ping.php index 614864529..0256500df 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -132,7 +132,7 @@ function ping_init(App $a) $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar', 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid']; $params = ['order' => ['created' => true]]; - $items = Item::select(local_user(), $fields, $condition, $params); + $items = Item::select(local_user(), $fields, $condition, $params); if (DBM::is_result($items)) { $items_unseen = dba::inArray($items);