Created
December 1, 2010 01:19
-
-
Save bradhintze/722767 to your computer and use it in GitHub Desktop.
Checks for Facebook Authorization on Flickr.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meta { | |
name "fb_flickr_likr" | |
description << | |
>> | |
author "Mark Horstmeier / Brad Hintze" | |
// Uncomment this line to require Marketplace purchase to use this app. | |
// authz require user | |
logging on | |
key facebook { | |
"consumer_key" : REDACTED, | |
"consumer_secret" : REDACTED | |
} | |
// use css resource jquery_ui_vader_css | |
use javascript resource jquery_ui_js | |
} | |
dispatch { | |
domain "flickr.com" | |
} | |
global { | |
hate = "http://tutorialresources.s3.amazonaws.com/FlickrLikr/Thumbs_Dn.jpeg"; | |
like = "http://tutorialresources.s3.amazonaws.com/FlickrLikr/Thumbs_Up.jpeg"; | |
} | |
rule auth_app is active { | |
select using ".*flickr.com" setting () | |
if (not facebook:authorized()) | |
then | |
facebook:authorize(["publish_stream","offline_access"]) | |
with opacity = 1 and | |
sticky = true; | |
fired { | |
last; | |
} | |
} | |
rule first_rule is active { | |
select when pageview ".*com/photos/([\w|@]+)/(\w+)" setting (username,photoid) | |
pre { | |
//pictitle = $K("#title_div4384114859").text(); | |
jq_uif = << | |
<div class="jLiker"><form id="jLikerForm" onsubmit="return false;"> | |
<input type="hidden" name="dummy" value="default" id="jAnchor"/> | |
<input type="hidden" name="mine" value="default"/> | |
<input type="hidden" name="mimg" value="default"/> | |
<input type="hidden" name="fuser" value="default"/> | |
<input type="hidden" name="ftitle" value="default"/> | |
<input type="image" name="lke" src="#{like}" alt="I like it" value="stink" | |
onclick="this.form.mine.value='love';this.form.mimg.value=$K('div.photo-div img').attr('src');this.form.ftitle.value=$K('#title_div4384114859').text();this.form.fuser.value='#{username}';" border="0" id="limg"/> | |
<input type="image" name="hte" src="#{hate}" alt="I hate it" onclick="this.form.mine.value='hate';this.form.mimg.value=$K('div.photo-div img').attr('src');this.form.fuser.value='#{username}';this.form.ftitle.value=$K('#title_div4384114859').text();" border="0" id="himg"/> | |
>>; | |
} | |
{ | |
before(".photo-title", jq_uif); | |
watch("#jLikerForm","submit"); | |
} | |
} | |
rule liker is active { | |
select when web submit "#LIKERForm" or web submit "#jLikerForm" | |
and pageview "(.*)" setting (myurl) | |
pre { | |
// Get the fb data needed for our post | |
mdata = facebook:metadata(); | |
fid =mdata.pick("$.id"); | |
fname = mdata.pick("$.first_name"); | |
// Read the data from our form | |
m = page:param("mine"); | |
pimg = page:param("mimg"); | |
fluser = page:param("fuser"); | |
fltitle = page:param("ftitle"); | |
subject = fname + " " + m + "s this picture by " + fluser; | |
// Just add the flickr url | |
from = myurl; | |
} | |
{ | |
facebook:post({"id" : fid, | |
"connection" : "feed", | |
"message" : subject, | |
"picture" : pimg, | |
"link" : from, | |
"description" : "Posted by Flickr Likr"}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule auth_app is active { | |
select using ".*flickr.com" setting () | |
if (not facebook:authorized()) | |
then | |
facebook:authorize(["publish_stream","offline_access"]) | |
with opacity = 1 and | |
sticky = true; | |
fired { | |
last; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule liker is active { | |
select when web submit "#LIKERForm" or web submit "#jLikerForm" | |
and pageview "(.*)" setting (myurl) | |
pre { | |
// Get the fb data needed for our post | |
mdata = facebook:metadata(); | |
fid =mdata.pick("$.id"); | |
fname = mdata.pick("$.first_name"); | |
// Read the data from our form | |
m = page:param("mine"); | |
pimg = page:param("mimg"); | |
fluser = page:param("fuser"); | |
fltitle = page:param("ftitle"); | |
subject = fname + " " + m + "s this picture by " + fluser; | |
// Just add the flickr url | |
from = myurl; | |
} | |
{ | |
facebook:post({"id" : fid, | |
"connection" : "feed", | |
"message" : subject, | |
"picture" : pimg, | |
"link" : from, | |
"description" : "Posted by Flickr Likr"}); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule first_rule is active { | |
select when pageview ".*com/photos/([\w|@]+)/(\w+)" setting (username,photoid) | |
pre { | |
//pictitle = $K("#title_div4384114859").text(); | |
jq_uif = << | |
<div class="jLiker"><form id="jLikerForm" onsubmit="return false;"> | |
<input type="hidden" name="dummy" value="default" id="jAnchor"/> | |
<input type="hidden" name="mine" value="default"/> | |
<input type="hidden" name="mimg" value="default"/> | |
<input type="hidden" name="fuser" value="default"/> | |
<input type="hidden" name="ftitle" value="default"/> | |
<input type="image" name="lke" src="#{like}" alt="I like it" value="stink" | |
onclick="this.form.mine.value='love';this.form.mimg.value=$K('div.photo-div img').attr('src');this.form.ftitle.value=$K('#title_div4384114859').text();this.form.fuser.value='#{username}';" border="0" id="limg"/> | |
<input type="image" name="hte" src="#{hate}" alt="I hate it" onclick="this.form.mine.value='hate';this.form.mimg.value=$K('div.photo-div img').attr('src');this.form.fuser.value='#{username}';this.form.ftitle.value=$K('#title_div4384114859').text();" border="0" id="himg"/> | |
>>; | |
} | |
{ | |
before(".photo-title", jq_uif); | |
watch("#jLikerForm","submit"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment