Пример #1
0
def editPost(blog, postID, action, format):
    # There should be a blank line and then the title
    titleline = sys.stdin.readline()
    titleline = sys.stdin.readline()

    postTitle = encode(titleline.split(":")[1].strip())

    # categories should be on the next line
    catline = encode(sys.stdin.readline())

    categoryList = catline.split(":")[1].strip()
    categories = categoryList.split(",")

    # Skip the next blank line
    sys.stdin.readline()

    postBody = ""
    # Post body comes after this
    for line in sys.stdin.readlines():
        postBody = postBody + line

    postBodyPre = postBody
    if format == "rz":
        postBody = rhizml.rhizml2xml(StringIO.StringIO(postBody), prettyprint=True)
    else:
        postBody = encode(postBody)

    try:
        if action.startswith("n"):
            postID = blog.addPost(postTitle, postBody, categories)
            postID = replace(postID, "http://" + HOST, "")
        else:
            blog.editPost(postID, postTitle, postBody, categories)
    except Exception, e:
        print "ERROR: " + str(e)
Пример #2
0
#!/usr/bin/python
#
# Asks the user for an html link and then replaces the text with the proper HTML
#
# -- TextExtras User Script Info --
# %%%{TEName=Process with rhizml}%%%
# %%%{TEInput=Selection}%%%
# %%%{TEOutput=ReplaceSelection}%%%
# %%%{TEKeyEquivalent=^@r}%%%


import sys, os
import StringIO

sys.path.append('/Users/kstaken/Workspace/Book/Blog/dist/scripts/lib')
sys.path.append("/Users/kstaken/Workspace/Book/Blog/client/rhizml")

import rhizml

INPUT = sys.stdin.read()

print rhizml.rhizml2xml(StringIO.StringIO(INPUT), prettyprint=True)