Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Install Timeline js to your javascripts directory (See related posts)

1) Export the Timeline source from the Google repository into a local directory 'timeline' Note this directory does NOT have to be served by your webserver.
svn export http://simile-widgets.googlecode.com/svn/timeline/trunk timeline

2) Create a directory served by your web server for the timeline library and the needed timeline ajax library
mkdir javascripts/timeline

3) Run my simple timeline installer (below) to move just the necessary files from your local timeline source directory to your web server's javascript directory

4) In your html file that includes a Timeline:
Option 1:
No changes to the timeline-api.js -- Need to explicitly load the ajax library as shown here:
   <script src="http://YOUR_SERVER/javascripts/timeline/timeline_ajax/simile-ajax-api.js" type="text/javascript">
   </script>
   <script>
     (function() {
       Timeline_urlPrefix='http://YOUR_SERVER/javascripts/timeline/timeline_js/';       
       Timeline_parameters='bundle=true';
      })();
    </script>
    <script src="http://YOUR_SERVER/javascripts/timeline/timeline_js/timeline-api.js" type="text/javascript">
    </script>


Note: There may be a race condition caused by creating the Timeline before the dom is ready for changes.

Alternate is modify timeline-api.js to use your server to supply the simile-ajax-api.js library.

The install script copies over just the files needed at runtime.

#!/bin/sh

# timeline_install.sh
# 
# Run from the timeline root directory after doing an export.
# The directory should have the following files in it:
#   src/webapp/api/timeline-bundle.js
#   src/ajax/api/simile-ajax-bundle.js
#
# 
# arguments: <dir> destination root directory for js.
#
timeline_api_dir="src/webapp/api/"
timeline_api_files="timeline-api.js timeline-bundle.js timeline-bundle.css"
timeline_subdirs='./images ./scripts/l10n'

ajax_api_dir="src/ajax/api/"
ajax_api_files="simile-ajax-api.js simile-ajax-bundle.js"
ajax_subdirs='./images ./scripts/signal.js'


if [ $# -eq 0 ]
then
  echo "usage: timeline_install.sh destination_directory"
  exit
fi

# are we starting in the right place?
if [ ! -s src/webapp/api/timeline-bundle.js ]
then
  echo "problem: this command must be run in the directory that has the src/ subdirectory for Timeline. (src/webapp/api/timeline-bundle.js not found)"
  exit
fi

if [ ! -s src/ajax/api/simile-ajax-bundle.js ]
then
  echo "problem: this command must be run in the directory that has the src/ subdirectory for the Simile Ajax library. (src/ajax/api/simile-ajax-bundle.js not found)"
  exit
fi

# destination directory exists?
dest=$1  # dest -- destination directory

if [ ! -d $dest ]
then
  echo "problem: the destination $dest is not a vailid directory"
  exit
fi

# Good to go!
echo "Installing Timeline library to $dest"

timeline_src_dir=`pwd`

# create destination directories
cd $dest
mkdir timeline_js
mkdir timeline_ajax
cd timeline_js
dest_timeline=`pwd`
cd ../timeline_ajax
dest_ajax=`pwd`
cd $timeline_src_dir # back to source dir

# Timeline and supporting libraries
for t in $timeline_api_files
do
  cp "$timeline_api_dir$t" $dest_timeline
done 

  (
    cd $timeline_api_dir
    for t in $timeline_subdirs
    do
      tar -cf - $t |(cd $dest_timeline; tar -xpf -) 
    done
   )
  
# Ajax library
for t in $ajax_api_files
do
  cp "$ajax_api_dir$t" $dest_ajax
done 

  (
    cd $ajax_api_dir
    for t in $ajax_subdirs
    do
      tar -cf - $t |(cd $dest_ajax; tar -xpf -) 
    done
   )
   
echo "#####################################################################"
echo "#"
echo "#"
echo "# In your Timeline file, the js urls should translate to the files"
echo "#    $dest/timeline_js/simile-ajax-api.js    and"
echo "#    $dest/timeline_ajax/timeline-api.js"
echo "#"
echo "#"
echo "#####################################################################"
echo ""
echo ""


You need to create an account or log in to post comments to this site.


Click here to browse all 6642 code snippets

Related Posts