diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-07 14:16:21 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-07 14:16:21 +0100 |
commit | 7065a8cc1b8b01cd32d4b1d5317b323fec5238bd (patch) | |
tree | d6608f463b066aa6caf33357fd9ae0e508e49084 | |
parent | 75d9fe614dca572aa1d7cfa53553e9c103eb2dd0 (diff) | |
download | thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.gz thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.bz2 thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.xz thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.zip |
Bump versions
-rw-r--r-- | client/src/Thermoprint/Client.hs | 55 | ||||
-rw-r--r-- | client/thermoprint-client.cabal | 4 | ||||
-rw-r--r-- | client/thermoprint-client.nix | 2 | ||||
-rw-r--r-- | default.nix | 2 | ||||
-rw-r--r-- | server/src/Thermoprint/Server/Push.hs | 2 | ||||
-rw-r--r-- | server/thermoprint-server.cabal | 4 | ||||
-rw-r--r-- | spec/src/Thermoprint/API.hs | 8 | ||||
-rw-r--r-- | spec/src/Thermoprint/Identifiers.hs | 8 | ||||
-rw-r--r-- | spec/thermoprint-spec.cabal | 6 | ||||
-rw-r--r-- | spec/thermoprint-spec.nix | 2 | ||||
-rw-r--r-- | tp-bbcode/thermoprint-bbcode.cabal | 8 | ||||
-rw-r--r-- | tp-bbcode/thermoprint-bbcode.nix | 2 | ||||
-rw-r--r-- | tprint/src/Options.hs | 24 | ||||
-rw-r--r-- | tprint/src/Options/Utils.hs | 1 | ||||
-rw-r--r-- | tprint/tprint.cabal | 8 | ||||
-rw-r--r-- | tprint/tprint.nix | 2 | ||||
-rw-r--r-- | webgui/src/Main.hs | 11 | ||||
-rw-r--r-- | webgui/thermoprint-webgui.cabal | 6 | ||||
-rw-r--r-- | webgui/thermoprint-webgui.nix | 2 |
19 files changed, 72 insertions, 85 deletions
diff --git a/client/src/Thermoprint/Client.hs b/client/src/Thermoprint/Client.hs index 448a912..46f6073 100644 --- a/client/src/Thermoprint/Client.hs +++ b/client/src/Thermoprint/Client.hs | |||
@@ -5,12 +5,12 @@ | |||
5 | {-# LANGUAGE RecordWildCards #-} | 5 | {-# LANGUAGE RecordWildCards #-} |
6 | {-# LANGUAGE FlexibleContexts #-} | 6 | {-# LANGUAGE FlexibleContexts #-} |
7 | {-# LANGUAGE FlexibleInstances #-} | 7 | {-# LANGUAGE FlexibleInstances #-} |
8 | {-# LANGUAGE RankNTypes #-} | ||
8 | 9 | ||
9 | -- | A client library for 'Thermoprint.API' | 10 | -- | A client library for 'Thermoprint.API' |
10 | module Thermoprint.Client | 11 | module Thermoprint.Client |
11 | ( Client(..) | 12 | ( Client(..) |
12 | , mkClient, mkClient' | 13 | , mkClient, mkClient' |
13 | , throwNat, ioNat | ||
14 | -- = Reexports | 14 | -- = Reexports |
15 | , ServantError(..) | 15 | , ServantError(..) |
16 | , module Thermoprint.API | 16 | , module Thermoprint.API |
@@ -27,10 +27,11 @@ import Data.Time (UTCTime) | |||
27 | import Servant.Client hiding (HasClient(..)) | 27 | import Servant.Client hiding (HasClient(..)) |
28 | import qualified Servant.Client as S | 28 | import qualified Servant.Client as S |
29 | import Servant.Common.BaseUrl | 29 | import Servant.Common.BaseUrl |
30 | import Servant.Common.Req | ||
30 | import Network.HTTP.Client (Manager, ManagerSettings, newManager, defaultManagerSettings) | 31 | import Network.HTTP.Client (Manager, ManagerSettings, newManager, defaultManagerSettings) |
31 | import Servant.API | 32 | import Servant.API |
32 | import Servant.Utils.Enter | 33 | import Servant.Utils.Enter |
33 | import Control.Monad.Except (ExceptT, runExceptT) | 34 | import Control.Monad.Except (ExceptT(..), runExceptT) |
34 | 35 | ||
35 | import Control.Monad.Reader (ReaderT, runReaderT, ask) | 36 | import Control.Monad.Reader (ReaderT, runReaderT, ask) |
36 | import Control.Monad.Catch (Exception, MonadThrow(..)) | 37 | import Control.Monad.Catch (Exception, MonadThrow(..)) |
@@ -92,29 +93,10 @@ withArgs subAPI = (\(a :<|> _) -> a) . subAPI :<|> (\(_ :<|> b) -> b) . subAPI | |||
92 | 93 | ||
93 | mkClientS :: Monad m | 94 | mkClientS :: Monad m |
94 | => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors | 95 | => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors |
95 | -> ManagerSettings | ||
96 | -> BaseUrl | ||
97 | -> Client m | 96 | -> Client m |
98 | -- ^ Generate a 'Client' | 97 | -- ^ Generate a 'Client' |
99 | mkClientS n mgrS url = Client | 98 | mkClientS n = Client{..} |
100 | { printers = clientF n printers | ||
101 | , jobs = \a b c -> clientF n $ jobs a b c | ||
102 | , jobCreate = \a b -> clientF n $ jobCreate a b | ||
103 | , job = \a -> clientF n $ job a | ||
104 | , jobStatus = \a -> clientF n $ jobStatus a | ||
105 | , jobDelete = \a -> clientF n $ jobDelete a | ||
106 | , drafts = clientF n drafts | ||
107 | , draftCreate = \a b -> clientF n $ draftCreate a b | ||
108 | , draftReplace = \a b c -> clientF n $ draftReplace a b c | ||
109 | , draft = \a -> clientF n $ draft a | ||
110 | , draftDelete = \a -> clientF n $ draftDelete a | ||
111 | , draftPrint = \a b -> clientF n $ draftPrint a b | ||
112 | } | ||
113 | where | 99 | where |
114 | clientF :: Monad m => (ClientM :~> m) -> (Manager -> BaseUrl -> m a) -> m a | ||
115 | clientF n f = do | ||
116 | mgr <- unNat n $ (liftIO $ newManager mgrS :: ClientM Manager) | ||
117 | f mgr url | ||
118 | printers | 100 | printers |
119 | :<|> (jobs :<|> jobCreate) | 101 | :<|> (jobs :<|> jobCreate) |
120 | :<|> (withArgs -> job :<|> (withArgs -> jobStatus :<|> jobDelete)) | 102 | :<|> (withArgs -> job :<|> (withArgs -> jobStatus :<|> jobDelete)) |
@@ -122,23 +104,14 @@ mkClientS n mgrS url = Client | |||
122 | :<|> (withArgs -> draftReplace :<|> (withArgs -> draft :<|> (withArgs -> draftDelete :<|> draftPrint))) | 104 | :<|> (withArgs -> draftReplace :<|> (withArgs -> draft :<|> (withArgs -> draftDelete :<|> draftPrint))) |
123 | = enter n $ client thermoprintAPI | 105 | = enter n $ client thermoprintAPI |
124 | 106 | ||
125 | mkClient :: Monad m | 107 | mkClient :: (MonadThrow m, MonadIO m) => ManagerSettings -> BaseUrl -> Client m |
126 | => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors | 108 | mkClient mSettings url = mkClientS $ Nat clientNat |
127 | -> BaseUrl | 109 | where |
128 | -> Client m | 110 | clientNat :: forall m a. (MonadThrow m, MonadIO m) => ClientM a -> m a |
129 | mkClient n url = mkClientS n defaultManagerSettings url | 111 | clientNat cAct = do |
130 | 112 | mgr <- liftIO $ newManager mSettings | |
131 | mkClient' :: (MonadThrow m, MonadIO m) => BaseUrl -> Client m | 113 | either throwM return =<< liftIO (runClientM cAct $ ClientEnv mgr url) |
132 | -- ^ @mkClient' = mkClient $ ioNat . throwNat@ | ||
133 | mkClient' = mkClient $ ioNat . throwNat | ||
134 | |||
135 | throwNat :: (Exception e, MonadThrow m) => ExceptT e m :~> m | ||
136 | -- ^ Squash a layer of 'EitherT' into the underlying monad supporting 'throwM' | ||
137 | throwNat = Nat $ either throwM return <=< runExceptT | ||
138 | |||
139 | ioNat :: MonadIO m => IO :~> m | ||
140 | -- ^ @ioNat = Nat liftIO@ | ||
141 | ioNat = Nat liftIO | ||
142 | 114 | ||
143 | readerNat :: a -> ReaderT a m :~> m | 115 | mkClient' :: (MonadThrow m, MonadIO m) => BaseUrl -> Client m |
144 | readerNat a = Nat $ flip runReaderT a | 116 | -- ^ @mkClient' = mkClient defaultManagerSettings |
117 | mkClient' = mkClient defaultManagerSettings | ||
diff --git a/client/thermoprint-client.cabal b/client/thermoprint-client.cabal index 0920773..1306542 100644 --- a/client/thermoprint-client.cabal +++ b/client/thermoprint-client.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: thermoprint-client | 4 | name: thermoprint-client |
5 | version: 1.0.1 | 5 | version: 2.0.0 |
6 | synopsis: Client for thermoprint-spec | 6 | synopsis: Client for thermoprint-spec |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | homepage: http://dirty-haskell.org/tags/thermoprint.html |
@@ -21,7 +21,7 @@ library | |||
21 | -- other-modules: | 21 | -- other-modules: |
22 | -- other-extensions: | 22 | -- other-extensions: |
23 | build-depends: base >=4.8 && <5 | 23 | build-depends: base >=4.8 && <5 |
24 | , thermoprint-spec ==5.0.* | 24 | , thermoprint-spec ==6.0.* |
25 | , servant >=0.4.4 && <1 | 25 | , servant >=0.4.4 && <1 |
26 | , servant-client >=0.4.4 && <1 | 26 | , servant-client >=0.4.4 && <1 |
27 | , servant-server >=0.4.4 && <1 | 27 | , servant-server >=0.4.4 && <1 |
diff --git a/client/thermoprint-client.nix b/client/thermoprint-client.nix index 8aadafb..7f83630 100644 --- a/client/thermoprint-client.nix +++ b/client/thermoprint-client.nix | |||
@@ -4,7 +4,7 @@ | |||
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
6 | pname = "thermoprint-client"; | 6 | pname = "thermoprint-client"; |
7 | version = "1.0.1"; | 7 | version = "2.0.0"; |
8 | src = ./.; | 8 | src = ./.; |
9 | libraryHaskellDepends = [ | 9 | libraryHaskellDepends = [ |
10 | base containers either exceptions http-client mtl servant | 10 | base containers either exceptions http-client mtl servant |
diff --git a/default.nix b/default.nix index 09e2b7b..f883c52 100644 --- a/default.nix +++ b/default.nix | |||
@@ -7,6 +7,8 @@ rec { | |||
7 | overrides = self: super: with super; { | 7 | overrides = self: super: with super; { |
8 | # threepenny-gui = pkgs.haskell.lib.appendPatch threepenny-gui ./threepenny.patch; | 8 | # threepenny-gui = pkgs.haskell.lib.appendPatch threepenny-gui ./threepenny.patch; |
9 | encoding = pkgs.haskell.lib.doJailbreak encoding; | 9 | encoding = pkgs.haskell.lib.doJailbreak encoding; |
10 | cabal-test-quickcheck = pkgs.haskell.lib.doJailbreak cabal-test-quickcheck; | ||
11 | extended-reals = pkgs.haskell.lib.doJailbreak extended-reals; | ||
10 | }; | 12 | }; |
11 | }; | 13 | }; |
12 | thermoprint-spec = haskellPackages.callPackage ./spec/thermoprint-spec.nix {}; | 14 | thermoprint-spec = haskellPackages.callPackage ./spec/thermoprint-spec.nix {}; |
diff --git a/server/src/Thermoprint/Server/Push.hs b/server/src/Thermoprint/Server/Push.hs index 07b81fb..7ae03a6 100644 --- a/server/src/Thermoprint/Server/Push.hs +++ b/server/src/Thermoprint/Server/Push.hs | |||
@@ -32,7 +32,7 @@ import qualified Data.Text as Text | |||
32 | type Notification = URI | 32 | type Notification = URI |
33 | 33 | ||
34 | withPush :: TChan Notification -> Application -> Application | 34 | withPush :: TChan Notification -> Application -> Application |
35 | withPush chan = websocketsOr defaultConnectionOptions $ flip acceptRequestWith (AcceptRequest $ Just protocolSpec) >=> handleClient chan | 35 | withPush chan = websocketsOr defaultConnectionOptions $ flip acceptRequestWith (AcceptRequest (Just protocolSpec) []) >=> handleClient chan |
36 | 36 | ||
37 | protocolSpec :: ByteString | 37 | protocolSpec :: ByteString |
38 | protocolSpec = CBS.pack $ "thermoprint-server.notification." ++ showVersion version | 38 | protocolSpec = CBS.pack $ "thermoprint-server.notification." ++ showVersion version |
diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index eae3754..1ed55a6 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal | |||
@@ -50,7 +50,7 @@ library | |||
50 | , servant-server >=0.4.4 && <1 | 50 | , servant-server >=0.4.4 && <1 |
51 | , stm >=2.4.4 && <3 | 51 | , stm >=2.4.4 && <3 |
52 | , text >=1.2.1 && <2 | 52 | , text >=1.2.1 && <2 |
53 | , thermoprint-spec ==5.0.* | 53 | , thermoprint-spec ==6.0.* |
54 | , time >=1.5.0 && <2 | 54 | , time >=1.5.0 && <2 |
55 | , wai >=3.0.4 && <4 | 55 | , wai >=3.0.4 && <4 |
56 | , warp >=3.1.9 && <4 | 56 | , warp >=3.1.9 && <4 |
@@ -76,7 +76,7 @@ Test-Suite tests | |||
76 | main-is: Spec.hs | 76 | main-is: Spec.hs |
77 | build-depends: base >=4.8.1 && <5 | 77 | build-depends: base >=4.8.1 && <5 |
78 | , thermoprint-server ==2.0.* | 78 | , thermoprint-server ==2.0.* |
79 | , thermoprint-client ==1.0.* | 79 | , thermoprint-client ==2.0.* |
80 | , thermoprint-spec -any | 80 | , thermoprint-spec -any |
81 | , hspec >=2.2.1 && <3 | 81 | , hspec >=2.2.1 && <3 |
82 | , QuickCheck >=2.8.1 && <3 | 82 | , QuickCheck >=2.8.1 && <3 |
diff --git a/spec/src/Thermoprint/API.hs b/spec/src/Thermoprint/API.hs index 8e98db8..5b24e54 100644 --- a/spec/src/Thermoprint/API.hs +++ b/spec/src/Thermoprint/API.hs | |||
@@ -55,11 +55,11 @@ import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary(..)) | |||
55 | import Test.QuickCheck.Gen (scale, variant, oneof) | 55 | import Test.QuickCheck.Gen (scale, variant, oneof) |
56 | import Test.QuickCheck.Instances | 56 | import Test.QuickCheck.Instances |
57 | 57 | ||
58 | instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where | 58 | -- instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where |
59 | toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) | 59 | -- toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) |
60 | 60 | ||
61 | instance (Enum k, Ord k, FromJSON v) => FromJSON (Map k v) where | 61 | -- instance (Enum k, Ord k, FromJSON v) => FromJSON (Map k v) where |
62 | parseJSON = fmap (IntMap.foldMapWithKey $ Map.singleton . castId) . parseJSON | 62 | -- parseJSON = fmap (IntMap.foldMapWithKey $ Map.singleton . castId) . parseJSON |
63 | 63 | ||
64 | data PrinterStatus = Busy JobId | 64 | data PrinterStatus = Busy JobId |
65 | | Available | 65 | | Available |
diff --git a/spec/src/Thermoprint/Identifiers.hs b/spec/src/Thermoprint/Identifiers.hs index 2a07318..e90602c 100644 --- a/spec/src/Thermoprint/Identifiers.hs +++ b/spec/src/Thermoprint/Identifiers.hs | |||
@@ -13,16 +13,16 @@ import GHC.Generics (Generic) | |||
13 | import Control.DeepSeq (NFData) | 13 | import Control.DeepSeq (NFData) |
14 | 14 | ||
15 | import Servant.API (ToHttpApiData, FromHttpApiData) | 15 | import Servant.API (ToHttpApiData, FromHttpApiData) |
16 | import Data.Aeson (FromJSON, ToJSON) | 16 | import Data.Aeson (FromJSON, ToJSON, FromJSONKey, ToJSONKey) |
17 | 17 | ||
18 | newtype PrinterId = PrinterId Integer | 18 | newtype PrinterId = PrinterId Integer |
19 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) | 19 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData) |
20 | 20 | ||
21 | newtype JobId = JobId Integer | 21 | newtype JobId = JobId Integer |
22 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) | 22 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData) |
23 | 23 | ||
24 | newtype DraftId = DraftId Integer | 24 | newtype DraftId = DraftId Integer |
25 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) | 25 | deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData) |
26 | 26 | ||
27 | castId :: (Integral a, Enum b) => a -> b | 27 | castId :: (Integral a, Enum b) => a -> b |
28 | castId = toEnum . fromInteger . toInteger | 28 | castId = toEnum . fromInteger . toInteger |
diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal index 138a06e..4bcfe6a 100644 --- a/spec/thermoprint-spec.cabal +++ b/spec/thermoprint-spec.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: thermoprint-spec | 4 | name: thermoprint-spec |
5 | version: 5.0.1 | 5 | version: 6.0.0 |
6 | synopsis: A specification of the API and the payload datatypes and associated utilities | 6 | synopsis: A specification of the API and the payload datatypes and associated utilities |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | homepage: http://dirty-haskell.org/tags/thermoprint.html |
@@ -41,7 +41,7 @@ library | |||
41 | , Cabal >=1.22.4 && <2 | 41 | , Cabal >=1.22.4 && <2 |
42 | , cabal-test-quickcheck >=0.1.6 && <1 | 42 | , cabal-test-quickcheck >=0.1.6 && <1 |
43 | , servant >=0.4.4 && <1 | 43 | , servant >=0.4.4 && <1 |
44 | , aeson >=0.9.0 && <1 | 44 | , aeson >=1.0 && <2 |
45 | , base64-bytestring >=1.0.0 && <2 | 45 | , base64-bytestring >=1.0.0 && <2 |
46 | , encoding >=0.8 && <1 | 46 | , encoding >=0.8 && <1 |
47 | , time >=1.5.0 && <2 | 47 | , time >=1.5.0 && <2 |
@@ -62,4 +62,4 @@ Test-Suite tests | |||
62 | , hspec >=2.2.1 && <3 | 62 | , hspec >=2.2.1 && <3 |
63 | , QuickCheck >=2.8.1 && <3 | 63 | , QuickCheck >=2.8.1 && <3 |
64 | , quickcheck-instances >=0.3.11 && <4 | 64 | , quickcheck-instances >=0.3.11 && <4 |
65 | , aeson >=0.9.0 && <1 \ No newline at end of file | 65 | , aeson >=1.0 && <2 \ No newline at end of file |
diff --git a/spec/thermoprint-spec.nix b/spec/thermoprint-spec.nix index a3093de..d28b405 100644 --- a/spec/thermoprint-spec.nix +++ b/spec/thermoprint-spec.nix | |||
@@ -4,7 +4,7 @@ | |||
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
6 | pname = "thermoprint-spec"; | 6 | pname = "thermoprint-spec"; |
7 | version = "5.0.1"; | 7 | version = "6.0.0"; |
8 | src = ./.; | 8 | src = ./.; |
9 | libraryHaskellDepends = [ | 9 | libraryHaskellDepends = [ |
10 | aeson base base64-bytestring bytestring Cabal cabal-test-quickcheck | 10 | aeson base base64-bytestring bytestring Cabal cabal-test-quickcheck |
diff --git a/tp-bbcode/thermoprint-bbcode.cabal b/tp-bbcode/thermoprint-bbcode.cabal index 89ed326..9fdf216 100644 --- a/tp-bbcode/thermoprint-bbcode.cabal +++ b/tp-bbcode/thermoprint-bbcode.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: thermoprint-bbcode | 4 | name: thermoprint-bbcode |
5 | version: 2.0.1 | 5 | version: 3.0.0 |
6 | synopsis: Parse bbcode for use in thermoprint | 6 | synopsis: Parse bbcode for use in thermoprint |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | homepage: http://dirty-haskell.org/tags/thermoprint.html |
@@ -24,7 +24,7 @@ library | |||
24 | , OverloadedLists | 24 | , OverloadedLists |
25 | -- other-extensions: | 25 | -- other-extensions: |
26 | build-depends: base >=4.8.1 && <5 | 26 | build-depends: base >=4.8.1 && <5 |
27 | , thermoprint-spec ==5.0.* | 27 | , thermoprint-spec ==6.0.* |
28 | , bbcode >=3.1.1 && <4 | 28 | , bbcode >=3.1.1 && <4 |
29 | , containers -any | 29 | , containers -any |
30 | , text -any | 30 | , text -any |
@@ -44,10 +44,10 @@ Test-Suite tests | |||
44 | , OverloadedLists | 44 | , OverloadedLists |
45 | build-depends: base >=4.8.1 && <5 | 45 | build-depends: base >=4.8.1 && <5 |
46 | , thermoprint-bbcode -any | 46 | , thermoprint-bbcode -any |
47 | , thermoprint-spec ==5.0.* | 47 | , thermoprint-spec ==6.0.* |
48 | , hspec >=2.2.1 && <3 | 48 | , hspec >=2.2.1 && <3 |
49 | , QuickCheck >=2.8.1 && <3 | 49 | , QuickCheck >=2.8.1 && <3 |
50 | , quickcheck-instances >=0.3.11 && <4 | 50 | , quickcheck-instances >=0.3.11 && <4 |
51 | , aeson >=0.9.0 && <1 | 51 | , aeson >=1.0 && <2 |
52 | , containers -any | 52 | , containers -any |
53 | , text -any \ No newline at end of file | 53 | , text -any \ No newline at end of file |
diff --git a/tp-bbcode/thermoprint-bbcode.nix b/tp-bbcode/thermoprint-bbcode.nix index 3c698f1..deab20e 100644 --- a/tp-bbcode/thermoprint-bbcode.nix +++ b/tp-bbcode/thermoprint-bbcode.nix | |||
@@ -4,7 +4,7 @@ | |||
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
6 | pname = "thermoprint-bbcode"; | 6 | pname = "thermoprint-bbcode"; |
7 | version = "2.0.1"; | 7 | version = "3.0.0"; |
8 | src = ./.; | 8 | src = ./.; |
9 | libraryHaskellDepends = [ | 9 | libraryHaskellDepends = [ |
10 | base bbcode bytestring case-insensitive containers text | 10 | base bbcode bytestring case-insensitive containers text |
diff --git a/tprint/src/Options.hs b/tprint/src/Options.hs index e146f91..703c23b 100644 --- a/tprint/src/Options.hs +++ b/tprint/src/Options.hs | |||
@@ -26,8 +26,12 @@ import Instances () | |||
26 | import Paths_tprint (version) | 26 | import Paths_tprint (version) |
27 | import Data.Version (showVersion) | 27 | import Data.Version (showVersion) |
28 | 28 | ||
29 | import Data.Maybe | ||
30 | import Data.Monoid | ||
29 | import Data.Bifunctor (Bifunctor(..)) | 31 | import Data.Bifunctor (Bifunctor(..)) |
30 | 32 | ||
33 | import System.Environment (lookupEnv) | ||
34 | |||
31 | data TPrint = TPrint | 35 | data TPrint = TPrint |
32 | { baseUrl :: BaseUrl | 36 | { baseUrl :: BaseUrl |
33 | , dryRun :: Bool | 37 | , dryRun :: Bool |
@@ -149,12 +153,15 @@ pOperation = hsubparser $ mconcat [ command "printers" cmdPrinters | |||
149 | ) (progDesc "Interact with drafts") | 153 | ) (progDesc "Interact with drafts") |
150 | ] | 154 | ] |
151 | 155 | ||
152 | pTPrint :: Parser TPrint | 156 | pTPrint :: IO (Parser TPrint) |
153 | pTPrint = TPrint <$> option (eitherReader $ first show . parseBaseUrl) (metavar "URL" <> long "baseurl" <> short 'u' <> help "Server to interact with" <> value (BaseUrl Http "localhost" 3000 "") <> showDefaultWith showBaseUrl) | 157 | pTPrint = do |
154 | <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state") | 158 | baseUrl <- parseBaseUrl =<< (fromMaybe "http://localhost:3000/" <$> lookupEnv "TPRINT_BASEURL") |
155 | <*> pOutput | 159 | return $ |
156 | <*> pOperation | 160 | TPrint <$> option (eitherReader $ first show . parseBaseUrl) (metavar "URL" <> long "baseurl" <> short 'u' <> help "Server to interact with; also read from TPRINT_BASEURL when set" <> value baseUrl <> showDefaultWith showBaseUrl) |
157 | <*> switch (long "dump-options" <> internal) | 161 | <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state") |
162 | <*> pOutput | ||
163 | <*> pOperation | ||
164 | <*> switch (long "dump-options" <> internal) | ||
158 | 165 | ||
159 | pOutput :: Parser Output | 166 | pOutput :: Parser Output |
160 | pOutput = (,) <$> pOutputFormat <*> pSink | 167 | pOutput = (,) <$> pOutputFormat <*> pSink |
@@ -177,4 +184,7 @@ pInput = (,) <$> pInputFormat <*> pSource | |||
177 | rSource' x = ReadFile x | 184 | rSource' x = ReadFile x |
178 | 185 | ||
179 | withArgs :: (TPrint -> IO a) -> IO a | 186 | withArgs :: (TPrint -> IO a) -> IO a |
180 | withArgs a = customExecParser (prefs $ showHelpOnError) (info pTPrint $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a | 187 | withArgs a = do |
188 | pTPrint' <- pTPrint | ||
189 | customExecParser (prefs $ showHelpOnError) (info pTPrint' $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a | ||
190 | |||
diff --git a/tprint/src/Options/Utils.hs b/tprint/src/Options/Utils.hs index 237aa56..3fae250 100644 --- a/tprint/src/Options/Utils.hs +++ b/tprint/src/Options/Utils.hs | |||
@@ -13,6 +13,7 @@ import Options.Applicative | |||
13 | import Data.Text (Text) | 13 | import Data.Text (Text) |
14 | import qualified Data.Text as T (pack) | 14 | import qualified Data.Text as T (pack) |
15 | 15 | ||
16 | import Data.Monoid | ||
16 | import Data.Char | 17 | import Data.Char |
17 | import Data.Maybe | 18 | import Data.Maybe |
18 | import Data.List | 19 | import Data.List |
diff --git a/tprint/tprint.cabal b/tprint/tprint.cabal index 5fcd00b..94b0a8a 100644 --- a/tprint/tprint.cabal +++ b/tprint/tprint.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: tprint | 4 | name: tprint |
5 | version: 2.0.0 | 5 | version: 3.0.0 |
6 | synopsis: A CLI for thermoprint-client | 6 | synopsis: A CLI for thermoprint-client |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | homepage: http://dirty-haskell.org/tags/thermoprint.html |
@@ -23,15 +23,15 @@ executable tprint | |||
23 | , Instances | 23 | , Instances |
24 | -- other-extensions: | 24 | -- other-extensions: |
25 | build-depends: base >=4.8 && <5 | 25 | build-depends: base >=4.8 && <5 |
26 | , thermoprint-bbcode >=2.0.0 && <3 | 26 | , thermoprint-bbcode >=3.0.0 && <4 |
27 | , thermoprint-client ==1.0.* | 27 | , thermoprint-client ==2.0.* |
28 | , optparse-applicative >=0.12.1 && <1 | 28 | , optparse-applicative >=0.12.1 && <1 |
29 | , containers >=0.5.6 && <1 | 29 | , containers >=0.5.6 && <1 |
30 | , time >=1.5.0 && <2 | 30 | , time >=1.5.0 && <2 |
31 | , pretty-show >=1.6.9 && <2 | 31 | , pretty-show >=1.6.9 && <2 |
32 | , text >=1.2.2 && <2 | 32 | , text >=1.2.2 && <2 |
33 | , aeson-pretty >=0.7.2 && <1 | 33 | , aeson-pretty >=0.7.2 && <1 |
34 | , aeson >=0.9.0 && <1 | 34 | , aeson >=1.0 && <2 |
35 | , bytestring >=0.10.6 && <1 | 35 | , bytestring >=0.10.6 && <1 |
36 | , exceptions >=0.8.2 && <1 | 36 | , exceptions >=0.8.2 && <1 |
37 | , deepseq >=1.4.1 && <2 | 37 | , deepseq >=1.4.1 && <2 |
diff --git a/tprint/tprint.nix b/tprint/tprint.nix index 946a4ce..9ce247d 100644 --- a/tprint/tprint.nix +++ b/tprint/tprint.nix | |||
@@ -4,7 +4,7 @@ | |||
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
6 | pname = "tprint"; | 6 | pname = "tprint"; |
7 | version = "2.0.0"; | 7 | version = "3.0.0"; |
8 | src = ./.; | 8 | src = ./.; |
9 | isLibrary = false; | 9 | isLibrary = false; |
10 | isExecutable = true; | 10 | isExecutable = true; |
diff --git a/webgui/src/Main.hs b/webgui/src/Main.hs index 03cd318..65dbfc7 100644 --- a/webgui/src/Main.hs +++ b/webgui/src/Main.hs | |||
@@ -40,6 +40,7 @@ import Data.Time | |||
40 | import Control.Concurrent | 40 | import Control.Concurrent |
41 | import Control.Exception | 41 | import Control.Exception |
42 | import Control.Monad.Catch | 42 | import Control.Monad.Catch |
43 | import Control.Monad.Catch.Pure | ||
43 | 44 | ||
44 | import Control.Applicative | 45 | import Control.Applicative |
45 | import Control.Monad hiding (sequence) | 46 | import Control.Monad hiding (sequence) |
@@ -151,9 +152,9 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do | |||
151 | status <- stepper init statusEvent | 152 | status <- stepper init statusEvent |
152 | return (status, triggerStatusChange) | 153 | return (status, triggerStatusChange) |
153 | 154 | ||
154 | Client{..} = mkClient (hoistNat $ Nat liftIO) server | 155 | Client{..} = (mkClient' server :: Client (CatchT UI)) |
155 | withFatal :: ExceptT ServantError UI a -> UI a | 156 | withFatal :: CatchT UI a -> UI a |
156 | withFatal a = either (fatal . ("Error while communicating to Thermoprint.Server: " ++) . show) return =<< runExceptT a | 157 | withFatal a = either (fatal . ("Error while communicating to Thermoprint.Server: " ++) . show) return =<< runCatchT a |
157 | 158 | ||
158 | handleEditor selectedPrinter (_, modifyFocusedJobs) = do | 159 | handleEditor selectedPrinter (_, modifyFocusedJobs) = do |
159 | title <- fatal' "Could not find editor title field" =<< getElementById window "editorTitle" | 160 | title <- fatal' "Could not find editor title field" =<< getElementById window "editorTitle" |
@@ -259,7 +260,7 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do | |||
259 | enactDeletion <- fatal' "Could not find deletion button" =<< getElementById window "enactDeletion" | 260 | enactDeletion <- fatal' "Could not find deletion button" =<< getElementById window "enactDeletion" |
260 | on UI.click enactDeletion . const $ do | 261 | on UI.click enactDeletion . const $ do |
261 | cMarking <- currentValue marking | 262 | cMarking <- currentValue marking |
262 | mapM_ (runExceptT . draftDelete) cMarking | 263 | mapM_ (runCatchT . draftDelete) cMarking |
263 | cDraft <- associatedDraft <$> currentValue editorState | 264 | cDraft <- associatedDraft <$> currentValue editorState |
264 | when (Set.member cDraft $ Set.map Just cMarking) $ changeEditorState (\s -> s { associatedDraft = Nothing } ) | 265 | when (Set.member cDraft $ Set.map Just cMarking) $ changeEditorState (\s -> s { associatedDraft = Nothing } ) |
265 | updateMarking Set.empty | 266 | updateMarking Set.empty |
@@ -348,7 +349,7 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do | |||
348 | (marking, (liftIO .) -> updateMarking) <- stepper' $ Set.empty | 349 | (marking, (liftIO .) -> updateMarking) <- stepper' $ Set.empty |
349 | 350 | ||
350 | enactAbortion <- fatal' "Could not find deletion button" =<< getElementById window "enactAbortion" | 351 | enactAbortion <- fatal' "Could not find deletion button" =<< getElementById window "enactAbortion" |
351 | on UI.click enactAbortion . const $ currentValue marking >>= mapM_ (runExceptT . jobDelete) >> updateMarking Set.empty | 352 | on UI.click enactAbortion . const $ currentValue marking >>= mapM_ (runCatchT . jobDelete) >> updateMarking Set.empty |
352 | 353 | ||
353 | (selectedPrinter, updatePrinter) <- do | 354 | (selectedPrinter, updatePrinter) <- do |
354 | autoselectPrinter <- fatal' "Could not find printer autoselect switch" =<< getElementById window "autoselectPrinter" | 355 | autoselectPrinter <- fatal' "Could not find printer autoselect switch" =<< getElementById window "autoselectPrinter" |
diff --git a/webgui/thermoprint-webgui.cabal b/webgui/thermoprint-webgui.cabal index 9c67a9c..dcd3c4f 100644 --- a/webgui/thermoprint-webgui.cabal +++ b/webgui/thermoprint-webgui.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: thermoprint-webgui | 4 | name: thermoprint-webgui |
5 | version: 1.0.2 | 5 | version: 2.0.0 |
6 | synopsis: Threepenny interface for thermoprint-spec compliant servers | 6 | synopsis: Threepenny interface for thermoprint-spec compliant servers |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | homepage: http://dirty-haskell.org/tags/thermoprint.html |
@@ -26,8 +26,8 @@ executable thermoprint-webgui | |||
26 | -- other-modules: | 26 | -- other-modules: |
27 | -- other-extensions: | 27 | -- other-extensions: |
28 | build-depends: base >=4.8 && <5 | 28 | build-depends: base >=4.8 && <5 |
29 | , thermoprint-bbcode >=2.0.0 && <3 | 29 | , thermoprint-bbcode >=3.0.0 && <4 |
30 | , thermoprint-client ==1.0.* | 30 | , thermoprint-client ==2.0.* |
31 | , threepenny-gui >=0.6.0 && <1 | 31 | , threepenny-gui >=0.6.0 && <1 |
32 | , optparse-applicative >=0.12.1 && <1 | 32 | , optparse-applicative >=0.12.1 && <1 |
33 | , bytestring >=0.10.6 && <1 | 33 | , bytestring >=0.10.6 && <1 |
diff --git a/webgui/thermoprint-webgui.nix b/webgui/thermoprint-webgui.nix index d4cafe8..bff836e 100644 --- a/webgui/thermoprint-webgui.nix +++ b/webgui/thermoprint-webgui.nix | |||
@@ -5,7 +5,7 @@ | |||
5 | }: | 5 | }: |
6 | mkDerivation { | 6 | mkDerivation { |
7 | pname = "thermoprint-webgui"; | 7 | pname = "thermoprint-webgui"; |
8 | version = "1.0.2"; | 8 | version = "2.0.0"; |
9 | src = ./.; | 9 | src = ./.; |
10 | isLibrary = false; | 10 | isLibrary = false; |
11 | isExecutable = true; | 11 | isExecutable = true; |