Monthly Archives: June 2006

Javascript obfuscation

I’ve been getting much better along with atlas lately. Almost up to the point that it takes me almost the same time to create page in asp.net than it does me to create a page in atlas. Notice the word almost :) And that’s optimism talking

Anyway it does take a wee while longer to create an atlas page than it would to create an asp.net page. But the result is about 10x as usable and than a normal page.

That being said. All that atlas goodnes comes at a cost : A lot of javascript being pushed down to the browser. When I was in wellington on wednesday there was somebody talking about atlas in the user group.  Seen as I will go talk to the regional groups I was quite keen what Tatham had to say on the subject.

It was interesting but at a certain point he talked about the “obfuscated” javascript files. Those are just packed. That made me think that I also want to have packed javascript that is slightly less readable. I remember I have some open source library that I downloaded a year or so ago.

Well the guy has a nice library that you can download here :

http://dean.edwards.name/packer/

It’s nice but his HttpHandler doesn’t work for me. But there’s a simple work-around. Make your own handler that reads the javascript file and uses his Pack function.

If somebody is interested in the code just drop me an email and i’ll send it to you.

safari fix for the client library of atlas

If you’re not using the control toolkit for atlas and are doing some client side scripting. you may find that the April CTP has doesn’t always work in the safari browser.

This is in part due to the way that safari attaches events.

In the control toolkit they use the following script to “patch” the april CTP of atlas to support safari a whole lot better. Some might find it useful :-)

   40     // This fixes a bug in the Atlas Safari compatibility layer that

   41  // prevents chaining multiple handlers to an event.  We will remove

   42  // this after an Atlas CTP refresh resolves the underlying issue.

   43  //

   44  if (window.__safari) {

   45     window.console.log(“Patching Safari compat layer”);

   46     (function() {

   47         var attachEventProxy = function(eventName, eventHandler) {

   48             this.addEventListener(eventName.slice(2), eventHandler, true);

   49         }

   50 

   51         var detachEventProxy = function (eventName, eventHandler) {

   52             this.removeEventListener(eventName.slice(2), eventHandler, true);

   53         }

   54 

   55         window["HTMLHtmlElement"] = document.createElement(“html”).constructor;

   56 

   57         function HTMLElement() {}

   58 

   59         HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;

   60         var HTMLDocument = document.constructor;

   61         window.attachEvent = attachEventProxy;

   62         window.detachEvent = detachEventProxy;

   63         HTMLDocument.prototype.attachEvent = attachEventProxy;

   64         HTMLDocument.prototype.detachEvent = detachEventProxy;

   65         HTMLElement.prototype.attachEvent = attachEventProxy;

   66         HTMLElement.prototype.detachEvent = detachEventProxy;

   67 

   68     })();

   69 }

Make ATLAS support the Guid in javascript

I use guids as PK in my databases.

I like guids :) But atlas shows them as Object and that gives me some trouble using them in my atlas pages.

But to implement your own converter is not so difficult you just inherit from the JavaScriptConverter and override those methods.

And afterwards you have to register it in the converters section of the web.config

The web.config

   21 <microsoft.web>

   22         <converters>

   23             <add type=Microsoft.Web.Script.Serialization.Converters.DataSetConverter/>

   24             <add type=Microsoft.Web.Script.Serialization.Converters.DataRowConverter/>

   25             <add type=Microsoft.Web.Script.Serialization.Converters.DataTableConverter/>

   26             <add type=Flanders.Library.AtlasControls.GuidConverter />

   27         converters>

 

The Converter Class:

    1 using System;

    2 using Microsoft.Web.Script.Serialization;

    3 

    4 namespace Flanders.Library.AtlasControls

    5 {

    6     public class GuidConverter : JavaScriptConverter

    7     {

    8         public override string Serialize(object o)

    9         {

   10             Guid guid = Guid.Empty;

   11             if(o is Guid)

   12                 guid = (Guid)o;

   13             return “‘”+guid.ToString()+“‘”;

   14         }

   15         protected override string GetClientTypeName(Type serverType)

   16         {

   17             return “Guid”;

   18         }

   19         public override object Deserialize(string s, Type t)

   20         {

   21             throw new NotSupportedException();

   22         }

   23         protected override Type[] SupportedTypes

   24         {

   25             get

   26             {

   27                 return new Type[] { typeof(System.Guid) };

   28             }

   29         }

   30     }

   31 }

