packages feed

open-browser 0.1.0.0 → 0.1.1.0

raw patch · 4 files changed

+35/−18 lines, 4 files

Files

lib/Network/Browser.hs view
@@ -2,23 +2,15 @@ ( openBrowser ) where -import System.Exit (ExitCode(..))-import System.Process (rawSystem)--osxCommand :: String -> (String, [String])-osxCommand url = ("/usr/bin/osascript", argv)-    where argv = ["-e", appleScript, url]-          appleScript = "on run argv\n\-                        \    open location (item 1 of argv)\n\-                        \end run\n"--osx :: String -> IO Bool-osx url = exitCodeToBool `fmap` rawSystem executable argv-    where (executable, argv) = osxCommand url-          exitCodeToBool ExitSuccess     = True-          exitCodeToBool (ExitFailure _) = False+import Data.List (isInfixOf)+import Network.Browser.Linux (openBrowserLinux)+import Network.Browser.OSX (openBrowserOSX)+import System.Info (os)  -- |'openBrowser' opens a URL in the user's preferred web browser. Returns -- whether or not the operation succeeded. openBrowser :: String -> IO Bool-openBrowser = osx+openBrowser+    | "linux"  `isInfixOf` os = openBrowserLinux+    | "darwin" `isInfixOf` os = openBrowserOSX+    | otherwise               = error "unsupported platform"
+ lib/Network/Browser/Linux.hs view
@@ -0,0 +1,12 @@+module Network.Browser.Linux+( openBrowserLinux+) where++import System.Exit (ExitCode(..))+import System.Process (rawSystem)++openBrowserLinux :: String -> IO Bool+openBrowserLinux url = exitCodeToBool `fmap` rawSystem executable argv+    where (executable, argv) = ("xdg-open", [url])+          exitCodeToBool ExitSuccess     = True+          exitCodeToBool (ExitFailure _) = False
+ lib/Network/Browser/OSX.hs view
@@ -0,0 +1,12 @@+module Network.Browser.OSX+( openBrowserOSX+) where++import System.Exit (ExitCode(..))+import System.Process (rawSystem)++openBrowserOSX :: String -> IO Bool+openBrowserOSX url = exitCodeToBool `fmap` rawSystem executable argv+    where (executable, argv) = ("open", [url])+          exitCodeToBool ExitSuccess     = True+          exitCodeToBool (ExitFailure _) = False
open-browser.cabal view
@@ -1,8 +1,8 @@ name:                       open-browser-version:                    0.1.0.0+version:                    0.1.1.0 synopsis:                   Open a web browser from Haskell. description:                Open a web browser from Haskell.-                            Currently only OS X is supported.+                            Currently only Linux and OS X are supported. license:                    BSD3 license-file:               LICENSE author:                     rightfold@@ -18,6 +18,7 @@  library     exposed-modules:        Network.Browser+    other-modules:          Network.Browser.Linux, Network.Browser.OSX     hs-source-dirs:         lib     default-language:       Haskell2010     build-depends:          base >= 4 && < 5, process >= 1 && < 2