Thursday, September 14, 2006

TIPS - How to force font style of Lotus Notes rich text items on Web

I hate web site where text font changes between pages. It's possible to control graphical chart on public web sites but it's impossible with Intranet applications. If we define default font on rich text field, the users can change it. They just have to copy/paste Word document or Web Page in rich text to lose default font property.

Fortunately, Lotus Domino uses "old" html tag to change font properties : <font>. I don't use any more this font since CSS style sheet. If you redefine the properties of this tag in a CSS style sheet, you can bypass text font arguments passed by Lotus Domino and then force your text font properties for all the informations in rich text field.

For example if I define style :

<style>
font {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1em;
}
</style>
All the content of the rich text will be display in tahoma 1em. The user can add bold or italic but if he defines bigger size font, the content of the text will be display on Web in 1em, no more.

With this method you force font properties of all <font> tag of your document. If you want to restrict the effect to only one rich text field only, you just have to embedded it in div with specific class name :
<div class="mybody">
Richtext field
</div>
Then style sheet will look like this:
<style>
#mybody font {
font-family : georgia, "Times New Roman", Times, Roman, serif;
font-size : 12px;
}
</style>

GOOGLE API - Another tips with Google Maps

I've discovered two new functions in google maps api release 2 : Geographical localisation from postal address and multitab info box.

Geographical localisation with Google API

In one of my first entries in this blog I've describe a method to search geographical localisation from postal address. This method had two problems for me :

  1. I must separate each element of my postal address (street, town and country)
  2. I'm not sure this service will be available during long time
Google Maps API offers the solution with Geocoder.

One of the most simple solution to extract longitude and latitude is to use it thru http call like this :
http://maps.google.com/maps/geo?q=adresse+recherchee&output=csv&key=abcdefg
Where :
  • q= : postal address to search. For example : waterloo+bridge+london
  • output= : file format to send response. You can choose xml, kml, json or csv. The csv format is the most simple.
  • key= : your Google Maps API key

CSV format response send four values : code status (200 if all is good), zoom level, latitude and logitude.

Multi tabs info box

If you want to display information box with multiple tabs, you just have to replace the call marker.openInfoWindowHtml(bulle);, like I've described it in a precedent article, by marker.openInfoWindowTabsHtml(infoTabs); where infoTabs is defined like this :
var infoTabs = [
new GInfoWindowTab("Tab1 title", "Content of tab 1"),
new GInfoWindowTab("Tab2 title", "Content of tab 2")
];

Sunday, September 10, 2006

AJAX - Photo library (2nd Part) : How to zoom on a photo

A new Javascript Library is used more and more on Web 2.0 sites : Lightbox. This AJAX library, based on prototype.js and scriptaculous, display effect to zoom from a thumbnail. For example, you can find this functionality on Zoomr.


How to install the javascript library

  1. to download the javascript library on http://www.huddletogether.com/projects/lightbox2/
  2. to uncompress the zip file
  3. to add protoype.js, scriptaculous.js, effect.js, lightbox.js and lightbox.css files in shared resources library of your Lotus Notes Database
  4. to add close.gif, loading.gif, blank.gif in shared pictures resources of your Lotus Notes database. You can added this other pictures too but it's not necessary in this example.
How to use LightBox Javascript library with Lotus Notes
The first step is to declare javascript files on your web page. This web page can be a form or Lotus Notes page. The HTML header content looks like :
"<link rel=\"stylesheet\"
type=\"text/css\" href=\"lightbox.css\"
media=\"screen\" title=\"Normal\" />
<script src="\" type="\">
</script>
<script src="\" type="\">
</script>
<script src="\" type="\">
</script>"
Be careful with the path of your javascript files.

Add an Onload event :
initLightbox();
Your form or page is ready to use lightbox. To add photo in your web page you have to add in the content of your web page :
<a href="path_of_the_big_picture" rel="lightbox">
<img src="path_of_the_thumbnail_picture" />
</a>
Download an example
You can dowload an Lotus Notes Database who show how to implement lightbox library with Domino. This application is very simple and in english.

download the database

AJAX - Photo library (1st Part) : How to display a slideshow without Flash

After summer holiday, it's time to show photos to all the family. This article and the next present how to use AJAX libraries to add effects on photo without using Flash. This first part show how to integer a slideshow, the next how to zoom on photo with the actual very famous library lightbox.


Jonathan Shemoul's Smooth SlideShow
The Jonathan Shemoul's Smooth Slideshow javascript library allow to display animated splash screen or header to your web Site. This library uses protoype.js and moo.fx. The total file size of this library (without pictures) is around 21,6 kB. To compare with Flash solution, dewsliders (famous french flash picture slideshow) use 30,4 kB. I don't want to compare this two solutions because I don't know Flash. The choice of this javascript library is motivated by the target of this blog, how to implement AJAX solution with Lotus Domino.

Installation of the library
To use the library you must first download the files. Extract the files from the zip file. Add the files in shared resources of your database :

  • moo.fx.js
  • moo.fx.pack.js
  • protoype.lite.js
  • showcase.slideshow.js
  • timed.slideshow.js
  • jd.slideshow.css
