You are not logged in Log in Join
You are here: Home » Members » peterbe » Update Static page

Log in
Name

Password

 
 

Folder icon Update Static page

A humble script that opens your webpage and sucks in parts of it and saves the HTML into a DTML Document.

The id of the DTML Document will be the page name of the URL +_static. So, if you open /web/doc/index.html the id of the DTML Document will be index.html_static. Be careful not to request URLs like: www.server.com/. Use instead www.server.com/index_html to be explicit.

Then, to use it in DTML for example you do this:

 <html>
  <dtml-if "_.has_key('index_html_static') and REQUEST.QUERYSTRING==''">
   <dtml-var index_html_static>
  <dtml-else>
   <!--DYNAMIC-CONTENT-->
     <dtml-var expensive_resource_heavy_looper>
   <!--/DYNAMIC-CONTENT-->
  </dtml-if>
 </html>

To create the static DTML Document, you first need to create an External Method Id: update_staticpage, modulename: update_staticpage, functionname: update_staticpage Here's how:

  context.update_staticpage(context.web.doc.index_html.absolute_url())

or:

  context.update_staticpage(context.web.doc.index_html.absolute_url(), container=context.somefolder)

Alternativly in DTML:

 <dtml-call "update_staticpage(web.doc.index_html.absolute_url())">

This can be useful to not have to write a cronjob:

This is a very untested and simple script. It's idea is simple and anybody is free to do whatever they want and need with it.

 Title   Type   Size   Modified   Status 
 update static page Edit object Software Release   2001-08-31 published