Exemplo n.º 1
0
def create_post(post, data):
    post_url = get_post_url(post)
    if post_url == '/blog/2006/may/worried-sick.html': print "XXXXXXXXX"
    posted_on = parse_date(post["fields"]["posted_on"])
    post_name = convert_to_document_name(post_url)
    post_title = post[u"fields"]["title"]
    document = Document(post_name)
    if not document.exists(): 
        document.create(
            index_content = post[u'fields']["content"],
            format = "html", author = author, 
        )
    else:
        document.set_raw_index(post[u'fields']['content'], 'html')
    document.meta.author = author
    document.meta.title = post_title
    document.meta.url = post_url
    document.meta.type = "blog_post"
    document.meta.title_slug = post['fields']['title_slug']
    document.meta.posted_on = post['fields']['posted_on']
    for label_id in post['fields']['categories']:
        label_name = data["blog.category"][str(label_id)]["name_slug"]
        document.meta.setdefault("labels", []).append(label_name)
        gsettings.LOCAL_REPO_PATH.joinpath(
            "blogs/main/labels/%s.lst" % label_name
        ).open("a+").write("%s\n" % post_url)
    document.meta.save()
    blog_document(document, post_url, blog, posted_on)
Exemplo n.º 2
0
def get_post_url(p):
    posted_on = parse_date(p["fields"]["posted_on"])
    post_url = "/blog/%2d/%s/%s" % (
        posted_on.year, MONTHS[posted_on.month],
        p[u'fields']['title_slug']
    )
    if "." not in p[u'fields']['title_slug']:
        post_url += "/"
    return post_url
Exemplo n.º 3
0
def ts2date(s):
    return parse_date(s)
Exemplo n.º 4
0
def ts2date(s):
    return parse_date(s)