Пример #1
0
    def to_jsondict(self, path_prefix):
        title = self.title
        if not title:
            title = self.url

        mark_url = '%s/mark.%d.%02d' % (path_prefix, self.stamp0, self.stamp1)
        ts = time.gmtime(self.stamp0)
        # XXX common constructor with create_jsondict, please
        jsondict = {
            "date": time.strftime("%Y-%m-%d", ts),
            "href_mark": mark_url,
            "href_mark_url": slasti.escapeURL(self.url),
            "title": title,
            "note": self.note,
            "tags": [],
            "key": "%d.%02d" % (self.stamp0, self.stamp1),
        }

        for tag in self.tags:
            jsondict["tags"].append(
                {"href_tag": '%s/%s/' % (path_prefix,
                                         slasti.escapeURLComponent(tag)),
                 "name_tag": tag,
                })

        jsondict['_main_path'] = u"MOO"

        return jsondict
Пример #2
0
def full_tag_html(start_response, ctx):
    if ctx.method != 'GET':
        raise AppGetError(ctx.method)

    userpath = ctx.prefix + '/' + ctx.user['name']
    start_response("200 OK", [('Content-type', 'text/html; charset=utf-8')])
    jsondict = ctx.create_jsondict()
    jsondict['_main_path'] += ' / tags'
    jsondict["tags"] = []
    for tag in ctx.base.tagcurs():
        ref = tag.key()
        jsondict["tags"].append(
            {"href_tag": '%s/%s/' % (userpath, slasti.escapeURLComponent(ref)),
             "name_tag": ref,
             "num_tagged": tag.num(),
            })
    return [template_html_tags.substitute(jsondict)]
Пример #3
0
    def to_jsondict(self, path):
        tag1 = self._ourtag or "test_tag"

        tags = [
            {"href_tag": '%s/%s/' % (path, slasti.escapeURLComponent(tag1)),
             "name_tag": tag1}
        ]

        jsondict = {
            "date": time.strftime("%Y-%m-%d", time.gmtime(self._stamp0)),
            "href_mark": '%s/mark.%d.%02d' % (path, self._stamp0, 0),
            "href_mark_url": slasti.escapeURL("http://www.ibm.com/"),
            "title": "Test_title",
            "note": "",
            "tags": tags,
            "key": "%d.%02d" % (self._stamp0, 0),
        }
        return jsondict