Browse files

Plugins: hlint and import cleanup (gwern).

  • Loading branch information...
1 parent 53fb6c2 commit 112e8b06f7c8c172ea1337509e952e191f0862b7 @jgm committed Feb 26, 2010
View
2 plugins/CapitalizeEmphasis.hs
@@ -11,7 +11,7 @@ plugin :: Plugin
plugin = mkPageTransform capsTransform
capsTransform :: [Inline] -> [Inline]
-capsTransform ((Emph x):xs) = processWith capStr x ++ capsTransform xs
+capsTransform (Emph x : xs) = processWith capStr x ++ capsTransform xs
capsTransform (x:xs) = x : capsTransform xs
capsTransform [] = []
View
2 plugins/Deprofanizer.hs
@@ -13,6 +13,6 @@ deprofanize (Str x) | isBadWord x = Str "XXXXX"
deprofanize x = x
isBadWord :: String -> Bool
-isBadWord x = (map toLower x) `elem` ["darn", "blasted", "stinker"]
+isBadWord x = map toLower x `elem` ["darn", "blasted", "stinker"]
-- there are more, but this is a family program
View
8 plugins/Dot.hs
@@ -13,13 +13,13 @@ module Dot (plugin) where
-- of the file contents.
import Network.Gitit.Interface
-import System.Process
-import System.Exit
+import System.Process (readProcessWithExitCode)
+import System.Exit (ExitCode(ExitSuccess))
-- from the utf8-string package on HackageDB:
import Data.ByteString.Lazy.UTF8 (fromString)
-- from the SHA package on HackageDB:
-import Data.Digest.Pure.SHA
-import System.FilePath
+import Data.Digest.Pure.SHA (sha1, showDigest)
+import System.FilePath ((</>))
import Control.Monad.Trans (liftIO)
plugin :: Plugin
View
22 plugins/ImgTex.hs
@@ -26,11 +26,8 @@ modified by John MacFarlane to use withTempDir
-}
import Network.Gitit.Interface
-import Text.Pandoc.Shared
import System.Process (system)
-import System.Exit
import System.Directory
-import Data.Char (ord)
import Data.ByteString.Lazy.UTF8 (fromString)
import Data.Digest.Pure.SHA
import System.FilePath
@@ -39,22 +36,21 @@ import Control.Monad.Trans (liftIO)
plugin :: Plugin
plugin = mkPageTransformM transformBlock
-templateHeader =
- ( "\\documentclass[12pt]{article}\n"
- ++ "\\usepackage{amsmath,amssymb,bm}\n"
- ++ "\\begin{document}\n"
- ++ "\\thispagestyle{empty}\n"
- ++ "\\[\n"
- )
+templateHeader, templateFooter :: String
+templateHeader = concat
+ [ "\\documentclass[12pt]{article}\n"
+ , "\\usepackage{amsmath,amssymb,bm}\n"
+ , "\\begin{document}\n"
+ , "\\thispagestyle{empty}\n"
+ , "\\[\n"]
templateFooter =
- ( "\n"
+ "\n"
++ "\\]\n"
++ "\\end{document}\n"
- )
transformBlock :: Block -> PluginM Block
-transformBlock (CodeBlock (id, classes, namevals) contents)
+transformBlock (CodeBlock (_, classes, namevals) contents)
| "dvipng" `elem` classes = do
cfg <- askConfig
let (name, outfile) = case lookup "name" namevals of
View
2 plugins/Interwiki.hs
@@ -39,7 +39,7 @@ convertInterwikiLinks (Link ref (interwiki, article)) =
('!':interwiki') ->
case M.lookup interwiki' interwikiMap of
Just url -> case article of
- "" -> Link ref (url ++ (inlinesToURL ref), (summary $ unEscapeString $ inlinesToURL ref))
+ "" -> Link ref (url ++ inlinesToURL ref, summary $ unEscapeString $ inlinesToURL ref)
_ -> Link ref (interwikiurl article url, summary article)
Nothing -> Link ref (interwiki, article)
where -- 'http://starwars.wikia.com/wiki/Emperor_Palpatine'
View
3 plugins/PigLatin.hs
@@ -21,9 +21,10 @@ pigLatinStr (Str (c:cs)) | isLower c && isConsonant c =
Str (cs ++ (c : "ay"))
pigLatinStr (Str (c:cs)) | isUpper c && isConsonant c =
Str (capitalize cs ++ (toLower c : "ay"))
-pigLatinStr (Str x@(c:cs)) | isLetter c = Str (x ++ "yay")
+pigLatinStr (Str x@(c:_)) | isLetter c = Str (x ++ "yay")
pigLatinStr x = x
+isConsonant :: Char -> Bool
isConsonant c = c `notElem` "aeiouAEIOU"
capitalize :: String -> String
View
1 plugins/ShowUser.hs
@@ -4,7 +4,6 @@ module ShowUser (plugin) where
-- user, or the empty string if no one is logged in.
import Network.Gitit.Interface
-import Data.Maybe (fromMaybe)
plugin :: Plugin
plugin = mkPageTransformM showuser
View
12 plugins/Signature.hs
@@ -4,22 +4,20 @@ module Signature (plugin) where
-- of the last edit, prior to saving the page in the repository.
import Network.Gitit.Interface
-import Data.Maybe (fromMaybe)
-import Data.DateTime
-import Control.Monad
+import Data.DateTime (getCurrentTime, formatDateTime)
plugin :: Plugin
plugin = PreCommitTransform replacedate
replacedate :: String -> PluginM String
replacedate [] = return ""
replacedate ('$':'S':'I':'G':'$':xs) = do
- datetime <- liftIO $ getCurrentTime
+ datetime <- liftIO getCurrentTime
mbuser <- askUser
let username = case mbuser of
Nothing -> "???"
Just u -> uUsername u
- let sig = "-- " ++ username ++ " (" ++ formatDateTime "%c" datetime ++ ")"
- liftM (sig ++ ) $ replacedate xs
-replacedate (x:xs) = liftM (x : ) $ replacedate xs
+ let sig = concat ["-- ", username, " (", formatDateTime "%c" datetime, ")"]
+ fmap (sig ++ ) $ replacedate xs
+replacedate (x:xs) = fmap (x : ) $ replacedate xs
View
5 plugins/WebArchiver.hs
@@ -49,8 +49,9 @@ webciteArchive email url = forkIO (ignore $ openURL ("http://www.webcitation.org
ignore = fmap $ const ()
alexaArchive :: String -> IO ()
-alexaArchive url = do let archiveform = Form POST (fromJust $ parseURI "http://www.alexa.com/help/crawlrequest")
- [("url", url), ("submit", "")]
+alexaArchive url = do let archiveform = Form POST
+ (fromJust $ parseURI "http://www.alexa.com/help/crawlrequest")
+ [("url", url), ("submit", "")]
(uri, resp) <- browse $ request $ formToRequest archiveform
when (uriPath uri /= "/help/crawlthanks") $
error $ "Request failed! Did Alexa change webpages? Response:" ++ rspBody resp

0 comments on commit 112e8b0

Please sign in to comment.