Removing the Twitter demo, as it no longer works after May 2013's change on Twitter protocol
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 07 Nov 2013 09:24:37 +0100
changeset 14081d78661c2b57
parent 1407 32e050a07754
child 1409 3d1612be40bc
Removing the Twitter demo, as it no longer works after May 2013's change on Twitter protocol
javaquery/demo-twitter/bck2brwsr-assembly.xml
javaquery/demo-twitter/nb-configuration.xml
javaquery/demo-twitter/nbactions.xml
javaquery/demo-twitter/pom.xml
javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java
javaquery/demo-twitter/src/main/resources/org/apidesign/bck2brwsr/demo/twitter/index.html
javaquery/demo-twitter/src/main/resources/org/apidesign/bck2brwsr/demo/twitter/twitterExample.css
javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java
javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterProtocolTest.java
javaquery/pom.xml
     1.1 --- a/javaquery/demo-twitter/bck2brwsr-assembly.xml	Sat Nov 02 21:09:52 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,62 +0,0 @@
     1.4 -<?xml version="1.0"?>
     1.5 -<!--
     1.6 -
     1.7 -    Back 2 Browser Bytecode Translator
     1.8 -    Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.9 -
    1.10 -    This program is free software: you can redistribute it and/or modify
    1.11 -    it under the terms of the GNU General Public License as published by
    1.12 -    the Free Software Foundation, version 2 of the License.
    1.13 -
    1.14 -    This program is distributed in the hope that it will be useful,
    1.15 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 -    GNU General Public License for more details.
    1.18 -
    1.19 -    You should have received a copy of the GNU General Public License
    1.20 -    along with this program. Look for COPYING file in the top folder.
    1.21 -    If not, see http://opensource.org/licenses/GPL-2.0.
    1.22 -
    1.23 --->
    1.24 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    1.25 -  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    1.26 -  
    1.27 -  <id>bck2brwsr</id>
    1.28 -  <formats>
    1.29 -      <format>zip</format>
    1.30 -  </formats>
    1.31 -  <baseDirectory>public_html</baseDirectory>
    1.32 -  <dependencySets>
    1.33 -    <dependencySet>
    1.34 -        <useProjectArtifact>false</useProjectArtifact>
    1.35 -        <scope>runtime</scope>
    1.36 -        <outputDirectory>lib</outputDirectory>
    1.37 -        <includes>
    1.38 -            <include>*:jar</include>
    1.39 -            <include>*:rt</include>
    1.40 -        </includes>
    1.41 -    </dependencySet>
    1.42 -  </dependencySets> 
    1.43 -  <fileSets>
    1.44 -      <fileSet>
    1.45 -          <directory>${project.build.directory}/classes/org/apidesign/bck2brwsr/demo/twitter/</directory>
    1.46 -          <includes>
    1.47 -              <include>**/*</include>
    1.48 -          </includes>
    1.49 -          <excludes>
    1.50 -              <exclude>**/*.class</exclude>
    1.51 -          </excludes>
    1.52 -          <outputDirectory>/</outputDirectory>
    1.53 -      </fileSet>
    1.54 -  </fileSets>
    1.55 -  <files>
    1.56 -    <file>
    1.57 -      <source>${project.build.directory}/${project.build.finalName}.jar</source>
    1.58 -      <outputDirectory>/</outputDirectory>
    1.59 -    </file>
    1.60 -    <file>
    1.61 -      <source>${project.build.directory}/bck2brwsr.js</source>
    1.62 -      <outputDirectory>/</outputDirectory>
    1.63 -    </file>
    1.64 -  </files>
    1.65 -</assembly>
    1.66 \ No newline at end of file
     2.1 --- a/javaquery/demo-twitter/nb-configuration.xml	Sat Nov 02 21:09:52 2013 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,37 +0,0 @@
     2.4 -<?xml version="1.0" encoding="UTF-8"?>
     2.5 -<!--
     2.6 -
     2.7 -    Back 2 Browser Bytecode Translator
     2.8 -    Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.9 -
    2.10 -    This program is free software: you can redistribute it and/or modify
    2.11 -    it under the terms of the GNU General Public License as published by
    2.12 -    the Free Software Foundation, version 2 of the License.
    2.13 -
    2.14 -    This program is distributed in the hope that it will be useful,
    2.15 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.16 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.17 -    GNU General Public License for more details.
    2.18 -
    2.19 -    You should have received a copy of the GNU General Public License
    2.20 -    along with this program. Look for COPYING file in the top folder.
    2.21 -    If not, see http://opensource.org/licenses/GPL-2.0.
    2.22 -
    2.23 --->
    2.24 -<project-shared-configuration>
    2.25 -    <!--
    2.26 -This file contains additional configuration written by modules in the NetBeans IDE.
    2.27 -The configuration is intended to be shared among all the users of project and
    2.28 -therefore it is assumed to be part of version control checkout.
    2.29 -Without this configuration present, some functionality in the IDE may be limited or fail altogether.
    2.30 --->
    2.31 -    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
    2.32 -        <!--
    2.33 -Properties that influence various parts of the IDE, especially code formatting and the like. 
    2.34 -You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
    2.35 -That way multiple projects can share the same settings (useful for formatting rules for example).
    2.36 -Any value defined here will override the pom.xml file value but is only applicable to the current project.
    2.37 --->
    2.38 -        <netbeans.compile.on.save>none</netbeans.compile.on.save>
    2.39 -    </properties>
    2.40 -</project-shared-configuration>
     3.1 --- a/javaquery/demo-twitter/nbactions.xml	Sat Nov 02 21:09:52 2013 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,29 +0,0 @@
     3.4 -<?xml version="1.0" encoding="UTF-8"?>
     3.5 -<!--
     3.6 -
     3.7 -    Back 2 Browser Bytecode Translator
     3.8 -    Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     3.9 -
    3.10 -    This program is free software: you can redistribute it and/or modify
    3.11 -    it under the terms of the GNU General Public License as published by
    3.12 -    the Free Software Foundation, version 2 of the License.
    3.13 -
    3.14 -    This program is distributed in the hope that it will be useful,
    3.15 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 -    GNU General Public License for more details.
    3.18 -
    3.19 -    You should have received a copy of the GNU General Public License
    3.20 -    along with this program. Look for COPYING file in the top folder.
    3.21 -    If not, see http://opensource.org/licenses/GPL-2.0.
    3.22 -
    3.23 --->
    3.24 -<actions>
    3.25 -    <action>
    3.26 -        <actionName>run</actionName>
    3.27 -        <goals>
    3.28 -            <goal>process-classes</goal>
    3.29 -            <goal>bck2brwsr:brwsr</goal>
    3.30 -        </goals>
    3.31 -    </action>
    3.32 -</actions>
     4.1 --- a/javaquery/demo-twitter/pom.xml	Sat Nov 02 21:09:52 2013 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,151 +0,0 @@
     4.4 -<?xml version="1.0" encoding="UTF-8"?>
     4.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4.6 -  <modelVersion>4.0.0</modelVersion>
     4.7 -  <parent>
     4.8 -    <artifactId>javaquery</artifactId>
     4.9 -    <groupId>org.apidesign.bck2brwsr</groupId>
    4.10 -    <version>0.9-SNAPSHOT</version>
    4.11 -  </parent>
    4.12 -
    4.13 -  <groupId>org.apidesign.bck2brwsr</groupId>
    4.14 -  <artifactId>demo-twitter</artifactId>
    4.15 -  <version>0.9-SNAPSHOT</version>
    4.16 -  <packaging>jar</packaging>
    4.17 -
    4.18 -  <name>Bck2Brwsr's Twttr</name>
    4.19 -  <description>
    4.20 -      Rewrite of knockoutjs example to use model written in Java and
    4.21 -      execute using Bck2Brwsr virtual machine.
    4.22 -  </description>
    4.23 -
    4.24 -  <repositories>
    4.25 -      <repository>
    4.26 -          <id>java.net</id>
    4.27 -          <name>Java.net</name>
    4.28 -          <url>https://maven.java.net/content/repositories/releases/</url>
    4.29 -          <snapshots>
    4.30 -          </snapshots>
    4.31 -      </repository>
    4.32 -      <repository>
    4.33 -          <id>netbeans</id>
    4.34 -          <name>NetBeans</name>
    4.35 -          <url>http://bits.netbeans.org/maven2/</url>
    4.36 -      </repository>
    4.37 -  </repositories>
    4.38 -  <pluginRepositories>
    4.39 -      <pluginRepository>
    4.40 -          <id>java.net</id>
    4.41 -          <name>Java.net</name>
    4.42 -          <url>https://maven.java.net/content/repositories/releases/</url>
    4.43 -          <snapshots>
    4.44 -          </snapshots>
    4.45 -      </pluginRepository>
    4.46 -  </pluginRepositories>
    4.47 -
    4.48 -  <properties>
    4.49 -    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    4.50 -    <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
    4.51 -  </properties>
    4.52 -  <build>
    4.53 -      <plugins>
    4.54 -            <plugin>
    4.55 -                <groupId>org.apidesign.bck2brwsr</groupId>
    4.56 -                <artifactId>bck2brwsr-maven-plugin</artifactId>
    4.57 -                <version>${project.version}</version>
    4.58 -                <executions>
    4.59 -                    <execution>
    4.60 -                        <goals>
    4.61 -                            <goal>brwsr</goal>
    4.62 -                            <goal>j2js</goal>
    4.63 -                        </goals>
    4.64 -                    </execution>
    4.65 -                </executions>
    4.66 -                <configuration>
    4.67 -                    <startpage>org/apidesign/bck2brwsr/demo/twitter/index.html</startpage>
    4.68 -                    <javascript>${project.build.directory}/bck2brwsr.js</javascript>
    4.69 -                    <obfuscation>${bck2brwsr.obfuscationlevel}</obfuscation>
    4.70 -                </configuration>
    4.71 -            </plugin>
    4.72 -         <plugin>
    4.73 -            <groupId>org.apache.maven.plugins</groupId>
    4.74 -            <artifactId>maven-compiler-plugin</artifactId>
    4.75 -            <version>2.3.2</version>
    4.76 -            <configuration>
    4.77 -               <source>1.7</source>
    4.78 -               <target>1.7</target>
    4.79 -            </configuration>
    4.80 -         </plugin>
    4.81 -         <plugin>
    4.82 -             <groupId>org.apache.maven.plugins</groupId>
    4.83 -             <artifactId>maven-jar-plugin</artifactId>
    4.84 -             <version>2.4</version>
    4.85 -             <configuration>
    4.86 -                 <archive>
    4.87 -                     <manifest>
    4.88 -                         <addClasspath>true</addClasspath>
    4.89 -                         <classpathPrefix>lib/</classpathPrefix>
    4.90 -                     </manifest>
    4.91 -                 </archive>
    4.92 -             </configuration>
    4.93 -         </plugin>
    4.94 -         <plugin>
    4.95 -           <groupId>org.apache.maven.plugins</groupId>
    4.96 -           <artifactId>maven-deploy-plugin</artifactId>
    4.97 -           <version>2.7</version>
    4.98 -           <configuration>
    4.99 -             <skip>true</skip>
   4.100 -           </configuration>
   4.101 -         </plugin>      
   4.102 -         <plugin>
   4.103 -             <artifactId>maven-assembly-plugin</artifactId>
   4.104 -             <version>2.4</version>
   4.105 -             <executions>
   4.106 -                 <execution>
   4.107 -                     <id>distro-assembly</id>
   4.108 -                     <phase>package</phase>
   4.109 -                     <goals>
   4.110 -                         <goal>single</goal>
   4.111 -                     </goals>
   4.112 -                     <configuration>
   4.113 -                         <descriptors>
   4.114 -                             <descriptor>bck2brwsr-assembly.xml</descriptor>
   4.115 -                         </descriptors>
   4.116 -                     </configuration>
   4.117 -                 </execution>
   4.118 -             </executions>                
   4.119 -         </plugin>      
   4.120 -      </plugins>
   4.121 -  </build>
   4.122 -
   4.123 -  <dependencies>
   4.124 -    <dependency>
   4.125 -      <groupId>org.apidesign.bck2brwsr</groupId>
   4.126 -      <artifactId>emul</artifactId>
   4.127 -      <version>${project.version}</version>
   4.128 -      <classifier>rt</classifier>
   4.129 -    </dependency>
   4.130 -    <dependency>
   4.131 -      <groupId>org.apidesign.bck2brwsr</groupId>
   4.132 -      <artifactId>javaquery.api</artifactId>
   4.133 -      <version>${project.version}</version>
   4.134 -    </dependency>
   4.135 -    <dependency>
   4.136 -      <groupId>org.testng</groupId>
   4.137 -      <artifactId>testng</artifactId>
   4.138 -      <version>6.5.2</version>
   4.139 -      <scope>test</scope>
   4.140 -    </dependency>
   4.141 -    <dependency>
   4.142 -      <groupId>org.apidesign.bck2brwsr</groupId>
   4.143 -      <artifactId>vmtest</artifactId>
   4.144 -      <version>${project.version}</version>
   4.145 -      <scope>test</scope>
   4.146 -    </dependency>
   4.147 -    <dependency>
   4.148 -      <groupId>org.apidesign.bck2brwsr</groupId>
   4.149 -      <artifactId>launcher.http</artifactId>
   4.150 -      <version>${project.version}</version>
   4.151 -      <scope>runtime</scope>
   4.152 -    </dependency>
   4.153 -  </dependencies>
   4.154 -</project>
     5.1 --- a/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java	Sat Nov 02 21:09:52 2013 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,194 +0,0 @@
     5.4 -/**
     5.5 - * Back 2 Browser Bytecode Translator
     5.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     5.7 - *
     5.8 - * This program is free software: you can redistribute it and/or modify
     5.9 - * it under the terms of the GNU General Public License as published by
    5.10 - * the Free Software Foundation, version 2 of the License.
    5.11 - *
    5.12 - * This program is distributed in the hope that it will be useful,
    5.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 - * GNU General Public License for more details.
    5.16 - *
    5.17 - * You should have received a copy of the GNU General Public License
    5.18 - * along with this program. Look for COPYING file in the top folder.
    5.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    5.20 - */
    5.21 -package org.apidesign.bck2brwsr.demo.twitter;
    5.22 -
    5.23 -import java.util.Arrays;
    5.24 -import java.util.List;
    5.25 -import org.apidesign.bck2brwsr.htmlpage.api.*;
    5.26 -import org.apidesign.bck2brwsr.htmlpage.api.Page;
    5.27 -import org.apidesign.bck2brwsr.htmlpage.api.Property;
    5.28 -import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
    5.29 -
    5.30 -/** Controller class for access to Twitter.
    5.31 - * 
    5.32 - * @author Jaroslav Tulach
    5.33 - */
    5.34 -@Page(xhtml="index.html", className="TwitterModel", properties={
    5.35 -    @Property(name="savedLists", type=Tweeters.class, array = true),
    5.36 -    @Property(name="activeTweetersName", type=String.class),
    5.37 -    @Property(name="activeTweeters", type=String.class, array = true),
    5.38 -    @Property(name="userNameToAdd", type=String.class),
    5.39 -    @Property(name="currentTweets", type=Tweet.class, array = true)
    5.40 -})
    5.41 -public class TwitterClient {
    5.42 -    @Model(className = "Tweeters", properties = {
    5.43 -        @Property(name="name", type = String.class),
    5.44 -        @Property(name="userNames", type = String.class, array = true)
    5.45 -    })
    5.46 -    static class Twttrs {
    5.47 -    }
    5.48 -    @Model(className = "Tweet", properties = {
    5.49 -        @Property(name = "from_user", type = String.class),
    5.50 -        @Property(name = "from_user_id", type = int.class),
    5.51 -        @Property(name = "profile_image_url", type = String.class),
    5.52 -        @Property(name = "text", type = String.class),
    5.53 -        @Property(name = "created_at", type = String.class),
    5.54 -    })
    5.55 -    static final class Twt {
    5.56 -        @ComputedProperty static String html(String text) {
    5.57 -            StringBuilder sb = new StringBuilder(320);
    5.58 -            for (int pos = 0;;) {
    5.59 -                int http = text.indexOf("http", pos);
    5.60 -                if (http == -1) {
    5.61 -                    sb.append(text.substring(pos));
    5.62 -                    return sb.toString();
    5.63 -                }
    5.64 -                int spc = text.indexOf(' ', http);
    5.65 -                if (spc == -1) {
    5.66 -                    spc = text.length();
    5.67 -                }
    5.68 -                sb.append(text.substring(pos, http));
    5.69 -                String url = text.substring(http, spc);
    5.70 -                sb.append("<a href='").append(url).append("'>").append(url).append("</a>");
    5.71 -                pos = spc;
    5.72 -            }
    5.73 -        }
    5.74 -        
    5.75 -        @ComputedProperty static String userUrl(String from_user) {
    5.76 -            return "http://twitter.com/" + from_user;
    5.77 -        }
    5.78 -    }
    5.79 -    @Model(className = "TwitterQuery", properties = {
    5.80 -        @Property(array = true, name = "results", type = Twt.class)
    5.81 -    })
    5.82 -    public static final class TwttrQr {
    5.83 -    }
    5.84 -    
    5.85 -    @OnReceive(url="{root}/search.json?{query}&callback={me}", jsonp="me")
    5.86 -    static void queryTweets(TwitterModel page, TwitterQuery q) {
    5.87 -        page.getCurrentTweets().clear();
    5.88 -        page.getCurrentTweets().addAll(q.getResults());
    5.89 -    }
    5.90 -    
    5.91 -    @OnPropertyChange("activeTweetersName")
    5.92 -    static void changeTweetersList(TwitterModel model) {
    5.93 -        Tweeters people = findByName(model.getSavedLists(), model.getActiveTweetersName());        
    5.94 -        model.getActiveTweeters().clear();
    5.95 -        model.getActiveTweeters().addAll(people.getUserNames());
    5.96 -    }
    5.97 -    
    5.98 -    @OnPropertyChange({ "activeTweeters", "activeTweetersCount" })
    5.99 -    static void refreshTweets(TwitterModel model) {
   5.100 -        StringBuilder sb = new StringBuilder();
   5.101 -        sb.append("rpp=25&q=");
   5.102 -        String sep = "";
   5.103 -        for (String p : model.getActiveTweeters()) {
   5.104 -            sb.append(sep);
   5.105 -            sb.append("from:");
   5.106 -            sb.append(p);
   5.107 -            sep = " OR ";
   5.108 -        }
   5.109 -        model.queryTweets("http://search.twitter.com", sb.toString());
   5.110 -    }
   5.111 -    
   5.112 -    static {
   5.113 -        final TwitterModel model = new TwitterModel();
   5.114 -        final List<Tweeters> svdLst = model.getSavedLists();
   5.115 -        svdLst.add(newTweeters("API Design", "JaroslavTulach"));
   5.116 -        svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson"));
   5.117 -        svdLst.add(newTweeters("Microsoft people", "BillGates", "shanselman", "ScottGu"));
   5.118 -        svdLst.add(newTweeters("NetBeans", "GeertjanW","monacotoni", "NetBeans", "petrjiricka"));
   5.119 -        svdLst.add(newTweeters("Tech pundits", "Scobleizer", "LeoLaporte", "techcrunch", "BoingBoing", "timoreilly", "codinghorror"));
   5.120 -
   5.121 -        model.setActiveTweetersName("NetBeans");
   5.122 -
   5.123 -        model.applyBindings();
   5.124 -    }
   5.125 -    
   5.126 -    @ComputedProperty
   5.127 -    static boolean hasUnsavedChanges(List<String> activeTweeters, List<Tweeters> savedLists, String activeTweetersName) {
   5.128 -        Tweeters tw = findByName(savedLists, activeTweetersName);
   5.129 -        if (activeTweeters == null) {
   5.130 -            return false;
   5.131 -        }
   5.132 -        return !tw.getUserNames().equals(activeTweeters);
   5.133 -    }
   5.134 -    
   5.135 -    @ComputedProperty
   5.136 -    static int activeTweetersCount(List<String> activeTweeters) {
   5.137 -        return activeTweeters.size();
   5.138 -    }
   5.139 -    
   5.140 -    @ComputedProperty
   5.141 -    static boolean userNameToAddIsValid(
   5.142 -        String userNameToAdd, String activeTweetersName, List<Tweeters> savedLists, List<String> activeTweeters
   5.143 -    ) {
   5.144 -        return userNameToAdd != null && 
   5.145 -            userNameToAdd.matches("[a-zA-Z0-9_]{1,15}") &&
   5.146 -            !activeTweeters.contains(userNameToAdd);
   5.147 -    }
   5.148 -    
   5.149 -    @OnFunction
   5.150 -    static void deleteList(TwitterModel model) {
   5.151 -        final List<Tweeters> sl = model.getSavedLists();
   5.152 -        sl.remove(findByName(sl, model.getActiveTweetersName()));
   5.153 -        if (sl.isEmpty()) {
   5.154 -            final Tweeters t = new Tweeters();
   5.155 -            t.setName("New");
   5.156 -            sl.add(t);
   5.157 -        }
   5.158 -        model.setActiveTweetersName(sl.get(0).getName());
   5.159 -    }
   5.160 -    
   5.161 -    @OnFunction
   5.162 -    static void saveChanges(TwitterModel model) {
   5.163 -        Tweeters t = findByName(model.getSavedLists(), model.getActiveTweetersName());
   5.164 -        int indx = model.getSavedLists().indexOf(t);
   5.165 -        if (indx != -1) {
   5.166 -            t.setName(model.getActiveTweetersName());
   5.167 -            t.getUserNames().clear();
   5.168 -            t.getUserNames().addAll(model.getActiveTweeters());
   5.169 -        }
   5.170 -    }
   5.171 -    
   5.172 -    @OnFunction
   5.173 -    static void addUser(TwitterModel model) {
   5.174 -        String n = model.getUserNameToAdd();
   5.175 -        model.getActiveTweeters().add(n);
   5.176 -    }
   5.177 -    @OnFunction
   5.178 -    static void removeUser(String data, TwitterModel model) {
   5.179 -        model.getActiveTweeters().remove(data);
   5.180 -    }
   5.181 -    
   5.182 -    private static Tweeters findByName(List<Tweeters> list, String name) {
   5.183 -        for (Tweeters l : list) {
   5.184 -            if (l.getName() != null && l.getName().equals(name)) {
   5.185 -                return l;
   5.186 -            }
   5.187 -        }
   5.188 -        return list.isEmpty() ? new Tweeters() : list.get(0);
   5.189 -    }
   5.190 -    
   5.191 -    private static Tweeters newTweeters(String listName, String... userNames) {
   5.192 -        Tweeters t = new Tweeters();
   5.193 -        t.setName(listName);
   5.194 -        t.getUserNames().addAll(Arrays.asList(userNames));
   5.195 -        return t;
   5.196 -    }
   5.197 -}
     6.1 --- a/javaquery/demo-twitter/src/main/resources/org/apidesign/bck2brwsr/demo/twitter/index.html	Sat Nov 02 21:09:52 2013 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,99 +0,0 @@
     6.4 -<?xml version="1.0" encoding="UTF-8"?>
     6.5 -<!--
     6.6 -
     6.7 -    Back 2 Browser Bytecode Translator
     6.8 -    Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     6.9 -
    6.10 -    This program is free software: you can redistribute it and/or modify
    6.11 -    it under the terms of the GNU General Public License as published by
    6.12 -    the Free Software Foundation, version 2 of the License.
    6.13 -
    6.14 -    This program is distributed in the hope that it will be useful,
    6.15 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.16 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.17 -    GNU General Public License for more details.
    6.18 -
    6.19 -    You should have received a copy of the GNU General Public License
    6.20 -    along with this program. Look for COPYING file in the top folder.
    6.21 -    If not, see http://opensource.org/licenses/GPL-2.0.
    6.22 -
    6.23 --->
    6.24 -
    6.25 -<!--
    6.26 -    Copied from knockout.js Twitter example:
    6.27 -    http://knockoutjs.com/examples/twitter.html
    6.28 --->
    6.29 -
    6.30 -<!DOCTYPE html>
    6.31 -<html xmlns="http://www.w3.org/1999/xhtml">
    6.32 -    <head>
    6.33 -        <title>Bck2Brwsr's Twitter</title>
    6.34 -    </head>
    6.35 -    <body>
    6.36 -        <link href='twitterExample.css' rel='Stylesheet' ></link>
    6.37 -        
    6.38 -        <style type='text/css'>
    6.39 -           .liveExample select { height: 1.7em; }
    6.40 -           .liveExample button { height: 2em; }
    6.41 -        </style>
    6.42 -        
    6.43 -        
    6.44 -        <h2>Bck2Brwsr's Twitter</h2>
    6.45 -        
    6.46 -        <p>
    6.47 -        This code based on original <a href="http://knockoutjs.com/examples/twitter.html">knockout.js Twitter example</a> and
    6.48 -        uses almost unmodified HTML code. It just changes the model. It 
    6.49 -        is written in Java language and it is executed using <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a>
    6.50 -        virtual machine. The Java source code has about 190 lines and is available 
    6.51 -        <a href="http://source.apidesign.org/hg/bck2brwsr/file/7fc6b7e9c982/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java">here</a>
    6.52 -        - in fact it may even be more dense than the original JavaScript model.
    6.53 -        </p>
    6.54 -        
    6.55 -        <div class='liveExample'>
    6.56 -            <div class='configuration'>
    6.57 -                <div class='listChooser'>
    6.58 -                    <button data-bind='click: deleteList, enable: activeTweetersName'>Delete</button>
    6.59 -                    <button data-bind='click: saveChanges, enable: hasUnsavedChanges'>Save</button> 
    6.60 -                    <select data-bind='options: savedLists, optionsValue: "name", value: activeTweetersName'> </select>
    6.61 -                </div>
    6.62 -
    6.63 -                <p>Currently viewing <span data-bind='text: activeTweetersCount'> </span> user(s):</p>
    6.64 -                <div class='currentUsers' >
    6.65 -                    <ul data-bind='foreach: activeTweeters'>
    6.66 -                        <li>
    6.67 -                            <button data-bind='click: $root.removeUser'>Remove</button>
    6.68 -                            <div data-bind='text: $data'> </div>
    6.69 -                        </li>
    6.70 -                    </ul>
    6.71 -                </div>
    6.72 -
    6.73 -                <form data-bind='submit: addUser'>
    6.74 -                    <label>Add user:</label>
    6.75 -                    <input data-bind='value: userNameToAdd, valueUpdate: "keyup", css: { invalid: !userNameToAddIsValid() }' />
    6.76 -                    <button data-bind='enable: userNameToAddIsValid' type='submit'>Add</button>
    6.77 -                </form>
    6.78 -            </div>
    6.79 -            <div class='tweets'>
    6.80 -                <div class='loadingIndicator'>Loading...</div>
    6.81 -                <table data-bind='foreach: currentTweets' width='100%'>
    6.82 -                    <tr>
    6.83 -                        <td><img data-bind='attr: { src: profile_image_url }' /></td>
    6.84 -                        <td>
    6.85 -                            <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
    6.86 -                            <span data-bind='html: html'> </span>
    6.87 -                            <div class='tweetInfo' data-bind='text: created_at'> </div>
    6.88 -                        </td>
    6.89 -                    </tr>
    6.90 -                </table>
    6.91 -            </div>
    6.92 -        </div>
    6.93 -        
    6.94 -        <script src="bck2brwsr.js"></script>
    6.95 -        <script type="text/javascript">
    6.96 -            var vm = bck2brwsr('demo-twitter-0.8-SNAPSHOT.jar');
    6.97 -            vm.loadClass('org.apidesign.bck2brwsr.demo.twitter.TwitterClient');
    6.98 -        </script>
    6.99 -
   6.100 -
   6.101 -    </body>
   6.102 -</html>
     7.1 --- a/javaquery/demo-twitter/src/main/resources/org/apidesign/bck2brwsr/demo/twitter/twitterExample.css	Sat Nov 02 21:09:52 2013 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,50 +0,0 @@
     7.4 -/**
     7.5 - * Back 2 Browser Bytecode Translator
     7.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     7.7 - *
     7.8 - * This program is free software: you can redistribute it and/or modify
     7.9 - * it under the terms of the GNU General Public License as published by
    7.10 - * the Free Software Foundation, version 2 of the License.
    7.11 - *
    7.12 - * This program is distributed in the hope that it will be useful,
    7.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 - * GNU General Public License for more details.
    7.16 - *
    7.17 - * You should have received a copy of the GNU General Public License
    7.18 - * along with this program. Look for COPYING file in the top folder.
    7.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    7.20 - */
    7.21 -
    7.22 -/*
    7.23 -    Copied from knockout.js Twitter example:
    7.24 -    http://knockoutjs.com/examples/twitter.html
    7.25 -*/
    7.26 -
    7.27 -.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; }
    7.28 -.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; }
    7.29 -.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; }
    7.30 -.tweets table { border-width: 0;}
    7.31 -.tweets tr { vertical-align: top; }
    7.32 -.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; }
    7.33 -.tweets img { width: 4em; }
    7.34 -.tweetInfo { color: Gray; font-size: 0.9em; }
    7.35 -.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; }
    7.36 -input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; }
    7.37 -
    7.38 -.listChooser select, .listChooser button { vertical-align:top; }
    7.39 -.listChooser select { width: 60%; font-size:1.2em; height:1.4em; }
    7.40 -.listChooser button { width: 19%; height:1.68em; float:right; }
    7.41 -
    7.42 -.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; }
    7.43 -.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; }
    7.44 -.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 }
    7.45 -.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; }
    7.46 -.currentUsers li div { padding: 0.6em; }
    7.47 -.currentUsers li:hover { background-color: #EEC; }
    7.48 -
    7.49 -.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; }
    7.50 -.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; }
    7.51 -.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; }
    7.52 -
    7.53 -.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; display: none; }
     8.1 --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java	Sat Nov 02 21:09:52 2013 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,67 +0,0 @@
     8.4 -/**
     8.5 - * Back 2 Browser Bytecode Translator
     8.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     8.7 - *
     8.8 - * This program is free software: you can redistribute it and/or modify
     8.9 - * it under the terms of the GNU General Public License as published by
    8.10 - * the Free Software Foundation, version 2 of the License.
    8.11 - *
    8.12 - * This program is distributed in the hope that it will be useful,
    8.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.15 - * GNU General Public License for more details.
    8.16 - *
    8.17 - * You should have received a copy of the GNU General Public License
    8.18 - * along with this program. Look for COPYING file in the top folder.
    8.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    8.20 - */
    8.21 -package org.apidesign.bck2brwsr.demo.twitter;
    8.22 -
    8.23 -import java.util.List;
    8.24 -import static org.testng.Assert.*;
    8.25 -import org.testng.annotations.BeforeMethod;
    8.26 -import org.testng.annotations.Test;
    8.27 -
    8.28 -/** We can unit test the TwitterModel smoothly.
    8.29 - *
    8.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    8.31 - */
    8.32 -public class TwitterClientTest {
    8.33 -    private TwitterModel model;
    8.34 -    
    8.35 -
    8.36 -    @BeforeMethod
    8.37 -    public void initModel() {
    8.38 -        model = new TwitterModel().applyBindings();
    8.39 -    }
    8.40 -
    8.41 -    @Test public void testIsValidToAdd() {
    8.42 -        model.setUserNameToAdd("Joe");
    8.43 -        Tweeters t = new Tweeters();
    8.44 -        t.setName("test");
    8.45 -        model.getSavedLists().add(t);
    8.46 -        model.setActiveTweetersName("test");
    8.47 -        
    8.48 -        assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
    8.49 -        TwitterClient.addUser(model);
    8.50 -        assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
    8.51 -        assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
    8.52 -        
    8.53 -        List<String> mod = model.getActiveTweeters();
    8.54 -        assertTrue(model.isHasUnsavedChanges(), "We have modifications");
    8.55 -        assertEquals(mod.size(), 1, "One element in the list");
    8.56 -        assertEquals(mod.get(0), "Joe", "Its name is Joe");
    8.57 -        
    8.58 -        assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
    8.59 -        
    8.60 -        TwitterClient.saveChanges(model);
    8.61 -        assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
    8.62 -        
    8.63 -        assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
    8.64 -    }
    8.65 -    
    8.66 -    @Test public void httpAtTheEnd() {
    8.67 -        String res = TwitterClient.Twt.html("Ahoj http://kuk");
    8.68 -        assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
    8.69 -    }
    8.70 -}
     9.1 --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterProtocolTest.java	Sat Nov 02 21:09:52 2013 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,94 +0,0 @@
     9.4 -/**
     9.5 - * Back 2 Browser Bytecode Translator
     9.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     9.7 - *
     9.8 - * This program is free software: you can redistribute it and/or modify
     9.9 - * it under the terms of the GNU General Public License as published by
    9.10 - * the Free Software Foundation, version 2 of the License.
    9.11 - *
    9.12 - * This program is distributed in the hope that it will be useful,
    9.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.15 - * GNU General Public License for more details.
    9.16 - *
    9.17 - * You should have received a copy of the GNU General Public License
    9.18 - * along with this program. Look for COPYING file in the top folder.
    9.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    9.20 - */
    9.21 -package org.apidesign.bck2brwsr.demo.twitter;
    9.22 -
    9.23 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    9.24 -import org.apidesign.bck2brwsr.vmtest.Http;
    9.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    9.26 -import org.testng.annotations.Factory;
    9.27 -
    9.28 -/**
    9.29 - *
    9.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    9.31 - */
    9.32 -public class TwitterProtocolTest {
    9.33 -    private TwitterModel page;
    9.34 -    @Http(@Http.Resource(
    9.35 -        path = "/search.json",
    9.36 -        mimeType = "application/json",
    9.37 -        parameters = {"callback"},
    9.38 -        content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
    9.39 -        + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
    9.40 -        + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
    9.41 -        + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
    9.42 -        + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
    9.43 -        + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
    9.44 -        + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
    9.45 -        + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.46 -        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.47 -        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
    9.48 -        + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
    9.49 -        + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
    9.50 -        + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
    9.51 -        + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
    9.52 -        + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
    9.53 -        + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
    9.54 -        + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
    9.55 -        + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.56 -        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.57 -        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
    9.58 -        + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
    9.59 -        + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
    9.60 -        + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
    9.61 -        + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
    9.62 -        + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
    9.63 -        + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.64 -        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.65 -        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
    9.66 -        + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
    9.67 -        + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
    9.68 -        + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
    9.69 -        + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
    9.70 -        + "{\"result_type\":\"recent\"},\"profile_image_url\":"
    9.71 -        + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.72 -        + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
    9.73 -        + "\"source\":\"&lt;a href=&quot;http:\\/\\/twitter.com\\/&quot;&gt;web&lt;\\/a&gt;\",\"text\":"
    9.74 -        + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
    9.75 -        + "\"since_id\":0,\"since_id_str\":\"0\"})"
    9.76 -    ))
    9.77 -    @BrwsrTest public void readFromTwttr() throws InterruptedException {
    9.78 -        if (page == null) {
    9.79 -            page = new TwitterModel();
    9.80 -            page.applyBindings();
    9.81 -            page.queryTweets("", "q=xyz");
    9.82 -        }
    9.83 -
    9.84 -        if (page.getCurrentTweets().isEmpty()) {
    9.85 -            throw new InterruptedException();
    9.86 -        }
    9.87 -
    9.88 -        assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
    9.89 -        
    9.90 -        String firstDate = page.getCurrentTweets().get(0).getCreated_at();
    9.91 -        assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
    9.92 -    }
    9.93 -    
    9.94 -    @Factory public static Object[] create() {
    9.95 -        return VMTest.create(TwitterProtocolTest.class);
    9.96 -    }
    9.97 -}
    10.1 --- a/javaquery/pom.xml	Sat Nov 02 21:09:52 2013 +0100
    10.2 +++ b/javaquery/pom.xml	Thu Nov 07 09:24:37 2013 +0100
    10.3 @@ -15,6 +15,5 @@
    10.4          <module>api</module>
    10.5          <module>demo-calculator</module>
    10.6          <module>demo-calculator-dynamic</module>
    10.7 -    <module>demo-twitter</module>
    10.8    </modules>
    10.9 -</project>
   10.10 \ No newline at end of file
   10.11 +</project>