Skip to content

Commit

Permalink
Got merges working.
Browse files Browse the repository at this point in the history
  • Loading branch information
John MacFarlane committed May 22, 2012
1 parent e21aaa9 commit 54331c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
31 changes: 19 additions & 12 deletions Network/Gitit2.hs
Expand Up @@ -33,7 +33,7 @@ import Data.ByteString.Lazy.UTF8 (toString)
import Text.Blaze.Html hiding (contents) import Text.Blaze.Html hiding (contents)
import Text.HTML.SanitizeXSS (sanitizeAttribute) import Text.HTML.SanitizeXSS (sanitizeAttribute)
import Data.Monoid (Monoid, mappend) import Data.Monoid (Monoid, mappend)
import Data.Maybe (mapMaybe, isJust) import Data.Maybe (mapMaybe, isJust, isNothing)
import System.Random (randomRIO) import System.Random (randomRIO)
import Control.Exception (throwIO, catch, try) import Control.Exception (throwIO, catch, try)


Expand Down Expand Up @@ -472,15 +472,18 @@ edit mbtext mbrev page = do
return (r, toString c) return (r, toString c)
let contents = Textarea $ T.pack $ cont let contents = Textarea $ T.pack $ cont
mr <- getMessageRender mr <- getMessageRender
let comment = maybe "" (mr . MsgReverted) mbrev let comment = case (mbtext, mbrev) of
(Nothing, Just r) -> mr $ MsgReverted r
_ -> ""
when (isJust mbtext) $ setMessageI $ MsgMerged revid
(form, enctype) <- generateFormPost $ editForm (form, enctype) <- generateFormPost $ editForm
$ Just Edit{ editContents = contents $ Just Edit{ editContents = contents
, editComment = comment } , editComment = comment }
toMaster <- getRouteToMaster toMaster <- getRouteToMaster
makePage pageLayout{ pgName = Just page makePage pageLayout{ pgName = Just page
, pgTabs = [ViewTab,EditTab,HistoryTab,DiscussTab] , pgTabs = [ViewTab,EditTab,HistoryTab,DiscussTab]
, pgSelectedTab = EditTab } $ do , pgSelectedTab = EditTab } $ do
when (isJust mbrev) $ toWidget [julius| when (isJust mbrev && isNothing mbtext) $ toWidget [julius|
$(document).ready(function (){ $(document).ready(function (){
$('textarea').attr('readonly','readonly').attr('style','color: gray;'); $('textarea').attr('readonly','readonly').attr('style','color: gray;');
}); |] }); |]
Expand All @@ -498,17 +501,21 @@ postUpdateR revid page = do
user <- requireUser user <- requireUser
((res, _form), _enctype) <- runFormPost $ editForm Nothing ((res, _form), _enctype) <- runFormPost $ editForm Nothing
fs <- filestore <$> getYesodSub fs <- filestore <$> getYesodSub
toMaster <- getRouteToMaster
case res of case res of
FormSuccess r -> do FormSuccess r -> do
liftIO $ modify fs (pathForPage page) "" mres <- liftIO $ modify fs (pathForPage page) revid
(Author (gititUserName user) (gititUserEmail user)) (Author (gititUserName user) (gititUserEmail user))
(T.unpack $ editComment r) (filter (/='\r') . T.unpack (T.unpack $ editComment r) (filter (/='\r') . T.unpack
$ unTextarea $ editContents r) $ unTextarea $ editContents r)
-- TODO handle mergeinfo case mres of
return () Right () -> redirect $ toMaster $ ViewR page
_ -> return () Left mergeinfo ->
toMaster <- getRouteToMaster edit (Just $ mergeText mergeinfo)
redirect $ toMaster $ ViewR page (Just $ revId $ mergeRevision mergeinfo) page
FormFailure ts -> setMessage (toMarkup $ T.intercalate "; " ts) >>
redirect (toMaster $ ViewR page)
FormMissing -> error "Form missing"


data Edit = Edit { editContents :: Textarea data Edit = Edit { editContents :: Textarea
, editComment :: Text , editComment :: Text
Expand Down
2 changes: 2 additions & 0 deletions messages/en.msg
Expand Up @@ -22,3 +22,5 @@ ConfirmDelete page@Page: Are you sure you want to delete #{page}?
Delete: Delete Delete: Delete
Deleted page@Page: Deleted #{page} Deleted page@Page: Deleted #{page}
Reverted rev@RevisionId: Reverted to #{rev} Reverted rev@RevisionId: Reverted to #{rev}
Merged rev@RevisionId: The page has been edited since you checked it out. Changes from revision #{rev} have been merged into your edits below.

2 changes: 1 addition & 1 deletion static/css/screen.css
Expand Up @@ -119,7 +119,7 @@ pre.matches span.highlighted { background-color: yellow; }
/* .req is used to hide a honeypot in a form */ /* .req is used to hide a honeypot in a form */
.req { display: none; } .req { display: none; }


p.message { color: red; font-weight: bold; } p.message { color: red; font-weight: bold; margin-left: 160px; }


ul.tabs { padding: 0; margin: 0 0 1px 0; } ul.tabs { padding: 0; margin: 0 0 1px 0; }
ul.tabs li { display: inline; border: 1px solid #ccc; border-bottom: none; padding: 0 0.6em 0 0.6em; ul.tabs li { display: inline; border: 1px solid #ccc; border-bottom: none; padding: 0 0.6em 0 0.6em;
Expand Down

0 comments on commit 54331c4

Please sign in to comment.