From d30590de23f2b9a138ec6923016c4e9af6b9a989 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 24 Feb 2009 04:31:31 +0000 Subject: [PATCH 01/25] Print stylesheet --- lib/action.php | 4 ++++ theme/base/css/print.css | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 theme/base/css/print.css diff --git a/lib/action.php b/lib/action.php index 455ebeff0b..dd7dd44e7f 100644 --- a/lib/action.php +++ b/lib/action.php @@ -173,6 +173,10 @@ class Action extends HTMLOutputter // lawsuit // TODO: "handheld" CSS for other mobile devices 'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit } + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => theme_path('css/print.css', 'base') . '?version=' . LACONICA_VERSION, + 'media' => 'print')); Event::handle('EndShowLaconicaStyles', array($this)); } if (Event::handle('StartShowUAStyles', array($this))) { diff --git a/theme/base/css/print.css b/theme/base/css/print.css new file mode 100644 index 0000000000..cf3ac0391c --- /dev/null +++ b/theme/base/css/print.css @@ -0,0 +1,28 @@ +body { font-size:12pt; } +a:after { background-color:#fff; } +a:not([href^="#"]):after { content:" ( "attr(href)" ) "; } +a:not([href^="http:"]):after { content: " ( http://identi.ca/"attr(href)" ) "; } +a[href^="/"]:after { content: " ( http://identi.ca" attr(href) " ) "; } + +img { border:none; } +p { orphans: 2; widows: 1; } + +#site_nav_global_primary, +#site_nav_local_views, +#form_notice, +.pagination, +#site_nav_global_secondary, +.entity_actions, +.notice-options, +#aside_primary { +display:none; +} + +.timestamp dt, .timestamp dd, +.device dt, .device dd { +display:inline; +} + +.notices li { +margin-bottom:18px; +} From 240ea969214fe3d18c96d0f9ba1d2b5af63aa54d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 24 Feb 2009 05:09:23 +0000 Subject: [PATCH 02/25] Print stylesheet - Added license and cleanup --- theme/base/css/print.css | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/theme/base/css/print.css b/theme/base/css/print.css index cf3ac0391c..2da3e5e444 100644 --- a/theme/base/css/print.css +++ b/theme/base/css/print.css @@ -1,8 +1,14 @@ -body { font-size:12pt; } +/** theme: base + * + * @package Laconica + * @author Sarven Capadisli + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + a:after { background-color:#fff; } a:not([href^="#"]):after { content:" ( "attr(href)" ) "; } -a:not([href^="http:"]):after { content: " ( http://identi.ca/"attr(href)" ) "; } -a[href^="/"]:after { content: " ( http://identi.ca" attr(href) " ) "; } img { border:none; } p { orphans: 2; widows: 1; } @@ -14,7 +20,8 @@ p { orphans: 2; widows: 1; } #site_nav_global_secondary, .entity_actions, .notice-options, -#aside_primary { +#aside_primary, +.form_subcription_edit .submit { display:none; } @@ -23,6 +30,7 @@ display:none; display:inline; } +.profiles li, .notices li { margin-bottom:18px; } From 7af6f5392be2b847c4c026f2632fc1c900338b81 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 26 Feb 2009 19:56:31 +0000 Subject: [PATCH 03/25] Hook for setting document content type, charset, language, DOCTYPE and html element properties --- EVENTS.txt | 6 ++++++ lib/action.php | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/EVENTS.txt b/EVENTS.txt index 37e2203d50..ed461ee9fe 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -88,3 +88,9 @@ StartShowLocalNavBlock: Showing the local nav menu EndShowLocalNavBlock: At the end of the local nav menu - $action: the current action +StartShowHTML: Chance to set document content type, charset, language, DOCTYPE and html element properties +- $action: the current action + +EndShowHTML: Showing after the html element +- $action: the current action + diff --git a/lib/action.php b/lib/action.php index dd7dd44e7f..9c71a153dd 100644 --- a/lib/action.php +++ b/lib/action.php @@ -93,7 +93,10 @@ class Action extends HTMLOutputter // lawsuit */ function showPage() { - $this->startHTML(); + if (Event::handle('StartShowHTML', array($this))) { + $this->startHTML(); + Event::handle('EndShowHTML', array($this)); + } $this->showHead(); $this->showBody(); $this->endHTML(); From 42eecfabca67e5caee1f4e5894b711cacd0a9f9d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 18:51:56 +0100 Subject: [PATCH 04/25] Adds some missing routes. --- lib/router.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/router.php b/lib/router.php index b18a5523e9..b142022f0a 100644 --- a/lib/router.php +++ b/lib/router.php @@ -117,6 +117,11 @@ class Router $m->connect('main/openid', array('action' => 'openidlogin')); $m->connect('main/remote', array('action' => 'remotesubscribe')); + foreach (array('requesttoken', 'accesstoken', 'userauthorization', + 'postnotice', 'updateprofile') as $action) { + $m->connect('index.php?action=' . $action, array('action' => $action)); + } + // settings foreach (array('profile', 'avatar', 'password', 'openid', 'im', @@ -411,4 +416,4 @@ class Router return $this->m->generate($args, $params, $fragment); } -} \ No newline at end of file +} From 89197210cf706683c8ab22deedc43724fa1fe235 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 19:04:27 +0100 Subject: [PATCH 05/25] Fixes #1067: Avatar stretched on authorize remote subscription page. The img tag used a wrong class which had a width: 100% applied. --- actions/userauthorization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/userauthorization.php b/actions/userauthorization.php index ed17ceec97..0dc1841d4f 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -105,7 +105,7 @@ class UserauthorizationAction extends Action $this->elementStart('div', 'profile'); if ($avatar) { $this->element('img', array('src' => $avatar, - 'class' => 'avatar profile', + 'class' => 'avatar', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $nickname)); From 616fd16bc528ce78d7fc1fa8a6ad5a67f10ae5eb Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 19:43:18 +0100 Subject: [PATCH 06/25] Auth_Yadis_Yadis::PlainHTTPFetcher expects plain arrays, not hashes. --- actions/finishremotesubscribe.php | 2 +- actions/remotesubscribe.php | 3 +-- lib/omb.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index 76db887deb..acfacbdc1c 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -283,7 +283,7 @@ class FinishremotesubscribeAction extends Action $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('got result: "'.print_r($result,true).'"', __FILE__); diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index f727a63b82..7ea7acd6d3 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -321,8 +321,7 @@ class RemotesubscribeAction extends Action $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); - + array('User-Agent: Laconica/' . LACONICA_VERSION)); if ($result->status != 200) { return null; } diff --git a/lib/omb.php b/lib/omb.php index 29e14c75f7..befcf4666a 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -206,7 +206,7 @@ function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); @@ -291,7 +291,7 @@ function omb_update_profile($profile, $remote_profile, $subscription) common_debug('postdata = '.$req->to_postdata(), __FILE__); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); From d4b6e7266ad80add5ff29c947cfad4bd5dbd3c8a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 22:41:24 +0100 Subject: [PATCH 07/25] Correctly handle avatars at updateProfile --- actions/updateprofile.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 898c535432..4751a04ff3 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -162,7 +162,13 @@ class UpdateprofileAction extends Action if ($avatar) { $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar'); copy($avatar, $temp_filename); - if (!$profile->setOriginal($temp_filename)) { + $imagefile = new ImageFile($profile->id, $temp_filename); + $filename = Avatar::filename($profile->id, + image_type_to_extension($imagefile->type), + null, + common_timestamp()); + rename($temp_filename, Avatar::path($filename)); + if (!$profile->setOriginal($filename)) { $this->serverError(_('Could not save avatar info'), 500); return false; } From c87349350d0422157575f93ab4dd9abc108cc8d8 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 22:48:30 +0100 Subject: [PATCH 08/25] Add finishremotesubscribe to the unrouted actions list. --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/router.php b/lib/router.php index b142022f0a..e5b8e7d236 100644 --- a/lib/router.php +++ b/lib/router.php @@ -118,7 +118,7 @@ class Router $m->connect('main/remote', array('action' => 'remotesubscribe')); foreach (array('requesttoken', 'accesstoken', 'userauthorization', - 'postnotice', 'updateprofile') as $action) { + 'postnotice', 'updateprofile', 'finishremotesubscribe') as $action) { $m->connect('index.php?action=' . $action, array('action' => $action)); } From a90a8da5c3c445b11e1e2bf0d0530eb48fa146c0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 22:50:59 +0100 Subject: [PATCH 09/25] Broadcast profile via OMB after avatar change. --- actions/avatarsettings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index f38a44a24a..6545d94893 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -324,13 +324,12 @@ class AvatarsettingsAction extends AccountSettingsAction return; } - // If image is not being cropped assume pos & dimentions of original + // If image is not being cropped assume pos & dimensions of original. $dest_x = $this->arg('avatar_crop_x') ? $this->arg('avatar_crop_x'):0; $dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y'):0; $dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w'):$filedata['width']; $dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h'):$filedata['height']; - $size = min($dest_w, $dest_h); - $size = ($size > MAX_ORIGINAL) ? MAX_ORIGINAL:$size; + $size = min($dest_w, $dest_h, MAX_ORIGINAL); $user = common_current_user(); $profile = $user->getProfile(); @@ -343,6 +342,7 @@ class AvatarsettingsAction extends AccountSettingsAction unset($_SESSION['FILEDATA']); $this->mode = 'upload'; $this->showForm(_('Avatar updated.'), true); + common_broadcast_profile($profile); } else { $this->showForm(_('Failed updating avatar.')); } From fa82722e5abd2e1cbf75050aea594f65a384d8d7 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 13:31:50 +0100 Subject: [PATCH 10/25] More routes. --- lib/router.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/router.php b/lib/router.php index e5b8e7d236..f70b67f383 100644 --- a/lib/router.php +++ b/lib/router.php @@ -133,6 +133,7 @@ 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/notice/rss', array('action' => 'noticesearchrss')); @@ -140,6 +141,9 @@ class Router // notice $m->connect('notice/new', array('action' => 'newnotice')); + $m->connect('notice/new?replyto=:replyto', + array('action' => 'newnotice'), + array('replyto' => '[A-Za-z0-9_-]+')); $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); From 210647a56c0ee917ec5bb7d4753ad2603d28d7c4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 13:32:14 +0100 Subject: [PATCH 11/25] Fix replyto parameter in newnotice --- actions/newnotice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/newnotice.php b/actions/newnotice.php index 9face96443..9f44d25165 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -253,7 +253,7 @@ class NewnoticeAction extends Action } } - $notice_form = new NoticeForm($this, $content); + $notice_form = new NoticeForm($this, '', $content); $notice_form->show(); } From d005b370712943eed3edae2ff82d38dfa3d42a92 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 13:38:16 +0100 Subject: [PATCH 12/25] Fixes #1241: in-reply-to links were broken due to copy and paste error (Variable name was wrong). --- actions/noticesearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index dc58d7528a..0bbaa02560 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -201,7 +201,7 @@ class NoticesearchAction extends SearchAction if ($notice->reply_to) { $replyurl = common_local_url('shownotice', - array('notice' => $this->notice->reply_to)); + array('notice' => $notice->reply_to)); $this->elementStart('dl', 'response'); $this->element('dt', null, _('To')); $this->elementStart('dd'); From bdb8c12d975846ce128619e672b8064b8f5f890a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 14:02:17 +0100 Subject: [PATCH 13/25] Completely refactored noticesearch list, now using subclassing for highlighting. Fixes #1240 and probably other bugs. --- actions/noticesearch.php | 152 +++++++++++---------------------------- 1 file changed, 41 insertions(+), 111 deletions(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 0bbaa02560..83e59dd9ae 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -113,123 +113,58 @@ class NoticesearchAction extends SearchAction } else { $cnt = $notice->find(); } - if ($cnt > 0) { - $terms = preg_split('/[\s,]+/', $q); - $this->elementStart('ul', array('class' => 'notices')); - for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) { - if ($notice->fetch()) { - $this->showNotice($notice, $terms); - } else { - // shouldn't happen! - break; - } - } - $this->elementEnd('ul'); - } else { + if ($cnt === 0) { $this->element('p', 'error', _('No results')); - } - - $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'noticesearch', array('q' => $q)); - } - - /** - * Show notice - * - * @param class $notice notice - * @param array $terms terms to highlight - * - * @return void - * - * @todo refactor and combine with StreamAction::showNotice() - */ - function showNotice($notice, $terms) - { - $profile = $notice->getProfile(); - if (!$profile) { - common_log_db_error($notice, 'SELECT', __FILE__); - $this->serverError(_('Notice without matching profile')); return; } - // XXX: RDFa - $this->elementStart('li', array('class' => 'hentry notice', - 'id' => 'notice-' . $notice->id)); + $terms = preg_split('/[\s,]+/', $q); + $nl = new SearchNoticeList($notice, $this, $terms); - $this->elementStart('div', 'entry-title'); - $this->elementStart('span', 'vcard author'); - $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - $this->elementStart('a', array('href' => $profile->profileurl, - 'class' => 'url')); - $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), - 'class' => 'avatar photo', - 'width' => AVATAR_STREAM_SIZE, - 'height' => AVATAR_STREAM_SIZE, - 'alt' => - ($profile->fullname) ? $profile->fullname : - $profile->nickname)); - $this->element('span', 'nickname fn', $profile->nickname); - $this->elementEnd('a'); - $this->elementEnd('span'); + $cnt = $nl->show(); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'noticesearch', array('q' => $q)); + } + function isReadOnly() + { + return true; + } +} + +class SearchNoticeList extends NoticeList { + function __construct($notice, $out=null, $terms) + { + parent::__construct($notice, $out); + $this->terms = $terms; + } + + function newListItem($notice) + { + return new SearchNoticeListItem($notice, $this->out, $this->terms); + } +} + +class SearchNoticeListItem extends NoticeListItem { + function __construct($notice, $out=null, $terms) + { + parent::__construct($notice, $out); + $this->terms = $terms; + } + + function showContent() + { // FIXME: URL, image, video, audio - $this->elementStart('p', array('class' => 'entry-content')); - if ($notice->rendered) { - $this->raw($this->highlight($notice->rendered, $terms)); + $this->out->elementStart('p', array('class' => 'entry-content')); + if ($this->notice->rendered) { + $this->out->raw($this->highlight($this->notice->rendered, $this->terms)); } else { // XXX: may be some uncooked notices in the DB, // we cook them right now. This should probably disappear in future // versions (>> 0.4.x) - $this->raw($this->highlight(common_render_content($notice->content, $notice), $terms)); + $this->out->raw($this->highlight(common_render_content($this->notice->content, $this->notice), $this->terms)); } - $this->elementEnd('p'); - $this->elementEnd('div'); + $this->out->elementEnd('p'); - $noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); - $this->elementStart('div', 'entry-content'); - $this->elementStart('dl', 'timestamp'); - $this->element('dt', null, _('Published')); - $this->elementStart('dd', null); - $this->elementStart('a', array('rel' => 'bookmark', - 'href' => $noticeurl)); - $dt = common_date_iso8601($notice->created); - $this->element('abbr', array('class' => 'published', - 'title' => $dt), - common_date_string($notice->created)); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', - array('notice' => $notice->reply_to)); - $this->elementStart('dl', 'response'); - $this->element('dt', null, _('To')); - $this->elementStart('dd'); - $this->element('a', array('href' => $replyurl, - 'rel' => 'in-reply-to'), - _('in reply to')); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - } - $this->elementEnd('div'); - - $this->elementStart('div', 'notice-options'); - - $reply_url = common_local_url('newnotice', - array('replyto' => $profile->nickname)); - - $this->elementStart('dl', 'notice_reply'); - $this->element('dt', null, _('Reply to this notice')); - $this->elementStart('dd'); - $this->elementStart('a', array('href' => $reply_url, - 'title' => _('Reply to this notice'))); - $this->text(_('Reply')); - $this->element('span', 'notice_id', $notice->id); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementEnd('div'); - $this->elementEnd('li'); } /** @@ -242,7 +177,7 @@ class NoticesearchAction extends SearchAction */ function highlight($text, $terms) { - /* Highligh serach terms */ + /* Highligh search terms */ $pattern = '/('.implode('|', array_map('htmlspecialchars', $terms)).')/i'; $result = preg_replace($pattern, '\\1', $text); @@ -253,10 +188,5 @@ class NoticesearchAction extends SearchAction } while ($count); return $result; } - - function isReadOnly() - { - return true; - } } From 32e0fb148312bb2a052111513ed71fc4948a9fb7 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 14:27:09 +0100 Subject: [PATCH 14/25] Route for remote subscribe link on profile page. --- lib/router.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/router.php b/lib/router.php index f70b67f383..95ce77e5ef 100644 --- a/lib/router.php +++ b/lib/router.php @@ -116,6 +116,7 @@ class Router $m->connect('main/openid', array('action' => 'openidlogin')); $m->connect('main/remote', array('action' => 'remotesubscribe')); + $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+')); foreach (array('requesttoken', 'accesstoken', 'userauthorization', 'postnotice', 'updateprofile', 'finishremotesubscribe') as $action) { From 120eb77400843669980850882dfae83ca7f8e7e7 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 17:45:26 +0100 Subject: [PATCH 15/25] Fixes #1258: A period in a hashtag leads to the tag being interpreted as url and hence breaking the tag. --- lib/util.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util.php b/lib/util.php index 5345a08bba..18e4f310ce 100644 --- a/lib/util.php +++ b/lib/util.php @@ -456,6 +456,9 @@ function common_replace_urls_callback($text, $callback) { if (!in_array($url_parts[2], $tlds)) continue; + // Make sure we didn't capture a hash tag + if (strpos($url, '#') === 0) continue; + // Put the url back the way we found it. $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url); From 3f7d70c5e4c5e91d552cc629a9371109cb859bc3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 25 Feb 2009 01:36:58 +0100 Subject: [PATCH 16/25] Hopefully fixes #1260: Mess with norwegian languages. Moreover corrected ltr/rtl for Italian and Hebrew and added Finnish. --- lib/language.php | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/lib/language.php b/lib/language.php index a73b73f280..79e9030ae4 100644 --- a/lib/language.php +++ b/lib/language.php @@ -94,40 +94,43 @@ function get_nice_language_list() * Get a list of all languages that are enabled in the default config * * This should ONLY be called when setting up the default config in common.php. - * Any other attempt to get a list of lanugages should instead call + * Any other attempt to get a list of languages should instead call * common_config('site','languages') * * @return array mapping of language codes to language info */ function get_all_languages() { return array( - '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'), - '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' => array('q' => 1, 'lang' => 'en', 'name' => 'English', 'direction' => 'ltr'), - 'es' => array('q' => 0.5, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'), - 'fr-fr' => array('q' => 0.2, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'), - 'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'ltr'), - 'it' => array('q' => 0.9, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'rtl'), - 'jp' => array('q' => 0.5, 'lang' => 'ja_JP', 'name' => 'Japanese', 'direction' => 'ltr'), -# 'ko' => array('q' => 0, '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 (bokmal)', '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'), - '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'), - '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'), + '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'), + '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' => 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'), + 'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'rtl'), + 'it' => array('q' => 0.9, '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'), + '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'), + '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'), + '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'), + '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'), ); } From d92beda526f1495d16b54880a40ebb3c7d7e5f2e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 25 Feb 2009 16:59:32 +0100 Subject: [PATCH 17/25] Add route for new message to user. --- lib/router.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/router.php b/lib/router.php index 95ce77e5ef..4b70c01505 100644 --- a/lib/router.php +++ b/lib/router.php @@ -154,6 +154,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/:message', array('action' => 'showmessage'), array('message' => '[0-9]+')); From 0a96edac9cd553cc0d1fa32defb80582699bcdd2 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sat, 28 Feb 2009 23:10:40 +0000 Subject: [PATCH 18/25] Slightly toned down the text-shadow on navigation --- theme/base/css/display.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index be124f4330..c741ed4cba 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -297,7 +297,7 @@ padding:4px 11px; border-width:1px; border-style:solid; border-bottom:0; -text-shadow: 4px 4px 4px #ddd; +text-shadow: 2px 2px 2px #ddd; font-weight:bold; } #site_nav_local_views .nav { From 0369946b6d1b01a3d90fe641521a1ed117219d89 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 15:17:49 -0800 Subject: [PATCH 19/25] fix problem with dupe tags in profile --- classes/Profile_tag.php | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index cb60cbaec9..0a1ad9cd6b 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_tag extends Memcached_DataObject +class Profile_tag extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -23,45 +23,46 @@ class Profile_tag extends Memcached_DataObject ###END_AUTOCODE static function getTags($tagger, $tagged) { - + $tags = array(); # XXX: store this in memcached - + $profile_tag = new Profile_tag(); $profile_tag->tagger = $tagger; $profile_tag->tagged = $tagged; - + $profile_tag->find(); - + while ($profile_tag->fetch()) { $tags[] = $profile_tag->tag; } - + $profile_tag->free(); - + return $tags; } - + static function setTags($tagger, $tagged, $newtags) { - + + $newtags = array_unique($newtags); $oldtags = Profile_tag::getTags($tagger, $tagged); - + # Delete stuff that's old that not in new - + $to_delete = array_diff($oldtags, $newtags); - + # Insert stuff that's in new and not in old - + $to_insert = array_diff($newtags, $oldtags); - + $profile_tag = new Profile_tag(); - + $profile_tag->tagger = $tagger; $profile_tag->tagged = $tagged; - + $profile_tag->query('BEGIN'); - + foreach ($to_delete as $deltag) { $profile_tag->tag = $deltag; $result = $profile_tag->delete(); @@ -70,7 +71,7 @@ class Profile_tag extends Memcached_DataObject return false; } } - + foreach ($to_insert as $instag) { $profile_tag->tag = $instag; $result = $profile_tag->insert(); @@ -79,12 +80,12 @@ class Profile_tag extends Memcached_DataObject return false; } } - + $profile_tag->query('COMMIT'); - + return true; } - + # Return profiles with a given tag static function getTagged($tagger, $tag) { $profile = new Profile(); From f0d3ba2bc2b9a4391a89e343e9dea2622d7d9972 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 17:42:12 -0800 Subject: [PATCH 20/25] Add a flag for if there's no config file --- lib/common.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/common.php b/lib/common.php index 4fc749ca06..2298c5f88f 100644 --- a/lib/common.php +++ b/lib/common.php @@ -178,9 +178,12 @@ if (strlen($_path) > 0) { $_config_files[] = INSTALLDIR.'/config.php'; +$_have_a_config = false; + foreach ($_config_files as $_config_file) { if (file_exists($_config_file)) { include_once($_config_file); + $_have_a_config = true; } } From c77bb62f2d0a958e074ad0d9b1334d533cb33121 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 17:42:27 -0800 Subject: [PATCH 21/25] show a form for installation --- install.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 install.php diff --git a/install.php b/install.php new file mode 100644 index 0000000000..5ee6b10b3e --- /dev/null +++ b/install.php @@ -0,0 +1,68 @@ + +

