2012/01/20

front page

There is no doubt that you know where the following image comes from:



It has a somewhat cryptic message : If required your dynamic import application space can mask the root path. Ok. Fine. Thumbs up. But ... did you get that?

What it means is that you can replace the default root page with your own. Cool. But how?

Now I'm a bit lost when I have to create a front end (my graphical skills are under par ... working on it :-), so I get help. The Skeleton Boilerplate is excellent (thanks go to Joe Devon for pointing it out).

Serving it in NetKernel is easy. Dump it in the resources directory of a new module, customize the webpages as you like and serve it up with the webserver pattern :

  <rootspace>    
    <fileset>
      <regex>res:/etc/system/SimpleDynamicImportHook.xml</regex>
    </fileset>
    <fileset>
      <regex>res:/skeleton/(.*)</regex>
      <rewrite>res:/resources/$1</rewrite>
    </fileset> 
  </rootspace>

However, that leaves one problem. You can now see your pages by requesting http://localhost:8080/skeleton/index.html, but http://localhost:8080/ is still showing the default page. Wasn't it our purpose to change that?

Yes indeed and there are several ways to accomplish it. Here is one:

  <rootspace>    
    <fileset>
      <regex>res:/etc/system/SimpleDynamicImportHook.xml</regex>
    </fileset>
    <mapper>
      <config>
        <endpoint>
          <grammar>
            <simple>res:/</simple>
          </grammar>
          <request>
            <identifier>active:redirectHTML</identifier>
            <argument name="url">/skeleton/index.html</argument>
          </request>
        </endpoint>
      </config>
      <space>
        <import>
          <uri>urn:org:netkernel:web:core</uri>
        </import>
      </space>
    </mapper>
    <fileset>
      <regex>res:/skeleton/(.*)</regex>
      <rewrite>res:/resources/$1</rewrite>
    </fileset> 
  </rootspace>

As you can see we redirect the root request to the index.html page of the Skeleton Boilerplate. The webserver pattern takes over from there.

This might not be the most elegant solution, but it works. If you have a better solution, step forward and send it to me at practical<dot>netkernel<at>gmail<dot>com. The rules are simple, I have to be able to dump the Skeleton Boilerplate in a module and without any change to the boilerplate itself (no, not even to index.html) it gets served and the index.html file becomes the root page of the NetKernel instance (http://localhost:8080/).

The price? I'll discuss your solution (giving you full credits) in a next blog entry. Gentlemen and Ladies, faites vos jeux!