on i4PACE(i for Personal Archiving and Creating Environment)
actions » SearchLogin 89 articles • 11 Mar 2010

Recent articles in 'javascript'

Thursday, 25 Dec 2008

permalink CouchDB

Got interested one of Apache projects called CouchDB (http://couchdb.apache.org).

Looked at http://wiki.apache.org/couchdb/Installing_on_Ubuntu, and installing on Ubuntu8.10 is just

$ sudo apt-get install couchdb

To start,

$ sudo /etc/init.d/couchdb start

$ sudo /etc/init.d/couchdb status

returns

Apache CouchDB is running as process 4455. Time to relax.

Accessing http://localhost:4455/ gives me an error. Following http://wiki.apache.org/couchdb/Installing_on_Ubuntu, accessed http://localhost:5984/ gives me

{"couchdb":"Welcome","version":"0.8.0-incubating"}

on a browser. Well, /etc/couchdb/couch.ini shows the port 5984. Should've looked at.

OK, what's next? Going back to FrontPage of the wiki, and hit Basics. Among the listed languages, choose Getting started with Python. It tells me to install couch-python, but on Ubuntu8.10, all i need is to do

$ sudo apt-get install python-couchdb

python-httplib2 and python-simplejson are installed as well.

python-couchdb installed was version 0.3, and didn't run some examples i ran. Uninstalled it and did

$ easy_install couchdb

which installed versio 0.5 at

/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg

Following http://www.ibm.com/developerworks/jp/web/library/j_wa-couchdb/, installed couchdb0.8.1 after unistalling 0.8.0 as

$ tar zxvf apache-couchdb-0.8.0-incubating.tar.gz
$ cd apache-couchdb-0.8.0-incubating
$ ./configure

At the end on terminal, there were comments checking for JS_NewContext in -ljs... no

checking for JS_NewContext in -lmozjs... no
configure: error: Could not find the js library.
Is the Mozilla SpiderMonkey library installed?

Guess i need to install js library... Installed spidermonkey and libmozjs0d, and ran ./confiture... failed again. Well, i don't know what's missing, but installed the following applications which i skipped

sudo apt-get install build-essentials
sudo apt-get install libtool
sudo apt-get install automake
sudo apt-get install libmozjs-dev
sudo apt-get install libicu-dev
sudo apt-get install erlang

Over 100MB downloaded. Ran ./configure again, and got the last line

You have configured Apache CouchDB. Time to relax.

Ran

$ make
$ make install

Check

$ couchdb -V
couchdb - Apache CouchDB 0.8.1-incubating

OK.

Ran couchdb as

$ couchdb -b
Apache CouchDB has started. Time to relax.
$ couchdb -s
Apache CouchDB is running as process 21959. Time to relax.

The couchdb-python example using Javascript functions now works :-)

• Wrote Teru at 23:47 (edited 11×, last on 27 Dec 2008) | read 33× | 0 Comments

Friday, 04 Jul 2008

permalink Gears

Found Google Gears interesting. Recently its name is changed to Gears, aiming at general purpose API for making web-applications work offline.

To install, visited http://gears.google.com/, and pushed the Install button. After following a couple of instructions on screen by clicking buttons and restarting the Firefox, it's done! Cool :-)

Now samples. Following the link at http://code.google.com/apis/gears/sample.html, download gears_init.js and a zip file for samples and tools.

(to be continues.)

• Wrote Teru at 09:34 (edited 4×, last on 04 Jul 2008) | read 10× | 0 Comments

Thursday, 22 May 2008

permalink Hybrid applications thru Opera widgets

Opera Software announced a draft specification for File I/O access in widgets at http://labs.opera.com/news/2008/05/08/, so that the widgets can access both local files and remote files on servers, leading to so-called "hybrid applications". This is a good direction :-)

To create a widget, Opera Widgets SDK is available athttp://dev.opera.com/articles/view/opera-widgets-sdk/ for download.

• Wrote Teru at 23:28 (edited 1×, last on 22 May 2008) | read 1576× | 0 Comments

Saturday, 03 May 2008

permalink Exhibit Source 2

Found it hard to analyse the source of Exhibit on a server, and decided to do it on my notebook PC.

First install subversion

sudo apt-get install subversion

Installed other recommended packages, subversion-tools and db4.5util as well. Ran, as a user,

cd ~
mkdir Workspace
cd Workspace
svn checkout http://simile.mit.edu/repository/exhibit/branches/2.0 exhibit

As for Java, previously OpenJDK is installed as part of Japanese Setup Helper:

