views:

270

answers:

6

We have a client for whom we build a lot of template based sites. Ideally we would use something like kohana (http://www.kohanaphp.com/) to handle the templating and make doing site wide changes a breeze.

Unfortunately our client cannot (and will not) host any server side code (and before you ask, this will not change and hosting the files ourselves is not an option), so any files deployed to them must be HTML, Javascript, CSS, images and Flash only.

Is there a good way to develop in a framework environment like kohana to make the site manageable, but be able to deploy or export a HTML only version of the site (there is no dynamic aspect to the site such as searching that requires server side languages, and no database use)?

I guess it would be similar to spidering the site, but I'd like something a bit more reliable because some page assets are loaded dynamically with javascript.

Thanks

A: 

Consider alternative solutions, even if you don't think you can use them. It is a mistake to become blind to novel solutions because your client "can not handle server side languages" (paraphrased). Sometimes a requirement is a result of incorrect knowledge. For example, is the client really unable to host any server side languages because they can't host IIS or Apache - or is it because they don't have them and can't install any other application either? (If they can install an application, perhaps a solution could be to just provide a "small" webserver - perhaps XSP).

I also suggest you take a look at, eg, google "gears". I've heard pretty good things about that, though it might not be a good fit for your needs.

Failing that, you are probably best off ignoring classic server-side languages and doing it all on the client side, or using server side languages as an exporter. (Which will be a custom job). I think "exporting" a site using custom scripts is probably the best approach.

Finally, this question really does not have a single answer - as a programmer, it is your job to weigh different strengths and different solutions and choose the best one.

Arafangion
They are a bank, they flat out refuse to host sites developed by a 3rd party (us) built with a server side component for security reasons. This has been brought up with them many times, and the answer is a very clear and definite NO. Its not about being blind to novel solutions, this is the situation we have to work with. Google gears is not really appropriate for templating (and neither is doing it all on the client side). Exporting the site with custom scripts seems to be the only way, but I was looking for good ways to do it, particularly if they integrate with Kohana.
micmcg
Also I am not looking for a single answer, just any good way to solve the problem.
micmcg
Makes me kind of curious - why would a bank want a website without any dynamic content?
jimyi
micmcg: I suspect that when the bank says "No", they are responding from an incorrect frame of reference with a particular technology (Whatever that may be), and thus refuse all "server side technologies", or they might be preferring to avoid all server side technologies for compatibility reasons (ie, can switch to any host at any time), both are unfounded, I can say I'm glad I'm not in your shoes!They may well have valid reasons, though, would be wise to learn what they are, though might have to wait until after the project is complete because you've already discussed this at length.
Arafangion
@jimyi - Think product advertising microsites, not their core website.
micmcg
A: 

Hmm... If the client's server does not allow PHP or ASP I don't think they will go for CGI which is more insecure.

Well, you could make your pages in a dev app, load up those pages in a browser and then save the resultant html. Do that for all the pages and you're set.

Just make sure the links are pointing right.

Cyril Gupta
That falls under the spidering umbrella, which unfortunately doesn't feel reliable enough.
micmcg
What kind of problems do you foresee?
Cyril Gupta
While there is no content dynamically generated by a server side language, content is added to the page dynamically with javascript, and I'm concerned that a simple spidering of the site would miss some of these. The site is big enough that it is not an acceptable solution to open up each page in a browser and save it out.
micmcg
A: 

I don't know of any specific solution to this but if you are willing to create a simple templating-system of your own in the language of your choice it's really only a matter of making a script to generate the pages. I had a site like that back in my teens. Anytime I uploaded something new I regenerated the site and uploaded the new pages. Back then I was using PERL.

The complexity of creating such a script depends a lot on what you're using to build the site. I was working with an entirely custom build that was built to work as it did. In this case I imagine you might want to write a simple template-system yourself to get the advantage of templates as well as being able to generate static HTML from it.

jbn
A: 

I don't know if this will be an option, but I would suggest CushyCms. This is an online CMS where you define content areas using CSS classes, and can edit the content online. You do need to provide FTP details, so this might be a deal breaker for you, but I thought it was worth mentioning.

John McCollum
+1  A: 

Give WaveMaker Studio a try. It will solve your problem partially.

WaveMaker Studio has a kind of templating feature and it comes in community open source version.

HTH

Yogi Yang 007
+1  A: 

I use Template Toolkit (Perl) and have a simple script that generates static files from the templates. This is great for the situation you are in (common navigation etc etc).

It comes with a ttree command that'll process a directory tree and put the results in another.

Here's the tt.rc file I use:

# ignore these files (regular expressions)
ignore = \.svn
ignore = ^#
ignore = ~$
ignore = .DS_Store
ignore = \.tt$

# if these template files change, reprocess everything
depend *=tpl/wrapper,tpl/defaults,style/default.html

# just copy these files, don't process as templates
copy = \.(gif|png|pdf|jpg)$

# verbose output
verbose

# recurse into subdirectories
recurse

# setup some defaults from tpl/defaults
pre_process = tpl/defaults

# process this file instead of the real file (see below how this is used)
process     = tpl/wrapper

# process files from src/, output to html/
# extra templates in lib/ (tpl/wrapper for example).
src  = src
dest = html
lib  = lib

A couple of special files, tpl/defaults is

[%-  page = {
            title = template.title,
            style = template.style or 'default.html'
    };

    base = INCLUDE tpl/base_uri;

    # don't include any whitespace from here...
    RETURN;
-%]

And tpl/wrapper is

[%- content = PROCESS $template;    
   IF !template.name.search('.html') OR page.style == 'none';
      content;
   ELSE;
      default_style_template = "style/" _ page.style;
      PROCESS $default_style_template;
   END;
%]

This will process the real template; put the results in the content variable and then process the style template (set with page.style in tpl/defaults; defaults to defaults.html).

the lib/style/default.html style file just needs to have

[% content %]

somewhere to include the real template; before and after that you can have the standard footer and headers.

You can read more about Template Toolkit at tt2.org.

Another option would be to use wget (or similar) in recursive mode to "mirror" pages generated by PHP on the development server; but I wouldn't recommend that.

Ask Bjørn Hansen
Very interesting and the closest to what I'm looking for. Will mark as accepted if nothing else (preferably php based) comes up soon. Thanks!
micmcg