Changed Styling. Added category id to responses

This commit is contained in:
2022-05-20 00:12:35 +01:00
parent a974a59121
commit d52c401206
2 changed files with 135 additions and 81 deletions
+6 -3
View File
@@ -43,7 +43,8 @@ getPostListing c page = do
let sub = ("subtext", toJSString $ fromSql subtext)
let cat = ("category", toJSString category)
let id = ("id", toJSString $ show $ (fromSql pid::Int))
return $ showJSON $ toJSObject [id, title, sub, cat]
let catid = ("catid", toJSString $ fromSql cid)
return $ showJSON $ toJSObject [id, title, sub, cat, catid]
) result
return $ Just $ showJSON $ JSArray posts
@@ -75,7 +76,8 @@ getPostsInCategory c cat page = do
let sub = ("subtext", toJSString $ fromSql subtext)
let id = ("id", toJSString $ show $ (fromSql pid::Int))
let cat = ("category", toJSString category)
return $ showJSON $ toJSObject [id, cat, title, sub]
let catid = ("catid", toJSString $ fromSql cid)
return $ showJSON $ toJSObject [id, cat, title, sub, catid]
) result
return $ Just $ showJSON $ toJSObject [("category", showJSON $ toJSString category), ("posts", showJSON $ JSArray posts)]
@@ -92,7 +94,8 @@ getPostContent c pid = do
let title = ("title", toJSString $ fromSql t)
let content = ("content", toJSString $ fromSql con)
let cat = ("category", toJSString category)
return $ Just $ showJSON $ toJSObject [title, content, cat];
let catid = ("catid", toJSString $ fromSql cid)
return $ Just $ showJSON $ toJSObject [title, content, cat, catid];
_ -> fail "Post does not exist!"
main :: IO ()