How to use the library
To use the library you must :
  • to declare javascript library ans css style sheet in the header of your web page
  • to declare the pictures files to display in the slideshow
  • to custommize the size of the slideshow
  • to define where to display the slideshow in your web page
The pictures to display is define thru a javascript array like this :
mySlideData[countArticle++] = new Array(
'picture1.jpg',
'linkedwebpage1.html',
'Item 1 Title',
'Item 1 Description'
);
How to use it in Lotus Notes database
To manage easily the photo to display in my slideshow, I use a form to record each pictures. This form have the fields :
  • Title : text field
  • Link : text field
  • Description : text field
  • Photo : rich-text field
I define a view to display this documents. This view will be called by the javascript to define the array. Then I specify the formula of my second column like this :
"mySlideData[countArticle++] = new Array('"
+ "0/" + @Text(@DocumentUniqueID) + "/$file/"
+ @subset(@attachmentnames; 1) + "', '"
+ Lien + "', '"
+ Titre + "', '"
+ Description + "');"
The first column of my view is defined with the sort key I want to use. In my example the title of the document. Don't forgotto specify this column as sorted to use @dbcolumn.

To created my Web page who displayed the SlideShow I use a Lotus Notes Page. You can use a form too if you want.

In the HTML header content we must specify the path to javascript files and css stylesheet file, add an OnLoad event to load the library and add the picture array :
Photos:= @DbColumn("":"";"";"Photos" 1);
@If(@IsError(val); "" ;
"<script src="\" type="\"></script>
<script src="\" type="\"></script>
<script src="\" type="\"></script>
<script src="\" type="\"></script>
<link rel=\"stylesheet\" href=\"jd.slideshow.css\"
type=\"text/css\" media=\"screen\" />

<script type="\">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func; }
else {
window.onload = function() {
oldonload();
func();
}
}
}
function startSlideshow() {
initSlideShow($('mySlideshow'), mySlideData);
}

countArticle = 0;
var mySlideData = new Array();"
+ @Implode(Photos) +
"addLoadEvent(startSlideshow); </script>
<style>
#mySlideshow {
width: 400px !important;
height: 200px !important;
}
</style>");

With "Photo" the name of view who displayed photos.

Now, you just have to add in your web page :
<div id="mySlideshow"></div>
to define where you want to display the slideshow.

You can display an example with my photos from Britain.

Monday, September 04, 2006

AJAX - Tag Clouds

I searched how to implement a tag cloud on my Lotus Notes application for web and I've the surprise to find quickly 3 solutions. All this solution implemented three differents way. I find them very interresting because they reproduced the three standard new ways to develop Lotus Notes Application on Web; Formula & Javascript, LotusScript and LotusScript with DXL.

What is a tag cloud ?

A tag cloud is a representation of keywords defined by users who are displayed with a font size proportional at his importance. The most common criteria to define importance is the number of occurence of this tag in all the documents.

You can find tag cloud in all the important web 2.0 application like delicious, Flickr or Technorati.


If I want to use tag use, it's to replace the categorized view. I find categorization too hard to manage in web application.

Three ways to implement a tag cloud in Lotus Notes for the Web

First Way : Formula & Javascript
Ferdy Christant suggest to create a javascript array thru Notes view with little formula. The tag cloud is generated by Javascript on browser.

The principal advantage is to not overload the server. Only a view is called by the users.

Unfortunately this solution is not perfect

  • The browser must support Javascript. If all the modern browser allow to run Javascript code, the user can deactivate this option. Second thing, if the Javascript can be executed, we must be careful to not overload the browser with too much data.
  • One of the advantages of tag cloud for webmaster is for indexation on search engine. For search bots, a tag cloud is a library of links with smart keywords, the tag, to index the content of the link. Today, the javascript isn't running by this bots. Then, the tag cloud is ignore by search engine.
  • You can't use this method to display tag cloud on Lotus Notes Client
Second way : Traditional LotusScript
Thomas Adrian uses a LotusScript agent to build the TagCloud. The tag cloud is computed in real time from an agent who is based on NotesView Navigator and print function. The server must run this agent for every call to display the tag cloud. The advantage is that the tag cloud is coded in HTML format, then the search bot can index it. The disavantage of that solution is the avantage of the first solution and inverse.

If I had to choose one these two solution, I will prefer first for an Intranet and second for Internet. In an intranet application I can control browsers versions, I don't need to index my tag cloud and the most important is to preserve the CPU.

Third way : LotusScript with DXL
Christian Mueller purpose a variation of the second solution with DXL. He computes the tag cloud with the same method than Thomas Adrian but doesn't display the result directly to the browser. He saves the result in a new form with DXL. We just need to execute the agent when a document is created, updated or deleted, when the tag cloud is modified.

With this solution the server has just to open a form to display the tag cloud in HTML format. Another advantage is it's possible to display the tag cloud on Lotus Notes Client.

Is the ideal solution ? It's the best solution for my first constraints. But there are two new problems :
  • In french version of this blog, Yogi has remarked it's not possible to manage documents with reader field,
  • It's difficult today to find developper who really knows DXL to integer and maintain this type of application.