From e668709ce48f366b4477bc62434db28b3e211a33 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Jan 2010 13:02:41 -0800 Subject: drop debug statement --- actions/publictagcloud.php | 1 - 1 file changed, 1 deletion(-) diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index b5b474f13..9e4478dbb 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -132,7 +132,6 @@ class PublictagcloudAction extends Action $this->elementStart('dd'); $this->elementStart('ul', 'tags xoxo tag-cloud'); foreach ($tw as $tag => $weight) { - common_log(LOG_DEBUG, "$weight/$sum"); if ($sum) { $weightedSum = $weight/$sum; } else { -- cgit v1.2.3-54-g00ecf From 440b9957f9ae6fdfdb44c39074803fcdbc64112d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Jan 2010 14:24:16 -0800 Subject: Exclude process-specific link & result cache references from serialized Memcached_Data_Object instances. Should fix seemingly-random bugs due to destructor free()ing local resources by mistake. --- classes/Memcached_DataObject.php | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index a77e43d38..d830884b6 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } class Memcached_DataObject extends DB_DataObject { - /** + /** * Destructor to free global memory resources associated with * this data object when it's unset or goes out of scope. * DB_DataObject doesn't do this yet by itself. @@ -35,6 +35,42 @@ class Memcached_DataObject extends DB_DataObject } } + /** + * Magic function called at serialize() time. + * + * We use this to drop a couple process-specific references + * from DB_DataObject which can cause trouble in future + * processes. + * + * @return array of variable names to include in serialization. + */ + function __sleep() + { + $vars = array_keys(get_object_vars($this)); + $skip = array('_DB_resultid', '_link_loaded'); + return array_diff($vars, $skip); + } + + /** + * Magic function called at unserialize() time. + * + * Clean out some process-specific variables which might + * be floating around from a previous process's cached + * objects. + * + * Old cached objects may still have them. + */ + function __wakeup() + { + // Refers to global state info from a previous process. + // Clear this out so we don't accidentally break global + // state in *this* process. + $this->_DB_resultid = null; + + // We don't have any local DBO refs, so clear these out. + $this->_link_loaded = false; + } + /** * Wrapper for DB_DataObject's static lookup using memcached * as backing instead of an in-process cache array. -- cgit v1.2.3-54-g00ecf From d59ffeaab53ebf80b031e2810feaad58aff3288f Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 4 Jan 2010 23:36:22 +0000 Subject: Refactored NoticeLocationAttach(). It works better in UAs that don't support Geolocation API. --- js/util.js | 133 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 57 deletions(-) diff --git a/js/util.js b/js/util.js index 2d108118a..0334a41ab 100644 --- a/js/util.js +++ b/js/util.js @@ -442,6 +442,9 @@ var SN = { // StatusNet }, NoticeLocationAttach: function() { + var NLat = $('#'+SN.C.S.NoticeLat).val(); + var NLon = $('#'+SN.C.S.NoticeLon).val(); + function removeNoticeDataGeo() { $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); $('#'+SN.C.S.NoticeDataGeoSelected).hide(); @@ -451,6 +454,36 @@ var SN = { // StatusNet $('#'+SN.C.S.NoticeLocationId).val(''); } + function getJSONgeocodeURL(geocodeURL, data) { + $.getJSON(geocodeURL, data, function(location) { + NLN = $('#'+SN.C.S.NoticeLocationName); + NLN.replaceWith(''); + NLN = $('#'+SN.C.S.NoticeLocationName); + + if (typeof(location.location_ns) != 'undefined') { + $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); + } + + if (typeof(location.location_id) != 'undefined') { + $('#'+SN.C.S.NoticeLocationId).val(location.location_id); + } + + if (typeof(location.name) == 'undefined') { + NLN_text = position.coords.latitude + ';' + position.coords.longitude; + } + else { + NLN_text = location.name; + } + + NLN.attr('href', location.url); + NLN.text(NLN_text); + NLN.click(function() { + window.open(location.url); + + return false; + }); + }); + } var NDG = $('#'+SN.C.S.NoticeDataGeo); if (NDG.length > 0) { var NLE = $('#notice_data-location_wrap'); @@ -459,48 +492,48 @@ var SN = { // StatusNet $('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text())); - if (navigator.geolocation) { - NDG.change(function() { - $.cookie(SN.C.S.NoticeLocationCookieName, $('#'+SN.C.S.NoticeDataGeo).attr('checked')); + NDG.change(function() { + $.cookie(SN.C.S.NoticeLocationCookieName, $('#'+SN.C.S.NoticeDataGeo).attr('checked')); - var NLN = $('#'+SN.C.S.NoticeLocationName); - if (NLN.length > 0) { - NLN.remove(); - } + var NLN = $('#'+SN.C.S.NoticeLocationName); + if (NLN.length > 0) { + NLN.remove(); + } + + if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true) { + $('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked'); var S = '
'; var NDGS = $('#'+SN.C.S.NoticeDataGeoSelected); + if (NDGS.length > 0) { NDGS.replaceWith(S); } else { $('#'+SN.C.S.FormNotice).append(S); } + NDGS = $('#'+SN.C.S.NoticeDataGeoSelected); - NDGS.prepend('Geo'); + NDGS.prepend('Geo '); var NLN = $('#'+SN.C.S.NoticeLocationName); + NLN.addClass('processing'); - if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true) { - NLN.addClass('processing'); - $('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked'); - - NDGS.append(' '); + $('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){ + $('#'+SN.C.S.NoticeDataGeoSelected).remove(); + $('#'+SN.C.S.NoticeDataGeo).attr('checked', false); + $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - $('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){ - $('#'+SN.C.S.NoticeDataGeoSelected).remove(); - $('#'+SN.C.S.NoticeDataGeo).attr('checked', false); - $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - - return false; - }); + return false; + }); - $('#'+SN.C.S.NoticeDataGeoSelected+' button.minimize').click(function(){ - $('#'+SN.C.S.NoticeDataGeoSelected).hide(); + $('#'+SN.C.S.NoticeDataGeoSelected+' button.minimize').click(function(){ + $('#'+SN.C.S.NoticeDataGeoSelected).hide(); - return false; - }); + return false; + }); + if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(position) { $('#'+SN.C.S.NoticeLat).val(position.coords.latitude); @@ -512,34 +545,7 @@ var SN = { // StatusNet 'token': $('#token').val() }; - $.getJSON(geocodeURL, data, function(location) { - NLN = $('#'+SN.C.S.NoticeLocationName); - NLN.replaceWith(''); - NLN = $('#'+SN.C.S.NoticeLocationName); - - if (typeof(location.location_ns) != 'undefined') { - $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); - } - - if (typeof(location.location_id) != 'undefined') { - $('#'+SN.C.S.NoticeLocationId).val(location.location_id); - } - - if (typeof(location.name) == 'undefined') { - NLN_text = position.coords.latitude + ';' + position.coords.longitude; - } - else { - NLN_text = location.name; - } - - NLN.attr('href', location.url); - NLN.text(NLN_text); - NLN.click(function() { - window.open(location.url); - - return false; - }); - }); + getJSONgeocodeURL(geocodeURL, data); }, function(error) { @@ -550,13 +556,26 @@ var SN = { // StatusNet ); } else { - removeNoticeDataGeo(); + if (NLat.length > 0 && NLon.length > 0) { + var data = { + 'lat': NLat, + 'lon': NLon, + 'token': $('#token').val() + }; + + getJSONgeocodeURL(geocodeURL, data); + } } - }).change(); + } + else { + $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); - NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); - } + removeNoticeDataGeo(); + } + }).change(); + + var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); + NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); } }, -- cgit v1.2.3-54-g00ecf From 9fadfd850e3713e15ea9bf1a097aef4a42b2c1f7 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 00:15:26 +0000 Subject: If user checked shared location but didn't enter their location, don't show the checkbox --- js/util.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/util.js b/js/util.js index 0334a41ab..feea13b52 100644 --- a/js/util.js +++ b/js/util.js @@ -565,11 +565,13 @@ var SN = { // StatusNet getJSONgeocodeURL(geocodeURL, data); } + else { + removeNoticeDataGeo(); + $('label[for='+SN.C.S.NoticeDataGeo+']').remove(); + } } } else { - $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); - removeNoticeDataGeo(); } }).change(); -- cgit v1.2.3-54-g00ecf From db1a7d6f8883b5a37803b656c10305f082fdf270 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 00:37:53 +0000 Subject: Remove input geo data as well --- js/util.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/util.js b/js/util.js index feea13b52..a2212cac2 100644 --- a/js/util.js +++ b/js/util.js @@ -484,6 +484,7 @@ var SN = { // StatusNet }); }); } + var NDG = $('#'+SN.C.S.NoticeDataGeo); if (NDG.length > 0) { var NLE = $('#notice_data-location_wrap'); @@ -567,6 +568,7 @@ var SN = { // StatusNet } else { removeNoticeDataGeo(); + $('#'+SN.C.S.NoticeDataGeo).remove(); $('label[for='+SN.C.S.NoticeDataGeo+']').remove(); } } -- cgit v1.2.3-54-g00ecf From eb9514120a882aacae38f8b85a1f431852b44b89 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 01:15:08 +0000 Subject: Retain the geo data when FormNoticeXHR is complete because form gets reset --- js/util.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index a2212cac2..d84d21582 100644 --- a/js/util.js +++ b/js/util.js @@ -178,12 +178,13 @@ var SN = { // StatusNet }, FormNoticeXHR: function(form) { + var NDG, NLat, NLon, NLNS, NLID; form_id = form.attr('id'); form.append(''); form.ajaxForm({ dataType: 'xml', timeout: '60000', - beforeSend: function(xhr) { + beforeSend: function(formData) { if ($('#'+form_id+' #'+SN.C.S.NoticeDataText)[0].value.length === 0) { form.addClass(SN.C.S.Warning); return false; @@ -191,6 +192,13 @@ var SN = { // StatusNet form.addClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled); + + NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked'); + NLat = $('#'+SN.C.S.NoticeLat).val(); + NLon = $('#'+SN.C.S.NoticeLon).val(); + NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + NLID = $('#'+SN.C.S.NoticeLocationId).val(); + return true; }, error: function (xhr, textStatus, errorThrown) { @@ -273,6 +281,12 @@ var SN = { // StatusNet form.removeClass(SN.C.S.Processing); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled); $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled); + + $('#'+SN.C.S.NoticeDataGeo).attr('checked', NDG); + $('#'+SN.C.S.NoticeLat).val(NLat); + $('#'+SN.C.S.NoticeLon).val(NLon); + $('#'+SN.C.S.NoticeLocationNs).val(NLNS); + $('#'+SN.C.S.NoticeLocationId).val(NLID); } }); }, @@ -444,6 +458,8 @@ var SN = { // StatusNet NoticeLocationAttach: function() { var NLat = $('#'+SN.C.S.NoticeLat).val(); var NLon = $('#'+SN.C.S.NoticeLon).val(); + var NLNS = $('#'+SN.C.S.NoticeLocationNs).val(); + var NLID = $('#'+SN.C.S.NoticeLocationId).val(); function removeNoticeDataGeo() { $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked'); -- cgit v1.2.3-54-g00ecf From a08e683ac3bf07b19d704ac524a2e18804e908a7 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 01:31:34 +0000 Subject: Reuse cookie location_enabled before .change() --- js/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/util.js b/js/util.js index d84d21582..af6e0ff20 100644 --- a/js/util.js +++ b/js/util.js @@ -503,6 +503,9 @@ var SN = { // StatusNet var NDG = $('#'+SN.C.S.NoticeDataGeo); if (NDG.length > 0) { + var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); + NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); + var NLE = $('#notice_data-location_wrap'); var geocodeURL = NLE.attr('title'); NLE.removeAttr('title'); @@ -593,9 +596,6 @@ var SN = { // StatusNet removeNoticeDataGeo(); } }).change(); - - var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName); - NDG.attr('checked', (cookieVal === null || cookieVal == 'true')); } }, -- cgit v1.2.3-54-g00ecf From 2960193cc4f9be74713896ddb0e7debb1190c163 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 5 Jan 2010 03:07:26 +0100 Subject: Updated default theme for geo --- theme/default/css/display.css | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 50209bfd3..0c8db45e7 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -111,6 +111,19 @@ box-shadow:3px 3px 3px rgba(194, 194, 194, 0.1); text-shadow:none; } +.form_notice span#notice_data-location_name { +background-position:0 47%; +} +.form_notice a#notice_data-location_name { +background-position:0 -1711px; +} +.form_notice label[for=notice_data-geo] { +background-position:0 -1780px; +} +.form_notice label[for=notice_data-geo].checked { +background-position:0 -1846px; +} + a, .form_settings input.form_action-primary, .notice-options input, @@ -177,7 +190,10 @@ button.close, .entity_sandbox input.submit, .entity_silence input.submit, .entity_delete input.submit, -.notice-options .repeated { +.notice-options .repeated, +.form_notice a#notice_data-location_name, +.form_notice label[for=notice_data-geo], +button.minimize { background-image:url(../../base/images/icons/icons-01.gif); background-repeat:no-repeat; background-color:transparent; @@ -239,6 +255,9 @@ background-color:#EFF3DC; button.close { background-position:0 -1120px; } +button.minimize { +background-position:0 -1912px; +} #anon_notice { background-color:#87B4C8; -- cgit v1.2.3-54-g00ecf