From 75f2095a0009b3a3414ec6063e24256b83fd7030 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 12 Mar 2009 12:39:57 -0400 Subject: update q-factors for new translations --- lib/language.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/language.php b/lib/language.php index 79e9030ae..6791df699 100644 --- a/lib/language.php +++ b/lib/language.php @@ -104,33 +104,33 @@ function get_all_languages() { 'bg' => array('q' => 0.8, 'lang' => 'bg_BG', 'name' => 'Bulgarian', 'direction' => 'ltr'), 'ca' => array('q' => 0.5, 'lang' => 'ca_ES', 'name' => 'Catalan', 'direction' => 'ltr'), 'cs' => array('q' => 0.5, 'lang' => 'cs_CZ', 'name' => 'Czech', 'direction' => 'ltr'), - 'de' => array('q' => 0.5, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'), + 'de' => array('q' => 0.8, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'), 'el' => array('q' => 0.1, 'lang' => 'el', 'name' => 'Greek', 'direction' => 'ltr'), 'en-us' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'), - 'en-gb' => array('q' => 0.3, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'), + 'en-gb' => array('q' => 1, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'), 'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English', 'direction' => 'ltr'), - 'es' => array('q' => 0.5, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'), - 'fi' => array('q' => 0.5, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'), - 'fr-fr' => array('q' => 0.2, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'), + 'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'), + 'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'), + 'fr-fr' => array('q' => 1, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'), 'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'rtl'), - 'it' => array('q' => 0.9, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'), + 'it' => array('q' => 1, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'), 'jp' => array('q' => 0.5, 'lang' => 'ja_JP', 'name' => 'Japanese', 'direction' => 'ltr'), -# 'ko' => array('q' => 0, 'lang' => 'ko', 'name' => 'Korean', 'direction' => 'ltr'), + 'ko' => array('q' => 0.9, 'lang' => 'ko', 'name' => 'Korean', 'direction' => 'ltr'), 'mk' => array('q' => 0.5, 'lang' => 'mk_MK', 'name' => 'Macedonian', 'direction' => 'ltr'), 'nb' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'), 'no' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'), - 'nn' => array('q' => 0.1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'), + 'nn' => array('q' => 1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'), 'nl' => array('q' => 0.5, 'lang' => 'nl_NL', 'name' => 'Dutch', 'direction' => 'ltr'), 'pl' => array('q' => 0.5, 'lang' => 'pl_PL', 'name' => 'Polish', 'direction' => 'ltr'), -# 'pt' => array('q' => 0, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'), - 'pt-br' => array('q' => 0.7, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'), - 'ru' => array('q' => 0.1, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'), - 'sv' => array('q' => 0.9, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'), + 'pt' => array('q' => 0.1, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'), + 'pt-br' => array('q' => 0.9, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'), + 'ru' => array('q' => 0.9, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'), + 'sv' => array('q' => 0.8, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'), 'te' => array('q' => 0.3, 'lang' => 'te_IN', 'name' => 'Telugu', 'direction' => 'ltr'), 'tr' => array('q' => 0.5, 'lang' => 'tr_TR', 'name' => 'Turkish', 'direction' => 'ltr'), - 'uk' => array('q' => 0.7, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'), - 'vi' => array('q' => 0.7, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'), + 'uk' => array('q' => 1, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'), + 'vi' => array('q' => 0.8, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'), 'zh-cn' => array('q' => 0.9, 'lang' => 'zh_CN', 'name' => 'Chinese (Simplified)', 'direction' => 'ltr'), - 'zh-hant' => array('q' => 0.2, 'lang' => 'zh_hant', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'), + 'zh-hant' => array('q' => 0.2, 'lang' => 'zh_TW', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'), ); } -- cgit v1.2.3-54-g00ecf From 0b436ec99747d9f8bc5962798993d166a42123a9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 12 Mar 2009 12:45:03 -0400 Subject: update version number to 0.7.2.1 --- README | 12 ++++++------ lib/common.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/README b/README index a7798a26a..71760ce4f 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ README ------ -Laconica 0.7.2 ("Talk about the Passion") +Laconica 0.7.2.1 ("Talk about the Passion") 11 March 2009 This is the README file for Laconica, the Open Source microblogging @@ -257,9 +257,9 @@ especially if you've previously installed PHP/MySQL packages. 1. Unpack the tarball you downloaded on your Web server. Usually a command like this will work: - tar zxf laconica-0.7.1.tar.gz + tar zxf laconica-0.7.2.1.tar.gz - ...which will make a laconica-0.7.1 subdirectory in your current + ...which will make a laconica-0.7.2.1 subdirectory in your current directory. (If you don't have shell access on your Web server, you may have to unpack the tarball on your local computer and FTP the files to the server.) @@ -267,7 +267,7 @@ especially if you've previously installed PHP/MySQL packages. 2. Move the tarball to a directory of your choosing in your Web root directory. Usually something like this will work: - mv laconica-0.7.1 /var/www/mublog + mv laconica-0.7.2.1 /var/www/mublog This will make your Laconica instance available in the mublog path of your server, like "http://example.net/mublog". "microblog" or @@ -757,7 +757,7 @@ Upgrading If you've been using Laconica 0.6, 0.5 or lower, or if you've been tracking the "git" version of the software, you will probably want to upgrade and keep your existing data. There is no automated upgrade -procedure in Laconica 0.7.1. Try these step-by-step instructions; read +procedure in Laconica 0.7.2.1. Try these step-by-step instructions; read to the end first before trying them. 0. Download Laconica and set up all the prerequisites as if you were @@ -1181,7 +1181,7 @@ repository (see below), and you get a compilation error ("unexpected T_STRING") in the browser, check to see that you don't have any conflicts in your code. -If you upgraded to Laconica 0.7.1 without reading the "Notice inboxes" +If you upgraded to Laconica 0.7.2.1 without reading the "Notice inboxes" section above, and all your users' 'Personal' tabs are empty, read the "Notice inboxes" section above. diff --git a/lib/common.php b/lib/common.php index 44ed270d7..1ca9e521b 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -define('LACONICA_VERSION', '0.7.2'); +define('LACONICA_VERSION', '0.7.2.1'); define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_STREAM_SIZE', 48); -- cgit v1.2.3-54-g00ecf From 40073120b9575dc08db16a5005ba6beb408290e2 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 13 Mar 2009 22:06:02 +0100 Subject: Fix typo in the the newmessage route. --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index 50d5a4ee1..e39dc217a 100644 --- a/lib/router.php +++ b/lib/router.php @@ -156,7 +156,7 @@ class Router array('notice' => '[0-9]+')); $m->connect('message/new', array('action' => 'newmessage')); - $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]')); + $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+')); $m->connect('message/:message', array('action' => 'showmessage'), array('message' => '[0-9]+')); -- cgit v1.2.3-54-g00ecf From 221c61a49939dac779f68e4584dd9655b3e7201e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 13 Mar 2009 22:06:02 +0100 Subject: Fix typo in the the newmessage route. --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index 50d5a4ee1..e39dc217a 100644 --- a/lib/router.php +++ b/lib/router.php @@ -156,7 +156,7 @@ class Router array('notice' => '[0-9]+')); $m->connect('message/new', array('action' => 'newmessage')); - $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]')); + $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+')); $m->connect('message/:message', array('action' => 'showmessage'), array('message' => '[0-9]+')); -- cgit v1.2.3-54-g00ecf From 85d61475aab64a08ba67cdedfcb795af4ce4850d Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Mon, 16 Mar 2009 17:42:24 -0400 Subject: Output code to explicitly reference favicons. This makes favicons work when Laconica is not installed at a web server's DOCUMENT_ROOT. I've also added the capability to override the Laconica default favicon.ico file with a theme-specific one simply by dropping a themed favicon.ico in the appropriate theme directory. --- lib/action.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 975c2bfcb..285eae59a 100644 --- a/lib/action.php +++ b/lib/action.php @@ -112,6 +112,7 @@ class Action extends HTMLOutputter // lawsuit // XXX: attributes (profile?) $this->elementStart('head'); $this->showTitle(); + $this->showShortcutIcon(); $this->showStylesheets(); $this->showScripts(); $this->showOpenSearch(); @@ -147,6 +148,22 @@ class Action extends HTMLOutputter // lawsuit return _("Untitled page"); } + /** + * Show themed shortcut icon + * + * @return nothing + */ + function showShortcutIcon() + { + if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/favicon.ico')) { + $this->element('link', array('rel' => 'shortcut icon', + 'href' => theme_path('favicon.ico'))); + } else { + $this->element('link', array('rel' => 'shortcut icon', + 'href' => common_path('favicon.ico'))); + } + } + /** * Show stylesheets * -- cgit v1.2.3-54-g00ecf From 91b0fb8028b30438401bebafd13119fe360337a3 Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Mon, 16 Mar 2009 18:03:58 -0400 Subject: Add `apple-touch-icon.png` support; favicons for the iPhone OS. --- apple-touch-icon.png | Bin 0 -> 6265 bytes lib/action.php | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 apple-touch-icon.png (limited to 'lib') diff --git a/apple-touch-icon.png b/apple-touch-icon.png new file mode 100644 index 000000000..d129298d4 Binary files /dev/null and b/apple-touch-icon.png differ diff --git a/lib/action.php b/lib/action.php index 285eae59a..f0baa062c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -162,6 +162,16 @@ class Action extends HTMLOutputter // lawsuit $this->element('link', array('rel' => 'shortcut icon', 'href' => common_path('favicon.ico'))); } + + if (common_config('site', 'mobile')) { + if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/apple-touch-icon.png')) { + $this->element('link', array('rel' => 'apple-touch-icon', + 'href' => theme_path('apple-touch-icon.png'))); + } else { + $this->element('link', array('rel' => 'apple-touch-icon', + 'href' => common_path('apple-touch-icon.png'))); + } + } } /** -- cgit v1.2.3-54-g00ecf From f1041a3b4e1f728ddffd8df80a5d5d6f5520fea6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 18 Mar 2009 16:34:41 -0400 Subject: fix bug in profile list owner check --- lib/profilelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/profilelist.php b/lib/profilelist.php index 766189ab4..bd9b51958 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,7 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); - $is_own = !is_null($user) && isset($this->user) && ($user->id === $this->user->id); + $is_own = !is_null($user) && isset($this->owner) && ($user->id === $this->owner->id); $this->out->elementStart('div', 'entity_profile vcard'); -- cgit v1.2.3-54-g00ecf From 0e93b638b5fe5a3f087c25a48dcb1bac032e400d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 18 Mar 2009 16:34:41 -0400 Subject: fix bug in profile list owner check --- lib/profilelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/profilelist.php b/lib/profilelist.php index 766189ab4..bd9b51958 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,7 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); - $is_own = !is_null($user) && isset($this->user) && ($user->id === $this->user->id); + $is_own = !is_null($user) && isset($this->owner) && ($user->id === $this->owner->id); $this->out->elementStart('div', 'entity_profile vcard'); -- cgit v1.2.3-54-g00ecf From e7c57b43073888d18760e2411b207a4ee2cf508b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 19 Mar 2009 09:21:50 -0400 Subject: ping handler returns proper boolean response The ping queue handler wasn't returning a true value -- filling up the queue with ping requests. It now returns a true value. --- lib/ping.php | 77 ++++++++++++++++++++++++++++++++------------ scripts/pingqueuehandler.php | 4 +-- 2 files changed, 58 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/ping.php b/lib/ping.php index 32c0b9806..2cbec2f21 100644 --- a/lib/ping.php +++ b/lib/ping.php @@ -1,7 +1,7 @@ is_local) { - return; + return true; } - + # Array of servers, URL => type $notify = common_config('ping', 'notify'); $profile = $notice->getProfile(); $tags = ping_notice_tags($notice); - + foreach ($notify as $notify_url => $type) { switch ($type) { case 'xmlrpc': case 'extended': $req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, # site name - common_local_url('showstream', + common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), - common_local_url('userrss', + common_local_url('userrss', array('nickname' => $profile->nickname)), $tags)); - - # We re-use this tool's fetcher, since it's pretty good - - $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); - if (!$fetcher) { - common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__); - return false; - } - - $result = $fetcher->post($notify_url, - $req); - + $context = stream_context_create(array('http' => array('method' => "POST", + 'header' => + "Content-Type: text/xml\r\n". + "User-Agent: Laconica/".LACONICA_VERSION."\r\n", + 'content' => $request))); + $file = file_get_contents($notify_url, false, $context); + $response = xmlrpc_decode($file); + if (xmlrpc_is_fault($response)) { + common_log(LOG_WARNING, + "XML-RPC error for ping ($notify_url, $notice->id) ". + "$response[faultString] ($response[faultCode])"); + } else { + common_log(LOG_INFO, + "Ping success for $notify_url $notice->id"); + } + break; + case 'get': - case 'post': + case 'post': + $args = array('name' => $profile->nickname, + 'url' => common_local_url('showstream', + array('nickname' => $profile->nickname)), + 'changesURL' => common_local_url('userrss', + array('nickname' => $profile->nickname))); + + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + + if ($type === 'get') { + $result = $fetcher->get($notify_url . '?' . http_build_query($args), + array('User-Agent: Laconica/'.LACONICA_VERSION)); + } else { + $result = $fetcher->post($notify_url, + http_build_query($args), + array('User-Agent: Laconica/'.LACONICA_VERSION)); + } + if ($result->status != '200') { + common_log(LOG_WARNING, + "Ping error for '$notify_url' ($notice->id): ". + "$result->body"); + } else { + common_log(LOG_INFO, + "Ping success for '$notify_url' ($notice->id): ". + "'$result->body'"); + } + break; + default: common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type); - } + } } + + return true; } - + function ping_notice_tags($notice) { $tag = new Notice_tag(); $tag->notice_id = $notice->id; diff --git a/scripts/pingqueuehandler.php b/scripts/pingqueuehandler.php index 55a266e4a..ada6ecdba 100644 --- a/scripts/pingqueuehandler.php +++ b/scripts/pingqueuehandler.php @@ -34,7 +34,7 @@ require_once(INSTALLDIR . '/lib/queuehandler.php'); set_error_handler('common_error_handler'); class PingQueueHandler extends QueueHandler { - + function transport() { return 'ping'; } @@ -47,7 +47,7 @@ class PingQueueHandler extends QueueHandler { function handle_notice($notice) { return ping_broadcast_notice($notice); } - + function finish() { } } -- cgit v1.2.3-54-g00ecf From 5dc913f58951815fcaa246e675ff7d30ad93f633 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 19 Mar 2009 09:21:50 -0400 Subject: ping handler returns proper boolean response The ping queue handler wasn't returning a true value -- filling up the queue with ping requests. It now returns a true value. --- lib/ping.php | 77 ++++++++++++++++++++++++++++++++------------ scripts/pingqueuehandler.php | 4 +-- 2 files changed, 58 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/ping.php b/lib/ping.php index 32c0b9806..2cbec2f21 100644 --- a/lib/ping.php +++ b/lib/ping.php @@ -1,7 +1,7 @@ is_local) { - return; + return true; } - + # Array of servers, URL => type $notify = common_config('ping', 'notify'); $profile = $notice->getProfile(); $tags = ping_notice_tags($notice); - + foreach ($notify as $notify_url => $type) { switch ($type) { case 'xmlrpc': case 'extended': $req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, # site name - common_local_url('showstream', + common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), - common_local_url('userrss', + common_local_url('userrss', array('nickname' => $profile->nickname)), $tags)); - - # We re-use this tool's fetcher, since it's pretty good - - $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); - if (!$fetcher) { - common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__); - return false; - } - - $result = $fetcher->post($notify_url, - $req); - + $context = stream_context_create(array('http' => array('method' => "POST", + 'header' => + "Content-Type: text/xml\r\n". + "User-Agent: Laconica/".LACONICA_VERSION."\r\n", + 'content' => $request))); + $file = file_get_contents($notify_url, false, $context); + $response = xmlrpc_decode($file); + if (xmlrpc_is_fault($response)) { + common_log(LOG_WARNING, + "XML-RPC error for ping ($notify_url, $notice->id) ". + "$response[faultString] ($response[faultCode])"); + } else { + common_log(LOG_INFO, + "Ping success for $notify_url $notice->id"); + } + break; + case 'get': - case 'post': + case 'post': + $args = array('name' => $profile->nickname, + 'url' => common_local_url('showstream', + array('nickname' => $profile->nickname)), + 'changesURL' => common_local_url('userrss', + array('nickname' => $profile->nickname))); + + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + + if ($type === 'get') { + $result = $fetcher->get($notify_url . '?' . http_build_query($args), + array('User-Agent: Laconica/'.LACONICA_VERSION)); + } else { + $result = $fetcher->post($notify_url, + http_build_query($args), + array('User-Agent: Laconica/'.LACONICA_VERSION)); + } + if ($result->status != '200') { + common_log(LOG_WARNING, + "Ping error for '$notify_url' ($notice->id): ". + "$result->body"); + } else { + common_log(LOG_INFO, + "Ping success for '$notify_url' ($notice->id): ". + "'$result->body'"); + } + break; + default: common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type); - } + } } + + return true; } - + function ping_notice_tags($notice) { $tag = new Notice_tag(); $tag->notice_id = $notice->id; diff --git a/scripts/pingqueuehandler.php b/scripts/pingqueuehandler.php index 55a266e4a..ada6ecdba 100644 --- a/scripts/pingqueuehandler.php +++ b/scripts/pingqueuehandler.php @@ -34,7 +34,7 @@ require_once(INSTALLDIR . '/lib/queuehandler.php'); set_error_handler('common_error_handler'); class PingQueueHandler extends QueueHandler { - + function transport() { return 'ping'; } @@ -47,7 +47,7 @@ class PingQueueHandler extends QueueHandler { function handle_notice($notice) { return ping_broadcast_notice($notice); } - + function finish() { } } -- cgit v1.2.3-54-g00ecf From d1b2a9d7087ecc171f941755b4c3a420cd202842 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 19 Mar 2009 11:01:58 -0400 Subject: Somewhat better behaviour with mixed caps in search Deal somewhat better with mixed caps in people and notice search. --- actions/groupsearch.php | 11 +++-------- actions/noticesearch.php | 2 +- actions/noticesearchrss.php | 3 --- actions/peoplesearch.php | 6 +++--- lib/search_engines.php | 34 +++++++++++++++++++++++++--------- 5 files changed, 32 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/actions/groupsearch.php b/actions/groupsearch.php index 9b0026db9..109a53ce1 100644 --- a/actions/groupsearch.php +++ b/actions/groupsearch.php @@ -1,9 +1,4 @@ terms = array_map('preg_quote', + $this->terms = array_map('preg_quote', array_map('htmlspecialchars', $terms)); $this->pattern = '/('.implode('|',$terms).')/i'; } - + function highlight($text) { return preg_replace($this->pattern, '\\1', htmlspecialchars($text)); diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 83e59dd9a..eb4a072de 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -103,7 +103,7 @@ class NoticesearchAction extends SearchAction function showResults($q, $page) { $notice = new Notice(); - $q = strtolower($q); + $search_engine = $notice->getSearchEngine('identica_notices'); $search_engine->set_sort_mode('chron'); // Ask for an extra to see if there's more. diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index 0f98ed04b..ba5276d06 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -62,9 +62,6 @@ class NoticesearchrssAction extends Rss10Action $notice = new Notice(); - # lcase it for comparison - $q = strtolower($q); - $search_engine = $notice->getSearchEngine('identica_notices'); $search_engine->set_sort_mode('chron'); diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index 14177fcf0..9e515ade1 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -63,13 +63,13 @@ class PeoplesearchAction extends SearchAction $profile = new Profile(); - # lcase it for comparison - $q = strtolower($q); + // lcase it for comparison + // $q = strtolower($q); $search_engine = $profile->getSearchEngine('identica_people'); $search_engine->set_sort_mode('chron'); - # Ask for an extra to see if there's more. + // Ask for an extra to see if there's more. $search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1); if (false === $search_engine->query($q)) { $cnt = 0; diff --git a/lib/search_engines.php b/lib/search_engines.php index 559107910..7b9dbb618 100644 --- a/lib/search_engines.php +++ b/lib/search_engines.php @@ -74,7 +74,7 @@ class SphinxSearch extends SearchEngine { //FIXME without LARGEST_POSSIBLE, the most recent results aren't returned // this probably has a large impact on performance - $LARGEST_POSSIBLE = 1e6; + $LARGEST_POSSIBLE = 1e6; if ($rss) { $this->sphinx->setLimits($offset, $count, $count, $LARGEST_POSSIBLE); @@ -109,12 +109,25 @@ class MySQLSearch extends SearchEngine { function query($q) { - if ('identica_people' === $this->table) - return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' . - 'against (\''.addslashes($q).'\')'); - if ('identica_notices' === $this->table) - return $this->target->whereAdd('MATCH(content) ' . - 'against (\''.addslashes($q).'\')'); + if ('identica_people' === $this->table) { + $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' . + 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)'); + if (strtolower($q) != $q) { + $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' . + 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR'); + } + return true; + } else if ('identica_notices' === $this->table) { + $this->target->whereAdd('MATCH(content) ' . + 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)'); + if (strtolower($q) != $q) { + $this->target->whereAdd('MATCH(content) ' . + 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR'); + } + return true; + } else { + throw new ServerException('Unknown table: ' . $this->table); + } } } @@ -122,10 +135,13 @@ class PGSearch extends SearchEngine { function query($q) { - if ('identica_people' === $this->table) + if ('identica_people' === $this->table) { return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')'); - if ('identica_notices' === $this->table) + } else if ('identica_notices' === $this->table) { return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')'); + } else { + throw new ServerException('Unknown table: ' . $this->table); + } } } -- cgit v1.2.3-54-g00ecf From 94271293ceb1098d559f83e80aa4578cddd8976a Mon Sep 17 00:00:00 2001 From: CiaranG Date: Thu, 19 Mar 2009 21:07:31 +0000 Subject: Remove 'Register' from login group nav when site is closed or inviteonly. See ticket #1335 --- lib/logingroupnav.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php index fd909581f..f23985f3a 100644 --- a/lib/logingroupnav.php +++ b/lib/logingroupnav.php @@ -70,16 +70,16 @@ class LoginGroupNav extends Widget function show() { // action => array('prompt', 'title') - $menu = - array('login' => - array(_('Login'), - _('Login with a username and password')), - 'register' => - array(_('Register'), - _('Sign up for a new account')), - 'openidlogin' => - array(_('OpenID'), - _('Login or register with OpenID'))); + $menu = array(); + + $menu['login'] = array(_('Login'), + _('Login with a username and password')); + if (!(common_config('site','closed') || common_config('site','inviteonly'))) { + $menu['register'] = array(_('Register'), + _('Sign up for a new account')); + } + $menu['openidlogin'] = array(_('OpenID'), + _('Login or register with OpenID')); $action_name = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); -- cgit v1.2.3-54-g00ecf From 8ba43f18cdfad31415bc9e26b2d4be9e9b4465c0 Mon Sep 17 00:00:00 2001 From: CiaranG Date: Sat, 21 Mar 2009 14:16:54 +0000 Subject: Changes to router setup to make notice search RSS feed work --- lib/router.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index e39dc217a..83b3ffe60 100644 --- a/lib/router.php +++ b/lib/router.php @@ -136,10 +136,14 @@ class Router foreach (array('group', 'people', 'notice') as $s) { $m->connect('search/'.$s, array('action' => $s.'search')); - $m->connect('search/'.$s.'?q=:q', array('action' => $s.'search'), array('q' => '.+')); + $m->connect('search/'.$s.'?q=:q', array('action' => $s.'search'),array('q' => '.+')); } + // The second of these is needed to make the link work correctly + // when inserted into the page. The first is needed to match the + // route on the way in. Seems to be another Net_URL_Mapper bug to me. $m->connect('search/notice/rss', array('action' => 'noticesearchrss')); + $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),array('q' => '.+')); // notice @@ -421,6 +425,8 @@ class Router function build($action, $args=null, $params=null, $fragment=null) { + if($params!=null) + common_log(LOG_DEBUG,"build: ".$action." ".print_r($args,true)." ".print_r($params,true)); $action_arg = array('action' => $action); if ($args) { @@ -429,6 +435,8 @@ class Router $args = $action_arg; } + if($params!=null) + common_log(LOG_DEBUG,"generate args:".print_r($args,true)); return $this->m->generate($args, $params, $fragment); } } -- cgit v1.2.3-54-g00ecf From c4072ef7c930b82b74f8e90f6554974b761c686c Mon Sep 17 00:00:00 2001 From: CiaranG Date: Sat, 21 Mar 2009 14:18:38 +0000 Subject: RSS 1.0 actions were reading the stream from the database twice. Inefficient, but more importantly made notice search RSS fail with a DB error due to double search on a DB_DataObject instance --- lib/rssaction.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/rssaction.php b/lib/rssaction.php index 66c2d9e8c..ddba862dc 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -94,11 +94,11 @@ class Rss10Action extends Action function handle($args) { - // Get the list of notices - $this->notices = $this->getNotices(); // Parent handling, including cache check parent::handle($args); - $this->showRss($this->limit); + // Get the list of notices + $this->notices = $this->getNotices($this->limit); + $this->showRss(); } /** @@ -132,15 +132,13 @@ class Rss10Action extends Action return null; } - function showRss($limit=0) + function showRss() { - $notices = $this->getNotices($limit); - $this->initRss(); - $this->showChannel($notices); + $this->showChannel(); $this->showImage(); - foreach ($notices as $n) { + foreach ($this->notices as $n) { $this->showItem($n); } @@ -148,7 +146,7 @@ class Rss10Action extends Action $this->endRss(); } - function showChannel($notices) + function showChannel() { $channel = $this->getChannel(); @@ -167,7 +165,7 @@ class Rss10Action extends Action $this->elementStart('items'); $this->elementStart('rdf:Seq'); - foreach ($notices as $notice) { + foreach ($this->notices as $notice) { $this->element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri)); } -- cgit v1.2.3-54-g00ecf From e947d9fdd1245d5b785df8c709d620e7d0940991 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 22 Mar 2009 15:23:40 -0400 Subject: variable name error --- lib/ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/ping.php b/lib/ping.php index 2cbec2f21..d7472b920 100644 --- a/lib/ping.php +++ b/lib/ping.php @@ -48,7 +48,7 @@ function ping_broadcast_notice($notice) { 'header' => "Content-Type: text/xml\r\n". "User-Agent: Laconica/".LACONICA_VERSION."\r\n", - 'content' => $request))); + 'content' => $req))); $file = file_get_contents($notify_url, false, $context); $response = xmlrpc_decode($file); if (xmlrpc_is_fault($response)) { -- cgit v1.2.3-54-g00ecf From 3ef4f251acbe8ebdfd9d7f1ea43b7344b7332b73 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 22 Mar 2009 16:58:38 -0400 Subject: One function for producing Atom entry for a Notice Took the various places that we create an atom entry for a notice, and jammed them together into one function of the notice class, and then used that function. Also, added Atom threading extension and categories for hashtags. --- classes/Notice.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/jabber.php | 57 ++++++++++----------------------- lib/twitterapi.php | 30 +++++------------ 3 files changed, 118 insertions(+), 63 deletions(-) (limited to 'lib') diff --git a/classes/Notice.php b/classes/Notice.php index 3087e39a7..44a6aeb98 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -799,4 +799,98 @@ class Notice extends Memcached_DataObject } } } + + function asAtomEntry($namespace=false, $source=false) + { + $profile = $this->getProfile(); + + $xs = new XMLStringer(true); + + if ($namespace) { + $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom', + 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0'); + } else { + $attrs = array(); + } + + $xs->elementStart('entry', $attrs); + + if ($source) { + $xs->elementStart('source'); + $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name')); + $xs->element('link', array('href' => $profile->profileurl)); + $user = User::staticGet('id', $profile->id); + if (!empty($user)) { + $atom_feed = common_local_url('api', + array('apiaction' => 'statuses', + 'method' => 'user_timeline', + 'argument' => $profile->nickname.'.atom')); + $xs->element('link', array('rel' => 'self', + 'type' => 'application/atom+xml', + 'href' => $profile->profileurl)); + $xs->element('link', array('rel' => 'license', + 'href' => common_config('license', 'url'))); + } + + $xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE)); + } + + $xs->elementStart('author'); + $xs->element('name', null, $profile->nickname); + $xs->element('uri', null, $profile->profileurl); + $xs->elementEnd('author'); + + if ($source) { + $xs->elementEnd('source'); + } + + $xs->element('title', null, $this->content); + $xs->element('summary', null, $this->content); + + $xs->element('link', array('rel' => 'alternate', + 'href' => $this->bestUrl())); + + $xs->element('id', null, $this->uri); + + $xs->element('published', null, common_date_w3dtf($this->created)); + $xs->element('updated', null, common_date_w3dtf($this->modified)); + + if ($this->reply_to) { + $reply_notice = Notice::staticGet('id', $this->reply_to); + if (!empty($reply_notice)) { + $xs->element('link', array('rel' => 'related', + 'href' => $reply_notice->bestUrl())); + $xs->element('thr:in-reply-to', + array('ref' => $reply_notice->uri, + 'href' => $reply_notice->bestUrl())); + } + } + + $xs->element('content', array('type' => 'html'), $this->rendered); + + $tag = new Notice_tag(); + $tag->notice_id = $this->id; + if ($tag->find()) { + while ($tag->fetch()) { + $xs->element('category', array('term' => $tag->tag)); + } + } + $tag->free(); + + $xs->elementEnd('entry'); + + return $xs->getString(); + } + + function bestUrl() + { + if (!empty($this->url)) { + return $this->url; + } else if (!empty($this->uri) && preg_match('/^https?:/', $this->uri)) { + return $this->uri; + } else { + return common_local_url('shownotice', + array('notice' => $this->id)); + } + } } diff --git a/lib/jabber.php b/lib/jabber.php index 3cd3b0d37..9108d1c47 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -163,50 +163,25 @@ function jabber_send_notice($to, $notice) function jabber_format_entry($profile, $notice) { - // FIXME: notice url might be remote - - $noticeurl = common_local_url('shownotice', - array('notice' => $notice->id)); - - $msg = jabber_format_notice($profile, $notice); - - $self_url = common_local_url('userrss', array('nickname' => $profile->nickname)); - - $entry = "\n\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . " - " . common_config('site', 'name') . "\n"; - $entry .= "\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . "\n"; - $entry .= "" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "\n"; - $entry .= "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "\n"; - $entry .= "". $notice->uri . "\n"; - $entry .= "".common_date_w3dtf($notice->created)."\n"; - $entry .= "".common_date_w3dtf($notice->modified)."\n"; - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', - array('notice' => $notice->reply_to)); - $entry .= "\n"; + $entry = $notice->asAtomEntry(true, true); + + $xs = new XMLStringer(); + $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im')); + $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml')); + $xs->element('a', array('href' => $profile->profileurl), + $profile->nickname); + $xs->text(": "); + if (!empty($notice->rendered)) { + $xs->raw($notice->rendered); + } else { + $xs->raw(common_render_content($notice->content, $notice)); } - $entry .= "\n"; - - $html = "\n\n"; - $html .= "\n"; - $html .= "".$profile->nickname.": "; - $html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice); - $html .= "\n\n"; - $html .= "\n\n"; - - $address = "\n"; - $address .= "
\n"; - $address .= "\n"; + $xs->elementEnd('body'); + $xs->elementEnd('html'); - // FIXME: include a pubsub event, too. + $html = $xs->asString(); - return $html . $entry . $address; + return $html . ' ' . $entry; } /** diff --git a/lib/twitterapi.php b/lib/twitterapi.php index e7239acd5..b8357c688 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -238,21 +238,6 @@ class TwitterapiAction extends Action $this->elementEnd('item'); } - function show_twitter_atom_entry($entry) - { - $this->elementStart('entry'); - $this->element('title', null, $entry['title']); - $this->element('content', array('type' => 'html'), $entry['content']); - $this->element('id', null, $entry['id']); - $this->element('published', null, $entry['published']); - $this->element('updated', null, $entry['updated']); - $this->element('link', array('href' => $entry['link'], 'rel' => 'alternate', 'type' => 'text/html'), null); - $this->elementStart('author'); - $this->element('name', null, $entry['author']); - $this->elementEnd('author'); - $this->elementEnd('entry'); - } - function show_json_objects($objects) { print(json_encode($objects)); @@ -383,7 +368,7 @@ class TwitterapiAction extends Action } if (!is_null($selfuri)) { - $this->element('link', array('href' => $selfuri, + $this->element('link', array('href' => $selfuri, 'rel' => 'self', 'type' => 'application/atom+xml'), null); } @@ -392,13 +377,11 @@ class TwitterapiAction extends Action if (is_array($notice)) { foreach ($notice as $n) { - $entry = $this->twitter_rss_entry_array($n); - $this->show_twitter_atom_entry($entry); + $this->raw($n->asAtomEntry()); } } else { while ($notice->fetch()) { - $entry = $this->twitter_rss_entry_array($notice); - $this->show_twitter_atom_entry($entry); + $this->raw($notice->asAtomEntry()); } } @@ -578,13 +561,16 @@ class TwitterapiAction extends Action function init_twitter_atom() { $this->startXML(); - $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US')); + // FIXME: don't hardcode the language here! + $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', + 'xml:lang' => 'en-US', + 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0')); } function end_twitter_atom() { - $this->endXML(); $this->elementEnd('feed'); + $this->endXML(); } function show_profile($profile, $content_type='xml', $notice=null) -- cgit v1.2.3-54-g00ecf From 14afe2d26874ed30a0ccef5e0acda2c5171afcde Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 23 Mar 2009 15:44:17 -0400 Subject: show subscribe button and block form again --- lib/profilelist.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/profilelist.php b/lib/profilelist.php index bd9b51958..a4cc23555 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -109,7 +109,7 @@ class ProfileList extends Widget $this->out->elementEnd('span'); $this->out->elementEnd('a'); - if ($this->profile->fullname !== '') { + if (!empty($this->profile->fullname)) { $this->out->elementStart('dl', 'entity_fn'); $this->out->element('dt', null, 'Full name'); $this->out->elementStart('dd'); @@ -119,7 +119,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->location !== '') { + if (!empty($this->profile->location)) { $this->out->elementStart('dl', 'entity_location'); $this->out->element('dt', null, _('Location')); $this->out->elementStart('dd', 'label'); @@ -127,7 +127,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->homepage !== '') { + if (!empty($this->profile->homepage)) { $this->out->elementStart('dl', 'entity_url'); $this->out->element('dt', null, _('URL')); $this->out->elementStart('dd'); @@ -138,7 +138,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->bio !== '') { + if (!empty($this->profile->bio)) { $this->out->elementStart('dl', 'entity_note'); $this->out->element('dt', null, _('Note')); $this->out->elementStart('dd', 'note'); @@ -194,11 +194,12 @@ class ProfileList extends Widget $this->out->elementStart('ul'); - if (!$is_own) { - # XXX: special-case for user looking at own - # subscriptions page + // Is this a logged-in user, looking at someone else's + // profile? + + if (!empty($user) && $this->profile->id != $user->id) { $this->out->elementStart('li', 'entity_subscribe'); - if (!is_null($user) && $user->isSubscribed($this->profile)) { + if ($user->isSubscribed($this->profile)) { $usf = new UnsubscribeForm($this->out, $this->profile); $usf->show(); } else { @@ -207,6 +208,9 @@ class ProfileList extends Widget } $this->out->elementEnd('li'); $this->out->elementStart('li', 'entity_block'); + if ($user->id == $this->owner->id) { + $this->showBlockForm(); + } $this->out->elementEnd('li'); } -- cgit v1.2.3-54-g00ecf