Enter your database connection information below to initialize the database.

+
+
+
    +
  • + + +

    The name of your site

    +
  • +
  • +
  • + + +

    Database hostname

    +
  • +
  • +
  • + + +

    Database username

    +
  • +
  • + + +

    Database password

    +
  • +
+ +
+
+ + + + Install Laconica + + + + + +
+
+
+

Install Laconica

+ +
+
+
+ + \ No newline at end of file From b70218dc437c5decc8b27a2bb70e2e1b6ec6e9e3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 20:32:31 -0800 Subject: [PATCH 22/25] automatically handle non-laconica-named databases --- lib/common.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/common.php b/lib/common.php index 2298c5f88f..0fff3af2ea 100644 --- a/lib/common.php +++ b/lib/common.php @@ -187,6 +187,16 @@ foreach ($_config_files as $_config_file) { } } +// XXX: Throw a conniption if database not installed + +// Fixup for laconica.ini + +$_db_name = substr($config['db']['database'], strrpos($config['db']['database'], '/') + 1); + +if ($_db_name != 'laconica' && !array_key_exists('ini_'.$_db_name, $config['db'])) { + $config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/laconica.ini'; +} + // XXX: how many of these could be auto-loaded on use? require_once('Validate.php'); From 1d610d3c6f9bb15a5cea93758ddd8d0ce64099f6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 20:32:53 -0800 Subject: [PATCH 23/25] don't use semicolons in comments --- db/laconica.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/laconica.sql b/db/laconica.sql index dd93a727b7..c2cd887dee 100644 --- a/db/laconica.sql +++ b/db/laconica.sql @@ -171,7 +171,7 @@ create table token ( tok char(32) not null comment 'identifying value', secret char(32) not null comment 'secret value', type tinyint not null default 0 comment 'request or access', - state tinyint default 0 comment 'for requests; 0 = initial, 1 = authorized, 2 = used', + state tinyint default 0 comment 'for requests, 0 = initial, 1 = authorized, 2 = used', created datetime not null comment 'date this record was created', modified timestamp comment 'date this record was modified', @@ -344,7 +344,7 @@ create table notice_inbox ( user_id integer not null comment 'user receiving the message' references user (id), notice_id integer not null comment 'notice received' references notice (id), created datetime not null comment 'date the notice was created', - source tinyint default 1 comment 'reason it is in the inbox; 1=subscription', + source tinyint default 1 comment 'reason it is in the inbox, 1=subscription', constraint primary key (user_id, notice_id), index notice_inbox_notice_id_idx (notice_id) From 2ad667f704300dcb825a4822d567cbc8ebfebe02 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 20:33:22 -0800 Subject: [PATCH 24/25] first pass at a working install.php --- install.php | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 5ee6b10b3e..a34214c48a 100644 --- a/install.php +++ b/install.php @@ -1,6 +1,9 @@

