Browse Source
Support for "likes" and adding "settings" page
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 instagrampull/5/head
Aaron Parecki
10 years ago
14 changed files with 419 additions and 44 deletions
-
3composer.json
-
67composer.lock
-
160controllers/controllers.php
-
7lib/config.template.php
-
20lib/helpers.php
-
17public/css/favorite.css
-
BINpublic/images/quill-logo-1024.png
-
8public/images/red-x.svg
-
8public/images/star.svg
-
23public/js/fav.js
-
8views/layout.php
-
22views/liked-js.php
-
20views/partials/fb-script.php
-
88views/settings.php
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
#quill-star { |
||||
|
position: absolute; |
||||
|
|
||||
|
top: 50%; |
||||
|
left: 50%; |
||||
|
margin-top: -100px; |
||||
|
margin-left: -100px; |
||||
|
|
||||
|
width: 200px; |
||||
|
height: 200px; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#quill-star.hidden { |
||||
|
display: none; |
||||
|
} |
After Width: 1024 | Height: 1024 | Size: 38 KiB |
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> |
||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" |
||||
|
width="108px" height="108px" viewBox="0 0 108 108" enable-background="new 0 0 108 108" xml:space="preserve"> |
||||
|
<line fill="none" stroke="#972D2C" stroke-width="20" stroke-miterlimit="10" x1="8.788" y1="8.308" x2="99.81" y2="99.329"/> |
||||
|
<line fill="none" stroke="#972D2C" stroke-width="20" stroke-miterlimit="10" x1="99.81" y1="8.308" x2="8.788" y2="99.329"/> |
||||
|
</svg> |
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> |
||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" |
||||
|
width="108px" height="108px" viewBox="0 0 108 108" enable-background="new 0 0 108 108" xml:space="preserve"> |
||||
|
<polygon fill="#FCB117" points="54.306,4.549 70.476,37.312 106.633,42.566 80.47,68.069 86.646,104.079 54.306,87.077 |
||||
|
21.967,104.079 28.143,68.069 1.98,42.566 38.136,37.312 "/> |
||||
|
</svg> |
@ -0,0 +1,23 @@ |
|||||
|
console.log("Favoriting with token: " + quill_token); |
||||
|
|
||||
|
var http = new XMLHttpRequest(); |
||||
|
var params = "like-of=" + encodeURIComponent(window.location) + "&token=" + quill_token; |
||||
|
|
||||
|
http.open("POST", "http://quill.dev/favorite", true); |
||||
|
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
||||
|
|
||||
|
http.onreadystatechange = function() {//Call a function when the state changes.
|
||||
|
console.log(http); |
||||
|
if(http.readyState == 4 && http.status == 200) { |
||||
|
alert(http.responseText); |
||||
|
} |
||||
|
} |
||||
|
http.send(params); |
||||
|
|
||||
|
/* |
||||
|
|
||||
|
(function(){var el=document.createElement('input'); el.type="hidden"; el.id="quill_token"; el.value="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMjciLCJtZSI6Imh0dHA6XC9cL2Fhcm9ucGFyZWNraS5jb20iLCJjcmVhdGVkX2F0IjoxNDEwMTE3NTM5fQ.ifp1VIgCTz9NPtMTlTLPBXAGSxHwpGS5tLPhXGxrjNk"; document.body.appendChild(el); document.body.appendChild(document.createElement('script')).src='http://quill.dev/js/fav.js';})(); |
||||
|
|
||||
|
(function(){document.body.appendChild(document.createElement('script')).src='http://quill.dev/favorite.js?url='+encodeURIComponent(window.location)+'&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMSIsIm1lIjoiaHR0cDpcL1wvcGsuZGV2XC8iLCJjcmVhdGVkX2F0IjoxNDE5MDM2NzAzfQ.AgJ5xyviiBzWOvQO0je0Bdi3BUpKJ4CLJnx8GIm-0OI';})(); |
||||
|
|
||||
|
*/ |
@ -0,0 +1,22 @@ |
|||||
|
<?= $this->facebook_id ? partial('partials/fb-script') : '' ?>
|
||||
|
|
||||
|
console.log("Favoriting URL: <?= $this->url ?>"); |
||||
|
|
||||
|
var star = document.createElement('img'); |
||||
|
star.id="quill-star"; |
||||
|
star.src="http://quill.dev/images/<?= $this->like_url ? 'star' : 'red-x' ?>.svg"; |
||||
|
document.body.appendChild(star); |
||||
|
|
||||
|
var css = document.createElement('link'); |
||||
|
css.rel="stylesheet"; |
||||
|
css.type="text/css"; |
||||
|
css.href="http://quill.dev/css/favorite.css"; |
||||
|
document.body.appendChild(css); |
||||
|
|
||||
|
setTimeout(function(){ |
||||
|
|
||||
|
document.getElementById('quill-star').classList.add('hidden'); |
||||
|
var el = document.getElementById('quill-star'); |
||||
|
el.parentNode.removeChild(el); |
||||
|
|
||||
|
}, 1200); |
@ -0,0 +1,20 @@ |
|||||
|
<script> |
||||
|
window.fbAsyncInit = function() { |
||||
|
FB.init({ |
||||
|
appId : '<?= Config::$fbClientID ?>', |
||||
|
xfbml : true, |
||||
|
version : 'v2.2' |
||||
|
}); |
||||
|
if(window.quillFbInit) { |
||||
|
window.quillFbInit(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
(function(d, s, id){ |
||||
|
var js, fjs = d.getElementsByTagName(s)[0]; |
||||
|
if (d.getElementById(id)) {return;} |
||||
|
js = d.createElement(s); js.id = id; |
||||
|
js.src = "//connect.facebook.net/en_US/sdk.js"; |
||||
|
fjs.parentNode.insertBefore(js, fjs); |
||||
|
}(document, 'script', 'facebook-jssdk')); |
||||
|
</script> |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue