25 August 2006

Another day, another gadget

It seems like there are quite a few sorts of mash up gadgets and widgets to be had: Microsoft gadgets, Yahoo widgets and Apple dashboard widgets to name but a few.

Today I put together a Space Browser virtual tour viewer Microsoft Gadget, based on the LazyGadget example. So far it doesn't have any parameters and has not been added to the Microsoft Live Gallery yet. [Later: here it is in the gallery - go to this page to "Add to Live.com" or "Add to your space".


Or you can add it your Windows Live site at www.live.com by clicking on Add Stuff then Advanced Options. After "Add a Gadget by URL", enter the gadget manifest XML URL:
http://www.spacebrowse.com/gadget/gadget.xml and click on "Subscribe". The site then prompts "Only install Gadgets from trusted sites". Click on "Install Gadget" after selecting "Remember my preference".
Only install Gadgets from trusted sites
That should be it. You should be able to move or collapse the gadget as normal. If you close your browser while the gadget is collapsed then it will not display correctly when expanded unless you refresh the page.

You can also add the gadget to your Windows Live Spaces site - click on "Add to your space" in the Gallery listing
Currently the gadget will only be visible to you when logged in; visitors will not see it. To add the gadget, click on this link: http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=http://www.spacebrowse.com/gadget/gadget.xml. Again, you will have to confirm the installation.

When the gadget is listed in the Windows Live Gallery you will be able to add it and make it visible to all viewers.

It is present on my Live Space at chriscant.spaces.live.com but you will not be able to see it as a visitor.

23 August 2006

My gadget's now also a widget

I've improved my Space Browse Google gadget since the previous post so that it fills the screen area better and has optional parameters to choose random or recent tours and tours just by a specified username.  Having provided a pithy author_aboutme and author_quote etc, I will submit it for listing in the Google content directory.  My gadget also seems to work OK on the Google Desktop Sidebar.

I had previously signed up to Widgetbox.  Last night I was able to add my gadget as a widget very easily - it worked first time, hurray!  Here it is: Widgetbox Space Browse widget.  Today I updated it to have parameters.  Where the gadget parameter was ShowMode, I specified a widget parameter called up_ShowMode, etc.

Widgetbox lets you add a widget directly onto any web page, eg onto a blogger template as can be seen below - optionally, in an widgetbox panel.  In Firefox, the widget overlaps the dotted vertical divider, which doesn't happen in Internet Explorer 6.  To add a widget to a blogger blog post you have to add a widgetbox panel (empty if you want) in the template and then use a specified DIV within the post itself:

21 August 2006

Internet Explorer 7: Locally run Java applet getAppletContext().showDocument(url) doesn't work - drive repeated

This issue has been fixed in Internet Explorer 7 RC1. Great!
[I can only assume that Microsoft did not acknowledge the problem in my bug report because they were testing with the fixed version rather than the beta 3 version.]


Just before last week's break, I posted feedback about Internet Explorer 7 beta 3.

A customer of our FindinSite-CD software had reported that a user of theirs had tried our software in IE7. It ran into a problem when run locally, ie from CD.

The problem is that a Local Machine Java applet call to getAppletContext().showDocument(url) does not work for a relative URL because the drive portion of the file URL is repeated. Instead, an error such as this is shown in a message box: Cannot find file 'file:///C:/C:/PHD/IE7test/iamshown.htm'

Here's my feedback report to Microsoft - you will need to register to see it. It seems as though Microsoft were unable to reproduce the problem and so closed the issue. If you can repeat it, please Validate and Vote for it once you have confirmed that my posted example fails as described.

Assuming that this is a real problem, then it will make our software not work in IE7 which is a crucial browser for us.


PS Just saw an article in Ethical Consumer which could be summarised as "New organic range of underwear approved by Soil Association".

10 August 2006

Made a first Google Gadget for Space Browse

Just a brief note to say that I managed to make a Google gadget very quickly for my Space Browse virtual tour site. Having read quickly through the Google Gadget starter documentation earlier in the day, it only took an hour or so to make a gadget that shows a random virtual tour.

I had to make a new web form page that used a new stored procedure to get a random publicly accessible photo-site. Thanks to whoever it was who had the tip that adding ORDER BY NEWID() gives a random result set for a SELECT statement. This works by generating a new uniqueidentifier/guid for each result row; because the Guids are random, ordering on this will return a randomly sorted result set. I added TOP 1 because I only wanted one random result.

