gravatar (empty) → 0.1
raw patch · 5 files changed
+103/−0 lines, 5 filesdep +basedep +bytestringdep +nano-md5setup-changed
Dependencies added: base, bytestring, nano-md5
Files
- LICENSE +30/−0
- Network/Gravatar.hs +38/−0
- Setup.lhs +3/−0
- gravatar.cabal +28/−0
- tests/tests.hs +4/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2008 Don Stewart++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Network/Gravatar.hs view
@@ -0,0 +1,38 @@+--------------------------------------------------------------------+-- |+-- Module : Network.Gravatar+-- Copyright : (c) Galois, Inc. 2008+-- License : BSD3+--+-- Maintainer: Don Stewart <dons@galois.com>+-- Stability : provisional+-- Portability:+--+--------------------------------------------------------------------+--+-- Return the url of a gravatar+--++module Network.Gravatar (+ gravatar+ , Rating(..)+ ) where++import Data.Digest.OpenSSL.MD5+import Data.List+import Data.Char+import qualified Data.ByteString.Char8 as S++-- | Classification ratings for gravatars+data Rating = G | PG | R | X+ deriving (Eq,Ord,Bounded,Enum,Show,Read)++baseURL = "http://www.gravatar.com/avatar.php?"+gravatar_id = "gravatar_id"++-- | Return the url of a gravatar for an email address (a globally recognized avatar).+gravatar :: String -> String+gravatar who = concat [baseURL ,gravatar_id ,"=" ,(md5sum (S.pack (clean who)))]+ where+ clean = let f = reverse . dropWhile isSpace in f . f+
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ gravatar.cabal view
@@ -0,0 +1,28 @@+name: gravatar+version: 0.1+homepage: http://code.haskell.org/~dons/code/gravatar+synopsis: Find the url of the gravatar associated with an email address.+description: + Gravatars <gravatar.com> are globally unique images associated with an email+ address, widely used in social networking sites. This library+ lets you find the URL of a gravatar .png associated with an email+ address.+category: Network+license: BSD3+license-file: LICENSE+author: Don Stewart +maintainer: <dons@galois.com>+cabal-version: >= 1.2+build-type: Simple++flag small_base+ description: Choose the new smaller, split-up base package.++library+ exposed-modules: Network.Gravatar++ if flag(small_base)+ build-depends: base >= 3, bytestring+ else+ build-depends: base < 3+ build-depends: nano-md5
+ tests/tests.hs view
@@ -0,0 +1,4 @@+import Network.Gravatar++main = do+ print $ gravatar "dons@galois.com" == "http://www.gravatar.com/avatar.php?gravatar_id=f21827076a1d0725c4f4bd5a640102e9"