Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.

Localize loading of facebook javascript #3

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cbcfc25
ignoring IntelliJ IDEA project files
Mar 1, 2011
91a065c
adding a MANIFEST entry to allow autodiscovery of the library
Mar 1, 2011
ff2920d
updating the README to reflect the latest changes
Mar 1, 2011
dcbbcbf
tabifying
Mar 1, 2011
51ccca0
remove unnecessary favicon
ascandroli Mar 17, 2011
66ffa87
* removed FBInit
ascandroli Mar 17, 2011
0178155
adding back the event subscription to the Like component
ascandroli Mar 17, 2011
d1ab493
completely removing FBAsyncSupport
ascandroli Mar 17, 2011
ee3df05
version bump due to dep on Tapestry5 current trunk
mlusetti Mar 24, 2011
1ede1bc
code formatting, my eyes blurs
mlusetti Mar 24, 2011
4f0844f
just in case i need to localize FB messages/ui & co, more to come as …
mlusetti Mar 24, 2011
fd457c8
Merge remote branch 'upstream/master'
mlusetti Mar 25, 2011
c203687
fix a typo and do some debug logging
mlusetti Mar 25, 2011
faa7726
make the whole more in sync with the way Tapestry codes stuff
mlusetti Mar 28, 2011
36c2989
I stil dubious on how to handle some git features
mlusetti Mar 28, 2011
53c359f
Restore like callback events while defaulting them to null, thanks as…
mlusetti Mar 28, 2011
d335a99
typo
mlusetti Mar 28, 2011
73d72e0
typo, this happens when there's no test
mlusetti Mar 28, 2011
4689711
typo, this happens when there's no test
mlusetti Mar 28, 2011
88d4540
typo, this happens when there's no test
mlusetti Mar 28, 2011
b3c458a
typo, this happens when there's no test
mlusetti Mar 28, 2011
3416201
typo, this happens when there's no test
mlusetti Mar 28, 2011
7b0bc39
bring it back to a release...
mlusetti Mar 28, 2011
2f68b5e
some logging and a more sane defaults to IMMEDIATE for FB initializin…
mlusetti Mar 28, 2011
0fad8fb
Fix the "called before" issues due to the async nature of our previou…
mlusetti Mar 28, 2011
62b9651
Tapestry 5.2.5 is out in the wild
mlusetti Mar 30, 2011
fa5c68f
merging with mlusetti fork
ascandroli Apr 5, 2011
f777ad0
removing FacebookUtils, moving the test to LikeTest
ascandroli Apr 5, 2011
7addf56
removing FacebookUtils, moving the test to LikeTest
ascandroli Apr 5, 2011
1f26fd6
removing old FacebookModule
ascandroli Apr 5, 2011
2bf9c7b
removing an empty folder
ascandroli Apr 5, 2011
f3072e7
move forward
mlusetti Jan 3, 2012
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ local.properties
.classpath
.settings/
.loadpath
.idea
tapestry-facebook.iml
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ This Tapestry component library implements the Facebook XFBML async javascript l
Currently to use the components you need to build the source then add the following to your pom file.

<dependency>
<groupId>com.trsvax</groupId>
<artifactId>tapestry-facebook</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>com.trsvax</groupId>
<artifactId>tapestry-facebook</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>


Expand Down
39 changes: 13 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.trsvax</groupId>
<artifactId>tapestry-facebook</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.2.0-alpha-1</version>
<packaging>jar</packaging>
<name>tapestry-facebook Tapestry 5 Application</name>
<dependencies>
Expand Down Expand Up @@ -57,36 +57,23 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's
<optimize>true</optimize>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Tapestry-Module-Classes>com.trsvax.tapestry.facebook.services.FBModule</Tapestry-Module-Classes>
</manifestEntries>
</archive>
</configuration>
</plugin>

</plugins>
</build>

<reporting>

<!-- Adds a report detailing the components, mixins and base classes defined by this module. -->
<plugins>
<plugin>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-component-report</artifactId>
<version>${tapestry-release-version}</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<rootPackage>com.trsvax.tapestry.facebook</rootPackage>
<archive>
<manifestEntries>
<Tapestry-Module-Classes>com.trsvax.tapestry.facebook.services.FBModule</Tapestry-Module-Classes>
</manifestEntries>
</archive>
</configuration>
</plugin>

