summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiyangHu <>2016-03-31 09:38:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-03-31 09:38:00 (GMT)
commit741678724e2ffc45a72103135c212916c0df4a52 (patch)
tree5498c078464a10e7e85e35d2e410e89d63f16153
parent718a94d7a597ec2f59fdc8f30420d0751e5d534f (diff)
version 0.0.1.2HEAD0.0.1.2master
-rw-r--r--example.hs63
-rw-r--r--google-mail-filters.cabal19
-rw-r--r--src/Data/Google/Mail/Filters.hs4
3 files changed, 63 insertions, 23 deletions
diff --git a/example.hs b/example.hs
index 169a7a0..43e2d06 100644
--- a/example.hs
+++ b/example.hs
@@ -1,9 +1,16 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# OPTIONS_GHC -Wall #-}
import Prelude
+#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
+#endif
+import qualified Data.Text.Lazy as TL
+import qualified Data.Text.Lazy.Builder as B
import qualified Data.Text.Lazy.IO as TL
import Data.Time.Clock
+import System.IO
import Text.XML as XML
import Language.Google.Search.Simple as Search
@@ -16,27 +23,49 @@ main = do
TL.putStrLn . XML.renderText def {rsPretty = True} $
Filters.toXML now ("Your Name", "you@example.com") filters
+ -- Search Terms for GMail Labs' ‘Quick Links’ by Dan P
+ TL.hPutStrLn stderr . TL.append "old:\t" . searchText $ orB
+ [ pure (Label "notification") /\ pure (Older 1 Months)
+ , pure (Label "dev") /\ pure (Older 6 Months)
+ :: Search.Mail ]
+
+searchText :: (SearchBuilder e) => e -> TL.Text
+searchText s = B.toLazyText b where PrecBuilder _prec b = searchBuilder s
+
filters :: [Filter]
filters =
+ [ Filter [Archive, LabelAs "shopping"]
+ $ (pure . From . orB)
+ [ "googleplay-noreply@google.com"
+ , "noreply@indiegogo.com" ]
+ \/ ( pure . From $ "amazon" /\ orB
+ ["confirm", "digital", "marketplace", "no-reply", "update"] )
+ \/ andB [ pure $ From "no-reply@kickstarter.com"
+ , notB . pure $ Subject "reminder" ]
- [ Filter [Archive, LabelAs "shopping"] $ orB
- [ pure (From $ ("auto-confirm" \/ "noreply") /\ "amazon")
- , pure (From "no-reply@kickstarter.com")
- , pure (From $ "service" /\ "paypal")
+ , Filter [Archive, LabelAs "dev"] $ orB
+ [ pure (From "ghc-devs@haskell.org")
+ /\ pure (Cc "ghc-tickets@haskell.org")
+ , pure . Subject $ Exact <$> "Haskell Weekly News"
+ , (pure . From . orB)
+ [ "notifications@travis-ci.org"
+ , "notifications@github.com"
+ , "googlecode.com"
+ ]
]
- , Filter [Archive, LabelAs "haskell"]
- $ pure (List "haskell-cafe.haskell.org")
- /\ notB haskellWeeklyNews -- keep in inbox
- , Filter [LabelAs "haskell"] haskellWeeklyNews
-
- , Filter [LabelAs "notification", MarkAsImportant False, NeverSpam] $ orB
- [ pure $ From "plus.google.com"
- , pure $ From "facebookmail.com"
- , pure $ From "postmaster.twitter.com"
- , pure $ From "noreply@foursquare.com"
- ]
+ , Filter [LabelAs "notification", MarkAsImportant False, NeverSpam]
+ $ (pure . From . orB)
+ [ "MAILER-DAEMON"
+ , "facebookmail.com"
+ , "no-reply@mail.instagram.com"
+ , "noreply@foursquare.com"
+ , "noreply@youtube.com"
+ , "notifications.pinterest.com"
+ , "notify@twitter.com"
+ , "plus.google.com"
+ ]
+ \/ pure (List "meetup.com")
- ] where
- haskellWeeklyNews = pure . Subject $ Exact <$> "Haskell Weekly News"
+ ]
diff --git a/google-mail-filters.cabal b/google-mail-filters.cabal
index f528777..f45f0ff 100644
--- a/google-mail-filters.cabal
+++ b/google-mail-filters.cabal
@@ -1,5 +1,5 @@
name: google-mail-filters
-version: 0.0.1.1
+version: 0.0.1.2
synopsis: Write GMail filters and output to importable XML
description:
Organise your Google Mail filters as a Haskell EDSL, and produce XML
@@ -18,24 +18,33 @@ cabal-version: >= 1.8
stability: experimental
extra-source-files:
example.hs
+tested-with:
+ GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4,
+ GHC == 7.10.2, GHC == 7.10.3
source-repository head
type: git
location: http://github.com/liyang/google-mail-filters
+flag old-time
+ description: time < 1.5
+ default: False
+
library
hs-source-dirs: src
+ ghc-options: -Wall
exposed-modules:
Data.Google.Mail.Filters
build-depends:
base >= 4.5 && <= 9000,
containers >= 0.4,
- google-search >= 0.1.0.1,
- old-locale >= 1.0,
+ google-search >= 0.2.0.0,
text >= 0.11,
- time >= 1.4,
xml-conduit >= 0.7
- ghc-options: -Wall
+ if flag(old-time)
+ build-depends: old-locale >= 1.0, time >= 1.4 && < 1.5
+ else
+ build-depends: time >= 1.5
test-suite example
type: exitcode-stdio-1.0
diff --git a/src/Data/Google/Mail/Filters.hs b/src/Data/Google/Mail/Filters.hs
index ad24622..cbec764 100644
--- a/src/Data/Google/Mail/Filters.hs
+++ b/src/Data/Google/Mail/Filters.hs
@@ -15,7 +15,9 @@ import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as B
import Data.Time.Clock
import Data.Time.Format
-import System.Locale
+#if !MIN_VERSION_time(1,5,0)
+import System.Locale (defaultTimeLocale)
+#endif
import Text.XML
import Language.Google.Search.Simple as Search