def editImage(form): postID = form.getfirst("postID", "none") if postID == "none": thePost = algaeModels.algaeImage() else: thePost = algaeModels.algaeImage.get(postID) theTitle = form.getfirst("postTitle", "Untitled").decode( 'utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r' ', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, 'algaeImage') thePost.cleanURL = url theImage = form.getfirst("img", "") thePost.imgData = db.Blob(theImage) smImage = images.resize(theImage, algaeUserConfig.smallImageSize, algaeUserConfig.smallImageSize) thePost.smData = db.Blob(smImage) mdImage = images.resize(theImage, algaeUserConfig.mediumImageSize, algaeUserConfig.mediumImageSize) thePost.mdData = db.Blob(mdImage) lgImage = images.resize(theImage, algaeUserConfig.largeImageSize, algaeUserConfig.largeImageSize) thePost.lgData = db.Blob(lgImage) thePost.mimeType = form['img'].type thePost.fileName = form['img'].filename if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() print "Location: admin?saved=yes&edit=image&key=" + str(thePost.key()) print 'Content-Type: text/html\n'
def editCssOrJs(contentType, form): postID = form.getfirst("postID", "none") if contentType == "styleSheet": if postID == "none": thePost = algaeModels.styleSheet() else: thePost = algaeModels.styleSheet.get(postID) else: if postID == "none": thePost = algaeModels.jScript() else: thePost = algaeModels.jScript.get(postID) theTitle = form.getfirst("postTitle", "Untitled").decode( 'utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r' ', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, contentType) thePost.cleanURL = url thePost.postText = db.Text(form.getfirst("postText", ""), encoding="utf-8") if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() if contentType == "styleSheet": print "Location: admin?saved=yes&edit=styleSheet&key=" + str(thePost.key()) else: print "Location: admin?saved=yes&edit=jScript&key=" + str(thePost.key()) print 'Content-Type: text/html\n'
def editImage(form): postID = form.getfirst("postID", "none") if postID == "none": thePost = algaeModels.algaeImage() else: thePost = algaeModels.algaeImage.get(postID) theTitle = form.getfirst("postTitle", "Untitled").decode('utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r' ', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, 'algaeImage') thePost.cleanURL = url theImage = form.getfirst("img", "") thePost.imgData = db.Blob(theImage) smImage = images.resize(theImage, algaeUserConfig.smallImageSize, algaeUserConfig.smallImageSize) thePost.smData = db.Blob(smImage) mdImage = images.resize(theImage, algaeUserConfig.mediumImageSize, algaeUserConfig.mediumImageSize) thePost.mdData = db.Blob(mdImage) lgImage = images.resize(theImage, algaeUserConfig.largeImageSize, algaeUserConfig.largeImageSize) thePost.lgData = db.Blob(lgImage) thePost.mimeType = form['img'].type thePost.fileName = form['img'].filename if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() print "Location: admin?saved=yes&edit=image&key=" + str(thePost.key()) print 'Content-Type: text/html\n'
def editCssOrJs(contentType, form): postID = form.getfirst("postID", "none") if contentType == "styleSheet": if postID == "none": thePost = algaeModels.styleSheet() else: thePost = algaeModels.styleSheet.get(postID) else: if postID == "none": thePost = algaeModels.jScript() else: thePost = algaeModels.jScript.get(postID) theTitle = form.getfirst("postTitle", "Untitled").decode('utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r' ', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, contentType) thePost.cleanURL = url thePost.postText = db.Text(form.getfirst("postText", ""), encoding="utf-8") if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() if contentType == "styleSheet": print "Location: admin?saved=yes&edit=styleSheet&key=" + str( thePost.key()) else: print "Location: admin?saved=yes&edit=jScript&key=" + str( thePost.key()) print 'Content-Type: text/html\n'
def editPostOrPage(contentType, form, thiscookie): postID = form.getfirst("postID", "none") if contentType == "blogPost": if postID == "none": thePost = algaeModels.blogPost() else: thePost = algaeModels.blogPost.get(postID) else: if postID == "none": thePost = algaeModels.basicPage() else: thePost = algaeModels.basicPage.get(postID) thePost.author = thiscookie['username'].value theTitle = form.getfirst("postTitle", "Untitled").decode('utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r'[- ]', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, contentType) thePost.cleanURL = url if contentType == "blogPost": extLink = form.getfirst("linkURL", "null").decode('utf-8', 'ignore') thePost.linkURL = extLink thePost.postText = db.Text(form.getfirst("postText", ""), encoding="utf-8") thePost.markdownText = db.Text( markdown2.markdown(form.getfirst("postText", "")) ) #, encoding="utf-8" as 2nd argument of db.Text if not already unicode if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() if contentType == "blogPost": print "Location: admin?saved=yes&edit=blogPost&key=" + str( thePost.key()) else: print "Location: admin?saved=yes&edit=basicPage&key=" + str( thePost.key()) print 'Content-Type: text/html\n'
def editPostOrPage(contentType, form, thiscookie): postID = form.getfirst("postID", "none") if contentType == "blogPost": if postID == "none": thePost = algaeModels.blogPost() else: thePost = algaeModels.blogPost.get(postID) else: if postID == "none": thePost = algaeModels.basicPage() else: thePost = algaeModels.basicPage.get(postID) thePost.author = thiscookie['username'].value theTitle = form.getfirst("postTitle", "Untitled").decode( 'utf-8', 'ignore') thePost.postTitle = theTitle url = re.sub(r'[- ]', "_", theTitle) url = re.sub(r'\W', "", url) url = re.sub(r'_+', "-", url) if url != thePost.cleanURL: url = algaePython.noDupeURL(url, contentType) thePost.cleanURL = url if contentType == "blogPost": extLink = form.getfirst("linkURL", "null").decode( 'utf-8', 'ignore') thePost.linkURL = extLink thePost.postText = db.Text(form.getfirst("postText", ""), encoding="utf-8") thePost.markdownText = db.Text(markdown2.markdown(form.getfirst("postText", ""))) #, encoding="utf-8" as 2nd argument of db.Text if not already unicode if form.getfirst("isPublished", "False") == "on": thePost.isPublished = True else: thePost.isPublished = False thePost.put() if contentType == "blogPost": print "Location: admin?saved=yes&edit=blogPost&key=" + str(thePost.key()) else: print "Location: admin?saved=yes&edit=basicPage&key=" + str(thePost.key()) print 'Content-Type: text/html\n'