</plugins>
</reporting>
</build>

<reporting />

<repositories>

Expand All @@ -109,6 +96,6 @@ of a Tapestry Maven plugin is not required. -->
</pluginRepositories>

<properties>
<tapestry-release-version>5.2.4</tapestry-release-version>
<tapestry-release-version>5.3.1</tapestry-release-version>
</properties>
</project>
87 changes: 0 additions & 87 deletions src/main/java/com/trsvax/tapestry/facebook/FBInit.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//Copyright [2011] [Barry Books]

// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,32 +17,27 @@
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.trsvax.tapestry.facebook.services.FBAsyncSupport;

/**
* @author bfb
* Facebook XFBML Activity component
* @author bfb Facebook XFBML Activity component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/activity/">Activity</a>
*
*
*/
@SupportsInformalParameters
public class Activity {
public class Activity
{
@Inject
private ComponentResources componentResources;

@Environmental
private FBAsyncSupport fbAsyncSupport;

@BeginRender
void beginRender(MarkupWriter writer) {
fbAsyncSupport.render();
void beginRender(MarkupWriter writer)
{
writer.element("fb:activity");

componentResources.renderInformalParameters(writer);

writer.end();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//Copyright [2011] [Barry Books]

// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,26 +14,69 @@

package com.trsvax.tapestry.facebook.components;

import java.util.Locale;

import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.javascript.InitializationPriority;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
import org.slf4j.Logger;

import com.trsvax.tapestry.facebook.FBInit;
import com.trsvax.tapestry.facebook.services.FBAsyncSupport;

public class AsyncInit {

@Parameter(autoconnect=true,required=true)
private FBInit fbinit;
/**
*
*
*/
public class AsyncInit
{
@Inject
private Logger logger;
@Inject
private RequestGlobals requestGlobals;

@Environmental
private FBAsyncSupport fbAsyncSupport;
private JavaScriptSupport javaScriptSupport;

@Parameter(required = true)
private String appId;
@Parameter(value = "literal:true")
private boolean status;
@Parameter(value = "literal:true")
private boolean cookie;
@Parameter(value = "literal:true")
private boolean xfbml;
@Parameter(value = "literal:false")
private boolean logging;

void setupRender(MarkupWriter writer)
{
// Facebook app registration and initialization
writer.element("div", "id", "fb-root");
writer.end();
}

@BeginRender
void beginRender(MarkupWriter writer) {
fbAsyncSupport.init(fbinit);
void beginRender(MarkupWriter writer)
{
Locale locale = requestGlobals.getRequest().getLocale();
String lang = locale.getLanguage();
String country = locale.getCountry();

if (country == null || country.trim().length() == 0)
country = lang.toUpperCase();

logger.debug("Intializing FB object. Locale defined as {} {}", lang, country);

javaScriptSupport.importJavaScriptLibrary(String.format("http://connect.facebook.net/%s_%s/all.js", lang, country));

String fbInit = "FB.init({appId: '%s', status: %s, cookie: %s, xfbml: %s, logging: %s});";

javaScriptSupport.addScript(
InitializationPriority.IMMEDIATE,
fbInit,
appId, status, cookie, xfbml, logging);
}

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//Copyright [2011] [Barry Books]

// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,35 +17,28 @@
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.trsvax.tapestry.facebook.services.FBAsyncSupport;


/**
* @author bfb
* Facebook XFBML Comments component
* @author bfb Facebook XFBML Comments component
* @see <a href="http://developers.facebook.com/docs/reference/plugins/comments/">Comments</a>
*
*
*/
@SupportsInformalParameters
public class Comments {
public class Comments
{
@Inject
private ComponentResources componentResources;

@Environmental
private FBAsyncSupport fbAsyncSupport;

@BeginRender
void beginRender(MarkupWriter writer) {
fbAsyncSupport.render();
void beginRender(MarkupWriter writer)
{
writer.element("fb:comments");

componentResources.renderInformalParameters(writer);

writer.end();
}


}
}
Loading