Exemple #1
0
def page_any_html(start_response, ctx, mark_top):
    userpath = ctx.prefix+'/'+ctx.user['name']

    jsondict = ctx.create_jsondict()

    what = mark_top.tag()
    if what:
        path = userpath + '/' + slasti.escapeURL(what)
        jsondict['_main_path'] += ' / '+slasti.escapeHTML(what)+'/'
    else:
        path = userpath
        jsondict['_main_path'] += ' / '+BLACKSTAR

    jsondict["marks"] = []

    mark = mark_top
    mark_next = None
    n = 0
    for n in range(PAGESZ):
        jsondict["marks"].append(mark.to_jsondict(userpath))

        mark_next = mark.succ()
        if mark_next == None:
            break
        mark = mark_next

    jsondict.update({
         "_page_prev": page_anchor_html(page_back(mark_top), path, "«"),
         "_page_this": page_anchor_html(mark_top,            path, BLACKSTAR),
         "_page_next": page_anchor_html(mark_next,           path, "»")
            })

    start_response("200 OK", [('Content-type', 'text/html; charset=utf-8')])
    return [template_html_page.substitute(jsondict)]
Exemple #2
0
 def _enforce_encoding(self, s):
     # handle HTML escaping stuff here
     # character encoding is done on the finished expanded template
     if isinstance(s, unicode) or isinstance(s, str):
         return escapeHTML(s)
     # We end here for every list, such as "$tags". The contents get
     # later escaped above too, as they get looked up one by one.
     return s