Permalink
Browse files

rough and ready update FBML > Javascript SDK; tidy UX with Twitter Bo…

…otstrap
  • Loading branch information...
1 parent f586b99 commit a92768fc7906fff631952934ddede9cc66cb01a1 @andyyoung committed Jul 16, 2012
View
@@ -84,8 +84,11 @@ public function getCanPostToPages()
*/
public function redirect($url)
{
- header('Location: ' . $url);
- // echo '<script>top.location.href = \'' . $url . "';</script>";
+ if (substr($url, 0, 1) == '/') {
+ header('Location: ' . $url);
+ } else {
+ echo "<script>window.top.location = '" . $url . "';</script>";
+ }
exit();
}
@@ -211,6 +214,7 @@ public function saveSettings()
$replace_names = !empty($_POST['replace_names']) ? 1 : 0;
$prefix = isset($_POST['prefix']) ? $_POST['prefix'] : '';
$this->db->exec("UPDATE selective_status_users SET allow_tag_anywhere = " . $this->db->quote($allow_tag_anywhere) . ", replace_names = " . $this->db->quote($replace_names) . ", show_twitter_link = " . $this->db->quote($show_follow_link) . ", prefix = " . $this->db->quote($prefix) . " WHERE fbuid = " . $this->db->quote($fbuid) . " LIMIT 1");
+ return true;
}
}
}
View
@@ -11,6 +11,10 @@
// must remember not to disclose actual secrets/passwords on github..
require '/etc/selectivetweets.conf.php';
+if (!defined('ROOT_URL')) {
+ define('ROOT_URL', '/');
+}
+
/*
the config file should define the following constants:
@@ -23,6 +27,8 @@
define('FB_APP_ID', 'app_id');
define('FB_APP_SECRET', 'secret');
+define('ROOT_URL', '/'); // absolute or relative URL for links to where the app is hosted
+
define('TWITTER_API_USER', 'username');
define('TWITTER_API_PASSWORD', 'password');
View
@@ -1,33 +1,39 @@
-<div style="float: left; width: 140px; padding-top: 10px;">
+<div style="margin-top: 20px;">
+<div style="float: left; width: 140px;">
<a href="https://twitter.com/andyy" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @andyy</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<p>
This app was built by me - <a href="http://twitter.com/andyy">@andyy</a>. I hope you find it useful! It's been growing quite popular, so if it helps you, your company, brand or cause, you may like to consider making a small donation.. :)
</p>
+</div>
-<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="4817248">
-<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make a donation using PayPal" style="vertical-align: middle;">
-<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
-
+<p style="text-align: center;">
+ <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" width="92" height="26" name="submit" alt="Make a donation using PayPal" style="vertical-align: middle; width:92px;">
+</p>
</form>
-<p>The code behind Selective Tweets is now available on GitHub -<br />
+<div style="margin: 20px 0;"><fb:facepile width="740"></fb:facepile></div>
+
+<p style="text-align: center;">The code behind Selective Tweets is now available on GitHub -<br />
Read the blog post: <a href="http://insomanic.me.uk/post/15507274276/selective-tweets-open-source?from=app">Selective Tweets: 3 years, 1 million users, now open-source!</a></p>
-<img src="/sts/img/github_logo.png" width="55" height="22" style="float: left; margin-right: 30px;" alt="" />
+<div style="text-align: center; padding-bottom: 40px;">
+<img src="/sts/img/github_logo.png" width="55" height="22" style="margin-right: 30px; vertical-align:top;" alt="" />
-<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=andyyoung&repo=Selective-Tweets&type=watch&count=true"
+<iframe src="<?php echo ROOT_URL; ?>misc/github-btn.html?user=andyyoung&repo=Selective-Tweets&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
-<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=andyyoung&repo=Selective-Tweets&type=fork&count=true"
+<iframe src="<?php echo ROOT_URL; ?>misc/github-btn.html?user=andyyoung&repo=Selective-Tweets&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="95px" height="20px"></iframe>
-<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=andyyoung&type=follow&count=true"
+<iframe src="<?php echo ROOT_URL; ?>misc/github-btn.html?user=andyyoung&type=follow&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="165px" height="20px"></iframe>
+</div>
</body>
</html>
View
@@ -1,9 +1,13 @@
-<html>
-<head>
+<!DOCTYPE html>
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
+ <head>
+ <meta charset="utf-8">
+
+<link rel="stylesheet" type="test/css" href="<?php echo ROOT_URL; ?>css/bootstrap.min.css" />
<style type="text/css">
body, td {
- font-size: 11px;
+ font-size: 12px;
color: #333;
font-family: 'lucida grande', tahoma, verdana, arial;
}
@@ -13,6 +17,14 @@
<meta property="og:title" content="Selective Tweets"/>
<meta property="og:image" content="http://graph.facebook.com/selectivetwitter/picture?type=large"/>
+<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
+
+<script type="text/javascript">
+ $(document).ready(function() {
+ // This is more like it!
+ });
+</script>
+
<script type="text/javascript">
var _gaq = _gaq || [];
@@ -30,9 +42,33 @@
</head>
<body>
-<h1 style="margin-top: 15px;">Welcome to Selective Tweets!</h1>
+<div id="fb-root"></div>
+<script>
+ window.fbAsyncInit = function() {
+ FB.init({
+ appId : '<?php echo FB_APP_ID; ?>',
+ channelUrl : '<?php echo ROOT_URL; ?>channel.html',
+ status : true, // check login status
+ cookie : true, // enable cookies to allow the server to access the session
+ xfbml : true // parse XFBML
+ });
+ };
+
+ // Load the SDK Asynchronously
+ (function(d){
+ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
+ if (d.getElementById(id)) {return;}
+ js = d.createElement('script'); js.id = id; js.async = true;
+ js.src = "//connect.facebook.net/en_US/all.js";
+ ref.parentNode.insertBefore(js, ref);
+ }(document));
+</script>
+
+
+<h1 style="margin-top: 15px;">Welcome to Selective Tweets! (#fb)</h1>
-<p>Selective Tweets lets you update your Facebook status from Twitter - <br>BUT you can choose which tweets you want - just end a tweet with <strong>#fb</strong> when you want to post it as your Facebook status - simple!</p>
+<p style="font-size: 15px; line-height: 19px;">Selective Tweets lets you update your Facebook status from Twitter - BUT only when you want.
+<br /><strong>Just end a tweet with the #fb hashtag</strong> when you want it to post to Facebook - simple!</p>
<?php include 'tabs.php'; ?>
View
@@ -1,45 +1,14 @@
<?php
-
-/*if ($fbuid) {
-
- connect_db();
-
- $rs = $_db->query("SELECT last_timestamp from sts_delay ORDER BY id desc limit 1");
- if ($row = $rs->fetch()) {
- $delay = time() - $row['last_timestamp'];
- $delay = $delay / 60;
-
- $h = (int) ($delay / 60);
- $m = $delay % 60;
-
- if ($delay <= 4) {
- echo '<p>Current time to update: <strong>less than 2 minutes</strong> - everything is working normally :)</p>';
- } elseif ($delay < 15) {
- echo '<p>Current time to update: <strong>' . ($h ? ($h . ' hour' . ($h > 1 ? 's ' : ' ')) : '') . $m . ' minutes</strong>. Twitter is under heavy load right now. :(<br>Usually the delay is under 2 minutes - We\'ll sync your tweets as soon as Twitter gives them to us!</p>';
- } else {
- echo '<p>Current time to update: <strong>' . ($h ? ($h . ' hour' . ($h > 1 ? 's ' : ' ')) : '') . $m . ' minutes</strong>. Sorry, Twitter is having problems at the moment :(<br>Usually the delay is under 2 minutes - We\'ll sync your tweets as soon as Twitter gives them to us!</p>';
- }
- }
-}
-
-<p style="padding: 10px; background-color: #ffebe8; border: 1px solid red;"><strong>Status Update Dec 29th 15:00 GMT: Normal service resumed</strong><br>
-Facebook has now restored this app - your updates should post again and previous updates reappear on your profile.<br>
-If you continue to experience problems please try reentering your twitter name below
-<?php /* Facebook has temporarily prevented this app from posting your updates. You may notice that previous updates have also been hidden. I've contacted Facebook and they should restore this app within the next 24 hours - thanks for your patience.<br>In the meantime you can still sign up or edit your settings.<br>
-<a href="http://www.facebook.com/selectivetwitter?sk=wall">More info on the app page</a> &middot; Follow <a href="http://twitter.com/andyy">@andyy</a> for updates* / ?>
-</p>
-
-<?php
-*/
-
$qs = '';
if (!empty($_REQUEST['fb_page_id'])) {
$qs = '?fb_page_id=' . htmlspecialchars(urlencode($_REQUEST['fb_page_id']));
}
?>
-<ul class="tabs">
- <li><a href="https://apps.facebook.com/selectivetwitter/<?php echo $qs; ?>" <?php if (!(strpos($_SERVER['REQUEST_URI'], 'settings') || strpos($_SERVER['REQUEST_URI'], 'pages') || strpos($_SERVER['REQUEST_URI'], 'help'))) echo 'class="selected" '; ?>>Your Profile</a></li>
- <li><a href="https://apps.facebook.com/selectivetwitter/pages<?php echo $qs; ?>" <?php if (strpos($_SERVER['REQUEST_URI'], 'pages')) echo 'class="selected" '; ?>>Your Pages</a></li>
- <li><a href="https://apps.facebook.com/selectivetwitter/settings<?php echo $qs; ?>" <?php if (strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'class="selected" '; ?>>Settings</a></li>
- <li><a href="https://apps.facebook.com/selectivetwitter/help<?php echo $qs; ?>" <?php if (strpos($_SERVER['REQUEST_URI'], 'help')) echo "selected='true' "; ?>>Help</a></li>
- </ul>
+
+<ul class="nav nav-tabs">
+ <li <?php if (!(strpos($_SERVER['REQUEST_URI'], 'settings') || strpos($_SERVER['REQUEST_URI'], 'pages') || strpos($_SERVER['REQUEST_URI'], 'help'))) echo 'class="active" '; ?>><a href="<?php echo ROOT_URL . $qs; ?>">Your Profile</a></li>
+ <li <?php if (strpos($_SERVER['REQUEST_URI'], 'pages')) echo 'class="active" '; ?>><a href="<?php echo ROOT_URL; ?>pages<?php echo $qs; ?>" >Your Pages</a></li>
+ <li <?php if (strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'class="active" '; ?>><a href="<?php echo ROOT_URL; ?>settings<?php echo $qs; ?>">Settings</a></li>
+ <li <?php if (strpos($_SERVER['REQUEST_URI'], 'help')) echo 'class="active" '; ?>><a href="<?php echo ROOT_URL; ?>help<?php echo $qs; ?>">Help</a></li>
+</ul>
+
View
@@ -0,0 +1,8 @@
+<?php
+$cache_expire = 60*60*24*365;
+header("Pragma: public");
+header("Cache-Control: max-age=".$cache_expire);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
+?>
+<script src="//connect.facebook.net/en_US/all.js"></script>
+
Oops, something went wrong.

0 comments on commit a92768f

Please sign in to comment.