Django vs ruby

Ruby looks to me like a hack. I’m not the only one with problems there :)

http://tabo.aurealsys.com/archives/2005/10/11/django-or-why-i-chose-it-over-turbogears-and-ruby-on-rails/

I  decided to ignore Ruby for the moment and focus on Rails. What i noted:

  • Very simple to install and set up new projects
  • You create a database and it’s tables, and Rails will handle them
  • Things get messy when you want to write SQL instead of using the framework to access the data model
  • URL generation is simple but not flexible
  • Rails templates looked ASPish, horrible, almost cthulhian. I couldn’t stand the sight of them. There is too much code in them and worst of all, I couldn’t find a way to change the template system (Clearsilver in Rails anyone?)

Modern web design time division

My friend Miel found this site from poisoned minds.

They have a nice breakdow on how time is really spent when developing a website. Of course this is good for a laugh :)

Poisoned mind webdesign piechart

I think they do have a point with the pure css lay-out. I for one am a dropshadow fan because if I put 2 divs on top of each other they need to look like there is some distance between them. I like the depth af the whole idea.  Up till now I haven’t found a way to create a rectangle with rounded corners and a dropshadow (like in photoshop or fireworks dropshadow) using only divs. I can do it easily using tables tho.

But IE users must die. People love to attack microsoft stuff and I think those that complain about the quirks in IE start developing their site for other browsers than IE and that’s where those people make a thinking mistake. The logic behind it is : if 95% of the users use IE why would you start developing a site that does not target this browser primarily.

Actually it is really starting to piss me off. All the time spent whining about how bad everything is what ms does, while working on a Windows XP machine with Office 2003/7 and visual studio on it, the time should be spent on making your life and the life of others easier. If you understand pc’s and coding a little it means you rarely have to be faced with the same problem twice.
I’ve been making websites for 8 years now, most of them not so pretty especially the first few years :)
And I haven’t come across the IE problem that all the others seem to be facing.  However i do have problems with browsers like Konqueror (this is just a piece of sh**), safari (Konqueror based say no more) and Opera.
Up to the point that i don’t want to spend the money on supporting those (except for safari if it is really necessary).

Essential Tools for web development

Peter has a post giving an overview of some tools that are essential to him as a developer.

http://jonesie.net.nz/EssentialTools.aspx

I would say that I use most of them but not all and I would like to add a few to the list because i mainly do webdevelopment and that’s a different story then winforms.
Obviously I made the choice to go for atlas so I won’t sum up any other ajax frameworks. That is reserved for a separate post. 

AJAX/Web development:

Internet Explorer :
Fiddler - a tool to view http traffic (that gets sent through IE)
WebdevelopmentHelper BHO - A tool written by Nikhil Kothari and I consider it crucial
Internet Explorer Developer Toolbar - This has got a lot of cool things you do want to know about your page sometimes.

Mozilla/firefox :
Greasemonkey - makes firefox highly extensible.
WebDeveloper toolbar - This has got a lot of cool things you do want to know about your page sometimes.
Venkman Javascript Debugger – Javascript debugging is a must :)
Greasemonkey Http Trace script – does the same as the BHO or fiddler for IE.

Collaborative development:
We are mostly using team foundation server to do continuous integration. However sometimes when a lot of different parties are involved we can’t use the team foundation testing suite and then we use other tools to do our integration.

TestDriven.NET - does nunit testing and code coverage in VS 2005 – this used to be free but it isn’t anymore.
CruiseControl.NET – does the builds based on nAnt or msbuild build scripts etc. It’s the continous integration server alternative that we use
GhostDoc - essential for documenting your code.

 

Enable Intellisense for skin files

Vladimir Bychkov explains it nicely.

http://vladimir.bychkov.info/blog/PermaLink,guid,be76b3bf-c524-456c-9c8f-a2584924aa32.aspx

This will take a lot of the pain out of creating themes :)