We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit be198c4a authored by Mitchell Rosen's avatar Mitchell Rosen

fixed broken previews

parent bdd8f107
......@@ -368,23 +368,8 @@ postNewProjectBlogPostR project_handle = do
case result of
FormSuccess mk_blog_post -> do
mode <- lookupPostParam "mode"
let action :: Text = "post"
case mode of
Just "preview" -> do
let blog_post :: ProjectBlog
blog_post = mk_blog_post now viewer_id project_id (Key $ PersistInt64 0)
title = projectBlogTitle blog_post
handle = projectBlogHandle blog_post
top_content = projectBlogTopContent blog_post
bottom_content = fromMaybe "" $ projectBlogBottomContent blog_post
content = top_content <> bottom_content
(form, _) <- generateFormPost $ projectBlogForm $ Just (title, handle, content)
defaultLayout $ previewWidget form action $ renderBlogPost project_handle blog_post
Just x | x == action -> do
lookupPostMode >>= \case
Just PostMode -> do
void $ runDB $ do
discussion_id <- insert $ Discussion 0
......@@ -396,9 +381,18 @@ postNewProjectBlogPostR project_handle = do
alertSuccess "posted"
redirect $ ProjectBlogR project_handle
x -> do
addAlertEm "danger" ("unrecognized mode: " <> T.pack (show x)) "Error: "
redirect $ NewProjectBlogPostR project_handle
_ -> do
let blog_post :: ProjectBlog
blog_post = mk_blog_post now viewer_id project_id (Key $ PersistInt64 0)
title = projectBlogTitle blog_post
handle = projectBlogHandle blog_post
top_content = projectBlogTopContent blog_post
bottom_content = fromMaybe "" $ projectBlogBottomContent blog_post
content = top_content <> bottom_content
(form, _) <- generateFormPost $ projectBlogForm $ Just (title, handle, content)
defaultLayout $ previewWidget form "post" $ renderBlogPost project_handle blog_post
x -> do
alertDanger $ T.pack $ show x
......
......@@ -4,22 +4,23 @@ module Handler.Wiki where
import Import
import Handler.Comment
import Handler.Discussion
import Handler.Wiki.Comment (makeWikiPageCommentForestWidget)
import Model.Comment
import Model.Comment.ActionPermissions
import Model.Comment.Sql
import Model.Discussion
import Model.Markdown
import Model.Notification
import Model.Permission
import Model.User
import Model.Wiki
import Widgets.Preview
import Widgets.Time
import View.Comment
import View.Wiki
import Handler.Comment
import Handler.Discussion
import Handler.Utils
import Handler.Wiki.Comment (makeWikiPageCommentForestWidget)
import Model.Comment
import Model.Comment.ActionPermissions
import Model.Comment.Sql
import Model.Discussion
import Model.Markdown
import Model.Notification
import Model.Permission
import Model.User
import Model.Wiki
import Widgets.Preview
import Widgets.Time
import View.Comment
import View.Wiki
import Data.Algorithm.Diff (getDiff, Diff (..))
import Data.Default (def)
......@@ -123,19 +124,8 @@ postWikiR project_handle target = do
case result of
FormSuccess (last_edit_id, content, comment) -> do
mode <- lookupPostParam "mode"
let action :: Text = "update"
case mode of
Just "preview" -> do
(form, _) <- generateFormPost $ editWikiForm last_edit_id content (Just comment)
defaultLayout $ previewWidget form action $
renderWiki 0 project_handle target False $
WikiPage now target project_id content (Key $ PersistInt64 (-1)) Normal
Just x | x == action -> do
lookupPostMode >>= \case
Just PostMode -> do
runSYDB $ do
lift $
update $ \ p -> do
......@@ -191,8 +181,12 @@ postWikiR project_handle target = do
redirect $ WikiR project_handle target
_ -> error "Error: unrecognized mode"
_ -> do
(form, _) <- generateFormPost $ editWikiForm last_edit_id content (Just comment)
defaultLayout $ previewWidget form "update" $
renderWiki 0 project_handle target False $
WikiPage now target project_id content (Key $ PersistInt64 (-1)) Normal
FormMissing -> error "Form missing."
FormFailure msgs -> error $ "Error submitting form: " ++ T.unpack (T.concat msgs)
......@@ -384,22 +378,18 @@ postNewWikiR project_handle target = do
((result, _), _) <- runFormPost $ newWikiForm Nothing
case result of
FormSuccess content -> do
mode <- lookupPostParam "mode"
let action :: Text = "create"
case mode of
Just "preview" -> do
(form, _) <- generateFormPost $ newWikiForm (Just content)
defaultLayout $ do
let page = WikiPage now target project_id content (Key $ PersistInt64 0) Normal
previewWidget form action $ renderWiki 0 project_handle target False page
Just x | x == action -> do
lookupPostMode >>= \case
Just PostMode -> do
runSDB (createWikiPageDB target project_id content Normal user_id)
alertSuccess "Created."
redirect $ WikiR project_handle target
_ -> error "unrecognized mode"
_ -> do
(form, _) <- generateFormPost $ newWikiForm (Just content)
defaultLayout $ do
let page = WikiPage now target project_id content (Key $ PersistInt64 0) Normal
previewWidget form "create" $ renderWiki 0 project_handle target False page
FormMissing -> error "Form missing."
FormFailure msgs -> error $ "Error submitting form: " ++ T.unpack (T.concat msgs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment