summaryrefslogtreecommitdiff
path: root/views/settings.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2014-12-24 16:44:44 -0800
committerAaron Parecki <aaron@parecki.com>2014-12-24 16:44:44 -0800
commit2cd148c792a47fea18d760b723d23569ae52d390 (patch)
treecbd2d277d7c56be7042fc7765ea7a3c26c4cd1f8 /views/settings.php
parent3f090eeb306dec5041d3c2c3b6baa3434f31802b (diff)
Support for "likes" and adding "settings" page
* Supports a bookmarklet to create "like" posts. * Beginning a "settings" page to connect silo profiles for POSSEing likes to twitter, facebook and instagram
Diffstat (limited to 'views/settings.php')
-rw-r--r--views/settings.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/views/settings.php b/views/settings.php
new file mode 100644
index 0000000..61feefc
--- /dev/null
+++ b/views/settings.php
@@ -0,0 +1,88 @@
+<div class="narrow">
+ <?= partial('partials/header') ?>
+
+ <h2>Signed In As</h2>
+ <code><?= session('me') ?></code>
+
+ <h3>Facebook</h3>
+ <input type="button" id="facebook-button" value="Checking" class="btn">
+
+ <h3>Twitter</h3>
+ <input type="button" id="twitter-button" value="Checking" class="btn">
+
+
+ <!--
+ <h3>Instagram</h3>
+
+ -->
+
+</div>
+<script>
+window.quillFbInit = function() {
+ FB.getLoginStatus(function(response) {
+ if (response.status === 'connected') {
+ // the user is logged in and has authenticated your
+ // app, and response.authResponse supplies
+ // the user's ID, a valid access token, a signed
+ // request, and the time the access token
+ // and signed request each expire
+ var uid = response.authResponse.userID;
+ var accessToken = response.authResponse.accessToken;
+
+ save_facebook_token(response.authResponse.accessToken);
+
+ } else if (response.status === 'not_authorized') {
+ // the user is logged in to Facebook,
+ // but has not authenticated your app
+ console.log("Logged in but not authorized");
+
+ $("#facebook-button").val("Sign In").addClass("btn-warning");
+
+ } else {
+ // the user isn't logged in to Facebook.
+ console.log("User isn't logged in");
+
+ $("#facebook-button").val("Sign In").addClass("btn-warning");
+ }
+ });
+};
+window.quillHandleFbLogin = function(response) {
+ save_facebook_token(response.authResponse.accessToken);
+};
+
+function save_facebook_token(token) {
+ console.log("Authed with token: " + token);
+ $.post('/auth/facebook', {
+ fb_token: token
+ }, function(data){
+ $("#facebook-button").val("Connected").addClass("btn-success");
+ });
+}
+
+$(function(){
+ $.getJSON("/auth/twitter", function(data){
+ // Check if we're already authorized with twitter
+ if(data && data.result == 'ok') {
+ $("#twitter-button").val("Connected").addClass("btn-success");
+ } else if(data && data.url) {
+ $("#twitter-button").val("Sign In").data("url", data.url).addClass("btn-warning");
+ } else {
+ $("#twitter-button").val("Error").addClass("btn-danger");
+ }
+ });
+
+ $("#twitter-button").click(function(){
+ if($(this).data('url')) {
+ window.location = $(this).data('url');
+ } else {
+ $.getJSON("/auth/twitter", {login: 1}, function(data){
+ window.location = data.url;
+ });
+ }
+ });
+
+ $("#facebook-button").click(function(){
+ FB.login(window.quillHandleFbLogin, {scope:'publish_actions'});
+ });
+});
+</script>