Enter your database connection information below to initialize the database.

-
+
  • @@ -22,11 +29,15 @@ function showForm()
  • - +

    Database hostname

  • + + +

    Database name

    +
  • @@ -44,9 +55,90 @@ function showForm() +
  • + +
  • + +
      + +
    + From 458c03786735bd3e3b6619b2d20538bd55acd0c6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 28 Feb 2009 21:01:33 -0800 Subject: [PATCH 25/25] check some prereqs for installation --- install.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index a34214c48a..18fc362b62 100644 --- a/install.php +++ b/install.php @@ -3,7 +3,11 @@ define('INSTALLDIR', dirname(__FILE__)); function main() { - checkPrereqs(); + if (!checkPrereqs()) + { + return; + } + if ($_SERVER['REQUEST_METHOD'] == 'POST') { handlePost(); } else { @@ -13,6 +17,55 @@ function main() function checkPrereqs() { + if (file_exists(INSTALLDIR.'/config.php')) { + ?>

    Config file "config.php" already exists.

    +

    Require PHP version 5 or greater.

    Cannot load required extension "".

    Cannot write config file to "".

    +

    On your server, try this command:

    +
    chmod a+w
    +

    Cannot write avatar directory "/avatar/".

    +

    On your server, try this command:

    +
    chmod a+w /avatar/
    +