Tags related to tag web
Wednesday, October 25. 2006
Imagine a webserver...
This server, is called zen-garden. zen-garden is my pet project. It is my tilting at a windmill, and it is rapidly approaching a 0.1 release. The fundamental difference between zen-garden and most other webservers is that zen-garden is built, and based around simple rules. You want to log every request to a database table? Write a rule that acts on every request, and writes the request info to the table. You want to run all of your HTML files through Tidy and or gzip to compress them? Write a rule to act on every response that doesn't already have gzip encoding, and has a content-type of text/html. As you can see, the rule-based webserver is a very powerful concept indeed.
Now you might be asking "How do you handle a request for a single page, a single CSS file?" The answer is simple: a rule to output the page or CSS file when the request method is GET, and the URI is /path/to/your/file. But imagine this, instead of making the webserver find the file, load it, and send it across the network, what if you told the webserver it should compile the serving of that file into itself on deploy time? What if part of the deploy is taking a source file in XML and doing some transformations on it, and then compiling the transformations into itself before deploying? But what if all this was developer friendly so that when working in a development environment, you don't have to deal with the daily grind of compile-test-debug, you could make a change to your file, and test it on the spot? zen-gardens host language is Scheme on Gambit, so it is interpreted for a really fast development cycle, but Gambit can also be compiled to C (which of course can be compiled to native code) so when it is time to deploy, your server will be fast.
The crux to zen-garden is the request-chains and request-handlers. A request-handler is a data structure, with 2 important parts: a predicate stating whether or not the handler should execute, and the handler itself. Both of these are functions that return booleans. A request-chain is really just a series of request handlers that are executed in a particular order, split out into 4 convenient phases: initialization, handling, fallback and finalization. A request-handler can be bound to any one of these 4 phases. If a request is not handled during the 'handling' phase, the fallback phase is executed, otherwise it is skipped.
The real interesting thing about this structure is that a request-handler can spawn a new request-chain. So you can have a request-handler that executes when the 'Host' header is set to 'my.foo.domain.com' that spawns a new request-chain. On top of that, there is nothing stopping you from dealing with requests in other ways, in fact, any way you see fit. Don't like my method of predicates and request chains and what have you? Write your own method of doing things. zen-garden is modular in design. Pull out the routine that I use to handle requests, and install your own.
What is in the future of zen-garden? Well, ZSP's, or Zen-Server-Pages, which is a JSP/PHP method of page generation. Unlike these other technologies, I plan on getting the separation of business logic and display logic right. No top-heavy tag libraries with presentational logic getting confused with document structure, yes JSP and the entire J2EE stack, I am looking at you. No business logic tied up with your presentation, dirty, nasty PHP! What else is in the future? My(and other)SQL connection pooling, GD integration, regular expressions, optional continuation based web programming, RESTful resources, specialized preprocessing of CSS and Javascript files (only send the browser the CSS it needs, and you want it to have).
Oh, and it is all under a BSD License.
For now, everything is available in a subversion repository, svn://panda-ba.sanriowasteland.net/zengarden/trunk . You will need the Gambit-C compiler and interpreter as well.
Tuesday, October 24. 2006
Why...? Standards and Browser Based CSS Selectors
Browser sniffing is sub-standard (excuse the pun), because we cannot rely on the user-agent string. But if we are going to browser sniff, then sniffing via Javascript is even worse.
Hacks are sub-standard (ditto) because they depend on comments to tell you what is going on. Imagine trying to figure out a voice-family hack if you aren't familiar with it at all.
Instead imagine if you could just do something like this:
@band-pass[ie5] { margin: 0; padding: 10 } /* This style for IE 5 only */
@low-pass[ie6] { margin:0 } /* this style for IE 6 and lower */
@band-reject[webkit] { margin: 0 } /* for every browser except webkit/safari*/
The closest to an ideal solution is some kind of pre-processing of a CSS file, so that you could use a @band-pass[ie5] style syntax, and it would transform that into the relevant CSS bandpass hack for that browser.
Update: Sorry about the... erm... substandard title. It is fixed now.
Monday, July 10. 2006
Really Simple Webservices: REST by virtue, not necessarily by design.
http://feeds.technorati.com/contacts/http://portfolio.jonnay.net/contact/
It is a very simple web service. A simple GET request returns a piece of data. It by virtue of its simplicity is RESTful. This is what REST web services really are all about.
Friday, June 23. 2006
Background image disappearing in IE 5.5
That is, if you are using IE 5.5 in stand-alone mode, along with IE 6.0.
Which goes to show, the only sane way to browser test is to install VMWare or have a separate machine for every IE version you need to test. Yes thats right, a separate computer for every (Microsoft) browser that you need to test.
Imagine that.
Insert heaping of scorn upon Microsoft here. Man. Just make your browsers stand-alone-able already.
Friday, June 16. 2006
Tastey SXSW podcasts
Here is a tastey list of SXSW podcasts that I ahve been enjoying. A lot of them are surprisingly non-techie, and will be enjoyable for most anyone. Checkem.
In July the podcast where I am mentioned goes up. I'll keep y'all posted. Man, such an attention whore.
Friday, June 9. 2006
the Firebug extension for firefox is like techno-chocolate-web-sex
It has a Javascript debugger that lets you set arbitrary breakpoints; DOM inspector that not only lets you see the structure of your page, but also any styles and events on each node in the DOM tree; an AJAX console viewer so you can see the raw HTTP requests and responses; and a console, where you can see Javascript and CSS errors and type in arbitrary Javascript.
The inspector alone is worth the price of admission, it allows you to hover over elements on a page, and it will not only highlight the element on page, but also highlight the corresponding element in the rendered source, and show you not only the styles applied to it, but where it got those style rules from. This is probably the feature of firebug that I use the most, and it has made my job as a web developer infinitely easier.
It provides a host of great Javascript functions as well through a console object. Not only can you send it debug, info, warning, and error log messages (no more alert debugging, horray!) but you can send it assertions—great for design by contract.
I have noticed a few problems with it. Every once in a blue moon my browser seems to crash, which might be a fault of firebug. It really is a once-in-awhile issue, like 2-3 times a week after a period of heavy usage. Firebug also has some known issues with regards to viewing HTTP Requests and Responses. Synchronous requests cause it to fail, as well as documents that are XML (like XHTML, for instance). In actual fact, these are Firefox issues, and not Firebug issues, but there is a good chance these issues are being worked on.
Despite these problems, Firebug is a very usable, very cool extension. If you do any kind of web development, as a job, or as a hobby, it is well worth installing.
Techno Chocolate! (oon tsch oon tsch oon tsch... dooo do do do do do!)
Tuesday, June 6. 2006
Mozilla Update Check is RESTful
I found a neat little surprise the other day. It appears that the Mozilla extension auto update feature is RESTful; I found this out through the use of LiveHTTPHeaders. Whenever you have an extension like Spellbound or Firebug, Firefox will call home to a server, and perform a version check, comparing your version with the latest version it has. It is not 100% RESTful, the biggest problem being that there is an end-point style URI (https://addons.mozilla.org/update/VersionCheck.php) with a query string (reqVersion=1&id=firebug@software.joehewitt.com...) ideally, the uri would be something like /update/VersionCheck.php/1/firebug.software.joehewitt.com/... giving each unique identifier its own space on the URI.
Beyond that however, it is very good use of HTTP, all the information needed is encapsulated in the request and is stateless. Really this shows that a lot of simple web services are either inherently RESTful, or are just a hop skip and jump away from being a true rest webservice.
This is the important thing about REST webservices. It is not that you need to conform to a "REST Standard", but instead you conform to the HTTP spec and end up, by design, following at least some of the REST constraints.
For reference (and the truly geeky) , here is the request and response:
Request
https://addons.mozilla.org/update/VersionCheck.php?reqVersion=1&id=firebug@software.joehewitt.com&version=0.4&maxAppVersion=3.0&appID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=1.5.0.3&appOS=WINNT&appABI=x86-msvc
GET /update/VersionCheck.php?reqVersion=1&id=firebug@software.joehewitt.com&version=0.4&maxAppVersion=3.0&appID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=1.5.0.3&appOS=WINNT&appABI=x86-msvc HTTP/1.1
Host: addons.mozilla.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en,en-us;q=0.7,ja;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cache-Control: no-cache
Response
HTTP/1.x 200 OK
Content-Length: 939
Connection: close
Content-Type: text/xml; charset=utf-8
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:firebug@software.joehewitt.com">
<em:updates>
<RDF:Seq>
<RDF:li resource="urn:mozilla:extension:firebug@software.joehewitt.com:0.4"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:firebug@software.joehewitt.com:0.4">
<em:version>0.4</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.5</em:minVersion>
<em:maxVersion>3.0</em:maxVersion>
<em:updateLink>http://releases.mozilla.org/pub/mozilla.org/extensions/firebug/firebug-0.4-fx+fl.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:RDF>




