From 95ba22c5d7ffb28fa5c44a398edca86cc0f637f5 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 18:27:27 -0400 Subject: Switch DOCTYPE's to the XHTML 5 DOCTYPE --- lib/htmloutputter.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 06603ac05..cba8a5f5e 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -110,9 +110,7 @@ class HTMLOutputter extends XMLOutputter $this->extraHeaders(); - $this->startXML('html', - '-//W3C//DTD XHTML 1.0 Strict//EN', - 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); + $this->startXML('html'); $language = $this->getLanguage(); -- cgit v1.2.3-54-g00ecf From b975a6a0e5a5a7332eea4834494029c5c1238540 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 18:55:47 -0400 Subject: Don't start HTML responses with extraHeaders(); - - $this->startXML('html'); + if( ! substr($type,0,strlen('text/html'))=='text/html' ){ + // Browsers don't like it when xw->startDocument('1.0', 'UTF-8'); + } + if ($doc) { + $this->xw->writeDTD('html', $public, $system); + } $language = $this->getLanguage(); -- cgit v1.2.3-54-g00ecf From feac024348e0584c84fd5392c503d912000d30bc Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 19:24:34 -0400 Subject: Accidentally caused the DOCTYPE to never be rendered - fix that. --- lib/htmloutputter.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 8f3b1a609..5da1fbe14 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -113,9 +113,7 @@ class HTMLOutputter extends XMLOutputter // Browsers don't like it when xw->startDocument('1.0', 'UTF-8'); } - if ($doc) { - $this->xw->writeDTD('html', $public, $system); - } + $this->xw->writeDTD('html', $public, $system); $language = $this->getLanguage(); -- cgit v1.2.3-54-g00ecf From 6a76addbe8bbfafd1a1dd6ed7ffbf8afebff5abe Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 19:35:42 -0400 Subject: Added cssLink() and script() functions to htmloutputter --- lib/htmloutputter.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 5da1fbe14..0b4c1405a 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -339,6 +339,42 @@ class HTMLOutputter extends XMLOutputter 'title' => $title)); } + /** + * output a script (almost always javascript) tag + * + * @param string $src relative or absolute script path + * @param string $type 'type' attribute value of the tag + * + * @return void + */ + function script($src, $type='text/javascript') + { + $this->element('script', array('type' => $type, + 'src' => common_path($src) . '?version=' . LACONICA_VERSION), + ' '); + } + + /** + * output a css link + * + * @param string $relative relative path within the theme directory + * @param string $theme 'theme' that contains the stylesheet + * @param string media 'media' attribute of the tag + * + * @return void + */ + function cssLink($relative,$theme,$media) + { + if (!$theme) { + $theme = common_config('site', 'theme'); + } + + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => theme_path($relative, $theme) . '?version=' . LACONICA_VERSION, + 'media' => $media)); + } + /** * output an HTML textarea and associated elements * -- cgit v1.2.3-54-g00ecf From 304db1d30b4ad96f8a2ca500d224bb1609588fed Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 19:45:12 -0400 Subject: Use script() and cssLink() methods everywhere instead of manually writing out javascript and css each time --- actions/avatarsettings.php | 17 +++-------------- actions/grouplogo.php | 17 +++-------------- lib/action.php | 39 +++++++++------------------------------ lib/designsettings.php | 17 +++-------------- lib/facebookaction.php | 27 +++------------------------ 5 files changed, 21 insertions(+), 96 deletions(-) (limited to 'lib') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index c2bb35a39..38e3103f4 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -382,13 +382,7 @@ class AvatarsettingsAction extends AccountSettingsAction function showStylesheets() { parent::showStylesheets(); - $jcropStyle = - common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $jcropStyle, - 'media' => 'screen, projection, tv')); + $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv'); } /** @@ -402,13 +396,8 @@ class AvatarsettingsAction extends AccountSettingsAction parent::showScripts(); if ($this->mode == 'crop') { - $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); - $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); - - $this->element('script', array('type' => 'text/javascript', - 'src' => $jcropPack)); - $this->element('script', array('type' => 'text/javascript', - 'src' => $jcropGo)); + $this->script('js/jcrop/jquery.Jcrop.pack.js'); + $this->script('js/jcrop/jquery.Jcrop.go.js'); } } } diff --git a/actions/grouplogo.php b/actions/grouplogo.php index 8f6158dac..5edb10cf8 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -428,13 +428,7 @@ class GrouplogoAction extends GroupDesignAction function showStylesheets() { parent::showStylesheets(); - $jcropStyle = - common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $jcropStyle, - 'media' => 'screen, projection, tv')); + $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv'); } /** @@ -448,13 +442,8 @@ class GrouplogoAction extends GroupDesignAction parent::showScripts(); if ($this->mode == 'crop') { - $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); - $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); - - $this->element('script', array('type' => 'text/javascript', - 'src' => $jcropPack)); - $this->element('script', array('type' => 'text/javascript', - 'src' => $jcropGo)); + $this->script('js/jcrop/jquery.Jcrop.pack.js'); + $this->script('js/jcrop/jquery.Jcrop.go.js'); } } diff --git a/lib/action.php b/lib/action.php index a5244371a..1c6170693 100644 --- a/lib/action.php +++ b/lib/action.php @@ -193,21 +193,12 @@ class Action extends HTMLOutputter // lawsuit if (Event::handle('StartShowStyles', array($this))) { if (Event::handle('StartShowLaconicaStyles', array($this))) { - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION, - 'media' => 'screen, projection, tv')); + $this->cssLink('css/display.css',null,'screen, projection, tv'); if (common_config('site', 'mobile')) { - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/mobile.css', 'base') . '?version=' . LACONICA_VERSION, - // TODO: "handheld" CSS for other mobile devices - 'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit + // TODO: "handheld" CSS for other mobile devices + $this->cssLink('css/mobile.css','base','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')); + $this->cssLink('css/print.css','base','print'); Event::handle('EndShowLaconicaStyles', array($this)); } @@ -253,26 +244,14 @@ class Action extends HTMLOutputter // lawsuit { if (Event::handle('StartShowScripts', array($this))) { if (Event::handle('StartShowJQueryScripts', array($this))) { - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.min.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.form.js')), - ' '); - - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.joverlay.min.js')), - ' '); - + $this->script('js/jquery.min.js'); + $this->script('js/jquery.form.js'); + $this->script('js/jquery.joverlay.min.js'); Event::handle('EndShowJQueryScripts', array($this)); } if (Event::handle('StartShowLaconicaScripts', array($this))) { - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/xbImportNode.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), - ' '); + $this->script('js/xbImportNode.js'); + $this->script('js/util.js'); // Frame-busting code to avoid clickjacking attacks. $this->element('script', array('type' => 'text/javascript'), 'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); diff --git a/lib/designsettings.php b/lib/designsettings.php index 1b0e62166..a48ec9d22 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -311,13 +311,7 @@ class DesignSettingsAction extends AccountSettingsAction function showStylesheets() { parent::showStylesheets(); - $farbtasticStyle = - common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $farbtasticStyle, - 'media' => 'screen, projection, tv')); + $this->cssLink('css/farbtastic.css','base','screen, projection, tv'); } /** @@ -330,13 +324,8 @@ class DesignSettingsAction extends AccountSettingsAction { parent::showScripts(); - $farbtasticPack = common_path('js/farbtastic/farbtastic.js'); - $userDesignGo = common_path('js/userdesign.go.js'); - - $this->element('script', array('type' => 'text/javascript', - 'src' => $farbtasticPack)); - $this->element('script', array('type' => 'text/javascript', - 'src' => $userDesignGo)); + $this->script('js/farbtastic/farbtastic.js'); + $this->script('js/farbtastic/farbtastic.go.js'); } /** diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 5be2f2fe6..ab11b613e 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -95,34 +95,13 @@ class FacebookAction extends Action function showStylesheets() { - // Add a timestamp to the file so Facebook cache wont ignore our changes - $ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts)); - - $theme = common_config('site', 'theme'); - - $ts = filemtime(INSTALLDIR. '/theme/' . $theme .'/css/display.css'); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', null) . '?ts=' . $ts)); - - $ts = filemtime(INSTALLDIR.'/theme/base/css/facebookapp.css'); - - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/facebookapp.css', 'base') . '?ts=' . $ts)); + $this->cssLink('css/display.css', 'base'); + $this->cssLink('css/facebookapp.css', 'base'); } function showScripts() { - // Add a timestamp to the file so Facebook cache wont ignore our changes - $ts = filemtime(INSTALLDIR.'/js/facebookapp.js'); - - $this->element('script', array('src' => common_path('js/facebookapp.js') . '?ts=' . $ts)); + $this->script('js/facebookapp.js'); } /** -- cgit v1.2.3-54-g00ecf From 2eaf738bf708ec4f49bd7bbc8ca67d6fad33317a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 20:28:46 -0400 Subject: Handle relative and absolute url parameters to script() and cssLink() --- lib/htmloutputter.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 0b4c1405a..9d3244625 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -349,29 +349,38 @@ class HTMLOutputter extends XMLOutputter */ function script($src, $type='text/javascript') { + $url = parse_url($src); + if(! ($url->scheme || $url->host || $url->query || $url->fragment)) + { + $src = common_path($src) . '?version=' . LACONICA_VERSION; + } $this->element('script', array('type' => $type, - 'src' => common_path($src) . '?version=' . LACONICA_VERSION), + 'src' => $src), ' '); } /** * output a css link * - * @param string $relative relative path within the theme directory + * @param string $src relative path within the theme directory, or an absolute path * @param string $theme 'theme' that contains the stylesheet * @param string media 'media' attribute of the tag * * @return void */ - function cssLink($relative,$theme,$media) + function cssLink($src,$theme,$media) { if (!$theme) { $theme = common_config('site', 'theme'); } - + $url = parse_url($src); + if(! ($url->scheme || $url->host || $url->query || $url->fragment)) + { + $src = theme_path($src) . '?version=' . LACONICA_VERSION; + } $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => theme_path($relative, $theme) . '?version=' . LACONICA_VERSION, + 'href' => $src, 'media' => $media)); } -- cgit v1.2.3-54-g00ecf From c8c2d9d7c93f40e7ac81c6211f8ba4c3f6ae91d9 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 6 Aug 2009 11:18:57 -0400 Subject: Make 2nd and 3rd cssLink() arguments optional --- lib/htmloutputter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 9d3244625..74876523a 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -368,7 +368,7 @@ class HTMLOutputter extends XMLOutputter * * @return void */ - function cssLink($src,$theme,$media) + function cssLink($src,$theme=null,$media=null) { if (!$theme) { $theme = common_config('site', 'theme'); -- cgit v1.2.3-54-g00ecf From e386a75d1b5271cfcd51825d0d2a420ef66d3622 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 6 Aug 2009 13:05:40 -0400 Subject: Check theme first for CSS files, then use the non-theme path. Fixes CSS links in plugins --- lib/htmloutputter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 74876523a..f4445b44f 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -376,7 +376,11 @@ class HTMLOutputter extends XMLOutputter $url = parse_url($src); if(! ($url->scheme || $url->host || $url->query || $url->fragment)) { - $src = theme_path($src) . '?version=' . LACONICA_VERSION; + if(file_exists(theme_file($src,$theme))){ + $src = theme_path($src, $theme) . '?version=' . LACONICA_VERSION; + }else{ + $src = common_path($src); + } } $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', -- cgit v1.2.3-54-g00ecf From 26b608d914bb5a04c2285111588cbdad12a5a936 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 6 Aug 2009 15:14:27 -0400 Subject: Support the 'lite' parameter to statuses/friends and statuses/followers twitter api methods. http://laconi.ca/trac/ticket/1786 --- actions/twitapistatuses.php | 16 +++++++++------- lib/twitterapi.php | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index c9943698d..185129d5e 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -449,7 +449,8 @@ class TwitapistatusesAction extends TwitterapiAction function friends($args, $apidata) { parent::handle($args); - return $this->subscriptions($apidata, 'subscribed', 'subscriber'); + $includeStatuses=! (boolean) $args['lite']; + return $this->subscriptions($apidata, 'subscribed', 'subscriber', false, $includeStatuses); } function friendsIDs($args, $apidata) @@ -461,7 +462,8 @@ class TwitapistatusesAction extends TwitterapiAction function followers($args, $apidata) { parent::handle($args); - return $this->subscriptions($apidata, 'subscriber', 'subscribed'); + $includeStatuses=! (boolean) $args['lite']; + return $this->subscriptions($apidata, 'subscriber', 'subscribed', false, $includeStatuses); } function followersIDs($args, $apidata) @@ -470,7 +472,7 @@ class TwitapistatusesAction extends TwitterapiAction return $this->subscriptions($apidata, 'subscriber', 'subscribed', true); } - function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false) + function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false, $includeStatuses=true) { $this->auth_user = $apidata['user']; $user = $this->get_user($apidata['api_arg'], $apidata); @@ -526,26 +528,26 @@ class TwitapistatusesAction extends TwitterapiAction if ($onlyIDs) { $this->showIDs($others, $type); } else { - $this->show_profiles($others, $type); + $this->show_profiles($others, $type, $includeStatuses); } $this->end_document($type); } - function show_profiles($profiles, $type) + function show_profiles($profiles, $type, $includeStatuses) { switch ($type) { case 'xml': $this->elementStart('users', array('type' => 'array')); foreach ($profiles as $profile) { - $this->show_profile($profile); + $this->show_profile($profile,$type,null,$includeStatuses); } $this->elementEnd('users'); break; case 'json': $arrays = array(); foreach ($profiles as $profile) { - $arrays[] = $this->twitter_user_array($profile, true); + $arrays[] = $this->twitter_user_array($profile, $includeStatuses); } print json_encode($arrays); break; diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 4115d9dcb..4737c5874 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -844,9 +844,9 @@ class TwitterapiAction extends Action $this->endXML(); } - function show_profile($profile, $content_type='xml', $notice=null) + function show_profile($profile, $content_type='xml', $notice=null, $includeStatuses=true) { - $profile_array = $this->twitter_user_array($profile, true); + $profile_array = $this->twitter_user_array($profile, $includeStatuses); switch ($content_type) { case 'xml': $this->show_twitter_xml_user($profile_array); -- cgit v1.2.3-54-g00ecf