Category: "Dojo"

Choosing javascript Libraries and Toolkits

If you want to add sophisticated client side functionality to a site, and are considering a javascript library like jQuery, dojo, scriptac….us, etc, remember:

  • Powerful tooks often add significant overhead. It isn’t worth using a library to support a single pull-down menu.
  • Try to find on-demand loading, where only the code required is downloaded.
  • Consider themes offered by the toolkits before designing the site. They can greatly improve your design and will work better with the library functions.
  • If you’re using AJAX, definitely use a library.
  • Remember that you can limit the library’s impact by placing it only on those pages which truly require the functionality.
  • Set up caching headers for the library code and CSS. They will probably never change (you shouldn’t change them).
  • Try the libraries out before choosing one. Use more than one if you feel it is worthwhile.
  • Use a CDN.
  • Be prepared to invest a significant amount of time in learning curve.

dojo - ContentPanes - compression

To compress the content delivered to a dojo ContentPane, you can compress the content and cache it with the Zlib functions of PHP, then open it with the filesystem functions and deliver it with the Content-Type header set to “text/html” (or other appropriate setting), and Content-Encoding set to “gzip“.

The compress and cache should be performed if the file is likely to be reused. If reuse is unlikely, or the file is relatively small, use gzencode or gzdeflate.

This should work with other libraries as well.

RIA Hosting

Using RPMs to install open source toolkits such as dojo, Smarty, and Zend Framework allows hosting companies to create a cost-efficient architecture to offer clients servers ready to support RIAs and sophisticated sites.

This may improve security by allowing the hosting company to prevent clients from modifying open source products. Access to the code can be provided easily through the use of symlinks. Account setup can be automated with server management/admin software like WebHostManager and Plesk - by customizing the account setup scripts with additional RPMs.

Advantages:

  • Significant savings in disk space
  • Elimination of installation at the account level
  • Permission management performed at the server level
  • Ease of toolkit maintenance, a single installation can be upgraded for the whole server
  • Offering an RIA ready server is a valuable service that may be delivered in a cost effective manner. It may be an offering that makes one hosting company more attractive to clients than another, in other words, good business sense.

Disadvantages:

  • Changes to the toolkits will affect every site, thus they cannot be changed easily, and upgrades may be disruptive. However, based on the assumption that this code should not be modified, and upgrades are often security related, synchronizing the toolkits across the server is reasonable.
  • An excellent understanding of the server architecture, software, and RIA toolkits is required for a graceful implementation.

Open Source RPM .spec file

This is an RPM .spec file for dojo, that will install it in /opt/os/dojo

.rpmmacros

%_topdir /home/account
%_buildroot %{_topdir}/BUILD
%_tmppath %{_topdir}/tmp

dojo.spec


%define targetdir opt/os/dojo
%define version 1.1
%define release 1
%define name dojo
%define dojo %{name}-release-%{version}.%{release}

Summary: dojo Toolkit
Name: %{name}
Version: %{version}
Release: %{release}
Copyright: GPL
Group: Development/Tools
#Source: dojo-release-1.1.1.tar.gz
Source: http://download.dojotoolkit.org/release-1.1.1/dojo-release-1.1.1.tar.gz
Provides: %{name}
BuildRoot: %{_buildroot}
%description
dojo Toolkit

%prep
%setup -q -n%{dojo}
tar tzf %{_topdir}/SOURCES/%{dojo}.tar.gz | grep -v "/$" | sed "s/dojo-release-1
.1.1//"| awk '{ print "\"/%{targetdir}"$0"\""; }' > %{_topdir}/outfile
mkdir -p $RPM_BUILD_ROOT/%{targetdir}
rm -rf $RPM_BUILD_ROOT/%{targetdir}/*
%build -n%{dojo}
%install -n%{dojo}
mv * $RPM_BUILD_ROOT/%{targetdir}
%clean -n%{dojo}
rm -rf $RPM_BUILD_ROOT

%files -f %{_topdir}/outfile

The same general approach will work for Zend, Smarty, Drupal and many others. Expect to have to adapt the name of the tar/gzip/zip file - hence the use of the %{dojo} macro. The tar tzf command allows the RPM to be installed in a directory with other code. Although it is unlikely dojo would be placed in a directory with other code, the tar listing allows you to place several tars in the same directory, and still manage them with RPMS.

Download: http://wirehopper.com/dojo-1.1-1.i386.rpm
Source RPM: http://wirehopper.com/dojo-1.1-1.src.rpm

If you use the RPM to install dojo, use a symlink (ln -s /opt/os/dojo dojo) from DocumentRoot. This will allow a single installation of dojo to support all your sites.

Notes

An image is worth 1000 pixels

Rich interface applications require careful designs, and should almost always be multi-lingual capable. One of the best ways to achieve this for small page elements is the use of images as labels.

Examples:

  • Red circle with line through it - means ‘you can’t do this’
  • WYSIWYG labels - are so prevalent most people understand all of them, including links, images, bold, italic, etc.

Page layouts

Many times, a page has more content than can be displayed. Accordian panes and tabs are a great way to make additional content available to the page viewer, without requiring them to scroll or navigate away from the page. dojo

eZ publish integration

Add these .htaccess to easily allow additional applications or files to be added to an eZ publish site. I haven’t tried them with eZ yet - but they work with b2evolution. Be sure to place them carefully. :)


# Redirect anything that's not an existing directory or file to index.php
#
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f