From 09d67d6f80abdf577f6cd94d7be2bc19ce5541fa Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 11:16:39 -0500 Subject: Fix js error on non-map containing pages --- plugins/Mapstraction/usermap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/Mapstraction/usermap.js b/plugins/Mapstraction/usermap.js index 7fb73fa88..19ec54c39 100644 --- a/plugins/Mapstraction/usermap.js +++ b/plugins/Mapstraction/usermap.js @@ -5,7 +5,7 @@ $(document).ready(function() { if(notice['geo']) notices.push(notice); }); - if($("#map_canvas") && notices.length>0) + if($("#map_canvas").length && notices.length>0) { showMapstraction($("#map_canvas"), notices); } -- cgit v1.2.3-54-g00ecf From e7663ce38f8eb4d918102351c45a5829a523141b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 20 Nov 2009 10:08:13 -0800 Subject: fix notice bug --- plugins/Mapstraction/MapstractionPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index a0dbf5204..37306a23c 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -58,12 +58,12 @@ class MapstractionPlugin extends Plugin * * The way to register new actions from a plugin. * - * @param Router &$m reference to router + * @param Router $m reference to router * * @return boolean event handler return */ - function onRouterInitialized(&$m) + function onRouterInitialized($m) { $m->connect(':nickname/all/map', array('action' => 'allmap'), -- cgit v1.2.3-54-g00ecf From 028a44e080e645d2fded19234e5cf389ed8086b5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 20 Nov 2009 07:58:28 -0800 Subject: use caching in geonames plugin --- plugins/GeonamesPlugin.php | 87 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/GeonamesPlugin.php b/plugins/GeonamesPlugin.php index 59232c1c5..340a6f0bf 100644 --- a/plugins/GeonamesPlugin.php +++ b/plugins/GeonamesPlugin.php @@ -63,6 +63,14 @@ class GeonamesPlugin extends Plugin function onLocationFromName($name, $language, &$location) { + $loc = $this->getCache(array('name' => $name, + 'language' => $language)); + + if (!empty($loc)) { + $location = $loc; + return false; + } + $client = HTTPClient::start(); // XXX: break down a name by commas, narrow by each @@ -87,6 +95,10 @@ class GeonamesPlugin extends Plugin $location->location_id = $n->geonameId; $location->location_ns = self::LOCATION_NS; + $this->setCache(array('name' => $name, + 'language' => $language), + $location); + // handled, don't continue processing! return false; } @@ -114,6 +126,13 @@ class GeonamesPlugin extends Plugin return true; } + $loc = $this->getCache(array('id' => $id)); + + if (!empty($loc)) { + $location = $loc; + return false; + } + $client = HTTPClient::start(); $str = http_build_query(array('geonameId' => $id, @@ -148,6 +167,9 @@ class GeonamesPlugin extends Plugin $location->lat = $last->lat; $location->lon = $last->lng; $location->names[$language] = implode(', ', array_reverse($parts)); + + $this->setCache(array('id' => $last->geonameId), + $location); } } @@ -173,6 +195,14 @@ class GeonamesPlugin extends Plugin function onLocationFromLatLon($lat, $lon, $language, &$location) { + $loc = $this->getCache(array('lat' => $lat, + 'lon' => $lon)); + + if (!empty($loc)) { + $location = $loc; + return false; + } + $client = HTTPClient::start(); $str = http_build_query(array('lat' => $lat, @@ -211,6 +241,10 @@ class GeonamesPlugin extends Plugin $location->names[$language] = implode(', ', $parts); + $this->setCache(array('lat' => $lat, + 'lon' => $lon), + $location); + // Success! We handled it, so no further processing return false; @@ -242,9 +276,17 @@ class GeonamesPlugin extends Plugin return true; } + $n = $this->getCache(array('id' => $location->location_id, + 'language' => $language)); + + if (!empty($n)) { + $name = $n; + return false; + } + $client = HTTPClient::start(); - $str = http_build_query(array('geonameId' => $id, + $str = http_build_query(array('geonameId' => $location->location_id, 'lang' => $language)); $result = $client->get('http://ws.geonames.org/hierarchyJSON?'.$str); @@ -271,6 +313,9 @@ class GeonamesPlugin extends Plugin if (count($parts)) { $name = implode(', ', array_reverse($parts)); + $this->setCache(array('id' => $location->location_id, + 'language' => $language), + $name); return false; } } @@ -326,4 +371,44 @@ class GeonamesPlugin extends Plugin // it's been filled, so don't process further. return false; } + + function getCache($attrs) + { + $c = common_memcache(); + + if (!$c) { + return null; + } + + return $c->get($this->cacheKey($attrs)); + } + + function setCache($attrs, $loc) + { + $c = common_memcache(); + + if (!$c) { + return null; + } + + $c->set($this->cacheKey($attrs), $loc); + } + + function clearCache($attrs) + { + $c = common_memcache(); + + if (!$c) { + return null; + } + + $c->delete($this->cacheKey($attrs)); + } + + function cacheKey($attrs) + { + return common_cache_key('geonames:'. + implode(',', array_keys($attrs)) . ':'. + common_keyize(implode(',', array_values($attrs)))); + } } -- cgit v1.2.3-54-g00ecf From 953f3a6e4fbc2e14a8aed18012b36200e7903849 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 15:34:48 -0500 Subject: Undo part of c6e4feb815a60a7baf613026c414a24c5c918650 so that blacklisted notices are not displayed in realtime --- plugins/Realtime/RealtimePlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index c5fb6de03..b737e442a 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -139,8 +139,8 @@ class RealtimePlugin extends Plugin // Add to the public timeline - if ($notice->is_local || - ($notice->is_local == 0 && !common_config('public', 'localonly'))) { + if ($notice->is_local == Notice::LOCAL_PUBLIC || + ($notice->is_local == Notice::REMOTE_OMB && !common_config('public', 'localonly'))) { $paths[] = array('public'); } -- cgit v1.2.3-54-g00ecf From 83ba93e945e5b933a73139f9e5db710444c99893 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 17:40:38 -0500 Subject: Change the format of the lat/lon output on a notice in HTML --- lib/noticelist.php | 9 ++++----- plugins/Mapstraction/usermap.js | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'plugins') diff --git a/lib/noticelist.php b/lib/noticelist.php index 5877827ff..167ba994b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -392,15 +392,14 @@ class NoticeListItem extends Widget $name = $location->getName(); - if (empty($name)) { - // XXX: Could be a translation issue. Fall back to... something? - return; - } - $lat = $this->notice->lat; $lon = $this->notice->lon; $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : ''; + if (empty($name)) { + $name = $lat . ' ' . $lon; //TODO tranform to N/S deg/min/sec format + } + $url = $location->getUrl(); $this->out->elementStart('span', array('class' => 'location')); diff --git a/plugins/Mapstraction/usermap.js b/plugins/Mapstraction/usermap.js index 19ec54c39..e667dd579 100644 --- a/plugins/Mapstraction/usermap.js +++ b/plugins/Mapstraction/usermap.js @@ -1,7 +1,7 @@ $(document).ready(function() { - notices = []; + var notices = []; $(".notice").each(function(){ - notice = getNoticeFromElement($(this)); + var notice = getNoticeFromElement($(this)); if(notice['geo']) notices.push(notice); }); @@ -10,8 +10,8 @@ $(document).ready(function() { showMapstraction($("#map_canvas"), notices); } - $('a.geo').click(function(){ - noticeElement = $(this).closest(".notice"); + $('.geo').click(function(){ + var noticeElement = $(this).closest(".notice"); notice = getNoticeFromElement(noticeElement); $.fn.jOverlay.options = { @@ -23,7 +23,7 @@ $(document).ready(function() { autoHide : true, css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'} }; - html="
"; + var html="
"; html+=""; html+=$("
").append($(this).clone()).html(); $().jOverlay({ "html": html }); @@ -47,11 +47,12 @@ function getMicroformatValue(element) function getNoticeFromElement(noticeElement) { - notice = {}; - if(noticeElement.find(".latitude").length){ + var notice = {}; + if(noticeElement.find(".geo").length){ + var latlon = noticeElement.find(".geo").attr('title').split(";"); notice['geo']={'coordinates': [ - parseFloat(getMicroformatValue(noticeElement.find(".latitude"))), - parseFloat(getMicroformatValue(noticeElement.find(".longitude")))] }; + parseFloat(latlon[0]), + parseFloat(latlon[1])] }; } notice['user']={ 'profile_image_url': noticeElement.find("img.avatar").attr('src'), -- cgit v1.2.3-54-g00ecf From 5973192593fde410f338e6de895b2e3f596e8617 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 24 Nov 2009 12:55:08 +0000 Subject: Enable border-top when Realtime pop up window is initialized --- plugins/Realtime/realtimeupdate.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index a2c4da113..4dbc80231 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -287,8 +287,6 @@ RealtimeUpdate = { $('#form_notice label[for=notice_data-text], h1').css({'display': 'none'}); - $('.notices li:first-child').css({'border-top-color':'transparent'}); - $('#form_notice label[for="notice_data-attach"], #form_notice #notice_data-attach').css({'top':'0'}); $('#form_notice #notice_data-attach').css({ -- cgit v1.2.3-54-g00ecf From 9f6b3daaec3a04ec301d13a0536fcdb0c76f1101 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 24 Nov 2009 13:09:17 +0000 Subject: Added realtime-popup class to for popup output. --- plugins/Realtime/RealtimePlugin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index b737e442a..cbfa6bae0 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -220,8 +220,9 @@ class RealtimePlugin extends Plugin $action->elementStart('body', (common_current_user()) ? array('id' => $action->trimmed('action'), - 'class' => 'user_in') - : array('id' => $action->trimmed('action'))); + 'class' => 'user_in realtime-popup') + : array('id' => $action->trimmed('action'), + 'class'=> 'realtime-popup')); // XXX hack to deal with JS that tries to get the // root url from page output -- cgit v1.2.3-54-g00ecf From 84ed094f40d4087704fc3354ea4c3743b1447331 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 24 Nov 2009 13:10:34 +0000 Subject: Moved initPopupWindow CSS out of JS in Realtime plugin --- plugins/Realtime/realtimeupdate.css | 29 +++++++++++++++++++++++++++++ plugins/Realtime/realtimeupdate.js | 18 ------------------ 2 files changed, 29 insertions(+), 18 deletions(-) (limited to 'plugins') diff --git a/plugins/Realtime/realtimeupdate.css b/plugins/Realtime/realtimeupdate.css index 0ab5dd32b..a5728b83d 100644 --- a/plugins/Realtime/realtimeupdate.css +++ b/plugins/Realtime/realtimeupdate.css @@ -1,3 +1,32 @@ +.realtime-popup address { +display:none; +} + +.realtime-popup #content { +width:93.5%; +} + +.realtime-popup #form_notice { +margin:18px 0 18px 1.795%; +width:93%; +max-width:451px; +} + +.realtime-popup #form_notice label[for=notice_data-text], +.realtime-popup h1 { +display:none; +} + +.realtime-popup #form_notice label[for=notice_data-attach], +.realtime-popup #form_notice #notice_data-attach { +top:0; +} + +.realtime-popup #form_notice #notice_data-attach { +left:auto; +right:0; +} + #notices_primary { position:relative; } diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 4dbc80231..b3c41456e 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -276,24 +276,6 @@ RealtimeUpdate = { initPopupWindow: function() { - $('address').hide(); - $('#content').css({'width':'93.5%'}); - - $('#form_notice').css({ - 'margin':'18px 0 18px 1.795%', - 'width':'93%', - 'max-width':'451px' - }); - - $('#form_notice label[for=notice_data-text], h1').css({'display': 'none'}); - - $('#form_notice label[for="notice_data-attach"], #form_notice #notice_data-attach').css({'top':'0'}); - - $('#form_notice #notice_data-attach').css({ - 'left':'auto', - 'right':'0' - }); - $('.notices .entry-title a, .notices .entry-content a').bind('click', function() { window.open(this.href, ''); -- cgit v1.2.3-54-g00ecf