Here's how you can serve the frontpager of your blog via WAP (I
would love to be able to server _any_ blog entry as WML, too, but
I have yet to find out how):

 (1) Create a sub-folder called e.g. /wap/ in your blog root

 (2) Create a DTML-document called index_html with these contents:

=== snip ===
<dtml-comment>
# -*- mode: HTML; TAB: 2; WRAP: 1024 -*-
##############################################################################
index_wml.dtml

WML ver 1.0

Copyright (C) 2004 Klaus Alexander Seistrup, Magnetic Ink, Copenhagen, DK
##############################################################################
</dtml-comment>
<dtml-var standard_wml_header>

        <card id="index" title="<dtml-var title>">
                <p>
<dtml-in "rev_day_entry_items(count=top_days)">
                        <a href="#entry<dtml-var id>" title="<dtml-var 
"wapify(title)">"><dtml-var "wapify(title)"></a><br />
</dtml-in>
                </p>
        </card>
<dtml-in "rev_day_entry_items(count=top_days)">

        <card id="entry<dtml-var id>" title="<dtml-var "wapify(title)">">
<dtml-if "_.len(subtitle)>0">           <p><dtml-var "wapify(subtitle)"></p>
</dtml-if>
                <p><dtml-var "wapify(excerpt)"></p>
                <p>Posted by <dtml-var "wapify(author)"> on <dtml-var 
"ZopeTime(created).toZone('UTC').strftime('%Y-%m-%dT%H:%M')">Z</p>
        </card>
</dtml-in>

<dtml-var standard_wml_footer>
=== snap ===

and give it an appropriate title.  Also, in the Properties tab set

        "content_type"  "text/vnd.wap.wml; charset=utf-8"

(or whatever your blogging charset is).

 (3) Create a DTML-method called standard_wml_header:
 
 === snip ===
 <dtml-call "RESPONSE.setHeader('Content-Type', 'text/vnd.wap.wml; charset=utf-8')">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" 
"http://www.wapforum.org/DTD/wml12.dtd";>

<wml>
        <head>
                <meta http-equiv="Cache-Control" content="max-age=2048" forua="true" />
        </head>
=== snap ===

Again: Adjust to your blogging charset.  I have put the WML header and
footer in my Zope root, next to the standard HTML ditto, so I can't
pull the charset from the blog setup.  You might want to do it in your
own way.

 (4) Create a DTML-method called standard_wml_footer:
 
=== snip ===
 </wml>
=== snap ===

 (5) Create a Python script called wapify:

=== snip ===
## Script (Python) "wapify"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=s
##title=
##
from string import strip, replace

s = strip(s)

if s:
        #s = replace(s, '&', '&amp;')
        #s = replace(s, '<', '&lt;')
        #s = replace(s, '>', '&gt;')
        s = replace(s, '$', '$$')
        s = replace(s, "'", '&apos;')
        s = replace(s, '"', '&quot;')
        s = replace(s, '\n', '<br />')
# end if

return s
# eof
=== snap ===

And you're all set.  Now visit http://www.example.com/path/to/blog/wap/ :-)

If you want to see a live example, please visit

        <http://www.magnetic-ink.dk/wap/>

Enjoy,

  // Klaus

-- 
Klaus Alexander Seistrup · Copenhagen · Denmark
http://www.magnetic-ink.dk/ · http://www.pnx.dk/
_______________________________________________
COREblog-en mailing list
[EMAIL PROTECTED]
http://munin.nbi.dk/cgi-bin/mailman/listinfo/coreblog-en

Reply via email to