Archive for the ‘ajax’ Category

viennastreetstyle.com

Tuesday, May 27th, 2008

ViennaStreetStyle

Some days ago my first Rails application went live:

ViennaStreetstyle.com - ViennaStreetStyle is a simple photo gallery showing people on the streets of Vienna, Austria presenting their own style of street fashion.

I developed this application for friends of mine who had the idea for ViennaStreetstyle.com.

Development was quite straight-forward without any kind of a big suprise by using the following plugins/libraries:

  • attachment_fu
    For uploading and handling the images
  • geokit
    for locating the shots on the map of Vienna
  • YM4R
    Greatest plugin for doing all the GoogleMaps stuff
  • prototip
    Javascript library for easy rendering of complex tooltips

The whole system is running on a busy 256 MB VPS under Mongrel with 2 server instances (so in best condition to get slashdotted or sth like that).
But it is somehow an experiment for me how far you can go with that low server specs.

AJAX Rain - Javascript/DHTML repository

Tuesday, March 18th, 2008

AjaxRain

 

 

 

AJAX Rain - for me the first place to look at - if I want Javascript magic!

AJAX file uploads in Rails

Friday, March 14th, 2008

Ever tried to do a file upload in a remote_form_tag. I did! - And I failed.
Digged a little bit deeper what a XMLHttpRequest is allowed to do and then it was clear for me that it won’t work. But I didn’t wanted to let loose and then I found some ideas about “iframe remoting pattern” - This seems to sove the problem - But how to implement it in Rails?

This tutorial was great help! It explains how to do that stuff using attachment_fu and respond_to_parent.
It was just a walktrough!

Using YM4R/GM

Wednesday, February 20th, 2008

In my actual RoR project I have a heavy usage of Google Maps. For gecoding I use the well known geokit plugin. But for rendering the maps I stepped across YM4R/GM.

It is so damn easy to render maps by writing Ruby code - and much more DRY than manually building your Javascript code!
From my point of view it is nearly a 1:1 Ruby mapping of what you can do with the GMap2 API.

While writing my first lines of YM4R/GM code I got a little bit nevous - what I wanted to do was just not working. YM4R/GM is quite well documented, but left out the hint for my actual problem. Finally I managed it, so I want to share my Heureka! with you:

The Situation:
I just wanted to create a map, initially add a Marker to it and add an event listener to this Marker …

My first code was:

@map = GMap.new(”map”)
@map.control_init(:map_type => false, :small_zoom => true)
@map.center_zoom_init(@shot.lat_lng, 15)
@marker = GMarker.new(@shot.lat_lng)
@map.overlay_init(@marker)
@map.event_init(@marker,:click, “function(){window.location.href =’#{shot_url(@shot)}’;}”)

and the output was:

map = new GMap2(document.getElementById(”map”));
map.setCenter(new GLatLng(48.221131,16.371907),15);
map.addOverlay(new GMarker( new GLatLng(48.221131,16.371907)));
GEvent.addListener(new GMarker( new GLatLng(48.221131,16.371907)) ,click”,
function(){window.location.href = ‘http://localhost:3002/shots/2-Peter’;});
map.addControl(new GSmallZoomControl());

So, as you can see, this code produced a Marker for adding to the map but a different Marker for assigning the event.

This code works:

@map = GMap.new(”map”)
@map.control_init(:map_type => false, :small_zoom => true)
@map.center_zoom_init(@shot.lat_lng, 15)
@marker = GMarker.new(@shot.lat_lng)
@map.declare_init(@marker, “marker_var_name”)
@map.overlay_init(@marker)
@map.event_init(@marker, :click,
“function(){window.location.href = ‘#{shot_url(@shot)}’;}”)

 

The bold line says YM4R to handle the variable @marker as a javascript variable further on!

the correct output:

map = new GMap2(document.getElementById(”map”));
map.setCenter(new GLatLng(48.221131,16.371907),15);
var marker_var_name = new GMarker(new GLatLng(48.221131,16.371907));
map.addOverlay(marker_var_name);
GEvent.addListener(marker_var_name,”click”,
function(){window.location.href = ‘http://localhost:3002/shots/2-Peter’;});
map.addControl(new GSmallZoomControl());

In the next couple of days I will try out the built in RJS magic to update Markers after changing the view of the map. Will get back to you with some new experiences.

Google API Slides

Monday, May 15th, 2006

Patrick Chanezon posted his slides that he used for his speech at the
“Ajax Experience” to his blog.

I find them really interesting and a whole lotta bunch of useful information about Google Maps API, Google Data API besides Einstein and Duffy Duck.

Yahoo! UI Library adds AutoComplete, Windowing, Menu and More

Thursday, May 11th, 2006

The Yahoo! team has released another version of the Yahoo! UI library.
These seems to be another real great bunch of handy AJAX tools from the YAHOO people!