Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Got merges working.

  • Loading branch information...
commit 54331c49b2c5762087421d7a986625a6ad330cbf 1 parent e21aaa9
@jgm jgm authored
Showing with 22 additions and 13 deletions.
  1. +19 −12 Network/Gitit2.hs
  2. +2 −0  messages/en.msg
  3. +1 −1  static/css/screen.css
View
31 Network/Gitit2.hs
@@ -33,7 +33,7 @@ import Data.ByteString.Lazy.UTF8 (toString)
import Text.Blaze.Html hiding (contents)
import Text.HTML.SanitizeXSS (sanitizeAttribute)
import Data.Monoid (Monoid, mappend)
-import Data.Maybe (mapMaybe, isJust)
+import Data.Maybe (mapMaybe, isJust, isNothing)
import System.Random (randomRIO)
import Control.Exception (throwIO, catch, try)
@@ -472,7 +472,10 @@ edit mbtext mbrev page = do
return (r, toString c)
let contents = Textarea $ T.pack $ cont
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
$ Just Edit{ editContents = contents
, editComment = comment }
@@ -480,7 +483,7 @@ edit mbtext mbrev page = do
makePage pageLayout{ pgName = Just page
, pgTabs = [ViewTab,EditTab,HistoryTab,DiscussTab]
, pgSelectedTab = EditTab } $ do
- when (isJust mbrev) $ toWidget [julius|
+ when (isJust mbrev && isNothing mbtext) $ toWidget [julius|
$(document).ready(function (){
$('textarea').attr('readonly','readonly').attr('style','color: gray;');
}); |]
@@ -498,17 +501,21 @@ postUpdateR revid page = do
user <- requireUser
((res, _form), _enctype) <- runFormPost $ editForm Nothing
fs <- filestore <$> getYesodSub
+ toMaster <- getRouteToMaster
case res of
FormSuccess r -> do
- liftIO $ modify fs (pathForPage page) ""
- (Author (gititUserName user) (gititUserEmail user))
- (T.unpack $ editComment r) (filter (/='\r') . T.unpack
- $ unTextarea $ editContents r)
- -- TODO handle mergeinfo
- return ()
- _ -> return ()
- toMaster <- getRouteToMaster
- redirect $ toMaster $ ViewR page
+ mres <- liftIO $ modify fs (pathForPage page) revid
+ (Author (gititUserName user) (gititUserEmail user))
+ (T.unpack $ editComment r) (filter (/='\r') . T.unpack
+ $ unTextarea $ editContents r)
+ case mres of
+ Right () -> redirect $ toMaster $ ViewR page
+ Left mergeinfo ->
+ edit (Just $ mergeText mergeinfo)
+ (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
, editComment :: Text
View
2  messages/en.msg
@@ -22,3 +22,5 @@ ConfirmDelete page@Page: Are you sure you want to delete #{page}?
Delete: Delete
Deleted page@Page: Deleted #{page}
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.
+
View
2  static/css/screen.css
@@ -119,7 +119,7 @@ pre.matches span.highlighted { background-color: yellow; }
/* .req is used to hide a honeypot in a form */
.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 li { display: inline; border: 1px solid #ccc; border-bottom: none; padding: 0 0.6em 0 0.6em;
Please sign in to comment.
Something went wrong with that request. Please try again.