From 4876a6a8539c46c6fbca118cc20738cf21470c1c Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 17 Oct 2014 16:06:39 +0200 Subject: [PATCH 1/7] replies in notification tab bug --- actions/qvitter.php | 4 ++-- js/dom-functions.js | 13 +++++++------ js/qvitter.js | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/actions/qvitter.php b/actions/qvitter.php index a8bfe64..809f994 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -386,11 +386,11 @@ class QvitterAction extends ApiAction - + - + diff --git a/js/dom-functions.js b/js/dom-functions.js index ca62d34..0d5fc7d 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -1403,7 +1403,7 @@ function checkForHiddenConversationQueets(qid) { · · · · · · · · · · · · · · */ -function addToFeed(feed, after, extraClasses) { +function addToFeed(feed, after, extraClasses, isReply) { // some streams, e.g. /statuses/show/1234.json is not enclosed in an array, make sure it is if(!$.isArray(feed)) { @@ -1414,8 +1414,9 @@ function addToFeed(feed, after, extraClasses) { var extraClassesThisRun = extraClasses; - // if this is the notifications feed - if(window.currentStream.substring(0,35) == 'qvitter/statuses/notifications.json') { + // if this is the notifications feed, but not if it is a reply + if(window.currentStream.substring(0,35) == 'qvitter/statuses/notifications.json' + && !isReply) { // only if this notification isn't already in stream @@ -1431,12 +1432,12 @@ function addToFeed(feed, after, extraClasses) { if(obj.ntype == 'like') { var noticeTime = parseTwitterDate(obj.notice.created_at); obj.notice = convertNewGNUSocialURItoURL(obj.notice); - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xFavedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xFavedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; } else if(obj.ntype == 'repeat') { obj.notice = convertNewGNUSocialURItoURL(obj.notice); var noticeTime = parseTwitterDate(obj.notice.created_at); - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xRepeatedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xRepeatedYourQueet + '
' + noticeTime + ': ' + $.trim(obj.notice.statusnet_html) + '
'; } else if(obj.ntype == 'mention') { var notificationHtml = buildQueetHtml(obj.notice, obj.id, extraClassesThisRun + ' notification mention'); @@ -1445,7 +1446,7 @@ function addToFeed(feed, after, extraClasses) { var notificationHtml = buildQueetHtml(obj.notice, obj.id, extraClassesThisRun + ' notification reply'); } else if(obj.ntype == 'follow') { - var notificationHtml = '
' + notificationTime + ' ' + window.sL.xStartedFollowingYou + '
'; + var notificationHtml = '
' + notificationTime + ' ' + window.sL.xStartedFollowingYou + '
'; } if(after) { diff --git a/js/qvitter.js b/js/qvitter.js index d62d92f..4c3ca93 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -1420,7 +1420,7 @@ $('body').on('click', '.queet-toolbar button',function () { // show real queet var new_queet = Array(); new_queet[0] = data; - addToFeed(new_queet,tempPostId,'visible'); + addToFeed(new_queet,tempPostId,'visible', true); // remove temp queet $('#' + tempPostId).remove(); From 387ecc59f4f2a579bfb3997ba35471cb66eec292 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 17 Oct 2014 17:08:14 +0200 Subject: [PATCH 2/7] better char counting and don't collapse queet box when content is too long --- js/dom-functions.js | 4 +++- js/misc-functions.js | 11 +++++++++-- js/qvitter.js | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/dom-functions.js b/js/dom-functions.js index 0d5fc7d..f4eaa62 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -842,7 +842,9 @@ function expand_queet(q,doScrolling) { if(q.hasClass('expanded') && !q.hasClass('collapsing')) { var sel = getSelection().toString(); - if(!sel && !q.find('.queet-button').children('button').hasClass('enabled')) { // don't collapse if text is selected, or if queet has an active queet button + if(!sel + && !q.find('.queet-button').children('button').hasClass('enabled') + && !q.find('.queet-button').children('button').hasClass('too-long')) { // don't collapse if text is selected, or if queet has an active queet button, or if queet text is too long // remove some things right away q.find('.inline-reply-caret').remove(); diff --git a/js/misc-functions.js b/js/misc-functions.js index 176208a..be6968b 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -514,8 +514,8 @@ function qOrAmp(stream) { function countCharsInQueetBox(src,trgt,btn) { - var $src_txt = $('
').append($.trim(src.html()).replace(/ /gi,' ').replace(/
/i,'').replace(/
/gi,"x")); - var numchars = ($.trim($src_txt.text())).length; + var $src_txt = $('
').append($.trim(src.text().replace(/^\s+|\s+$/g, ''))); + var numchars = ($src_txt.text()).length; // check for long urls and disable/enable url shorten button if present var longurls = 0; @@ -535,6 +535,7 @@ function countCharsInQueetBox(src,trgt,btn) { if(numchars > 0 && numchars < window.textLimit+1) { btn.removeClass('disabled'); btn.addClass('enabled'); + btn.removeClass('too-long'); // deactivate button if it's equal to the start text var queetBox = btn.closest('.inline-reply-queetbox').children('.queet-box-syntax'); @@ -546,9 +547,15 @@ function countCharsInQueetBox(src,trgt,btn) { } } } + else if(numchars > window.textLimit){ + btn.removeClass('enabled'); + btn.addClass('disabled'); + btn.addClass('too-long'); + } else { btn.removeClass('enabled'); btn.addClass('disabled'); + btn.removeClass('too-long'); } diff --git a/js/qvitter.js b/js/qvitter.js index 4c3ca93..2583a67 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -1376,7 +1376,7 @@ $('body').on('click', '.queet-toolbar button',function () { var queetBox = $(this).parent().parent().siblings('.queet-box'); var queetBoxID = queetBox.attr('id'); - var queetText = $.trim(queetBox.html().replace(/\n/g,'').replace(/
/g,"\n")); + var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '')); var queetHtml = '
'; queetHtml = detectRTL(queetHtml); From 4dca9463b47793f4bca27dfcfa0b337a3e3830b7 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 17 Oct 2014 19:06:29 +0200 Subject: [PATCH 3/7] better login, don't prompt with basic auth popup, redirect to front page on 404 from api --- actions/qvitter.php | 8 ++++---- edited-gnu-social-files/lib/apiauthaction.php | 7 ++++--- js/ajax-functions.js | 8 ++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/actions/qvitter.php b/actions/qvitter.php index 809f994..5c3c9a0 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -386,11 +386,11 @@ class QvitterAction extends ApiAction - - - + + + - + diff --git a/edited-gnu-social-files/lib/apiauthaction.php b/edited-gnu-social-files/lib/apiauthaction.php index 672e35b..af50db4 100644 --- a/edited-gnu-social-files/lib/apiauthaction.php +++ b/edited-gnu-social-files/lib/apiauthaction.php @@ -87,7 +87,8 @@ class ApiAuthAction extends ApiAction // qvitterfix, accepts regular login session - if ($this->scoped) { + if (common_logged_in()) { + $this->scoped = Profile::current(); $this->auth_user = $this->scoped->getUser(); $this->access = self::READ_WRITE; } @@ -290,7 +291,7 @@ class ApiAuthAction extends ApiAction // show error if the user clicks 'cancel' // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel". - $this->clientError(_('Could not authenticate you.'), 401); + $this->clientError(_('Could not authenticate you.'), 400); } elseif($required) { @@ -319,7 +320,7 @@ class ApiAuthAction extends ApiAction ); $this->logAuthFailure($msg); // TRANS: Client error thrown when authentication fails. - $this->clientError(_('Could not authenticate you.'), 401); + $this->clientError(_('Could not authenticate you.'), 400); } } else { diff --git a/js/ajax-functions.js b/js/ajax-functions.js index eb59a51..30dcee9 100644 --- a/js/ajax-functions.js +++ b/js/ajax-functions.js @@ -92,6 +92,14 @@ function getFromAPI(stream, actionOnSuccess) { $.ajax({ url: window.apiRoot + stream + qOrAmp(stream) + 't=' + timeNow(), type: "GET", dataType: 'json', + statusCode: { + 400:function() { + location.reload(); // we may have been logged out in another tab, reload page + }, + 404:function() { + window.location.replace(window.siteInstanceURL); // redirect to frontpage, probably when trying to access non-existing users + } + }, success: function(data) { data = convertEmptyObjectToEmptyArray(data); From 676ab4aba0502a6d4d6c413a95e716d01a71d11e Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Sun, 19 Oct 2014 15:30:45 +0200 Subject: [PATCH 4/7] shortener bug with % sign, thx to @simsa0 --- js/misc-functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/misc-functions.js b/js/misc-functions.js index be6968b..0348263 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -809,7 +809,7 @@ function shortenUrlsInBox(shortenButton) { console.log(data.url); - shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace($('
').text(data.url.url).html(), data.shorturl)); + shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace($('
').text(decodeURIComponent(data.url.url)).html(), data.shorturl)); shortenButton.parent().parent().siblings('.queet-box-syntax').trigger('keyup'); shortenButton.addClass('disabled'); // make sure the button is disabled right after } From d045c79853cc485827c11b6d1d5f297e17306d3c Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Thu, 30 Oct 2014 18:57:32 +0100 Subject: [PATCH 5/7] null bugfix in notifications --- actions/apiqvitternotifications.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/actions/apiqvitternotifications.php b/actions/apiqvitternotifications.php index 05f700b..bf1aa8c 100644 --- a/actions/apiqvitternotifications.php +++ b/actions/apiqvitternotifications.php @@ -91,9 +91,17 @@ class ApiQvitterNotificationsAction extends ApiPrivateAuthAction foreach($this->notifications as $notification) { + // all but follow has an notice if($notification->ntype != 'follow') { - $notice = self::twitterSimpleStatusArray(Notice::getKV($notification->notice_id)); + + // we need a notice id here, skip this notification if notice id is null + if($notification->notice_id === null) { + continue; + } + else { + $notice = self::twitterSimpleStatusArray(Notice::getKV($notification->notice_id)); + } } $notifications_populated[] = array( From 7d4139df13e28e489417edce153e97d925f68aef Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 31 Oct 2014 00:28:06 +0100 Subject: [PATCH 6/7] if qvitter is opt-out, disable the default register page --- QvitterPlugin.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/QvitterPlugin.php b/QvitterPlugin.php index 6f7cf8a..689ce3e 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -197,6 +197,12 @@ class QvitterPlugin extends Plugin { array('notice' => '[0-9]+'), 'qvitter'); } + + // if qvitter is opt-out, disable the default register page + if(self::settings('enabledbydefault')) { + $m->connect('main/register', + array('action' => 'qvitter')); + } } From d83677add4f37b33df8185f5757e7e88a9809872 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 4 Nov 2014 17:32:40 +0100 Subject: [PATCH 7/7] shortener bug --- actions/qvitter.php | 2 +- js/misc-functions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/qvitter.php b/actions/qvitter.php index 5c3c9a0..d9e659a 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -387,7 +387,7 @@ class QvitterAction extends ApiAction - + diff --git a/js/misc-functions.js b/js/misc-functions.js index 0348263..be6968b 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -809,7 +809,7 @@ function shortenUrlsInBox(shortenButton) { console.log(data.url); - shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace($('
').text(decodeURIComponent(data.url.url)).html(), data.shorturl)); + shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace($('
').text(data.url.url).html(), data.shorturl)); shortenButton.parent().parent().siblings('.queet-box-syntax').trigger('keyup'); shortenButton.addClass('disabled'); // make sure the button is disabled right after }