$ java -version
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode, sharing)

Started the built-in Jetty server:

cd exhibit
./run &

Access on Firebox to http://127.0.0.1:8888/exhibit/site/index.html works. But, when running examples, got errors. First of all, Googlemaps, of course. Could i get a Googlemaps key for 127.0.0.1:8888? Anyhow, found one example that doesn't use Googlemaps, cereals. OK, it runs! Still, seems to have a problem of links from "more" in a dialog window...

Since i got a desktop environment to run Exhibit with its source, i will try to do some analysis and experiments by using some tools. First, installed the SCiTE editor, which understand HTML and Javascript.

sudo apt-get install scite

does it, and works soundly :-)

Trying to replace http://static.simile.mit.edu/... with http://127.0.0.1:8888/... but, it's not very straightforward.

• Wrote Teru at 08:31 (edited 6×, last on 03 May 2008) | read 12× | 0 Comments

Friday, 02 May 2008

permalink Exhibit Source

Exhibit is nice, and could be customized to my needs. So, decided to download a source code from here.

cd /usr/local/var
svn checkout http://simile.mit.edu/repository/exhibit/branches/2.0 exhibit

downloaded the source code. Oops, pretty big, over 38MB :-O
To run Exhibit on the server,

cd exhibit
run

will start the Jetty server included in the code.
Got an error. Need to install java. Ran

sudo apt-get install sun-java6-jre

and installed the recommended packages, too:

sudo apt-get install   equivs binfmt-support sun-java6-plugin ia32-sun-java6-plugin sun-java6-fonts ttf-baekmuk ttf-unfonts ttf-unfonts-core ttf-kochi-gothic ttf-sazanami-gothic ttf-kochi-mincho ttf-sazanami-mincho ttf-arphic-uming libmyodbc odbc-postgresql libct1