The gadget found a bug in my existing code that assumed that something divided by something else was an integer. I fixed it by using Math.floor().

The gadget is still basic because it does not respond to the provided width. It also needs to remove some of its borders.

Anyway, here's the gadget:
http://www.spacebrowse.com/gadget/SpaceBrowse.xml
Add to Google

09 August 2006

asp:HyperLink includes an extra space in the link

Only a minor point, but poor form...
If you have an asp:HyperLink in an ASP.NET2 app then it is sometimes rendered with an extra space within the link which gives an underlined space at the end of the link.

Suppose you have the following:
<asp:HyperLink ID="idLink" runat="server" Text="Hello" />

When rendered incorrectly, there are line breaks between these three lines which causes the problem:
<a id="ctl00_MasterLoginView1_something" href="something.aspx">
Hello
</a>


When rendered correctly, there are no line breaks.

I haven't been able to determine exact circumstances when rendering is incorrect.

Coping with links in cookieless mode in ASP.NET2

A new web site project that I am working on might be used a lot from internet cafes and the like where it is possible that cookies are disabled. I therefore started to look at how to support cookieless mode in an existing alpha web site of mine www.spacebrowse.com - go there to try it out with cookies disabled once you have registered for free.

The ASP.NET2 site uses Forms authentication, specified in Web.Config as follows:
<authentication mode="Forms">
   <forms protection="All">
</authentication>


cookieless - UseDeviceProfile

The forms element "cookieless" attribute has a default value of "UseDeviceProfile". Basically this doesn't work if a browser has cookies turned off. "UseDeviceProfile" looks at the type of viewer, so it will assume that cookies are turned on for IE/FF/etc, but will assume they are not for some other device types.

cookieless - UseUri

Another option for "cookieless" is "UseUri" which means that cookies are not used. Instead, ASP.NET2 mangles the URL to include the information that would have been stored in the cookie. A http: URL such as this:
http://localhost/SpaceBrowse/Default.aspx
is mangled to look like this:
http://localhost/SpaceBrowse/(F(ekocDSRz...PZKv3ah41))/Default.aspx
where a lot of characters have been removed at the ellipses.

If you look carefully, you will see that the mangled URL contains an extra folder name. When I saw this, I thought that all resources and relative links from this page would go wrong. In fact, they don't because the ASP.NET ISAPI DLL filter intercepts all requests and resolves them correctly if it detects mangled URLs. Also note that Request.Path as seen by the ASPX page is correctly SpaceBrowse/Default.aspx, ie without any mangling.

cookieless mangled URL links

However there is an issue as regards links. If you want the user to stay logged in, then the URL they browse to has to have a mangled URL. This means that you must use relative links to stay logged in. Any absolute links will not include the mangled URL. You will be OK if you use <asp:hyperlink> and the like with NavigateUrl="~/sites.aspx" or whatever because ASP.NET resolves the ~/ correctly.

My MasterPage template is used by pages in various directories. My original code included static absolute HTML links to pages on the site. These links did not include the mangled URL and so the user's login status is forgotten. The solution is to use ASP.NET controls for all such links (even though that might require a small amount more server-side processing).

Aside 1: When testing "UseUri" mode in IE using ASP.NET Development Server, if you have links to directories then they will not work if they end in "/". You must change them to "/Default.aspx" to be able to see the requested page in cookieless mode. When working through IIS, ordinary directory requests will work OK.

Actually, it is important that all your links to directories end in / - otherwise the mangled URL will be lost.

Aside 2: When you log off in mangled URL mode (using asp:LoginStatus LogoutPageUrl="~/default.aspx"), the URL you get redirected looks like this:
http://localhost/SpaceBrowse/(X(1))/default.aspx
Although strange, everything works OK.

cookieless - AutoDetect

Anyway, back at my original problem: how to cope if a browser has cookies turned off. The best option is to set "cookieless" to "AutoDetect" in the Forms element. With this setting, ASP.NET probes to see if cookies are set; if cookies are enabled, then they are used; if not, then mangled URLs are used.

The probing mechanism seems to kick in when you click a Login button. To determine if a browser session has cookies enabled, this parameter is added to the login URL: AspxAutoDetectCookieSupport=1.

PS. I found it easiest to test in FF rather than IE because FF has a simple method of turning off cookies; IE does it on a zone basis which I could quickly not get to work for the dev server URL http://localhost:1234/whatever/

PPS. Found that cookies must be enabled for yahoo/flickr to let you log on.