By | Chris Done |
At | 2013-06-15 |
Title | Add spam filter support. |
Description |
Edit file src/Hpaste/View/Html.hs 33188 → 33188
- 1 {-# OPTIONS -Wall -fno-warn-name-shadowing #-}
+ 1 {-# OPTIONS -Wall -fno-warn-name-shadowing -fno-warn-unused-do-bind #-}
2 2 {-# LANGUAGE OverloadedStrings #-}
3 3 {-# LANGUAGE RecordWildCards #-}
4 4 5 5 -- | HTML-specific view functions.
6 6 … … … … Edit file src/Hpaste/Model/Paste.hs 33188 → 33188
189 189 tmpdir <- getTemporaryDirectory
190 190 let tmp = tmpdir </> pid ++ ".hs"
191 191 exists <- doesFileExist tmp
192 192 unless exists $ T.writeFile tmp $ contents
193 193 !hints <- hlint [tmp,"--quiet","--ignore=Parse error"]
+ 194 removeFile tmp
194 195 return hints
195 196 196 197 getHints :: PasteId -> HPModel [Hint]
197 198 getHints pid =
198 199 query ["SELECT type,content"
… … … … Edit file src/Hpaste/Controller/Paste.hs 33188 → 33188
15 15 import Hpaste.Types
16 16 import Hpaste.Controller.Cache (cache,resetCache)
17 17 import Hpaste.Model.Channel (getChannels)
18 18 import Hpaste.Model.Language (getLanguages)
19 19 import Hpaste.Model.Paste
+ 20 import Hpaste.Model.Spam
20 21 import Hpaste.Types.Cache as Key
21 22 import Hpaste.View.Paste (pasteFormlet,page)
22 23 23 24 import Control.Applicative
24 25 import Control.Monad ((>=>))
… … … … 87 88 (_,html) = pasteFormlet formlet { pfErrors = errors }
88 89 val = either (const Nothing) Just $ value
89 90 case val of
90 91 Nothing -> return ()
91 92 Just PasteSubmit{pasteSubmitSpamTrap=Just{}} -> goHome
+ 93 Just paste | isSpam paste -> goHome
92 94 Just paste -> do
93 95 resetCache Key.Home
94 96 maybe (return ()) (resetCache . Key.Paste . fromIntegral) $ pasteSubmitId paste
95 97 pid <- model $ createPaste languages channels paste
96 98 maybe (return ()) redirectToPaste pid
… … … … Edit file scripts/cron-update 33188 → 33188
1 1 cd /home/chris/hpaste
2 2 logger -t hpaste "Clearing cache ..."
3 3 rm cache/*
+ 4 rm log/*
… … … …