By | Chris Done |
At | 2013-03-01 |
Title | add diff of original vs prev annotation |
Description |
Edit file src/Amelie/View/Paste.hs 33188 → 33188
22 22 import Control.Arrow ((&&&))
23 23 import Control.Monad
24 24 import Data.ByteString.UTF8 (toString)
25 25 import Data.List (find,nub)
26 26 import qualified Data.Map as M
- 27 import Data.Maybe (fromMaybe)
+ 27 import Data.Maybe
28 28 import Data.Monoid.Operator ((++))
29 29 import Data.Text (Text,pack)
30 30 import qualified Data.Text as T
31 31 import Data.Text.Lazy (fromStrict)
32 32 import Data.Time.Show (showDateTime)
… … … … 222 222 href ("/report/" ++ pack (show pid) ++ "") ("Report/Delete" :: Text)
223 223 224 224 where pid = pasteId paste
225 225 pairs = zip (drop 1 pastes) pastes
226 226 parent = fmap snd $ find ((==pid).pasteId.fst) $ pairs
- 227 diffLink =
+ 227 diffLink = do
+ 228 case listToMaybe pastes of
+ 229 Nothing -> return ()
+ 230 Just Paste{pasteId=parentId} -> do
+ 231 href ("/diff/" ++ show parentId ++ "/" ++ show pid)
+ 232 ("Diff original" :: Text)
228 233 case parent of
229 234 Nothing -> return ()
230 235 Just Paste{pasteId=prevId} -> do
- 231 href ("/diff/" ++ show prevId ++ "/" ++ show pid)
- 232 ("Diff" :: Text)
- 233 " - "
+ 236 when (pasteType paste /= AnnotationOf prevId) $ do
+ 237 " / "
+ 238 href ("/diff/" ++ show prevId ++ "/" ++ show pid)
+ 239 ("prev" :: Text)
+ 240 case listToMaybe pastes of
+ 241 Nothing -> return (); Just{} -> " - "
234 242 lang = pasteLanguage paste >>= (`lookup` ls)
235 243 ls = map (languageId &&& languageName) langs
236 244 237 245 -- | Show the paste content with highlighting.
238 246 pasteContent :: [Paste] -> [Language] -> Paste -> Html
… … … … Edit file src/Amelie/Types/Paste.hs 33188 → 33188
50 50 -- | The type of a paste.
51 51 data PasteType
52 52 = NormalPaste
53 53 | AnnotationOf PasteId
54 54 | RevisionOf PasteId
- 55 deriving Show
+ 55 deriving (Eq,Show)
56 56 57 57 -- | A paste submission or annotate.
58 58 data PasteSubmit = PasteSubmit {
59 59 pasteSubmitId :: Maybe PasteId
60 60 ,pasteSubmitType :: PasteType
… … … …