Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Resources plugin integration (FacebookSdkResources created) + doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Hediard committed Oct 29, 2012
1 parent 4cfcb51 commit e668b2b
Show file tree
Hide file tree
Showing 22 changed files with 322 additions and 134 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -75,7 +75,7 @@ Project documentation is located here :
WARNING: Since V0.4.0, _FacebookApp_, _FacebookSdkFilters_ and _FacebookAppService_ from V0.3.* are DEPRECATED and have been replaced by _FacebookContext_.
Please check [FacebookContext](http://benorama.github.com/grails-facebook-sdk/guide/facebookContext.html) doc for more info.

* 2012-10-25 **V0.4.3** : channel integration added in fb-init tag
* 2012-10-29 **V0.4.3** : tag lib improvements: channel integration (_initJS_ tag), resources plugin integration (_FacebookSdkResources_ created)
* 2012-10-10 **V0.4.2** : bug fix in batch responses error handling
* 2012-09-25 **V0.4.1** : bug fix in server side OAuth redirect
* 2012-09-25 **V0.4.0** : complete refactoring to improve SDK architecture ([FacebookContext](http://benorama.github.com/grails-facebook-sdk/guide/facebookContext.html) implemented) and [multiple apps support](http://benorama.github.com/grails-facebook-sdk/guide/configuration.html) added
Expand Down
33 changes: 33 additions & 0 deletions grails-app/conf/FacebookSdkResources.groovy
@@ -0,0 +1,33 @@
modules = {

'fb-sdk-add-to-page-link' {
defaultBundle 'fb-sdk'
resource url: '/js/add-to-page-link.js'
}

'fb-sdk-invite-link' {
defaultBundle 'fb-sdk'
resource url: '/js/invite-link.js'
}

'fb-sdk-login-link' {
defaultBundle 'fb-sdk'
resource url: '/js/login-link.js'
}

'fb-sdk-logout-link' {
defaultBundle 'fb-sdk'
resource url: '/js/logout-link.js'
}

'fb-sdk-publish-link' {
defaultBundle 'fb-sdk'
resource url: '/js/publish-link.js'
}

'fb-sdk-send-link' {
defaultBundle 'fb-sdk'
resource url: '/js/send-link.js'
}

}
Expand Up @@ -52,11 +52,12 @@ class FacebookJSTagLib {
/**
* Add to page link (https://developers.facebook.com/docs/reference/dialogs/add_to_page/)
*
* @attr callback Optional javascript function name to call when dialog is confirmed or closed.
* @attr disabled Disable click on the link.
* @attr display Display mode in which to render the Dialog. Can be page (default), popup, iframe, or touch.
* @attr elementClass HTML element 'class' attribute value.
* @attr elementId HTML element 'id' attribute value.
* @attr returnUrl Return URL for redirect after login (if not defined page will be reloaded)
* @attr returnUrl Redirect URL after the page is added
*/
def addToPageLink = {attrs, body ->
Map model = [body:body()]
Expand Down Expand Up @@ -137,6 +138,7 @@ class FacebookJSTagLib {
/**
* Invite link (https://developers.facebook.com/docs/reference/dialogs/requests/)
*
* @attr callback Optional javascript function name to call when dialog is confirmed or closed.
* @attr data Additional data you may pass for tracking. The maximum length is 255 characters.
* @attr disabled Disable click on the link.
* @attr display Display mode in which to render the Dialog. Can be 'page' (default), 'popup', 'iframe', or 'touch'.
Expand All @@ -160,6 +162,7 @@ class FacebookJSTagLib {
/**
* Publish link (https://developers.facebook.com/docs/reference/dialogs/feed/)
*
* @attr callback Optional javascript function name to call when dialog is confirmed or closed.
* @attr disabled Disable click on the link.
* @attr display Display mode in which to render the Dialog. Can be page (default), popup, iframe, or touch.
* @attr caption The caption of the link (appears beneath the link name). If not specified, this field is automatically populated with the URL of the link.
Expand All @@ -182,6 +185,7 @@ class FacebookJSTagLib {
/**
* Send link (https://developers.facebook.com/docs/reference/dialogs/send/)
*
* @attr callback Optional javascript function name to call when dialog is confirmed or closed.
* @attr disabled Disable click on the link.
* @attr display Display mode in which to render the Dialog. Can be page (default), popup, iframe, or touch.
* @attr description The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page.
Expand Down
21 changes: 10 additions & 11 deletions grails-app/views/facebook-sdk/_add-to-page-link.gsp
@@ -1,11 +1,10 @@
<g:if test="${!disabled}">
<r:script disposition="footer">
function FBGrailsSDK_addToPage() {
FB.ui({
'method':'pagetab'
}<g:if test="${callBackJS}">, ${callBackJS}</g:if>);
return false;
}
</r:script>
</g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="<g:if test="${!disabled}">FBGrailsSDK_addToPage();</g:if><g:else>return false;</g:else>">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-add-to-page-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-add-to-page-link"
<g:if test="${callback}">data-callback="${callback}"</g:if>
<g:if test="${display}">data-display="${display}"</g:if>
<g:if test="${returnUrl}">data-return_url="${returnUrl}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
35 changes: 16 additions & 19 deletions grails-app/views/facebook-sdk/_invite-link.gsp
@@ -1,20 +1,17 @@
<%@ page import="grails.converters.JSON" %>
<g:if test="${!disabled}">
<r:script disposition="footer">
function FBGrailsSDK_invite() {
FB.ui({
method: 'apprequests',
message: '${message.encodeAsJavaScript()}'
<g:if test="${data}">, data: '${data}'</g:if>
<g:if test="${display}">, 'display':'${display}'</g:if>
<g:if test="${excludeIds}">, exclude_ids: '${excludeIds as JSON}'</g:if>
<g:if test="${filters}">, filters: ${filters as JSON}</g:if>
<g:if test="${maxRecipients}">, max_recipients: ${maxRecipients}</g:if>
<g:if test="${title}">, title: '${title.encodeAsJavaScript()}'</g:if>
<g:if test="${to}">, to: '${to}'</g:if>
}<g:if test="${callBackJS}">, ${callBackJS}</g:if>);
return false;
}
</r:script>
</g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="<g:if test="${!disabled}">FBGrailsSDK_invite();</g:if><g:else>return false;</g:else>">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-invite-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-invite-link"
data-message="${message.encodeAsJavaScript()}"
<g:if test="${callback}">data-callback="${callback}"</g:if>
<g:if test="${data}">data-data="${data}"</g:if>
<g:if test="${display}">data-display="${display}"</g:if>
<g:if test="${excludeIds}">data-exclude_ids="${(excludeIds as JSON).toString().replace('"',"'")}"</g:if>
<g:if test="${filters}">data-filters="${(filters as JSON).toString().replace('"',"'")}"</g:if>
<g:if test="${maxRecipients}">data-max_recipients="${maxRecipients}"</g:if>
<g:if test="${title}">data-title="${title.encodeAsJavaScript()}"</g:if>
<g:if test="${to}">data-to="${to}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
34 changes: 10 additions & 24 deletions grails-app/views/facebook-sdk/_login-link.gsp
@@ -1,24 +1,10 @@
<g:if test="${appPermissions instanceof List}">
<g:set var="appPermissions" value="${appPermissions.join(',')}" />
</g:if>
<r:script disposition="footer">
function FBGrailsSDK_login() {
FB.login(function(response) {
if (response.authResponse) {
// user is logged
<g:if test="${returnUrl}">
window.location.href = "${returnUrl}";
</g:if>
<g:else>
window.location.reload();
</g:else>
<g:if test="${cancelUrl}">
} else {
// user cancelled login
window.location.href = "${cancelUrl}";
</g:if>
}
}, {scope:"${appPermissions}"});
}
</r:script>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="FBGrailsSDK_login();">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-login-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-login-link"
data-permissions="${appPermissions instanceof List ? appPermissions.join(',') : appPermissions}"
<g:if test="${cancelUrl}">data-cancel_url="${cancelUrl}"</g:if>
<g:if test="${returnUrl}">data-return_url="${returnUrl}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
32 changes: 8 additions & 24 deletions grails-app/views/facebook-sdk/_logout-link.gsp
@@ -1,24 +1,8 @@
<r:script disposition="footer">
function FBGrailsSDK_logout() {
FB.getLoginStatus(function(response) {
if (response.authResponse) {
FB.logout(function(response) {
<g:if test="${nextUrl}">
window.location.href = "${nextUrl}";
</g:if>
<g:else>
window.location.reload();
</g:else>
});
} else {
<g:if test="${nextUrl}">
window.location.href = "${nextUrl}";
</g:if>
<g:else>
window.location.reload();
</g:else>
}
});
}
</r:script>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="FBGrailsSDK_logout();">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-logout-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-logout-link"
<g:if test="${nextUrl}">data-next_url="${nextUrl}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
33 changes: 15 additions & 18 deletions grails-app/views/facebook-sdk/_publish-link.gsp
@@ -1,18 +1,15 @@
<g:if test="${!disabled}">
<r:script disposition="footer">
function FBGrailsSDK_publish() {
FB.ui({
'method':'feed'
<g:if test="${display}">, 'display':'${display}'</g:if>
<g:if test="${caption}">, 'caption':'${caption.encodeAsJavaScript()}'</g:if>
<g:if test="${description}">, 'description':'${description.encodeAsJavaScript()}'</g:if>
<g:if test="${link}">, 'link':'${link}'</g:if>
<g:if test="${name}">, 'name':'${name.encodeAsJavaScript()}'</g:if>
<g:if test="${picture}">, 'picture':'${picture}'</g:if>
<g:if test="${source}">, 'source':'${source}'</g:if>
}<g:if test="${callBackJS}">, ${callBackJS}</g:if>);
return false;
}
</r:script>
</g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="<g:if test="${!disabled}">FBGrailsSDK_publish();</g:if><g:else>return false;</g:else>">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-publish-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-publish-link"
<g:if test="${callback}">data-callback="${callback}"</g:if>
<g:if test="${caption}">data-caption="${caption.encodeAsJavaScript()}"</g:if>
<g:if test="${display}">data-display="${display}"</g:if>
<g:if test="${description}">data-description="${description.encodeAsJavaScript()}"</g:if>
<g:if test="${link}">data-link="${link}"</g:if>
<g:if test="${name}">data-name="${name.encodeAsJavaScript()}"</g:if>
<g:if test="${picture}">data-picture="${picture}"</g:if>
<g:if test="${source}">data-source="${source}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
30 changes: 13 additions & 17 deletions grails-app/views/facebook-sdk/_send-link.gsp
@@ -1,17 +1,13 @@
<g:if test="${!disabled}">
<r:script disposition="footer">
function FBGrailsSDK_send() {
FB.ui({
'method':'send',
'to': ${to}
<g:if test="${display}">, 'display':'${display}'</g:if>
<g:if test="${description}">, 'description':'${description.encodeAsJavaScript()}'</g:if>
<g:if test="${link}">, 'link':'${link}'</g:if>
<g:if test="${name}">, 'name':'${name.encodeAsJavaScript()}'</g:if>
<g:if test="${picture}">, 'picture':'${picture}'</g:if>
}<g:if test="${callBackJS}">, ${callBackJS}</g:if>);
return false;
}
</r:script>
</g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if> <g:if test="${elementClass}">class="${elementClass}"</g:if> href="#" onclick="<g:if test="${!disabled}">FBGrailsSDK_send();</g:if><g:else>return false;</g:else>">${body}</a>
<g:if test="${!disabled}"><r:require module="fb-sdk-send-link" /></g:if>
<a <g:if test="${elementId}">id="${elementId}"</g:if>
class="<g:if test="${elementClass}">${elementClass} </g:if>fb-sdk-send-link"
data-to="${to}"
<g:if test="${display}">data-display="${display}"</g:if>
<g:if test="${description}">data-description="${description.encodeAsJavaScript()}"</g:if>
<g:if test="${link}">data-link="${link}"</g:if>
<g:if test="${name}">data-name="${name.encodeAsJavaScript()}"</g:if>
<g:if test="${picture}">data-picture="${picture}"</g:if>
<g:if test="${disabled}">disabled="disabled"</g:if>
href="#">
${body}
</a>
2 changes: 1 addition & 1 deletion src/docs/guide/introduction.gdoc
Expand Up @@ -21,7 +21,7 @@ WARNING: Since V0.4.0, @FacebookApp@, @FacebookSdkFilters@ and @FacebookAppServi
Please check [@FacebookContext@|guide:facebookContext] doc for more info.
{warning}

* 2012-10-25 *V0.4.3* : channel integration added in fb-init tag
* 2012-10-25 *V0.4.3* : tag lib improvements: channel integration (@initJS@ tag), resources plugin integration (@FacebookSdkResources@ created)
* 2012-10-10 *V0.4.2* : bug fix in batch responses error handling
* 2012-09-25 *V0.4.1* : bug fix in server side OAuth redirect
* 2012-10-25 *V0.4.0* : complete refactoring to improve SDK architecture ([@FacebookContext@|guide:facebookContext] implemented) and [multiple Facebook apps|guide:configuration] support added
Expand Down
16 changes: 12 additions & 4 deletions src/docs/ref/Tags/addToPageLink.gdoc
Expand Up @@ -10,11 +10,19 @@ The *Add Page Tab* Dialog prompts the user to add an app to a Facebook Page that
<facebook:addToPageLink>Add this app to your Facebook Page</facebook:addToPageLink>
{code}

To check if the app was successfully added or execute some code, you can use @callBackJS@ attribute.
To check if the app was successfully added or execute some code, you can use @callback@ attribute.

{code}
<script>
function someCallbackFunction(response) {
alert('callback called!');
alert(response && response.tabs_added.length + ' app added');
console.log(response);
}
</script>

<facebook:addToPageLink
callBackJS="function(response) {alert(response && response.tabs_added.length + ' app added')}">
callback="someCallbackFunction">
Add to page
</facebook:addToPageLink>
{code}
Expand All @@ -26,9 +34,9 @@ You must define the page tab URLs on your app settings to enable this dialog.
h3. Attributes

Optional attributes are :
* @callBackJS@ Javascript to code to execute on call back (if the user send the form or close the dialog).
* @callback@ Optional javascript function name to call when dialog is confirmed or closed.
* @disabled@ Disable click on the link.
* @display@ Display mode in which to render the Dialog. Can be page (default for web), touch (default for mobile), popup or iframe.
* @elementClass@ HTML element @class@ attribute value.
* @elementId@ HTML element @id@ attribute value.

* @redirectUri@ Redirect URL after the page is added
16 changes: 12 additions & 4 deletions src/docs/ref/Tags/sendLink.gdoc
Expand Up @@ -7,14 +7,22 @@ Display a link to open "Send Dialog":https://developers.facebook.com/docs/refere
The *Send Dialog* lets people to send content to specific friends. They'll have the option to privately share a link as a Facebook message, Group post or email.

{code}
<facebook:sendLink to="594317994">Send a link to a friend</facebook:sendLink>
<facebook:sendLink link="http://www.google.com" to="594317994">Send a link to a friend</facebook:sendLink>
{code}

To check if the app was successfully added or execute some code, you can use @callBackJS@ attribute.
To check if the app was successfully added or execute some code, you can use @callback@ attribute.

{code}
<script>
function someCallbackFunction(response) {
alert('callback called!');
if (response && response.success) alert('Sent successfully');
console.log(response);
}
</script>

<facebook:sendLink
callBackJS="function(response) {if (response && response.success) alert('Sent successfully')}"
callback="someCallbackFunction"
link="http://www.google.com"
to="594317994">
Send a link to a friend
Expand All @@ -28,7 +36,7 @@ Required attributes are :
* @to@ A user ID or username to which to send the message.

Optional attributes are :
* @callBackJS@ Javascript to code to execute on call back (if the user send the form or close the dialog).
* @callback@ Optional javascript function name to call when dialog is confirmed or closed.
* @disabled@ Disable click on the link.
* @description@ The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page.
* @elementClass@ HTML element 'class' attribute value.
Expand Down
13 changes: 10 additions & 3 deletions src/docs/ref/tags/inviteLink.gdoc
Expand Up @@ -10,11 +10,18 @@ The *Request Dialog* sends a Request from one user (the sender) to one or more u
<facebook:inviteLink message="Check this app!">Invite your friends</facebook:inviteLink>
{code}

To check if the app was successfully added or execute some code, you can use @callBackJS@ attribute.
To check if the app was successfully added or execute some code, you can use @callback@ attribute.

{code}
<script>
function someCallbackFunction(response) {
alert('callback called!');
console.log(response);
}
</script>

<facebook:inviteLink
callBackJS="function(response) {console.log(response)}"
callback="someCallbackFunction"
message="Check this app!">
Invite your friends
</facebook:inviteLink>
Expand All @@ -26,7 +33,7 @@ Required attribute is :
* @message@ The Request string the receiving user will see. The maximum length is 60 characters.

Optional attributes are :
* @callBackJS@ Javascript to code to execute on call back (if the user send the form or close the dialog).
* @callback@ Optional javascript function name to call when dialog is confirmed or closed.
* @data@ Additional data you may pass for tracking. The maximum length is 255 characters.
* @disabled@ Disable click on the link.
* @display@ Display mode in which to render the Dialog. Can be page (default for web), touch (default for mobile), popup or iframe.
Expand Down

0 comments on commit e668b2b

Please sign in to comment.