Database Reference
In-Depth Information
Figure 10-11. Editing a status update
Similar to the add feature, the edit feature will use a route in the App as well as a function in graphstory.js ,
which are edit and edit_content , respectively. The edit content route passes in the content object, with its content
id, and then calls the edit_content method in Content class, which is shown in Listing 10-33.
Listing 10-33. edit Route and Method for a Status Update
# edit a status update - route
post '/posts/edit' do
contentItem = JSON.parse(request.body.read)
# edit content
contentItem = edit_content(neo,contentItem,request.cookies[graphstoryUserAuthKey])
json contentItem
end
# edit a status update
def edit_content(neo,contentItem,username)
tagstr=trim_content_tags(contentItem["tagstr"])
tags=tagstr.split(",")
cypher = " MATCH (c:Content {contentId:{contentId}})-[:NEXTPOST*0..]-()-[:CURRENTPOST]-(user
{ username: {u}}) " +
" SET c.title = {title}, c.url = {url}, c.tagstr = {tagstr}" +
" FOREACH (tagName in {tags} | " +
" MERGE (t:Tag {wordPhrase:tagName}) " +
 
Search WWH ::




Custom Search