From 2c9759c3b329eff455b3998d748292d581635f90 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 16 Jan 2009 20:19:49 +0000 Subject: [PATCH 01/10] trac750 Don't accidentally show login form after user logs in --- actions/facebookhome.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actions/facebookhome.php b/actions/facebookhome.php index f72f08a345..b780b8cc32 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -71,15 +71,16 @@ class FacebookhomeAction extends FacebookAction // XXX: Do some error handling here $this->setDefaults(); - $this->showHome($flink, _('You can now use Identi.ca from Facebook!')); - + return; + } else { $msg = _('Incorrect username or password.'); } } $this->showLoginForm($msg); + } function setDefaults() From 3e18c2f0f8bbab01e16f66254dc9eadc9e1ffd60 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 01:31:39 +0000 Subject: [PATCH 02/10] trac750 Facebook App - generate HTML similar to uiredisign for everything --- actions/facebookhome.php | 10 ++- actions/facebookinvite.php | 8 +- actions/facebooksettings.php | 14 ++-- lib/facebookaction.php | 145 +++++++++++++++++++++++++---------- lib/facebookutil.php | 133 +++++++++++++++++++++++++++++++- 5 files changed, 253 insertions(+), 57 deletions(-) diff --git a/actions/facebookhome.php b/actions/facebookhome.php index b780b8cc32..46f886451c 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebookhomeAction extends FacebookAction { @@ -35,6 +35,8 @@ class FacebookhomeAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); if ($flink) { + $user = $flink->getUser(); + common_set_user($user); $this->showHome($flink, null); } else { $this->login($fbuid); @@ -103,7 +105,7 @@ class FacebookhomeAction extends FacebookAction update_profile_box($facebook, $fbuid, $user, $notice); - $this->show_header('Home'); + $this->showHeader('Home'); if ($msg) { common_element('fb:success', array('message' => $msg)); @@ -111,7 +113,7 @@ class FacebookhomeAction extends FacebookAction echo $this->show_notices($user); - $this->show_footer(); + $this->showFooter(); } function show_notices($user) @@ -132,7 +134,7 @@ class FacebookhomeAction extends FacebookAction function show_notice_list($notice) { - $nl = new NoticeList($notice); + $nl = new FacebookNoticeList($notice); return $nl->show(); } diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php index fe0c5e4934..d7e82dae7b 100644 --- a/actions/facebookinvite.php +++ b/actions/facebookinvite.php @@ -41,7 +41,7 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->show_header('Invite'); + $this->showHeader('Invite'); common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!')); common_element('p', null, _('Invitations have been sent to the following users:')); @@ -60,7 +60,7 @@ class FacebookinviteAction extends FacebookAction common_element_end("ul"); - $this->show_footer(); + $this->showFooter(); } function showInviteForm() @@ -69,7 +69,7 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->show_header('Invite'); + $this->showHeader('Invite'); // Get a list of users who are already using the app for exclusion $exclude_ids = $facebook->api_client->friends_getAppUsers(); @@ -104,7 +104,7 @@ class FacebookinviteAction extends FacebookAction common_element_end("ul"); - $this->show_footer(); + $this->showFooter(); } diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index ab04ad82b5..eafd911236 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebooksettingsAction extends FacebookAction { @@ -29,13 +29,13 @@ class FacebooksettingsAction extends FacebookAction parent::handle($args); if ($this->arg('save')) { - $this->save_settings(); + $this->saveSettings(); } else { - $this->show_form(); + $this->showForm(); } } - function save_settings() { + function saveSettings() { $noticesync = $this->arg('noticesync'); $replysync = $this->arg('replysync'); @@ -59,14 +59,14 @@ class FacebooksettingsAction extends FacebookAction } } - function show_form($msg = null, $success = false) { + function showForm($msg = null, $success = false) { $facebook = get_facebook(); $fbuid = $facebook->require_login(); $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - $this->show_header('Settings', $msg, $success); + $this->showHeader('Settings', $msg, $success); common_element_start('fb:if-section-not-added', array('section' => 'profile')); common_element('h2', null, _('Add an Identi.ca box to my profile')); @@ -108,7 +108,7 @@ class FacebooksettingsAction extends FacebookAction } - $this->show_footer(); + $this->showFooter(); } } diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 3a00c71dd0..1bf026281e 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -17,9 +17,11 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/facebookutil.php'); +require_once INSTALLDIR.'/lib/facebookutil.php'; class FacebookAction extends Action { @@ -29,32 +31,67 @@ class FacebookAction extends Action parent::handle($args); } - function show_header($selected = 'Home', $msg = null, $success = false) + function showLogo(){ + + global $xw; + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => get_facebook_css())); + + common_element_start('a', array('class' => 'url home bookmark', + 'href' => common_local_url('public'))); + if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { + common_element('img', array('class' => 'logo photo', + 'src' => (common_config('site', 'logo')) ? + common_config('site', 'logo') : theme_path('logo.png'), + 'alt' => common_config('site', 'name'))); + } + + common_element('span', array('class' => 'fn org'), common_config('site', 'name')); + common_element_end('a'); + + } + + function showHeader($selected = 'Home', $msg = null, $success = false) { start_fbml(); - # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $this->showLogo(); - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $cssurl)); + common_element_start('dl', array("id" => 'site_nav_local_views')); + common_element('dt', null, _('Local Views')); + common_element_start('dd'); - common_element('fb:dashboard'); + common_element_start('ul', array('class' => 'nav')); - common_element_start('fb:tabs'); - common_element('fb:tab-item', array('title' => 'Home', - 'href' => 'index.php', - 'selected' => ($selected == 'Home'))); - common_element('fb:tab-item', array('title' => 'Invite', - 'href' => 'invite.php', - 'selected' => ($selected == 'Invite'))); - common_element('fb:tab-item', array('title' => 'Settings', - 'href' => 'settings.php', - 'selected' => ($selected == 'Settings'))); - common_element_end('fb:tabs'); + common_element_start('li', array('class' => + ($selected == 'Home') ? 'current' : 'facebook_home')); + common_element('a', + array('href' => 'index.php', 'title' => _('Home')), _('Home')); + common_element_end('li'); + + + common_element_start('li', + array('class' => + ($selected == 'Invite') ? 'current' : 'facebook_invite')); + common_element('a', + array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); + common_element_end('li'); + + common_element_start('li', + array('class' => + ($selected == 'Settings') ? 'current' : 'facebook_settings')); + common_element('a', + array('href' => 'settings.php', + 'title' => _('Settings')), _('Settings')); + common_element_end('li'); + + common_element_end('ul'); + + common_element_end('dd'); + common_element_end('dl'); if ($msg) { @@ -69,44 +106,73 @@ class FacebookAction extends Action } - function show_footer() + function showFooter() { common_element_end('div'); common_end_xml(); } + + function showInstructions() + { + global $xw; + + common_element_start('dl', array('class' => 'system_notice')); + common_element('dt', null, 'Page Notice'); + + $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . + 'with your username and password. Don\'t have a username yet? '); + + $loginmsg_part2 = _(' a new account.'); + + common_element_start('dd'); + common_element_start('p'); + common_text(sprintf($loginmsg_part1, common_config('site', 'name'))); + common_element('a', + array('href' => common_local_url('register')), _('Register')); + common_text($loginmsg_part2); + common_element_end('dd'); + common_element_end('dl'); + } + function showLoginForm($msg = null) { start_fbml(); - common_element_start('a', array('href' => 'http://identi.ca')); - common_element('img', array('src' => 'http://theme.identi.ca/identica/logo.png', - 'alt' => 'Identi.ca', - 'id' => 'logo')); - common_element_end('a'); + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => get_facebook_css())); + + $this->showLogo(); + + common_element_start('div', array('class' => 'content')); + common_element('h1', null, _('Login')); + if ($msg) { common_element('fb:error', array('message' => $msg)); } + + $this->showInstructions(); - common_element("h2", null, - _('To add the Identi.ca application, you need to log into your Identi.ca account.')); + common_element_start('div', array('id' => 'content_inner')); - - common_element_start('div', array('class' => 'instructions')); - common_element_start('p'); - common_raw('Login with your username and password. Don\'t have a username yet?' - .' Register a new account.'); - common_element_end('p'); - common_element_end('div'); - - common_element_start('div', array('id' => 'content')); common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => 'index.php')); + + common_element_start('fieldset'); + common_element('legend', null, _('Login to site')); + + common_element_start('ul', array('class' => 'form_datas')); + common_element_start('li'); common_input('nickname', _('Nickname')); + common_element_end('li'); + common_element_start('li'); common_password('password', _('Password')); - + common_element_end('li'); + common_element_end('ul'); + common_submit('submit', _('Login')); common_element_end('form'); @@ -114,6 +180,7 @@ class FacebookAction extends Action common_element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); common_element_end('p'); + common_element_end('div'); common_end_xml(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 2529b8a4b8..532e9c9d74 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -require_once(INSTALLDIR.'/extlib/facebook/facebook.php'); -require_once(INSTALLDIR.'/lib/noticelist.php'); +require_once INSTALLDIR.'/extlib/facebook/facebook.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2 @@ -94,7 +94,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $xw = new XMLWriter(); $xw->openMemory(); - $item = new NoticeListItem($notice); + $item = new FacebookNoticeListItem($notice); $item->show(); $fbml = "$style " . $xw->outputMemory(false) . ""; @@ -104,3 +104,130 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); } + +function get_facebook_css() +{ + # Add a timestamp to the CSS file so Facebook cache wont ignore our changes + $ts = filemtime(theme_file('facebookapp.css')); + $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + return $cssurl; +} + + +class FacebookNoticeList extends NoticeList +{ + /** + * show the list of notices + * + * "Uses up" the stream by looping through it. So, probably can't + * be called twice on the same list. + * + * @return int count of notices listed. + */ + + function show() + { + common_element_start('div', array('id' =>'notices_primary')); + common_element('h2', null, _('Notices')); + common_element_start('ul', array('class' => 'notices')); + + $cnt = 0; + + while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { + $cnt++; + + if ($cnt > NOTICES_PER_PAGE) { + break; + } + + $item = $this->newListItem($this->notice); + $item->show(); + } + + common_element_end('ul'); + common_element_end('div'); + + return $cnt; + } + + /** + * returns a new list item for the current notice + * + * Overridden to return a Facebook specific list item. + * + * @param Notice $notice the current notice + * + * @return FacebookNoticeListItem a list item for displaying the notice + * formatted for display in the Facebook App. + */ + + function newListItem($notice) + { + return new FacebookNoticeListItem($notice); + } + +} + +class FacebookNoticeListItem extends NoticeListItem +{ + /** + * recipe function for displaying a single notice in the Facebook App. + * + * Overridden to strip out some of the controls that we don't + * want to be available. + * + * @return void + */ + + function show() + { + $this->showStart(); + + common_element_start('div', 'entry-title'); + $this->showAuthor(); + $this->showContent(); + common_element_end('div'); + + common_element_start('div', 'entry-content'); + $this->showNoticeLink(); + $this->showNoticeSource(); + $this->showReplyTo(); + common_element_end('div'); + + $this->showEnd(); + } + + function showStart() + { + // XXX: RDFa + // TODO: add notice_type class e.g., notice_video, notice_image + common_element_start('li', array('class' => 'hentry notice', + 'id' => 'notice-' . $this->notice->id)); + } + + function showNoticeLink() + { + $noticeurl = common_local_url('shownotice', + array('notice' => $this->notice->id)); + // XXX: we need to figure this out better. Is this right? + if (strcmp($this->notice->uri, $noticeurl) != 0 && + preg_match('/^http/', $this->notice->uri)) { + $noticeurl = $this->notice->uri; + } + + common_element_start('dl', 'timestamp'); + common_element('dt', null, _('Published')); + common_element_start('dd', null); + common_element_start('a', array('rel' => 'bookmark', + 'href' => $noticeurl)); + $dt = common_date_iso8601($this->notice->created); + common_element('abbr', array('class' => 'published', + 'title' => $dt), + common_date_string($this->notice->created)); + common_element_end('a'); + common_element_end('dd'); + common_element_end('dl'); + } + +} + From 8fdf888edbd74e707d2698c7625dc90b22f0aeef Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 06:12:47 +0000 Subject: [PATCH 03/10] trac750 Javascript file for Facebook app --- actions/facebooksettings.php | 17 +++++++---------- js/facebookapp.js | 25 +++++++++++++++++++++++++ lib/facebookaction.php | 15 ++++++++++++--- lib/facebookutil.php | 10 +++++++++- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 js/facebookapp.js diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index eafd911236..372c40c28c 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -68,19 +68,18 @@ class FacebooksettingsAction extends FacebookAction $this->showHeader('Settings', $msg, $success); - common_element_start('fb:if-section-not-added', array('section' => 'profile')); - common_element('h2', null, _('Add an Identi.ca box to my profile')); + common_element('form', array('id' => 'redirect_form', + 'style' => 'display: none;')); + common_element_start('p'); - common_element('fb:add-section-button', array('section' => 'profile')); - common_element_end('p'); - - common_element_end('fb:if-section-not-added'); - common_element_start('p'); - common_element_start('fb:prompt-permission', array('perms' => 'status_update')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'redirectSettings()')); common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); common_element_end('fb:prompt-permission'); common_element_end('p'); + + if ($facebook->api_client->users_hasAppPermission('status_update')) { common_element_start('form', array('method' => 'post', @@ -94,8 +93,6 @@ class FacebooksettingsAction extends FacebookAction common_checkbox('replysync', _('Send local "@" replies to Facebook.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - // function common_input($id, $label, $value=null,$instructions=null) - $prefix = $facebook->api_client->data_getUserPreference(1); diff --git a/js/facebookapp.js b/js/facebookapp.js new file mode 100644 index 0000000000..3f809e50cb --- /dev/null +++ b/js/facebookapp.js @@ -0,0 +1,25 @@ +/* + * Laconica - a distributed open-source microblogging tool + * Copyright (C) 2008, Controlez-Vous, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// Psycho Facebook redirect hack, used because 'document.location' +// simply does not work in FBJS +function redirectSettings() { + form = document.getElementById('redirect_form'); + form.setAction('settings.php'); + form.submit(); +} diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 1bf026281e..a8f16b34a6 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -37,7 +37,11 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => get_facebook_css())); + 'href' => getFacebookCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); common_element_start('a', array('class' => 'url home bookmark', 'href' => common_local_url('public'))); @@ -58,6 +62,12 @@ class FacebookAction extends Action start_fbml(); + common_element_start('fb:if-section-not-added', array('section' => 'profile')); + common_element_start('span', array('id' => 'add_to_profile')); + common_element('fb:add-section-button', array('section' => 'profile')); + common_element_end('span'); + common_element_end('fb:if-section-not-added'); + $this->showLogo(); common_element_start('dl', array("id" => 'site_nav_local_views')); @@ -141,8 +151,7 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => get_facebook_css())); - + 'href' => getFacebookCSS())); $this->showLogo(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 532e9c9d74..61469b3c64 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -105,7 +105,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); } -function get_facebook_css() +function getFacebookCSS() { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes $ts = filemtime(theme_file('facebookapp.css')); @@ -113,6 +113,14 @@ function get_facebook_css() return $cssurl; } +function getFacebookJS() { + + # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes + $ts = filemtime(INSTALLDIR.'/js/facebookapp.js'); + $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; + return $jsurl; +} + class FacebookNoticeList extends NoticeList { From aea172bee0f2ffdda55cc77016dd609481d7dfee Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 21:08:56 +0000 Subject: [PATCH 04/10] trac750 Removed psychotic FB redirect hack. Found a better way with document.setLocation() --- actions/facebooksettings.php | 12 ++++++------ js/facebookapp.js | 9 +-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index 372c40c28c..b678f19a14 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -67,19 +67,19 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $this->showHeader('Settings', $msg, $success); - - common_element('form', array('id' => 'redirect_form', - 'style' => 'display: none;')); common_element_start('p'); + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties(array('canvas_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; + common_element_start('fb:prompt-permission', array('perms' => 'status_update', - 'next_fbjs' => 'redirectSettings()')); + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); common_element_end('fb:prompt-permission'); common_element_end('p'); - - if ($facebook->api_client->users_hasAppPermission('status_update')) { common_element_start('form', array('method' => 'post', diff --git a/js/facebookapp.js b/js/facebookapp.js index 3f809e50cb..c7e8d6aa22 100644 --- a/js/facebookapp.js +++ b/js/facebookapp.js @@ -15,11 +15,4 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -// Psycho Facebook redirect hack, used because 'document.location' -// simply does not work in FBJS -function redirectSettings() { - form = document.getElementById('redirect_form'); - form.setAction('settings.php'); - form.submit(); -} + \ No newline at end of file From 12f7ec980ceb40d5241b63b88e7601e293c9f277 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 00:50:45 +0000 Subject: [PATCH 05/10] trac750 Better workflow for asking user for status update permission --- actions/facebookhome.php | 94 ++++++++++++++++++++++++++++++++++-- actions/facebooksettings.php | 49 ++++++++++++------- lib/facebookaction.php | 60 +++++++++++------------ lib/facebookutil.php | 26 +++++----- 4 files changed, 166 insertions(+), 63 deletions(-) diff --git a/actions/facebookhome.php b/actions/facebookhome.php index 46f886451c..d211e8844d 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -31,14 +31,41 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); + // If the user has opted not to initially allow the app to have + // Facebook status update permission, store that preference. Only + // promt the user the first time she uses the app + if ($this->arg('skip')) { + $facebook->api_client->data_setUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); + } + // Check to see whether there's already a Facebook link for this user $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); if ($flink) { + $user = $flink->getUser(); common_set_user($user); + + // If this is the first time the user has started the app + // prompt for Facebook status update permission + if (!$facebook->api_client->users_hasAppPermission('status_update')) { + + if ($facebook->api_client->data_getUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') { + $this->getUpdatePermission(); + return; + } + } + + // Use is authenticated and has already been prompted once for + // Facebook status update permission? Then show the main page + // of the app $this->showHome($flink, null); + } else { + + // User hasn't authenticated yet, prompt for creds $this->login($fbuid); } @@ -73,16 +100,18 @@ class FacebookhomeAction extends FacebookAction // XXX: Do some error handling here $this->setDefaults(); - $this->showHome($flink, _('You can now use Identi.ca from Facebook!')); + //$this->showHome($flink, _('You can now use Identi.ca from Facebook!')); + + $this->getUpdatePermission(); return; - + } else { $msg = _('Incorrect username or password.'); } } $this->showLoginForm($msg); - + } function setDefaults() @@ -90,7 +119,10 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); // A default prefix string for notices - $facebook->api_client->data_setUserPreference(1, 'dented: '); + $facebook->api_client->data_setUserPreference( + FACEBOOK_NOTICE_PREFIX, 'dented: '); + $facebook->api_client->data_setUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF, 'false'); } function showHome($flink, $msg) @@ -138,4 +170,58 @@ class FacebookhomeAction extends FacebookAction return $nl->show(); } + function getUpdatePermission() { + + $facebook = get_facebook(); + $fbuid = $facebook->require_login(); + + start_fbml(); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookCSS())); + + $this->showLogo(); + + common_element_start('div', array('class' => 'content')); + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties( + array('canvas_name', 'application_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/index.php'; + $app_name = $app_props['application_name']; + + $instructions = sprintf(_('If you would like the %s app to automatically update ' . + 'your Facebook status with your latest notice, you need ' . + 'to give it permission.'), $app_name); + + common_element_start('p'); + common_element('span', array('id' => 'permissions_notice'), $instructions); + common_element_end('p'); + + common_element_start('form', array('method' => 'post', + 'action' => $app_url, + 'id' => 'facebook-skip-permissions')); + + common_element_start('ul', array('id' => 'fb-permissions-list')); + common_element_start('li', array('id' => 'fb-permissions-item')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); + common_element('span', array('class' => 'facebook-button'), + _('Allow Identi.ca to update my Facebook status')); + common_element_end('fb:prompt-permission'); + common_element_end('li'); + + common_element_start('li', array('id' => 'fb-permissions-item')); + common_submit('skip', _('Skip')); + common_element_end('li'); + common_element_end('ul'); + + common_element_end('form'); + common_element_end('div'); + + common_end_xml(); + + } + } diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index b678f19a14..84e9a343bf 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -50,12 +50,13 @@ class FacebooksettingsAction extends FacebookAction $flink->set_flags($noticesync, $replysync, false); $result = $flink->update($original); - $facebook->api_client->data_setUserPreference(1, substr($prefix, 0, 128)); + $facebook->api_client->data_setUserPreference(FACEBOOK_NOTICE_PREFIX, + substr($prefix, 0, 128)); if ($result) { - $this->show_form('Sync preferences saved.', true); + $this->showForm('Sync preferences saved.', true); } else { - $this->show_form('There was a problem saving your sync preferences!'); + $this->showForm('There was a problem saving your sync preferences!'); } } @@ -67,18 +68,7 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $this->showHeader('Settings', $msg, $success); - - common_element_start('p'); - - // Figure what the URL of our app is. - $app_props = $facebook->api_client->Admin_getAppProperties(array('canvas_name')); - $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; - - common_element_start('fb:prompt-permission', array('perms' => 'status_update', - 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); - common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); - common_element_end('fb:prompt-permission'); - common_element_end('p'); + if ($facebook->api_client->users_hasAppPermission('status_update')) { @@ -90,11 +80,11 @@ class FacebooksettingsAction extends FacebookAction common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - common_checkbox('replysync', _('Send local "@" replies to Facebook.'), + common_checkbox('replysync', _('Send "@" replies to Facebook.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); $prefix = $facebook->api_client->data_getUserPreference(1); - + common_input('prefix', _('Prefix'), ($prefix) ? $prefix : null, @@ -103,6 +93,31 @@ class FacebooksettingsAction extends FacebookAction common_element_end('form'); + } else { + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties( + array('canvas_name', 'application_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; + $app_name = $app_props['application_name']; + + $instructions = sprintf(_('If you would like the %s app to automatically update ' . + 'your Facebook status with your latest notice, you need ' . + 'to give it permission.'), $app_name); + + common_element_start('p'); + common_element('span', array('id' => 'permissions_notice'), $instructions); + common_element_end('p'); + + common_element_start('ul', array('id' => 'fb-permissions-list')); + common_element_start('li', array('id' => 'fb-permissions-item')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); + common_element('span', array('class' => 'facebook-button'), + _('Allow Identi.ca to update my Facebook status')); + common_element_end('fb:prompt-permission'); + common_element_end('li'); + common_element_end('ul'); } $this->showFooter(); diff --git a/lib/facebookaction.php b/lib/facebookaction.php index a8f16b34a6..0a364851fe 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { +if (!defined('LACONICA')) { exit(1); } @@ -32,9 +32,9 @@ class FacebookAction extends Action } function showLogo(){ - + global $xw; - + common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookCSS())); @@ -47,14 +47,14 @@ class FacebookAction extends Action 'href' => common_local_url('public'))); if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { common_element('img', array('class' => 'logo photo', - 'src' => (common_config('site', 'logo')) ? + 'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'), 'alt' => common_config('site', 'name'))); } - + common_element('span', array('class' => 'fn org'), common_config('site', 'name')); common_element_end('a'); - + } function showHeader($selected = 'Home', $msg = null, $success = false) @@ -76,25 +76,25 @@ class FacebookAction extends Action common_element_start('ul', array('class' => 'nav')); - common_element_start('li', array('class' => + common_element_start('li', array('class' => ($selected == 'Home') ? 'current' : 'facebook_home')); - common_element('a', + common_element('a', array('href' => 'index.php', 'title' => _('Home')), _('Home')); common_element_end('li'); - - common_element_start('li', + + common_element_start('li', array('class' => ($selected == 'Invite') ? 'current' : 'facebook_invite')); - common_element('a', + common_element('a', array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); common_element_end('li'); - common_element_start('li', + common_element_start('li', array('class' => ($selected == 'Settings') ? 'current' : 'facebook_settings')); - common_element('a', - array('href' => 'settings.php', + common_element('a', + array('href' => 'settings.php', 'title' => _('Settings')), _('Settings')); common_element_end('li'); @@ -125,24 +125,24 @@ class FacebookAction extends Action function showInstructions() { - global $xw; - + global $xw; + common_element_start('dl', array('class' => 'system_notice')); common_element('dt', null, 'Page Notice'); - + $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . - 'with your username and password. Don\'t have a username yet? '); - + 'with your username and password. Don\'t have a username yet? '); + $loginmsg_part2 = _(' a new account.'); - + common_element_start('dd'); common_element_start('p'); common_text(sprintf($loginmsg_part1, common_config('site', 'name'))); - common_element('a', + common_element('a', array('href' => common_local_url('register')), _('Register')); common_text($loginmsg_part2); common_element_end('dd'); - common_element_end('dl'); + common_element_end('dl'); } function showLoginForm($msg = null) @@ -154,14 +154,14 @@ class FacebookAction extends Action 'href' => getFacebookCSS())); $this->showLogo(); - + common_element_start('div', array('class' => 'content')); common_element('h1', null, _('Login')); - + if ($msg) { common_element('fb:error', array('message' => $msg)); } - + $this->showInstructions(); common_element_start('div', array('id' => 'content_inner')); @@ -169,19 +169,19 @@ class FacebookAction extends Action common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => 'index.php')); - + common_element_start('fieldset'); common_element('legend', null, _('Login to site')); - + common_element_start('ul', array('class' => 'form_datas')); - common_element_start('li'); + common_element_start('li'); common_input('nickname', _('Nickname')); common_element_end('li'); common_element_start('li'); common_password('password', _('Password')); common_element_end('li'); common_element_end('ul'); - + common_submit('submit', _('Login')); common_element_end('form'); @@ -189,7 +189,7 @@ class FacebookAction extends Action common_element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); common_element_end('p'); - + common_element_end('div'); common_end_xml(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 61469b3c64..74e5945923 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -21,6 +21,8 @@ require_once INSTALLDIR.'/extlib/facebook/facebook.php'; require_once INSTALLDIR.'/lib/noticelist.php'; define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2 +define("FACEBOOK_NOTICE_PREFIX", 1); +define("FACEBOOK_PROMPTED_UPDATE_PREF", 2); // Gets all the notices from users with a Facebook link since a given ID function get_facebook_notices($since) @@ -106,18 +108,18 @@ function update_profile_box($facebook, $fbuid, $user, $notice) } function getFacebookCSS() -{ +{ # Add a timestamp to the CSS file so Facebook cache wont ignore our changes $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; return $cssurl; } function getFacebookJS() { - + # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/js/facebookapp.js'); - $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; + $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; return $jsurl; } @@ -157,7 +159,7 @@ class FacebookNoticeList extends NoticeList return $cnt; } - + /** * returns a new list item for the current notice * @@ -173,7 +175,7 @@ class FacebookNoticeList extends NoticeList { return new FacebookNoticeListItem($notice); } - + } class FacebookNoticeListItem extends NoticeListItem @@ -190,7 +192,7 @@ class FacebookNoticeListItem extends NoticeListItem function show() { $this->showStart(); - + common_element_start('div', 'entry-title'); $this->showAuthor(); $this->showContent(); @@ -201,10 +203,10 @@ class FacebookNoticeListItem extends NoticeListItem $this->showNoticeSource(); $this->showReplyTo(); common_element_end('div'); - + $this->showEnd(); } - + function showStart() { // XXX: RDFa @@ -222,9 +224,9 @@ class FacebookNoticeListItem extends NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - + common_element_start('dl', 'timestamp'); - common_element('dt', null, _('Published')); + common_element('dt', null, _('Published')); common_element_start('dd', null); common_element_start('a', array('rel' => 'bookmark', 'href' => $noticeurl)); @@ -237,5 +239,5 @@ class FacebookNoticeListItem extends NoticeListItem common_element_end('dl'); } -} +} From 64bda5bd6ca58289c3a525a20c2dc27501fb1cf8 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 01:34:25 +0000 Subject: [PATCH 06/10] trac750 New CSS files for FB app to allow bettter per-install theming --- lib/facebookaction.php | 6 +++++- lib/facebookutil.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 0a364851fe..fd171c4578 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -37,7 +37,11 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => getFacebookCSS())); + 'href' => getFacebookBaseCSS())); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); common_element('script', array('type' => 'text/javascript', 'src' => getFacebookJS()), diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 74e5945923..0bde68c0f6 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -107,14 +107,22 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); } -function getFacebookCSS() +function getFacebookBaseCSS() { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $ts = filemtime(theme_file('facebookapp_base.css')); + $cssurl = theme_path('facebookapp_base.css') . "?ts=$ts"; return $cssurl; } +function getFacebookThemeCSS() +{ + # Add a timestamp to the CSS file so Facebook cache wont ignore our changes + $ts = filemtime(theme_file('facebookapp_theme.css')); + $cssurl = theme_path('facebookapp_theme.css') . "?ts=$ts"; + return $cssurl; +} + function getFacebookJS() { # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes From 323432aec3da49b23c3fb270e42427abea745101 Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 01:48:04 +0000 Subject: [PATCH 07/10] Facebook base and theme stylesheets. Copy of site display.css files for now. --- theme/base/css/facebookapp.base.css | 285 ++++++ theme/identica/css/facebookapp.theme.css | 1177 ++++++++++++++++++++++ 2 files changed, 1462 insertions(+) create mode 100644 theme/base/css/facebookapp.base.css create mode 100644 theme/identica/css/facebookapp.theme.css diff --git a/theme/base/css/facebookapp.base.css b/theme/base/css/facebookapp.base.css new file mode 100644 index 0000000000..eb7b47a127 --- /dev/null +++ b/theme/base/css/facebookapp.base.css @@ -0,0 +1,285 @@ +/* theme: identica */ +html { +background-color:#ddd; +} +body { +font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; +font-size:1em; +background-color:#ddd; +} +input, textarea, select, option { +font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; +} +input, textarea, select { +border-color:#aaa; +} + +input:focus, textarea:focus, select:focus { +border-color:#A9BF4F; +} +input.submit { +background-color:#A9BF4F; +color:#fff; +} + +a { +color:#002E6E; +} +a:active { +background-color:#ddd; +} +.notice p.entry-content a:visited { +background-color:#fcfcfc; +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +} +.notice p.entry-content .vcard a { +background-color:#fcfffc; +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +} + + + +#aside_primary { +background-color:#CEE1E9; +} + +#form_notice textarea { +} + +#form_notice label { +color:#88171A; +} +#notice_text-count { +color:#333; +} +#form_notice.warning #notice_text-count { +color:#000; +background-color:#A9BF4F; +} +#form_notice.warning #notice_data-text { +border-color:#A9BF4F; +} + +#form_notice #notice_data-attach_view { +background-image:url(../images/icons/twotone/green/paper-clip.gif); +background-repeat:no-repeat; +background-position:0 45%; +background-color:transparent; +} + + +#site_nav_global_primary a { +} +#form_notice .form_actions input.submit { +} +#nav_register a { +background-color:#A9BF4F; +color:#fff; +text-decoration:none; +font-weight:bold; +padding:2px 4px; + +} +#nav_login a { +} + + +#site_nav_local_views a { +border-color:#fff; +background-color:rgba(255, 255, 255, 0.2); +} +#site_nav_local_views a:hover { +background-color:rgba(255, 255, 255, 0.7); +} + + +#content, +#site_nav_local_views .current a { +background-color:#fff; +} + + +#page_notice .error { +background-color:#F7E8E8; +} +#page_notice .success { +background-color:#EFF3DC; +} + +#export_data li a { +background-repeat:no-repeat; +background-position:0 45%; +} +#export_data li a.rss { +background-image:url(../../base/images/icons/icon_rss.jpg); +} +#export_data li a.atom { +background-image:url(../../base/images/icons/icon_atom.jpg); +} +#export_data li a.foaf { +background-image:url(../../base/images/icons/icon_foaf.gif); +} +#export_data li a.export_vcard { +background-image:url(../../base/images/icons/icon_vcard.gif); +} + + +/*user_actions*/ +#user_actions li { +border-top-color:#eee; +} +#user_actions a { +color:#000; +} +#user_subscribe a, +#TB_window input.submit, +.form_user_subscribe input.submit { +background:#CEE1E9 url(../images/icons/twotone/green/shield.gif) 0 45% no-repeat; +} +.form_user_unsubscribe input.submit { +background-color:#647819; +color:#fff; +} +#user_send-a-message a { +background:url(../images/icons/twotone/green/quote.gif) 0 45% no-repeat; +} +.form_user_nudge input.submit { +background:url(../images/icons/twotone/green/mail.gif) 0 45% no-repeat; +} +.form_user_block input.submit { +background:url(../images/icons/twotone/green/against.gif) 0 45% no-repeat; +} + + +.user_tags .mark_hash { +color:#555; +} + + + +.vcard .fn { +} +.vcard .fn:hover { +} + + + + +/* NOTICES */ +.notices li.over { +background-color:#fcfcfc; +} + + +.notice div.entry-content a { + +} +.notice div.entry-content a:hover { +} + + +.notice-data a span { +background-color:transparent; +background-repeat:no-repeat; +background-position:0 45%; +} +.notice_video .notice-data a span { +background-image:url(../images/icons/twotone/green/camera.gif); +} +.notice_audio .notice-data a span { +background-image:url(../images/icons/twotone/green/music.gif); +} +.notice_image .notice-data a span { +background-image:url(../images/icons/twotone/green/search.gif); +} +.notice_event .notice-data a span { +background-image:url(../images/icons/twotone/green/calendar.gif); +} +.notice_location .notice-data a span { +background-image:url(../images/icons/twotone/green/flag.gif); +} +.notice_document .notice-data a span { +background-image:url(../images/icons/twotone/green/document.gif); +} + +.notice-options .notice_reply a, +.notice-options form input.submit { +background-color:transparent; +} +.notice-options .notice_reply a { +background:transparent url(../images/icons/twotone/green/reply.gif) no-repeat 0 45%; +} +.notice-options form.form_favor input.submit { +background:transparent url(../images/icons/twotone/green/favourite.gif) no-repeat 0 45%; +} +.notice-options form.form_disfavor input.submit { +background:transparent url(../images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%; +} +.notice-options .notice_delete a { +background:transparent url(../images/icons/twotone/green/trash.gif) no-repeat 0 45%; +} + +div.notice-options { +opacity:0.3; +} + +div.entry-content { +color:#333; +} +div.notice-options a, +div.notice-options input { +font-family:sans-serif; +} +div.notice-options input { +color:#002E6E; + +} +.notices li.hover { +background-color:#fcfcfc; +} +.notices li.hover div.entry-content, +.notices li.hover div.notice-options { +opacity:1; +} + +.form_settings .form_note { +background-color:#A9BF4F; +} + +/*END: NOTICES */ + + + +.pagination .nav_prev a, +.pagination .nav_next a { +background-repeat:no-repeat; +} +.pagination .nav_prev a { +background-image:url(../images/icons/twotone/green/arrow-left.gif); +background-position:0 45%; +} +.pagination .nav_next a { +background-image:url(../images/icons/twotone/green/arrow-right.gif); +background-position:100% 45%; +} + + + +#home #intro #guide_steps li a { +border-color:#ccc; +color:#fff; +} +#home #intro #step_join-now a { +background-color:#f00; +} +#home #intro #step_start-a-group a { +background-color:#0f0; +} +#home #intro #step_create-a-community a { +background-color:#00f; +} + diff --git a/theme/identica/css/facebookapp.theme.css b/theme/identica/css/facebookapp.theme.css new file mode 100644 index 0000000000..716f3256f5 --- /dev/null +++ b/theme/identica/css/facebookapp.theme.css @@ -0,0 +1,1177 @@ +/* theme: base */ +* { margin:0; padding:0; } +img { display:block; border:0; } +a abbr { cursor: pointer; border-bottom:0; } +table { border-collapse:collapse; } +ol { list-style-position:inside; } +html { font-size: 87.5%; background-color:#fff; height:100%; } +body { +background-color:#fff; +color:#000; +font-family:sans-serif; +font-size:1em; +line-height:1.65; +position:relative; +margin:0 auto; +width:1004px; +width:71.714em; +} +h1,h2,h3,h4,h5,h6 { + text-transform:uppercase; + margin-bottom:7px; +} +h1 { +font-size:1.4em; +line-height:1; +margin-bottom:18px; +} +h2 { font-size:1.3em; } +h3 { font-size:1.2em; } +h4 { font-size:1.1em; } +h5 { font-size:1em; } +h6 { font-size:0.9em; } + +caption { +font-weight:bold; +} +.opened { display: block !important;} +.closed { display: none !important;} + +legend { +font-weight:bold; +font-size:1.3em; +text-transform:uppercase; +} +form { +} +input, textarea, select, option { +padding:4px; +font-family:sans-serif; +font-size:1em; +} +input, textarea, select { +border-width:2px; +border-style: solid; +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +} +input.submit { +font-weight:bold; +} +textarea { +overflow:auto; +} +select, option { +padding-bottom:0; +} +fieldset { +padding:0; +border:0; +} +form ul li { +list-style-type:none; +margin:0 0 18px 0; +} +form label { +font-weight:bold; +/*margin:0 0 11px 0;*/ +} +form ul li input { +} + +input.checkbox { +position:relative; +top:2px; +left:0; +border:0; +} + +#page_notice .error, +#page_notice .success { +padding:4px 7px; +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +} +form label.submit { +display:none; +} +.form_settings input.remove { +margin-left:11px; +} + + + + +/* FORM SETTINGS */ +.form_settings fieldset { +margin-bottom:29px; +} + +.form_guide { +font-style:italic; +} + + +.form_settings .form_datas li { +width:100%; +float:left; +} + +.form_settings .form_datas label { +float:left; +} +.form_settings .form_datas textarea, +.form_settings .form_datas select, +.form_settings .form_datas input { +margin-left:11px; +float:left; +} + +.form_settings label { +margin-top:2px; +width:152px; +} + +.form_actions label { +display:none; +} + +.form_settings #settings_autosubscribe label { +display:inline; +font-weight:bold; +} + +#form_settings_profile legend, +#form_login legend, +#form_register legend { +display:none; +} + +.form_settings .form_datas p.form_guide { +clear:both; +margin-left:163px; +margin-bottom:0; +} + +.form_settings p { +margin-bottom:11px; +} + +.form_settings input.checkbox { +margin-top:3px; +margin-left:0; +} +.form_settings label.checkbox { +font-weight:normal; +margin-top:0; +margin-right:0; +margin-left:11px; +float:left; +width:90%; +} + +#form_login p.form_guide, +#form_register #settings_rememberme p.form_guide { +margin-left:0; +} + + +.form_settings .form_note { +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +padding:0 7px; +} + +/* FORM SETTINGS */ + + + + +address { +float:left; +margin-bottom:18px; +margin-left:18px; +} +address .fn, +address .email { +display:none; +} + + + +#header { +width:100%; +position:relative; +float:left; +padding-top:18px; +margin-bottom:29px; +} + +#site_nav_global_primary { +float:right; +margin-right:18px; +} +#site_nav_global_primary ul li { +display:inline; +margin-left:11px; +} + + +.system_notice dt { +font-weight:bold; +text-transform:uppercase; +display:none; +} + +#site_notice { +position:absolute; +right:0; +top:49px; +float:right; +width:322px; +} +#page_notice { +clear:both; +margin-bottom:18px; +} + + + + +#footer { +float:left; +width:64%; +padding:18px; +} + + + +#site_nav_local_views { +width:100%; +float:left; +} +#site_nav_local_views dt { +display:none; +} +#site_nav_local_views li { +float:left; +margin-right:18px; +list-style-type:none; +} +#site_nav_local_views a { +float:left; +text-decoration:none; +padding:4px 11px; +-moz-border-radius-topleft:4px; +-moz-border-radius-topright:4px; +-webkit-border-top-left-radius:4px; +-webkit-border-top-right-radius:4px; +border-width:1px; +border-style:solid; +border-bottom:0; +text-shadow: 4px 4px 4px #ddd; +font-weight:bold; +} +#site_nav_local_views .nav { +float:left; +width:100%; +} + + +#site_nav_global_primary dt, +#site_nav_global_secondary dt { +display:none; +} +/* +#site_nav_global_primary .current a { +font-weight:bold; +border-style:solid; +} +*/ +#site_nav_global_secondary { +margin-bottom:11px; +} + +#site_nav_global_secondary ul li { +display:inline; +margin-right:11px; +} +#export_data li a { +padding-left:20px; +} +#export_data li a.foaf { +padding-left:30px; +} +#export_data li a.export_vcard { +padding-left:28px; +} + + + +#export_data ul { +display:inline; +} +#export_data li { +list-style-type:none; +display:inline; +margin-left:11px; +} +#export_data li:first-child { +margin-left:0; +} + + + +#licenses { +font-size:0.9em; +} + +#licenses dt { +font-weight:bold; +display:none; +} +#licenses dd { +margin-bottom:11px; +line-height:1.5; +} + +#site_content_license_cc { +margin-bottom:0; +} +#site_content_license_cc img { +display:inline; +vertical-align:top; +margin-right:4px; +} + + +#wrap { + float:left; + margin:0 auto; + width:1004px; + width:71.714em; +} + + +#core { +position:relative; +width:100%; +float:left; +margin-bottom:1em; +} + +#content { +width:644px; +padding:18px; +float:left; +border-radius:7px; +-moz-border-radius:7px; +-moz-border-radius-topleft:0; +-webkit-border-radius:7px; +-webkit-border-top-left-radius:0; +} + +#content_inner { +position:relative; +width:100%; +float;left; +} + +#aside_primary { +width:300px; +float:left; +margin-left:2px; +padding:18px 4px 18px 18px; +border-radius:7px; +-moz-border-radius:7px; +-webkit-border-radius:7px; +} + + + + +/*Start: FORM NOTICE*/ +#form_notice { +width:384px; +width:458px; +float:left; +margin-left:68px; +position:relative; +line-height:1; +} +#form_notice fieldset { +border:0; +padding:0; +} +#form_notice legend { +display:none; +} +#form_notice textarea { +border-radius:7px; +-moz-border-radius:7px; +-webkit-border-radius:7px; +width:377px; +width:370px; +height:86px; +line-height:1.5; +padding:7px 7px 14px 7px; +} +#form_notice label { +display:block; +font-size:1.3em; +margin-bottom:7px; +} +#form_notice .form_datas li { +float:left; +} + +#form_notice #notice_attach_file label, +#form_notice #notice_submit label { +display:none; +} + +#form_notice #notice_attachment { +margin-top:25px; +margin-left:4px; +} + +#form_notice .form_note { +position:absolute; +top:116px; +right:98px; +z-index:9; +} + +#form_notice .form_note dt { +font-weight:bold; +display:none; +} +#notice_text-count { +font-weight:bold; +line-height:1.15; +} + +#form_notice #notice_data-attach_view { +/*position:absolute;*/ +top:25px; +right:30px; +margin-left:4px; +padding:0; +cursor:pointer; +width:16px; +height:16px; +border:0; +text-indent:-9999px; +} +#form_notice .form_actions { +position:absolute; +bottom:0; +right:0; +} +#form_notice .form_actions input.submit { +width:60px; +padding:8px; +} + +#form_notice li { +margin-bottom:0; +} +/*end FORM NOTICE*/ + + + + + +/* user_profile */ +#user_profile { +position:relative; +width:633px; +min-height:123px; +float:left; +margin-bottom:17px; +margin-left:0; +} +#user_profile dt, +#user_statistics dt { +font-weight:bold; +} +#user_profile .user_depiction { +float:left; +position:absolute; +top:0; +left:0; +width:96px; +} +#user_profile .user_fn, +#user_profile .user_nickname, +#user_profile .user_location, +#user_profile .user_url, +#user_profile .user_note, +#user_profile .user_tags { +float:left; +clear:left; +margin-left:125px; +width:322px; +margin-bottom:4px; +} + +#user_profile .user_fn, +#user_profile .user_nickname { +width:auto; +clear:none; +} +#user_profile .user_nickname { +margin-left:11px; +} +#user_profile .user_nickname .nickname { +font-style:italic; +font-weight:bold; +margin-left:4px; +margin-right:4px; +} + +#user_profile .user_nickname dd:before { +content: "("; +} +#user_profile .user_nickname dd:after { +content: ")"; +} + +#user_profile dt { +display:none; +} +#user_profile h2 { +display:none; +} +/* user_profile */ + +/*user_actions*/ +#user_actions { +clear:left; +float:left; +position:absolute; +top:0; +right:0; +} +#user_actions h2 { +display:none; +} +#user_actions ul { +list-style-type:none; +} +#user_actions li { +border-top-width:1px; +border-top-style:dotted; +} +#user_actions li:first-child { +border-top:0; +} +#user_actions fieldset { +border:0; +padding:0; +} +#user_actions legend { +display:none; +} + +#user_actions a, +#user_actions input.submit { +display:block; +text-align:left; +padding:4px 0 4px 19px; +} +#user_actions a { +text-decoration:none; +} +#user_subscribe a, +#TB_window input.submit, +#user_actions input.submit { +border:0; +cursor:pointer; +padding-left:16px; +width:100%; +font-size:0.9em; +} + +#user_subscribe a { +width:auto; +padding-left:20px; +} + +#user_subscribe a, +#TB_window input.submit, +.form_user_subscribe input.submit { +font-weight:bold; +} + + + +#user_send-a-message form { +clear:left; +width:322px; +margin-top:18px; +} + +#user_send-a-message textarea { +width:96%; +} + +.user_tags ul { +list-style-type:none; +} +.user_tags li { +display:inline; +margin-right:1em; +float:left; +} + + + +.aside .section { +margin-bottom:29px; +clear:both; +} +.aside .section h2 { +text-transform:uppercase; +font-size:1em; +} + +#user_statistics dt, +#user_statistics dd { +display:inline; +} +#user_statistics dt:after { +content: ":"; +} + + +#user_subscriptions, +#user_subscriptions-common { +float:left; +} +#user_subscriptions ul.users { +width:220px; +float:left; +} +#user_subscriptions .users li { +list-style-type:none; +float:left; +margin-right:7px; +margin-bottom:7px; +} +#user_subscriptions .users li .photo { +width:24px; +height:24px; +margin-right:0; +} +#user_subscriptions .users li .fn { +display:none; +} +.aside .section .more { +clear:both; +} + + + + + +/* NOTICE */ +.notice { +position:relative; +padding-top:18px; +padding-bottom:18px; +clear:both; +float:left; +width:644px; +width:96.699%; +width:100%; +border-top:1px dashed #D1D9E4; +/*-moz-border-radius:7px;*/ +} +.notices li { +list-style-type:none; +/*margin-bottom:11px;*/ +} + +/* NOTICES */ +#notices_primary { +float:left; +width:644px; +border-radius:7px; +-moz-border-radius:7px; +-webkit-border-radius:7px; +} +#notices_primary h2 { +display:none; +} +.notice-data a span { +display:block; +padding-left:28px; +} + + +.notice .author { +margin-right:11px; +} +.notice .author a { +} +.notice .author:after { +/*content:":";*/ +} + +.vcard .photo { +display:inline; +margin-right:7px; +margin-bottom:7px; +float:left; +} +.vcard .url { +text-decoration:none; +} +.vcard .url:hover { +text-decoration:underline; +} +.vcard .fn { +font-style:italic; +} +.vcard .fn:hover { + +} + + +.notice .entry-title { +float:left; +width:100%; +} +.notice p.entry-content { +display:inline; +} + +.notice_video p.entry-content, +.notice_audio p.entry-content, +.notice_image p.entry-content, +.notice_location p.entry-content, +.notice_event p.entry-content, +.notice_document p.entry-content { +} +#laconicat .notice p.entry-content { +/*margin-left:199px;*/ +} +.notice p.entry-content a { + +} +.notice p.entry-content a:hover { + +} +.notice p.entry-content .tag a { + +} +.notice p.entry-content .tag a:hover { + +} + + +.notice div.entry-content { +/*border:1px solid blue;*/ +clear:left; +float:left; +width:48%; +font-size:0.95em; +} +.notice div.entry-content a, +.notice .notice-options a, +.notice .notice-options input { + +} +.notice .notice-options a, +.notice .notice-options input { +float:left; +font-size:1.025em; +} + +#laconicat .notice div.entry-content { +/*margin-left:0;*/ +} + +.notice div.entry-content dl, +.notice div.entry-content dt, +.notice div.entry-content dd { +display:inline; +} +.notice div.entry-content .timestamp dt, +.notice div.entry-content .response dt { +display:none; +} +.notice div.entry-content .timestamp a { +display:inline-block; +} +.notice div.entry-content .device dt { +text-transform:lowercase; +} +.notice div.entry-content a { + +} +.notice div.entry-content a:hover { +} + + + +.notice-data { +position:absolute; +top:18px; +right:0; +min-height:50px; +margin-bottom:4px; +} +.notice .entry-content .notice-data dt { +display:none; +} + +.notice-data a { +display:block; +outline:none; +} + +.notice-options { +padding-left:2%; +float:left; +width:50%; +position:relative; +font-size:0.95em; +} + +.notice-options a { +float:left; +} +.notice-options .notice_delete, +.notice-options .notice_reply, +.notice-options .form_favor, +.notice-options .form_disfavor { +position:absolute; +top:0; +} +.notice-options .form_favor, +.notice-options .form_disfavor { +left:0; +} +.notice-options .notice_reply { +left:29px; +} +.notice-options .notice_delete { +left:76px; +} +.notice-options .notice_reply dt { +display:none; +} + +.notice-options input, +.notice-options a { +text-indent:-9999px; +outline:none; +} + +.notice-options .notice_reply a, +.notice-options form input.submit { +display:block; +border:0; +} +.notice-options .notice_reply a, +.notice-options .notice_delete a { +text-decoration:none; +padding-left:16px; +} + +.notice-options .notice_delete { + +} + +.notice-options form input.submit { +cursor:pointer; +width:16px; +padding:2px 0; +} + +.notice-options .notice_delete dt, +.notice-options .form_favor legend, +.notice-options .form_disfavor legend { +display:none; +} +.notice-options .notice_delete fieldset, +.notice-options .form_favor fieldset, +.notice-options .form_disfavor fieldset { +border:0; +padding:0; +} + +/*END: NOTICES */ + + + + + +.pagination dt { +font-weight:bold; +display:none; +} + +.pagination .nav { +float:left; +width:100%; +list-style-type:none; +} + +.pagination .nav_prev { +float:left; +} +.pagination .nav_next { +float:right; +} + +.pagination a { +display:block; +text-decoration:none; +font-weight:bold; +padding:7px; +border:1px dotted #D1D9E4; +border-bottom:0; +} + +.pagination .nav_prev a { +-moz-border-radius-topright:7px; +-webkit-border-top-right-radius:7px; +padding-left:20px; +border-left:0; +} +.pagination .nav_next a { +-moz-border-radius-topleft:7px; +-webkit-border-top-left-radius:7px; +padding-right:20px; +border-right:0; +} + + +/* END: NOTICE */ + + + + + + + +/*START: LOAD ALONG WITH JS*/ +.notice .in-reply-to { + width:98%; + margin-left:2%; +} +.notice .in-reply-to li { +background-color:#F7F9FB; +} +.notice .in-reply-to li .in-reply-to li { +background-color:#E4E9F0; +} +.notice .in-reply-to li .in-reply-to li .in-reply-to li { +background-color:#D1D9E4; +} + + + +#user_actions #user_subscribe .form_note, +#user_actions #user_subscribe .form_datas, +#user_actions #user_subscribe .form_actions label { +display:none; +} +#form_user-relationship .form_note, +#form_user-relationship .form_datas, +#form_user-relationship .form_actions label { +display:block; +} + +#user_actions #user-relationship_submit { +margin-bottom:0; +} +#form_user-relationship .form_datas li label { +margin-right:11px; +} + +#user_relationship_xfn { +/*z-index:1000; +position:absolute; +width:521px; +height:322px;*/ +display:none; +} +#user_relationship_xfn fieldset { +background-color:#fff; +} + +/*END: LOAD ALONG WITH JS*/ + + + +/* TOP_POSTERS */ +#top-posters caption { +text-align:left; +text-transform:uppercase; +} + +#top-posters thead { +display:none; +} +#top-poster_user { +width:199px; +} +#top-poster_number-of-notices { +width:123px; +} +#top-posters tbody td { +padding-right:11px; +padding-bottom:4px; +} +#top-posters img { +margin-right:7px; +height:24px; +width:24px; +} + + + +/* tagcloud */ +#tagcloud ul { +list-style-type:none; +} +#tagcloud ul li { +display:inline; +margin-right:7px; +line-height:1.4; +} + +#tagcloud.section dt { +text-transform:uppercase; +font-weight:bold; +} +#tagcloud .weight_1 { +font-size:1em; +} +#tagcloud .weight_2 { +font-size:1.3em; +} +#tagcloud .weight_3 { +font-size:1.6em; +} +#tagcloud .weight_4 { +font-size:1.9em; +} +#tagcloud .weight_5 { +font-size:2.2em; +} + + + +#form_settings_photo .form_datas { +clear:both; +} + + + + +#photo_original, +#photo_preview { +float:left; +} +#photo_preview, +#settings_photo_action-crop { +margin-left:29px; +} +#photo_preview_view { +height:96px; +width:96px; +overflow:hidden; +} + + + + +.section .groups, +#users_featured ul { +list-style-type:none; +} +.section .groups li, +#users_featured li { +margin-top:11px; +float:left; +width:100%; +} +.section .groups li:first-child, +#users_featured li:first-child { +margin-top:0; +} + +.section .groups .vcard, +#users_featured .vcard { +float:left; +margin-bottom:-23px; +} + +.section .groups dl, +#users_featured dl { +float:left; +margin-left:63px; +clear:left; +} +.section .groups dt, +#users_featured dt { +display:none; +font-weight:bold; +} + + + +#home.logged_out h1 { +display:none; +} + +#home #intro { +margin-bottom:29px; +float:left; +width:100%; +} + +#home #intro p { +margin-bottom:18px; +font-size:1.8em; +} + +#home #intro #guide_steps { +list-style-type:none; +} +#home #intro #guide_steps li { +float:left; +margin-left:18px; +} +#home #intro #guide_steps li:first-child { +margin-left:0; +} +#home #intro #guide_steps li a { +display:block; +float:left; +width:185px; +height:109px; +border-width:1px; +border-style:dotted; +text-decoration:none; +border-radius:7px; +-moz-border-radius:7px; +-webkit-border-radius:7px; +padding:7px; +font-size:1.6em; +font-weight:bold; +text-align:center; +} + + +#testimonials { +clear:both; +} From 5f2fce04cb7726f44b797908b073e22e399b8be2 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 01:59:31 +0000 Subject: [PATCH 08/10] trac750 Updated paths for new css files; deleted old unused css file --- lib/facebookutil.php | 8 +- theme/identica/facebookapp.css | 161 --------------------------------- 2 files changed, 4 insertions(+), 165 deletions(-) delete mode 100644 theme/identica/facebookapp.css diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 0bde68c0f6..cc4941bdc1 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -110,16 +110,16 @@ function update_profile_box($facebook, $fbuid, $user, $notice) function getFacebookBaseCSS() { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp_base.css')); - $cssurl = theme_path('facebookapp_base.css') . "?ts=$ts"; + $ts = filemtime(INSTALLDIR.'/theme/base/css/facebookapp.base.css'); + $cssurl = INSTALLDIR.'/theme/base/css/facebookapp.base.css' . "?ts=$ts"; return $cssurl; } function getFacebookThemeCSS() { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp_theme.css')); - $cssurl = theme_path('facebookapp_theme.css') . "?ts=$ts"; + $ts = filemtime(theme_file('css/facebookapp.theme.css')); + $cssurl = theme_path('css/facebookapp.theme.css') . "?ts=$ts"; return $cssurl; } diff --git a/theme/identica/facebookapp.css b/theme/identica/facebookapp.css deleted file mode 100644 index b2bbbac510..0000000000 --- a/theme/identica/facebookapp.css +++ /dev/null @@ -1,161 +0,0 @@ - -/* XXX: Most of this just copied out of display.css -- need to factor out what we really neeed -- Zach */ - -body { - color: #193441; -} - -a { -color: #d1451a; -text-decoration: none; -} -a:hover { -text-decoration: underline; -} -img, img a { -border: 0; -} -h1 { -font-size: 14px; -} - -#wrap { -margin: 0 auto; -padding: 0 20px; -width: 760px; -background: url(bg-header.gif) repeat-x #fbf2d7; -} - - -#notices { -clear: both; -margin: 0 auto; -padding: 0; -list-style-type: none; -width: 600px; -border-top: 1px solid #dec5b5; -} -#notices a:hover { -text-decoration: underline; -} -.notice_single { -clear: both; -display: block; -margin: 0; -padding: 5px 5px 5px 0; -min-height: 48px; -font-family: Georgia, "Times New Roman", Times, serif; -font-size: 13px; -line-height: 16px; -border-bottom: 1px solid #dec5b5; -background-color:#FCFFF5; -opacity:1; -} -.notice_single:hover { -background-color: #f7ebcc; -} -.notice_single p { -display: inline; -margin: 0; -padding: 0; -} -#notice_delete_form #confirmation_text { - display: block; -font-size: 14px; -font-weight: bold; -} - -input#submit_yes, input#submit_no { -margin: 18px 10px 0px 0px; -padding: 4px; -font-weight: bold; -color: #fff6d5; -background-color: #F60; -cursor: pointer; -border: 0; -width: 40px; -} -input#submit_yes:hover, input#submit_no:hover { -background-color: #701238; -} -.avatar.stream { -float: left; -margin: 0 10px 0.5em 0; -} -p.time { -display: block; -font-family: Verdana, Arial, Helvetica, sans-serif; -font-size: 10px; -line-height: 15px; -} -p.time a { -color: #dab134; -} - - -/* ----- Forms General Style ----- */ -form { - margin: 0 auto; - padding: 0; - } -form { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 12px; - } -form label { - display: block; - font-size: 12px; - font-weight: bold; - line-height: 18px; - } -form input { - border: 1px solid #dec5b5; - width: 264px; - } -input#submit, input.submit { - display: block; - margin: 18px 0; - padding: 4px; - font-weight: bold; - color: #fff6d5; - background-color: #F60; - cursor: pointer; - border: 0; - width: auto; - } -input#submit:hover, input.submit:hover { - background-color: #701238; - } -input.checkbox { - /*width: 14px; - height: 14px;*/ - width: auto; - border: 0; - } - -label.checkbox_label { - display: inline; - font-weight: normal; -} - -textarea, input { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 12px; - color: #701238; - padding: 3px; - } -textarea:focus, input:focus { - background-color: #f8ebc0; - } -textarea { - width: 270px; - border: 1px solid #D8E2D7; - } -.input_instructions { - margin-top: 3px; - display: block; - font-size: 11px; - line-height: 15px; - color: #924959; - font-family: Verdana, Arial, Helvetica, sans-serif; - } From cd6b9d6c4608cc5bb524031f8de97a3dc5cc3ea9 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 02:13:25 +0000 Subject: [PATCH 09/10] trac750 fix method calls to get CSS files --- actions/facebookhome.php | 10 +++++++++- lib/facebookaction.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/actions/facebookhome.php b/actions/facebookhome.php index d211e8844d..7430cc41fa 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -179,7 +179,15 @@ class FacebookhomeAction extends FacebookAction common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => getFacebookCSS())); + 'href' => getFacebookBaseCSS())); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); $this->showLogo(); diff --git a/lib/facebookaction.php b/lib/facebookaction.php index fd171c4578..263248f679 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -155,7 +155,15 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => getFacebookCSS())); + 'href' => getFacebookBaseCSS())); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); $this->showLogo(); From 739baf0396b2e6796f07616cdb9d52d09cf6ed2f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 07:24:12 +0000 Subject: [PATCH 10/10] trac750 Add notice input box to FB app and ability to post notices --- actions/facebookhome.php | 93 ++++++++++++++++++-------- actions/facebookinvite.php | 3 +- actions/facebookremove.php | 2 +- actions/facebooksettings.php | 4 +- lib/facebookaction.php | 124 +++++++++++++++++++++++++---------- lib/facebookutil.php | 38 ++++++++++- scripts/update_facebook.php | 10 ++- 7 files changed, 205 insertions(+), 69 deletions(-) diff --git a/actions/facebookhome.php b/actions/facebookhome.php index 7430cc41fa..3696df90ac 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -30,6 +30,9 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); + + // Check to see whether there's already a Facebook link for this user + $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); // If the user has opted not to initially allow the app to have // Facebook status update permission, store that preference. Only @@ -39,11 +42,13 @@ class FacebookhomeAction extends FacebookAction FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); } - // Check to see whether there's already a Facebook link for this user - $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - if ($flink) { + if ($_POST['submit'] == 'Send') { + $this->saveNewNotice($flink); + return; + } + $user = $flink->getUser(); common_set_user($user); @@ -136,19 +141,16 @@ class FacebookhomeAction extends FacebookAction $notice = $user->getCurrentNotice(); update_profile_box($facebook, $fbuid, $user, $notice); - - $this->showHeader('Home'); - - if ($msg) { - common_element('fb:success', array('message' => $msg)); - } - - echo $this->show_notices($user); + $this->showHeader($msg); + $this->showNoticeForm($user); + $this->showNav('Home'); + + echo $this->showNotices($user); $this->showFooter(); } - function show_notices($user) + function showNotices($user) { $page = $this->trimmed('page'); @@ -158,13 +160,13 @@ class FacebookhomeAction extends FacebookAction $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - $cnt = $this->show_notice_list($notice); + $cnt = $this->showNoticeList($notice); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'all', array('nickname' => $user->nickname)); + facebookPagination($page > 1, $cnt > NOTICES_PER_PAGE, + $page, 'all', array('nickname' => $user->nickname)); } - function show_notice_list($notice) + function showNoticeList($notice) { $nl = new FacebookNoticeList($notice); return $nl->show(); @@ -175,19 +177,10 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - start_fbml(); + startFBML(); - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookBaseCSS())); - - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookThemeCSS())); - - common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + $this->showStylesheets(); + $this->showScripts(); $this->showLogo(); @@ -231,5 +224,49 @@ class FacebookhomeAction extends FacebookAction common_end_xml(); } + + function saveNewNotice($flink) + { + + $user = $flink->getUser(); + $content = $_POST['status_textarea']; + + if (!$content) { + $this->showHome($flink, _('No content!')); + return; + } else { + $content_shortened = common_shorten_links($content); + + if (mb_strlen($content_shortened) > 140) { + common_debug("Content = '$content_shortened'", __FILE__); + common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__); + $this->showHome($flink, _('That\'s too long. Max notice size is 140 chars.')); + return; + } + } + + $inter = new CommandInterpreter(); + + $cmd = $inter->handle_command($user, $content_shortened); + + if ($cmd) { + $cmd->execute(new WebChannel()); + return; + } + + $replyto = $this->trimmed('inreplyto'); + + $notice = Notice::saveNew($user->id, $content, + 'Facebook', 1, ($replyto == 'false') ? null : $replyto); + + if (is_string($notice)) { + $this->showHome($flink, 'Error!'); + return; + } + + common_broadcast_notice($notice); + $this->showHome($flink, 'Success!'); + } + } diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php index d7e82dae7b..e67bfaa000 100644 --- a/actions/facebookinvite.php +++ b/actions/facebookinvite.php @@ -69,7 +69,8 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->showHeader('Invite'); + $this->showHeader(); + $this->showNav('Invite'); // Get a list of users who are already using the app for exclusion $exclude_ids = $facebook->api_client->friends_getAppUsers(); diff --git a/actions/facebookremove.php b/actions/facebookremove.php index a200fefbfe..557c0655b4 100644 --- a/actions/facebookremove.php +++ b/actions/facebookremove.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebookremoveAction extends FacebookAction { diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index 84e9a343bf..a08abc9371 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -67,8 +67,8 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - $this->showHeader('Settings', $msg, $success); - + $this->showHeader($msg, $success); + $this->showNav('Settings'); if ($facebook->api_client->users_hasAppPermission('status_update')) { diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 263248f679..cd43a2ccb9 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -35,17 +35,8 @@ class FacebookAction extends Action global $xw; - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookBaseCSS())); - - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookThemeCSS())); - - common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + $this->showStylesheets(); + $this->showScripts(); common_element_start('a', array('class' => 'url home bookmark', 'href' => common_local_url('public'))); @@ -61,19 +52,34 @@ class FacebookAction extends Action } - function showHeader($selected = 'Home', $msg = null, $success = false) - { - start_fbml(); + function showHeader($msg = null, $success = false) + { + startFBML(); common_element_start('fb:if-section-not-added', array('section' => 'profile')); common_element_start('span', array('id' => 'add_to_profile')); common_element('fb:add-section-button', array('section' => 'profile')); common_element_end('span'); common_element_end('fb:if-section-not-added'); - + $this->showLogo(); + if ($msg) { + if ($success) { + common_element('fb:success', array('message' => $msg)); + } else { + // XXX do an error message here + } + } + + common_element_start('div', 'main_body'); + + } + + function showNav($selected = 'Home') + { + common_element_start('dl', array("id" => 'site_nav_local_views')); common_element('dt', null, _('Local Views')); common_element_start('dd'); @@ -86,7 +92,6 @@ class FacebookAction extends Action array('href' => 'index.php', 'title' => _('Home')), _('Home')); common_element_end('li'); - common_element_start('li', array('class' => ($selected == 'Invite') ? 'current' : 'facebook_invite')); @@ -107,17 +112,6 @@ class FacebookAction extends Action common_element_end('dd'); common_element_end('dl'); - - if ($msg) { - if ($success) { - common_element('fb:success', array('message' => $msg)); - } else { - // XXX do an error message here - } - } - - common_element_start('div', 'main_body'); - } function showFooter() @@ -149,10 +143,11 @@ class FacebookAction extends Action common_element_end('dl'); } - function showLoginForm($msg = null) - { - start_fbml(); + function showStylesheets() + { + global $xw; + common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookBaseCSS())); @@ -160,10 +155,23 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookThemeCSS())); - + } + + function showScripts() + { + global $xw; + common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + 'src' => getFacebookJS())); + + } + + function showLoginForm($msg = null) + { + startFBML(); + + $this->showStylesheets(); + $this->showScripts(); $this->showLogo(); @@ -179,6 +187,7 @@ class FacebookAction extends Action common_element_start('div', array('id' => 'content_inner')); common_element_start('form', array('method' => 'post', + 'class' => 'form_settings', 'id' => 'login', 'action' => 'index.php')); @@ -209,4 +218,53 @@ class FacebookAction extends Action } + function showNoticeForm($user) + { + + global $xw; + + common_element_start('form', array('id' => 'form_notice', + 'method' => 'post', + 'action' => 'index.php')); + + common_element_start('fieldset'); + common_element('legend', null, 'Send a notice'); + + common_element_start('ul', 'form_datas'); + common_element_start('li', array('id' => 'noticcommon_elemente_text')); + common_element('label', array('for' => 'notice_data-text'), + sprintf(_('What\'s up, %s?'), $user->nickname)); + + common_element('textarea', array('id' => 'notice_data-text', + 'cols' => 35, + 'rows' => 4, + 'name' => 'status_textarea')); + common_element_end('li'); + common_element_end('ul'); + + common_element_start('dl', 'form_note'); + common_element('dt', null, _('Available characters')); + common_element('dd', array('id' => 'notice_text-count'), + '140'); + common_element_end('dl'); + + common_element_start('ul', array('class' => 'form_actions')); + + common_element_start('li', array('id' => 'notice_submit')); + + common_submit('submit', _('Send')); + + /* + common_element('input', array('id' => 'notice_action-submit', + 'class' => 'submit', + 'name' => 'status_submit', + 'type' => 'submit', + 'value' => _('Send'))); + */ + common_element_end('li'); + common_element_end('ul'); + common_element_end('fieldset'); + common_element_end('form'); + } + } diff --git a/lib/facebookutil.php b/lib/facebookutil.php index cc4941bdc1..a133ce8ba5 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -44,7 +44,7 @@ function get_facebook() return new Facebook($apikey, $secret); } -function start_fbml($indent = true) +function startFBML($indent = true) { global $xw; $xw = new XMLWriter(); @@ -132,6 +132,42 @@ function getFacebookJS() { } +// Does a little before-after block for next/prev page + +function facebookPagination($have_before, $have_after, $page, $action, $args=null) +{ + + if ($have_before || $have_after) { + common_element_start('div', array('id' => 'pagination')); + common_element_start('ul', array('id' => 'nav_pagination')); + } + + if ($have_before) { + $pargs = array('page' => $page-1); + $newargs = ($args) ? array_merge($args,$pargs) : $pargs; + + common_element_start('li', 'before'); + common_element('a', array('href' => "index.php?page=$newargs[page]", 'rel' => 'prev'), + _('« After')); + common_element_end('li'); + } + + if ($have_after) { + $pargs = array('page' => $page+1); + $newargs = ($args) ? array_merge($args,$pargs) : $pargs; + common_element_start('li', 'after'); + common_element('a', array('href' => "index.php?page=$newargs[page]", 'rel' => 'next'), + _('Before »')); + common_element_end('li'); + } + + if ($have_before || $have_after) { + common_element_end('ul'); + common_element_end('div'); + } +} + + class FacebookNoticeList extends NoticeList { /** diff --git a/scripts/update_facebook.php b/scripts/update_facebook.php index 8c91df384b..0c54cec7cf 100755 --- a/scripts/update_facebook.php +++ b/scripts/update_facebook.php @@ -67,9 +67,13 @@ while($notice->fetch()) { // If it's not a reply, or if the user WANTS to send replies... if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) || (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) { - update_status($fbuid, $content); - update_profile_box($facebook, $fbuid, $user, $notice); - $cnt++; + + // Avoid a Loop + if ($notice->source != 'Facebook') { + update_status($fbuid, $content); + update_profile_box($facebook, $fbuid, $user, $notice); + $cnt++; + } } } }