Talking Meta

Meta talk about Smalltalk, Seaside, Magritte, Pier and related things.

110th birthday of René Magritte

Several people have pointed out that Google is displaying a montage of the work of René Magritte in honor of his 110th birthday:

Google-magritte.jpeg

Above the screenshot of the search engine as seen in Belgium, the home country of the famous surrealist artist. The paintings of René Magritte have always fascinated me and provided the necessary inspiration to the Magritte meta-modelling framework.

Posted by Lukas Renggli at 21 November 2008, 8:43 pm with tags magritte, google 1 comment link

Seaside Clarification

From Programming Gems (on GemStone) by James Foster:

Second is the ability to use continuations to treat an abstract view as a reusable component.

Actually these are two independent points:

  1. Reuseable Components. Seaside does not force you to think in a whole page at a time, but it lets you build your UI as a tree of individual, stateful components, each encapsulating a small portion of a page. Components can be instantiated multiple times and reused within and between applications.
  2. Natural Flow. Continuations allow one to express a complex, multi-page workflow as a continuous piece of code. Furthermore continuations enable one to call a component like a subroutine and return an object as an answer. And yes, the back button still works. Continuations are an implementation detail, and therefore I prefer to talk about natural flow to avoid unnecessary confusion. The use of continuations is optional from Seaside 2.8 on.
Posted by Lukas Renggli at 5 November 2008, 10:11 am with tags seaside 5 comments link

How to ignore Code Critics rules?

A less well known feature of my recent changes and improvements to the Refactoring Browser, and especially the integrated Code Critic tools (including Slime, the Seaside consultant in a box) is the possibility to ignore certain rules on annotated methods. Simply add a pragma to the method you want a certain rule to ignore:

renderContentOn: html
"Renders the basic structure of the application."

<lint: 'Long methods' rationale: 'Rendering method' author: 'lr'>
...

The first argument is the title of the rule, as it appears in code critics user interface. Second and third argument are optional, but it usually makes sense to explain why it is a good decision to ignore the rule in the given method.

The idea is not to overuse this feature. That’s also why you actually have to type it in all by hand, even if it would be easy to automate that. The goal is to encourage developers to fix the real issue instead, something that works very well for me.

Posted by Lukas Renggli at 25 October 2008, 12:11 pm with tags refactoring, omnibrowser 2 comments link

Seaside Ajaxification

Add the following 15 lines of Javascript to your Seaside application — and you’ll get a full blown Ajax web application for free:

$(document.body).observe("click", function (event) {
   var element = Event.element(event);
   var extractor = /&lt;body[^>]*>((.|\s)*)&lt;\/body>/;
   if (!element.href) element = element.up("a");
   if (element && element.href) {
       new Ajax.Request(element.href, {
           method: "get",
           requestHeaders: [ "X-Requested-With", "" ],
           onSuccess: function (transport) {
               document.body.innerHTML = 
                  extractor.exec(transport.responseText)[1];
           }
   	});
   	Event.stop(event);
   }
}.bindAsEventListener());

The script uses functionality provided by the Prototype Javascript framework. The script registers a click handler on the body of the DOM tree. The first few lines check if the clicked element is an anchor or within one. Then the anchor node is asked for its URL element.href and an Ajax request is instantiated. The last step of the event handler stops the event processing Event.stop(event);, so that the default action of the web browser is vetoed. We have to carefully tweak some options of the Ajax request: We use a GET request, as Prototype does a POST by default. Then we have to make Seaside think that we do a "full request", as we actually want to do a full request with callback processing and a rendering phase. Finally the onSuccess: handler extracts the body from the response and injects it into the current DOM tree.

That’s all that is needed to turn any Seaside application into a full blown Ajax application. People might argue that I am cheating here: I am still doing a full request, I just do it asynchronously in the background using XMLHttpRequest. This gives only a marginal speed improvement (the same amount of data is transfered), but looks much smoother than doing a full request. For example, the page does not scroll to the top and is replaced without the usual flickering a full request does. Best of it, the script works well, even if you have other manually crafted Ajax actions in your code. Furthermore it supports the use of call: and answer:, something that was not easily possible before.

Of course there are some quirks that the presented script does not solve, however all these things can be easily added. For example, it does not currently update the <head> and it does not evaluate load scripts that might come with the response. Furthermore, forms are currently not ajaxified automatically, something that can be done by observing the Javascript submit event. A major annoyance of the script is, that you loose the ability to use the back button of the web browser. The URL always stays the same. But again, this problem can be easily solved. The idea is to add the _k key as a fragment to the URL and observe potential changes in window.location. That’s something for another post.

Posted by Lukas Renggli at 24 October 2008, 8:08 pm with tags seaside, javascript, prototype comment link

PDFs from Seaside

The website of Seaside has seen a recent addition of documentation. A frequently asked question in the mailing list is on the creation of PDFs from Seaside web applications. Unfortunately there is not a single answer that rules them all, but there are many possibilities to choose from.

PDF in Seaside

The initiative of writing a document was started by Stephan Eggermont and myself at ESUG 2008 in Amsterdam. Later on, Michael Rueger and Boris Popov contributed snippets and corrections here and there. The document is not finished and it doesn’t provide a final answer either, but it gives a broad overview of the possibilites and the advantages and disadvantages of the different approaches. We believe that after reading, you can easily choose the approach that suits you the best.

And, best of all, this is not really Seaside specific. It is more of a Smalltalk thing.

Posted by Lukas Renggli at 3 October 2008, 10:28 pm with tags seaside, smalltalk, pdf 4 comments link
<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 >>