These days, the repository server in Japan is very slow :(( Need a break.

Gash, the terminal shows [[image: sun-java6-bin_DLJ.png]]
Donno what key should be hit to say Ok :-#
After some trial and errors, found TAB key works :->

Finished installing java (didn't installed the recommended packages yet), and ran

./run &

The Jetty server started successfully. After configuring my reverse-proxy server,http://exhibit.i4pace.net/exhibit/site/index.html showed the cover page for Exhibit. When running an example, got an error [[image: googlemaps_registration_key_request.png]]
Well, need a key for displaying a googlemap... Got a key for http://exhibit.i4pace.net from Google ABQIAAAA5rx0fP0jKPZGPYbWqbfu9xRp-edaKq-jRT1P7zhC_QXpGlaTbBQIYLZdNtFqV7rUKyzjYTgpmci34Q and edited presidents.html in /usr/local/var/exhibit/src/webapp/site/examples/presidents as follows:

<!-- google map key for http://127.0.0.1:8888/ -->
    <script src="http://exhibit.i4pace.net/exhibit/src/webapp/extensions/map/map-extension.js?gmapkey=ABQIAAAA5rx0fP0jKPZGPYbWqbfu9xRp-edaKq-jRT1P7zhC_QXpGlaTbBQIYLZdNtFqV7rUKyzjYTgpmci34Q" type="text/javascript"></script>

Worked!

Changed the reference to API in presidents.html at /usr/local/var/exhibit/src/webapp/site/examples/presidents as

<script href="http://exhibit.i4pace.net/exhibit/api/exhibit-api.js?bundle=false" type="text/javascript"></script>

Installed ant

sudo apt-get install ant

Ran

cd /usr/local/var/exhibit
ant

Past midnite... Sigh and rest.

• Wrote Teru at 22:09 (edited 6×, last on 03 May 2008) | read 146× | 0 Comments

Monday, 21 Apr 2008

permalink SIMILE Exhibit

Started to try SIMILE Exhibit.

Getting started tutorial is a good introduction. Liked facet model a lot :-D Timeline is incorporated in the example. Created a page on this server at http://blog.i4pace.net/exhibit/nobelists.html. Haven't figured out how to deal with a static page on Snakelet... It worked with Pylons runing a Paste server when putting in the static directory, for example, http://pylons.i4pace.net/nobeliists.html. It's straightforward and good. Well, how about running it with Jaxer? Would be interesting :-S

• Wrote Teru at 11:57 (edited 4×, last on 21 Apr 2008) | read 65× | 0 Comments

Friday, 11 Apr 2008

permalink OpenSocial Samples

Worked on part of OpenSocial APO Developer's Guide (v.07). Placed a listFriends application on Orkut Sandbox, and this time there is an output now that I have a friend on Orkut :-)

• Wrote Teru at 02:06 (edited 1×, last on 11 Apr 2008) | read 8× | 0 Comments

Wednesday, 09 Apr 2008

permalink Shindig Samples

Found Shindig samples while reading http://trac.hyves-api.nl/hyves-api/wiki/ShindigStarted. Following README at ~/Src/Shindig/javascript, ran the samples.

Sample 1 at http://localhost:8080/gadgets/files/container/sample1.html shows [[image: shindig_example1.png]]. Looks Ok, and worked fine.

Its source is sample1.html as below:

Line No.
-------        
      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Sample: Simple Container</title>
      5 <!-- default container look and feel -->
      6 <link rel="stylesheet" href="gadgets.css">
      7 <script type="text/javascript" src="../../js/rpc.js?c=1&debug=1"></script>
      8 <script type="text/javascript" src="cookies.js"></script>
      9 <script type="text/javascript" src="util.js"></script>
     10 <script type="text/javascript" src="gadgets.js"></script>
     11 <script type="text/javascript" src="cookiebaseduserprefstore.js"></script>
     12 <script type="text/javascript">
     13 var specUrl0 = 'http://www.google.com/ig/modules/horoscope.xml';
     14 var specUrl1 = 'http://www.labpixies.com/campaigns/todo/todo.xml';
     15 
     16 // This container lays out and renders gadgets itself.
     17 
     18 function renderGadgets() {
     19   var gadget0 = gadgets.container.createGadget({specUrl: specUrl0});
     20   var gadget1 = gadgets.container.createGadget({specUrl: specUrl1});
     21 
     22   gadgets.container.addGadget(gadget0);
     23   gadgets.container.addGadget(gadget1);
     24   gadgets.container.layoutManager.setGadgetChromeIds(
     25       ['gadget-chrome-x', 'gadget-chrome-y']);
     26 
     27   gadgets.container.renderGadget(gadget0);
     28   gadgets.container.renderGadget(gadget1);
     29 };
     30 </script>
     31 </head>
     32 <body onLoad="renderGadgets()">
     33   <h2>Sample: Simple Container</h2>
     34   <div id="gadget-chrome-x" class="gadgets-gadget-chrome"></div>
     35   <div id="gadget-chrome-y" class="gadgets-gadget-chrome"></div>
     36 </body>
     37 </html>

Reading the code:

  1. Body specifies divisions with ID and CLASS, and the function to be performed on loading.
  2. Header specifies title, CSS file, relevant JavaScript files, URLs of gadgets, and then define the onLoad function.
  3. Onload function:
    1. creates gadgets,
    2. adds gadgets to container,
    3. sets layout, and
    4. renders gadgets.

Pretty straightforward in meaning :-) Still found it difficult to analyse the gadget, e.g., at http://www.google.com/ig/modules/horoscope.xml.

Ran other samples. Sample 4 and 5 didn't perform well. Other samples upto 7 ran nicely.

• Wrote Teru at 17:46 (edited 5×, last on 10 Apr 2008) | read 32× | 0 Comments

Tuesday, 08 Apr 2008

permalink Caja

The Shindig page mentioned Caja, which enhances Javascript security.

Google-caja is a source-to-source translator for securing Javascript-based web content. OK, shall I install it? Wait... it might be better for me to first see how Caja works by using it untranslated as a library. Let me think...

Skipping around some pages of google caja wiki, I learned so far the following:

  1. Caja is a library to enhance security of JavaScript.
  2. Caja modules are created by "cajoling".
  3. Cajoling is to turn an OpenSocial gadget specification into a Caja module.
  4. Hosting Caja modules is explained at this link.

I figure I'd better find a good OpenSocial example first before trying Caja.

• Wrote Teru at 15:16 (edited 2×, last on 10 Apr 2008) | read 11× | 0 Comments

Saturday, 05 Apr 2008

permalink Shindig

Started to install Apache Shindig. At http://incubator.apache.org/shindig/, found the prerequisites:

  1. Java1.5 JDK/JRE or later
  2. Subversion
  3. Maven

The first two are available at Ubuntu Repositories. Download Maven and untar it as below:

su
cd /usr/local/lib
wget http://archive.apache.org/dist/maven/binaries/apache-maven-2.0.8-bin.tar.gz
tar -xzvf apache-maven-2.0.8-bin.tar.gz

Set the environment parameters PATH and JAVA_HOME by adding the following lines to /etc/bash.bashrc.

JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.03"
PATH="/usr/local/lib/apache-maven-2.0.8/bin:$JAVA_HOME/bin:$PATH"

As an example, http://localhost:8080/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml And, check

>source /etc/bash.bashrc
>printenv | grep JAVA
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.03
>printenv | grep PATH
PATH=/usr/local/lib/apache-maven-2.0.8/bin:/usr/lib/jvm/java-6-sun-1.6.0.03/bin:/usr/local/sbin…
>mvn --version
Maven version: 2.0.8
Java version: 1.6.0_03
OS name: "linux" version: "2.6.22-14-rt" arch: "i386" Family: "unix"

This completes the prerequisites, and now proceed to "Getting the code" at http://incubator.apache.org/shindig. As a user, do:

>mkdir -p ~/Src/Shindig
>cd ~/Src/Shindig
>svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ .

As a result,

>ls
COPYING  NOTICE  config  features  javascript  pom      site
LICENSE  README  etc     java      php         pom.xml

Then,

cd java/gadgets
mvn package

download lots and lots of files. Showing below is the last lines of the output.

:
:
[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[gadgets] in [/home/laurel/Src/Shindig/java/gadgets/target/gadgets]
[INFO] Processing war project
[INFO] Copy webapp webResources[/home/laurel/Src/Shindig/java/gadgets/../../javascript/] to[/home/laurel/Src/Shindig/java/gadgets/target/gadgets]
[INFO] Webapp assembled in[719 msecs]
[INFO] Building war: /home/laurel/Src/Shindig/java/gadgets/target/gadgets.war
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [source:jar {execution: attach-sources}]
[INFO] Building jar: /home/laurel/Src/Shindig/java/gadgets/target/gadgets-sources.jar
[INFO] [jar:jar {execution: default}]
[INFO] Building jar: /home/laurel/Src/Shindig/java/gadgets/target/gadgets.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 minutes 21 seconds
[INFO] Finished at: Sun Apr 06 00:00:33 JST 2008
[INFO] Final Memory: 25M/45M
[INFO] ------------------------------------------------------------------------

Now run the Jetty server by

mvn jetty:run-war

Its last output lines are

[INFO] [jetty:run-war]
[INFO] Configuring Jetty for project: Apache Shindig Java Gadget Server
2008-04-06 00:59:53.875::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /gadgets
[INFO] Tmp directory =  determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] Starting jetty 6.1.9 ...
2008-04-06 00:59:54.304::INFO:  jetty-6.1.9
2008-04-06 00:59:54.360::INFO:  Extract jar:file:/home/laurel/Src/Shindig/java/gadgets/target/gadgets.war!/ to /home/laurel/Src/Shindig/java/gadgets/target/work/webapp
2008-04-06 00:59:54.102::INFO:  No Transaction manager found - if your webapp requires one, please configure one.
2008-04-06 00:59:56.298::INFO:  Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

As an example, http://localhost:8080/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml showed the screen below.
[[image: jetty_server_gadget_example.png]]
OK, it works! :-> So nice! But, how did it work? Study (!) I think this gives me a good environment to study Gadget and OpenSocial applications.

Now how can I stop the server? This time, just hit Ctrl-C :-O Below is the output at the terminal.

2008-04-06 11:42:39.133::INFO:  Shutdown hook executing
2008-04-06 11:42:40.696::INFO:  Shutdown hook complete
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 644 minutes 59 seconds
[INFO] Finished at: Sun Apr 06 11:42:40 JST 2008
[INFO] Final Memory: 15M/28M
[INFO] -----------------------------------------------------------------------


Oh, how about my first helloworld gadget at http://blog.i4pace.net/helloworld.xml? Tried http://localhost:8080/gadgets/ifr?url=http://blog.i4pace.net/helloworld.xml, and the browser showed Hello World! A little yay :-) It's always good to start from the most simple way of doing things.

Another one introduced in a OpenSocial tutorial worked as well. Specifying the URL http://localhost:8080/gadgets/ifr?url=http://blog.i4pace.net/gifts_5_streams.xml shows a screen below: [[image: gifts_streams.png]]

Don't know how to daemonize the start/stop of the server... Meanwhile, will run it in the background. Then, need to find out what processes to kill to stop the server.

• Wrote Teru at 18:26 (edited 24×, last on 09 Apr 2008) | read 57× | 0 Comments

10 shown; more articles may be found in the archives. The permalink icon is the article's permalink.
Process times: page=0.388 request=0.399 cpu=0.400