By | Chris Done |
At | 2011-11-29 |
Title | Highlight paste line. |
Description |
Edit file src/Main.hs 33188 → 33188
75 75 ("/css/amelie.css", run Style.handle)
76 76 ,("/js/amelie.js", run Script.handle)
77 77 ,("/css/",serveDirectory "wwwroot/css")
78 78 ,("/js/",serveDirectory "wwwroot/js")
79 79 ,("/hs/",serveDirectory "wwwroot/hs")
+ 80 + 81 ,("/irc/:channel/:date/:timestamp/:paste",run Irclogs.handle)
80 82 ,("/irc/:channel/:date/:timestamp",run Irclogs.handle)
+ 83 81 84 -- /irc/haskell/2011-08-30/00-01-51
82 85 -- ,("/irc/:channel/:date",run Irclogs.handle)
83 86 -- ,("/irc/:channel",run Irclogs.handle)
84 87 -- ,("/irc",run Irclogs.handle)
85 88 -- @ label pageServe
… … … … Edit file src/Amelie/View/Irclogs.hs 33188 → 33188
23 23 import Text.Blaze.Extra
24 24 import Text.Blaze.Html5 as H hiding (map)
25 25 import qualified Text.Blaze.Html5.Attributes as A
26 26 27 27 -- | Render the irclogs page.
- 28 page :: String -> String -> String -> Either String [Text] -> Html
- 29 page channel date time entries =
+ 28 page :: String -> String -> String -> Either String [Text] -> Maybe Integer -> Html
+ 29 page channel date time entries pid =
30 30 layoutPage $ Page {
31 31 pageTitle = "Development irclogs"
- 32 , pageBody = irclogs channel entries
+ 32 , pageBody = irclogs pid channel entries
33 33 , pageName = "irclogs"
34 34 }
35 35 36 36 -- | View the paginated pastes.
- 37 irclogs :: String -> Either String [Text] -> Html
- 38 irclogs channel entries = do
+ 37 irclogs :: Maybe Integer -> String -> Either String [Text] -> Html
+ 38 irclogs pid channel entries = do
39 39 darkSection "IRC logs" $ do
40 40 p $ do "Channel: #"; toHtml channel
41 41 lightSection (fromString ("#" ++ channel)) $ do
42 42 case entries of
43 43 Left error -> do "Unable to get logs for this channel and date: "
44 44 toHtml error
45 45 Right entries ->
46 46 ul !. "amelie-irc-entries" $
47 47 forM_ entries $ \entry -> do
48 48 let date = toValue $ parseDate entry
- 49 li $ do
+ 49 url = "http://hpaste.org/" ++ maybe "0" (T.pack . show) pid
+ 50 currentline | T.isSuffixOf url entry = "current"
+ 51 | otherwise = ""
+ 52 li !. (toValue (currentline :: Text)) $ do
50 53 a ! A.name date ! A.id date $ return ()
51 54 toHtml entry
52 55 53 56 where parseDate = T.replace ":" "-" . T.takeWhile (not.isSpace)
… … … … Edit file src/Amelie/View/Style.hs 33188 → 33188
33 33 ircEntries = do
34 34 classRule "irc-entries" $ do
35 35 marginLeft "0"
36 36 paddingLeft "0"
37 37 listStyle "none"
+ 38 rule ".current" $ do
+ 39 fontWeight "bold"
+ 40 marginTop "1em"
+ 41 marginBottom "1em"
38 42 39 43 -- | Footer.
40 44 footer :: CSS Rule
41 45 footer = do
42 46 classRule "footer" $ do
… … … … Edit file src/Amelie/Controller/Irclogs.hs 33188 → 33188
13 13 import Amelie.View.Irclogs (page)
14 14 15 15 import Data.String.ToString
16 16 import Data.String
17 17 import Snap.Types
+ 18 import Safe
18 19 19 20 handle :: Controller ()
20 21 handle = do
21 22 channel <- get "channel"
22 23 date <- get "date"
23 24 time <- get "timestamp"
+ 25 pasteid <- getMaybe "paste"
24 26 logs <- getNarrowedLogs channel date time
- 25 output $ page channel date time logs
+ 27 output $ page channel date time logs pasteid
26 28 27 29 where get key = do
28 30 value <- fmap (fmap toString) $ getParam (fromString key)
29 31 case value of
30 32 Nothing -> error $ "Missing parameter: " ++ key
31 33 Just value -> return value
+ 34 getMaybe key = fmap ((>>= readMay) . fmap toString) $ getParam (fromString key)
… … … …