Rewriting to be Grizzly independent and also ajusting to Twitter's removal of 1.0 APIs
1.1 --- a/twitter/nbactions.xml Mon May 20 12:45:50 2013 +0200
1.2 +++ b/twitter/nbactions.xml Thu Jun 20 13:18:10 2013 +0200
1.3 @@ -23,23 +23,34 @@
1.4 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1.5 THE SOFTWARE.
1.6
1.7 --->
1.8 -<actions>
1.9 - <action>
1.10 - <actionName>run</actionName>
1.11 - <goals>
1.12 - <goal>process-classes</goal>
1.13 - <goal>bck2brwsr:brwsr</goal>
1.14 - </goals>
1.15 - </action>
1.16 - <action>
1.17 - <actionName>debug</actionName>
1.18 - <goals>
1.19 - <goal>process-classes</goal>
1.20 - <goal>bck2brwsr:brwsr</goal>
1.21 - </goals>
1.22 - <properties>
1.23 - <jpda.listen>maven</jpda.listen>
1.24 - </properties>
1.25 - </action>
1.26 +--><actions>
1.27 + <action>
1.28 + <actionName>debug</actionName>
1.29 + <packagings>
1.30 + <packaging>jar</packaging>
1.31 + </packagings>
1.32 + <goals>
1.33 + <goal>process-classes</goal>
1.34 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1.35 + </goals>
1.36 + <properties>
1.37 + <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.apidesign.html.demo.twitter.TwitterMain</exec.args>
1.38 + <exec.executable>java</exec.executable>
1.39 + <jpda.listen>true</jpda.listen>
1.40 + </properties>
1.41 + </action>
1.42 + <action>
1.43 + <actionName>run</actionName>
1.44 + <packagings>
1.45 + <packaging>jar</packaging>
1.46 + </packagings>
1.47 + <goals>
1.48 + <goal>process-classes</goal>
1.49 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1.50 + </goals>
1.51 + <properties>
1.52 + <exec.args>-classpath %classpath org.apidesign.html.demo.twitter.TwitterMain</exec.args>
1.53 + <exec.executable>java</exec.executable>
1.54 + </properties>
1.55 + </action>
1.56 </actions>
2.1 --- a/twitter/pom.xml Mon May 20 12:45:50 2013 +0200
2.2 +++ b/twitter/pom.xml Thu Jun 20 13:18:10 2013 +0200
2.3 @@ -20,8 +20,8 @@
2.4
2.5 <properties>
2.6 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.7 - <net.java.html.version>0.1</net.java.html.version>
2.8 - <bck2brwsr.version>0.7</bck2brwsr.version>
2.9 + <net.java.html.version>0.4-SNAPSHOT</net.java.html.version>
2.10 + <bck2brwsr.version>0.8-SNAPSHOT</bck2brwsr.version>
2.11 <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
2.12 <brwsr.startpage>org/apidesign/html/demo/twitter/index.html</brwsr.startpage>
2.13 </properties>
2.14 @@ -121,6 +121,12 @@
2.15 <version>${net.java.html.version}</version>
2.16 <type>jar</type>
2.17 </dependency>
2.18 + <dependency>
2.19 + <groupId>org.apidesign.html</groupId>
2.20 + <artifactId>boot-fx</artifactId>
2.21 + <version>0.4-SNAPSHOT</version>
2.22 + <scope>runtime</scope>
2.23 + </dependency>
2.24 </dependencies>
2.25 <profiles>
2.26 <profile>
2.27 @@ -140,7 +146,7 @@
2.28 <configuration>
2.29 <archive>
2.30 <manifest>
2.31 - <mainClass>org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher</mainClass>
2.32 + <mainClass>org.apidesign.html.demo.twitter.TwitterMain</mainClass>
2.33 <addClasspath>true</addClasspath>
2.34 <classpathPrefix>lib/</classpathPrefix>
2.35 </manifest>
3.1 --- a/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Mon May 20 12:45:50 2013 +0200
3.2 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Thu Jun 20 13:18:10 2013 +0200
3.3 @@ -26,7 +26,6 @@
3.4 import java.util.Arrays;
3.5 import java.util.List;
3.6 import net.java.html.json.ComputedProperty;
3.7 -import net.java.html.json.Context;
3.8 import net.java.html.json.Function;
3.9 import net.java.html.json.Model;
3.10 import net.java.html.json.OnPropertyChange;
3.11 @@ -52,14 +51,28 @@
3.12 })
3.13 static class Twttrs {
3.14 }
3.15 + @Model(className = "User", properties = {
3.16 + @Property(name = "name", type = String.class),
3.17 + @Property(name = "profile_image_url", type = String.class),
3.18 + @Property(name = "id", type = int.class)
3.19 + })
3.20 + static class Usr {
3.21 + }
3.22 @Model(className = "Tweet", properties = {
3.23 - @Property(name = "from_user", type = String.class),
3.24 - @Property(name = "from_user_id", type = int.class),
3.25 + @Property(name = "user", type = User.class),
3.26 @Property(name = "profile_image_url", type = String.class),
3.27 @Property(name = "text", type = String.class),
3.28 @Property(name = "created_at", type = String.class),
3.29 })
3.30 static final class Twt {
3.31 + @ComputedProperty static String from_user(User user) {
3.32 + return user != null ? user.getName() : null;
3.33 + }
3.34 +
3.35 + @ComputedProperty static String imageUrl(User user) {
3.36 + return user != null ? user.getProfile_image_url() : null;
3.37 + }
3.38 +
3.39 @ComputedProperty static String html(String text) {
3.40 StringBuilder sb = new StringBuilder(320);
3.41 for (int pos = 0;;) {
3.42 @@ -79,20 +92,20 @@
3.43 }
3.44 }
3.45
3.46 - @ComputedProperty static String userUrl(String from_user) {
3.47 - return "http://twitter.com/" + from_user;
3.48 + @ComputedProperty static String userUrl(User user) {
3.49 + return "http://twitter.com/" + user.getName();
3.50 }
3.51 }
3.52 @Model(className = "TwitterQuery", properties = {
3.53 - @Property(array = true, name = "results", type = Twt.class)
3.54 + @Property(array = true, name = "statuses", type = Twt.class)
3.55 })
3.56 public static final class TwttrQr {
3.57 }
3.58
3.59 - @OnReceive(url="{root}/search.json?{query}&callback={me}", jsonp="me")
3.60 + @OnReceive(url="{url}?{query}&callback={me}", jsonp="me")
3.61 static void queryTweets(TwitterModel page, TwitterQuery q) {
3.62 page.getCurrentTweets().clear();
3.63 - page.getCurrentTweets().addAll(q.getResults());
3.64 + page.getCurrentTweets().addAll(q.getStatuses());
3.65 page.setLoading(false);
3.66 }
3.67
3.68 @@ -106,26 +119,37 @@
3.69 @OnPropertyChange({ "activeTweeters", "activeTweetersCount" })
3.70 static void refreshTweets(TwitterModel model) {
3.71 StringBuilder sb = new StringBuilder();
3.72 - sb.append("rpp=25&q=");
3.73 + sb.append("users=");
3.74 String sep = "";
3.75 for (String p : model.getActiveTweeters()) {
3.76 sb.append(sep);
3.77 - sb.append("from:");
3.78 sb.append(p);
3.79 - sep = " OR ";
3.80 + sep = "%7C";
3.81 + }
3.82 + if (sep.isEmpty()) {
3.83 + return;
3.84 }
3.85 model.setLoading(true);
3.86 - model.queryTweets("http://search.twitter.com", sb.toString());
3.87 + model.queryTweets("http://services.netbeans.org/synergy/server/api/twitter.php", sb.toString());
3.88 }
3.89
3.90 - private static final Context DEFAULT = Context.findDefault(TwitterClient.class);
3.91 static {
3.92 - final TwitterModel model = new TwitterModel(DEFAULT);
3.93 + try {
3.94 + init();
3.95 + } catch (Throwable ex) {
3.96 + ex.printStackTrace();
3.97 + }
3.98 + }
3.99 + private static void init() {
3.100 + System.setProperty("http.proxyHost", "www-proxy.uk.oracle.com");
3.101 + System.setProperty("http.proxyPort", "80");
3.102 +
3.103 + final TwitterModel model = new TwitterModel();
3.104 final List<Tweeters> svdLst = model.getSavedLists();
3.105 svdLst.add(newTweeters("API Design", "JaroslavTulach"));
3.106 svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson"));
3.107 svdLst.add(newTweeters("Microsoft people", "BillGates", "shanselman", "ScottGu"));
3.108 - svdLst.add(newTweeters("NetBeans", "GeertjanW","monacotoni", "NetBeans", "petrjiricka"));
3.109 + svdLst.add(newTweeters("NetBeans", "GeertjanW","monacotoni", "NetBeans", "petrjiricka", "ladariha"));
3.110 svdLst.add(newTweeters("Tech pundits", "Scobleizer", "LeoLaporte", "techcrunch", "BoingBoing", "timoreilly", "codinghorror"));
3.111
3.112 model.setActiveTweetersName("NetBeans");
3.113 @@ -161,7 +185,7 @@
3.114 final List<Tweeters> sl = model.getSavedLists();
3.115 sl.remove(findByName(sl, model.getActiveTweetersName()));
3.116 if (sl.isEmpty()) {
3.117 - final Tweeters t = new Tweeters(DEFAULT);
3.118 + final Tweeters t = new Tweeters();
3.119 t.setName("New");
3.120 sl.add(t);
3.121 }
3.122 @@ -195,11 +219,11 @@
3.123 return l;
3.124 }
3.125 }
3.126 - return list.isEmpty() ? new Tweeters(DEFAULT) : list.get(0);
3.127 + return list.isEmpty() ? new Tweeters() : list.get(0);
3.128 }
3.129
3.130 private static Tweeters newTweeters(String listName, String... userNames) {
3.131 - Tweeters t = new Tweeters(DEFAULT);
3.132 + Tweeters t = new Tweeters();
3.133 t.setName(listName);
3.134 t.getUserNames().addAll(Arrays.asList(userNames));
3.135 return t;
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterMain.java Thu Jun 20 13:18:10 2013 +0200
4.3 @@ -0,0 +1,19 @@
4.4 +package org.apidesign.html.demo.twitter;
4.5 +
4.6 +import net.java.html.boot.BrowserBuilder;
4.7 +
4.8 +/**
4.9 + *
4.10 + * @author Jaroslav Tulach <jtulach@netbeans.org>
4.11 + */
4.12 +public class TwitterMain {
4.13 + private TwitterMain() {
4.14 + }
4.15 +
4.16 + public static void main(String... args) {
4.17 + BrowserBuilder.newBrowser().
4.18 + loadClass(TwitterClient.class).
4.19 + loadPage("index.html").
4.20 + showAndWait();
4.21 + }
4.22 +}
5.1 --- a/twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html Mon May 20 12:45:50 2013 +0200
5.2 +++ b/twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html Thu Jun 20 13:18:10 2013 +0200
5.3 @@ -83,7 +83,7 @@
5.4 <div class='loadingIndicator' data-bind="visible: loading">Loading...</div>
5.5 <table data-bind='foreach: currentTweets' width='100%'>
5.6 <tr>
5.7 - <td><img data-bind='attr: { src: profile_image_url }' /></td>
5.8 + <td><img data-bind='attr: { src: imageUrl }' /></td>
5.9 <td>
5.10 <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
5.11 <span data-bind='html: html'> </span>
5.12 @@ -93,13 +93,5 @@
5.13 </table>
5.14 </div>
5.15 </div>
5.16 -
5.17 - <script src="bck2brwsr.js"></script>
5.18 - <script type="text/javascript">
5.19 - var vm = bck2brwsr('demo-twitter-1.0-SNAPSHOT.jar');
5.20 - vm.loadClass('org.apidesign.html.demo.twitter.TwitterClient');
5.21 - </script>
5.22 -
5.23 -
5.24 </body>
5.25 </html>