diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,165 @@
+		   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/README b/README
new file mode 100644
--- /dev/null
+++ b/README
@@ -0,0 +1,59 @@
+nikepub
+
+INTRODUCTION
+
+nikepub is a simple commandline program that given a Nike+ user id will fetch the
+most recent Nike+ run and publish it to any blog and/or Twitter account.
+Assumes the Nike+ user profile is public. Supports customizable templates
+for the blog entry title, body and Twitter status update. Any blogging
+system with XML-RPC support for metaWeblog.newPost (like WordPress or MovableType)
+is supported.
+
+A description of the implementation can be found in this series of blog posts:
+
+http://www.codemanic.com/uwe/2009/05/publishing-nike-runs-part-1-numeric-lists.html
+http://www.codemanic.com/uwe/2009/06/publishing-nike-runs-part-2-google-charts.html
+http://www.codemanic.com/uwe/2009/06/publishing-nike-runs-part-3-handling-xml.html
+http://www.codemanic.com/uwe/2009/06/publishing-nike-runs-part-4-string-templates.html
+http://www.codemanic.com/uwe/2009/06/publishing-nike-runs-part-5-blogging-and-twitter.html
+
+INSTALLATION
+
+nikepub comes as a cabal package so doing 
+
+$ runhaskell Setup configure --prefix=$HOME --user
+$ runhaskell Setup build
+$ runhaskell Setup install
+
+in the untarred package directory will install nikepub in $HOME/bin.
+
+USAGE
+
+Example command line flags (fill in values where you see <value description>s):
+
+nikepub
+ --id=<your nike+ id> \
+ --templates=<path to a templates dir> \
+ --mtUrl=<url to your blog xml-rpc> \
+ --mtUser=<your blog username> \ 
+ --mtPassword=<path to a file containing your blog api password> \ 
+ --message=<any additional message you want in blog entry> \ 
+ --twitterUser=<your twitter username> \
+ --twitterPassword=<path to a file containing your twitter password>
+
+The distribution package contains an example template directory. It can be used directly or customized.
+The example template files have all the supported $fields$ in them. All three files must be present in
+a template directory. You might want to copy the template directory into a more convenient place.
+
+Your Nike+ profile is assumed to be public. nikepub doesn't work with non-public profiles (if you publish
+your runs with nikepub you might as well have your profile public). Your Nike+ id is an integer. The simplest way
+to find it out is to share a run or your profile in the Flash UI on the Nike+ website by choosing to grab
+the link to the run you want to share in the Share menu.
+The pasteboard now has a URL with your Nike+ user id in the URL params.
+
+The --message flag on the nikepub commandline lets you append an arbitrary message to the body of the generated
+blog entry.
+
+BUGS, SUGGESTIONS, COMMENTS
+
+Please send to uwe@codemanic.com
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/nikepub.cabal b/nikepub.cabal
new file mode 100644
--- /dev/null
+++ b/nikepub.cabal
@@ -0,0 +1,36 @@
+Name:                nikepub
+Version:             1.0
+Category:            Web
+Synopsis:            Command line utility publishes Nike+ runs on blogs and Twitter
+Description:         Simple commandline program that given a Nike+ user id will fetch the
+                     most recent Nike+ run and publish it to any blog and/or Twitter account.
+                     Assumes the Nike+ user profile is public. Supports customizable templates
+                     for the blog entry title, body and Twitter status update. Any blogging
+                     system with XML-RPC support for metaWeblog.newPost 
+                     (like WordPress or MovableType) is supported.
+License:             LGPL
+License-file:        LICENSE
+Author:              Uwe Hoffmann
+Maintainer:          uwe@codemanic.com
+Homepage:            http://www.codemanic.com/uwe
+Build-Type:          Simple
+Cabal-Version:       >=1.2
+Extra-Source-Files:  README, templates/mt_title.st, templates/mt_body.st,
+                     templates/twitter_status.st
+Executable nikepub
+  Main-is:           nikepub.hs
+  Build-Depends:     haskell98,
+                     base >= 4.1.0.0 && < 5,
+                     containers >= 0.2.0.1,
+                     regex-compat >= 0.71.0.1,
+                     old-time >= 1.0.0.2,
+                     old-locale >= 1.0.0.1,
+                     time >= 1.1.3,
+                     syb >= 0.1.0.1,
+                     network >= 2.2.1,
+                     HTTP >= 4000.0.6,
+                     GoogleChart >= 0.2,
+                     haxr >= 3000.2.1,
+                     hxt >= 8.3.0,
+                     hs-twitter >= 0.2.8,
+                     HStringTemplate >= 0.5.1.2
diff --git a/nikepub.hs b/nikepub.hs
new file mode 100644
--- /dev/null
+++ b/nikepub.hs
@@ -0,0 +1,175 @@
+module Main (main)
+where
+
+import Codemanic.NikeRuns
+import Codemanic.Blogging
+import System.Console.GetOpt
+import System
+import IO
+import Control.Monad
+import Data.Maybe
+import Web.Twitter.Fetch
+import Web.Twitter.Monad
+import System.Environment
+
+data Options = Options {
+  nikeId :: Int,
+  templateDir :: String,
+  chartWidth :: Int,
+  chartHeight :: Int,
+  mtUser :: Maybe String,
+  mtPassword :: Maybe FilePath,
+  mtUrl :: Maybe String,
+  twitterUser :: Maybe String,
+  twitterPassword :: Maybe FilePath,
+  message :: Maybe String
+} deriving (Eq, Show)
+
+defaultOptions :: Options
+defaultOptions = Options {
+  nikeId = 0,
+  templateDir = "",
+  chartWidth = 600,
+  chartHeight = 200,
+  mtUser = Nothing,
+  mtPassword = Nothing,
+  mtUrl = Nothing,
+  twitterUser = Nothing,
+  twitterPassword = Nothing,
+  message = Nothing
+}
+
+options :: [ OptDescr (Options -> IO Options) ]
+options = 
+  [ Option "" ["templates"]
+        (ReqArg
+            (\arg opt -> return opt { templateDir = arg })
+            "DIR")
+        "template directory"
+ 
+    , Option "u" ["id"]
+        (ReqArg
+            (\arg opt -> return opt { nikeId = (read arg) })
+            "INT")
+        "nike+ user id"
+
+    , Option "" ["mtUser"]
+        (ReqArg
+            (\arg opt -> return opt { mtUser = Just arg })
+            "STRING")
+        "mt user"
+
+    , Option "" ["mtPassword"]
+        (ReqArg
+            (\arg opt -> return opt { mtPassword = Just arg })
+            "FILEPATH")
+        "mt password file"
+
+    , Option "" ["mtUrl"]
+        (ReqArg
+            (\arg opt -> return opt { mtUrl = Just arg })
+            "STRING")
+        "mt url"
+
+    , Option "" ["twitterUser"]
+        (ReqArg
+            (\arg opt -> return opt { twitterUser = Just arg })
+            "STRING")
+        "twitter user"
+
+    , Option "" ["twitterPassword"]
+        (ReqArg
+            (\arg opt -> return opt { twitterPassword = Just arg })
+            "FILEPATH")
+        "twitter password file"
+
+    , Option "m" ["message"]
+        (ReqArg
+            (\arg opt -> return opt { message = Just arg })
+            "STRING")
+        "message"
+ 
+    , Option [] ["chartWidth"]
+        (ReqArg
+            (\arg opt -> return opt { chartWidth = read arg })
+            "INT")
+        "chart width"
+
+    , Option [] ["chartHeight"]
+        (ReqArg
+            (\arg opt -> return opt { chartHeight = read arg })
+            "INT")
+        "chart height"
+
+    , Option "v" ["version"]
+        (NoArg
+            (\_ -> do
+                hPutStrLn stderr "Version 1.00"
+                exitWith ExitSuccess))
+        "Print version"
+ 
+    , Option "h" ["help"]
+        (NoArg
+            (\_ -> do
+    	        prg <- getProgName
+                hPutStrLn stderr (usageInfo prg options)
+                exitWith ExitSuccess))
+        "Show help"
+    ]
+
+nikepubOpts :: [String] -> IO Options
+nikepubOpts args = do
+    case getOpt RequireOrder options args of
+      (o,n,[]  ) -> foldl (>>=) (return defaultOptions) o
+      (_,_,errs) -> ioError (userError (concat errs ++ usageInfo header options))
+  where header = "Usage: nikepub [OPTION...]"
+
+tweet :: NikeRun -> Options -> IO ()
+tweet nr opts = do
+  let cw = chartWidth opts
+  let ch = chartHeight opts
+  case (twitterUser opts) of
+    Just twu -> do
+      twitterMsg <- renderNikeRun cw ch (templateDir opts) "twitter_status" nr ""
+      twitterPswd <- readFile (fromJust $ twitterPassword opts)
+      putStrLn $ "tweeting update " ++ twitterMsg
+      runTM (AuthUser twu twitterPswd)
+        $ postMethod
+        $ restCall "update.json" (arg "status" twitterMsg [])
+      putStrLn "done tweeting"
+      return ()
+    Nothing -> return ()
+ 
+blog :: NikeRun -> Options -> IO ()
+blog nr opts = do
+  let cw = chartWidth opts
+  let ch = chartHeight opts
+  case (mtUrl opts) of 
+    Just u -> do
+      mtTitle <- renderNikeRun cw ch (templateDir opts) "mt_title" nr ""
+      mtBody  <- renderNikeRun cw ch (templateDir opts) "mt_body" nr (fromMaybe "" (message opts))
+      mtPswd <- readFile (fromJust $ mtPassword opts)
+      let blogEntry = BlogEntry {
+         title = mtTitle,
+         body = mtBody,
+         keywords = ["running"],
+         publishTime = (startTime nr) }
+      let blog = Blog {
+         url = u,
+         user = (fromJust $ mtUser opts),
+         password = mtPswd,         
+         blogId = 1}
+      publish blog blogEntry
+    Nothing  -> return ()
+  
+main :: IO ()
+main = do
+  args <- getArgs
+  opts <- nikepubOpts args
+  let userId = (nikeId opts)
+  putStrLn $ "fetching most recent run for nike user " ++ (show userId)
+  runId <- getMostRecentNikeRunId userId
+  putStrLn $ "fetching run " ++ (show runId)
+  nr <- getNikeRun userId runId
+  blog nr opts
+  tweet nr opts
diff --git a/templates/mt_body.st b/templates/mt_body.st
new file mode 100644
--- /dev/null
+++ b/templates/mt_body.st
@@ -0,0 +1,6 @@
+<a href="http://nikeplus.nike.com/nikeplus/v1/services/widget/get_public_run.jsp?id=$runId$&userID=$userId$">run</a> $startTime$, $distance$ km, $duration$ min, $calories$ calories,
+$pace$ min/km avg pace
+
+<img src="$chart$">
+
+$message$
diff --git a/templates/mt_title.st b/templates/mt_title.st
new file mode 100644
--- /dev/null
+++ b/templates/mt_title.st
@@ -0,0 +1,1 @@
+run $distance$ km
diff --git a/templates/twitter_status.st b/templates/twitter_status.st
new file mode 100644
--- /dev/null
+++ b/templates/twitter_status.st
@@ -0,0 +1,1 @@
+run $startTime$, $distance$ km, $duration$ min, $calories$ calories
