By | Chris Done |
At | 2013-06-19 |
Title | Tweak spam filtering. |
Description |
Remove file src/Text/Blaze/Extra.hs 33188
- 1 {-# OPTIONS -fno-warn-orphans #-} - 2 {-# LANGUAGE RecordWildCards #-} - 3 {-# LANGUAGE OverloadedStrings #-} - 4 {-# OPTIONS -fno-warn-name-shadowing -fno-warn-unused-do-bind #-} - 5 - 6 module Text.Blaze.Extra where - 7 - 8 import Control.Monad - 9 import Data.Monoid - 10 import Data.Monoid.Operator - 11 import Prelude hiding ((++),head,div) - 12 import Text.Blaze.Html5 as H hiding (map) - 13 import Text.Blaze.Html5.Attributes as A - 14 import Text.Blaze.Internal (Attributable) - 15 import Network.URI.Params - 16 import Network.URI - 17 import Text.Printf - 18 import Data.List (intercalate) - 19 - 20 (!.) :: (Attributable h) => h -> AttributeValue -> h - 21 elem !. className = elem ! class_ className - 22 - 23 (!#) :: (Attributable h) => h -> AttributeValue -> h - 24 elem !# idName = elem ! A.id idName - 25 - 26 linesToHtml :: String -> Html - 27 linesToHtml str = forM_ (lines str) $ \line -> do toHtml line; br - 28 - 29 htmlIntercalate :: Html -> [Html] -> Html - 30 htmlIntercalate _ [x] = x - 31 htmlIntercalate sep (x:xs) = do x; sep; htmlIntercalate sep xs - 32 htmlIntercalate _ [] = mempty - 33 - 34 htmlCommasAnd :: [Html] -> Html - 35 htmlCommasAnd [x] = x - 36 htmlCommasAnd [x,y] = do x; " and "; y - 37 htmlCommasAnd (x:xs) = do x; ", "; htmlCommasAnd xs - 38 htmlCommasAnd [] = mempty - 39 - 40 htmlCommas :: [Html] -> Html - 41 htmlCommas = htmlIntercalate ", " - 42 - 43 hrefSet :: URI -> String -> String -> Attribute - 44 hrefSet uri key value = hrefURI updated where - 45 updated = updateUrlParam key value uri - 46 - 47 hrefURI :: URI -> Attribute - 48 hrefURI uri = href (toValue (showURI uri)) where - 49 showURI URI{..} = uriPath ++ uriQuery - 50 - 51 hrefAssoc :: String -> [(String,String)] -> Attribute - 52 hrefAssoc path qs = href (toValue uri) where - 53 uri = "/" ++ path ++ "?" ++ intercalate "&" (map (uncurry (printf "%s=%s")) qs) - 54 - 55 instance ToValue URI where - 56 toValue = toValue . show Edit file src/Hpaste/Model/Spam.hs 33188 → 33188
- 1 {-# LANGUAGE RecordWildCards #-}
+ 1 {-# LANGUAGE RecordWildCards #-}
2 2 {-# LANGUAGE OverloadedStrings #-}
3 3 {-# LANGUAGE ScopedTypeVariables #-}
4 4 5 5 -- | Spam detection.
6 6 … … … … 62 62 63 63 -- | Multiple the rating by weights specific to hpaste.
64 64 weighted :: PasteSubmit -> Integer -> Integer
65 65 weighted ps n = foldr ($) n weights where
66 66 weights = [if T.isInfixOf "http://" text || T.isInfixOf "https://" text
- 67 then (*2) else id -- then (* (1 + fromIntegral (T.count "http://" text + T.count "https://" text))) else id
+ 67 then (+ (20 * fromIntegral (T.count "http://" text + T.count "https://" text))) else id
68 68 ,if pasteSubmitAuthor ps == "Anonymous Coward" || pasteSubmitAuthor ps == "Anonymous"
- 69 then (*2) else id
+ 69 then (+20) else id
70 70 ]
71 71 text = allText ps
72 72 73 73 -- | Get the text of the paste.
74 74 allText :: PasteSubmit -> Text
… … … …