upgrade to lts-17.15
This commit is contained in:
parent
398ab95b34
commit
02a55aedba
36
espial.cabal
36
espial.cabal
|
@ -4,10 +4,10 @@ cabal-version: 1.12
|
|||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: 7535921358f6f30b353ed1ea8a7bfff26aa471228add3c6392836563ee7fc58d
|
||||
-- hash: 6f3e508b4528e0e41eab58d1f0830dc3917d04d50226e7dba709392b50db0c96
|
||||
|
||||
name: espial
|
||||
version: 0.0.8
|
||||
version: 0.0.9
|
||||
synopsis: Espial is an open-source, web-based bookmarking server.
|
||||
description: .
|
||||
Espial is an open-source, web-based bookmarking server.
|
||||
|
@ -123,7 +123,7 @@ library
|
|||
Paths_espial
|
||||
hs-source-dirs:
|
||||
src
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents PartialTypeSignatures QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
build-depends:
|
||||
aeson >=1.4
|
||||
, attoparsec
|
||||
|
@ -158,9 +158,9 @@ library
|
|||
, monad-logger >=0.3 && <0.4
|
||||
, mtl
|
||||
, parser-combinators
|
||||
, persistent >=2.8 && <2.11
|
||||
, persistent >=2.8 && <2.12
|
||||
, persistent-sqlite >=2.6.2
|
||||
, persistent-template >=2.5 && <2.9
|
||||
, persistent-template >=2.5 && <2.10
|
||||
, pretty-show
|
||||
, safe
|
||||
, shakespeare >=2.0 && <2.1
|
||||
|
@ -171,7 +171,7 @@ library
|
|||
, unordered-containers
|
||||
, vector
|
||||
, wai
|
||||
, wai-extra >=3.0 && <3.1
|
||||
, wai-extra >=3.0 && <3.2
|
||||
, wai-logger >=2.2 && <2.4
|
||||
, warp >=3.0 && <3.4
|
||||
, yaml >=0.8 && <0.12
|
||||
|
@ -195,7 +195,7 @@ executable espial
|
|||
Paths_espial
|
||||
hs-source-dirs:
|
||||
app
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents PartialTypeSignatures QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
aeson >=1.4
|
||||
|
@ -232,9 +232,9 @@ executable espial
|
|||
, monad-logger >=0.3 && <0.4
|
||||
, mtl
|
||||
, parser-combinators
|
||||
, persistent >=2.8 && <2.11
|
||||
, persistent >=2.8 && <2.12
|
||||
, persistent-sqlite >=2.6.2
|
||||
, persistent-template >=2.5 && <2.9
|
||||
, persistent-template >=2.5 && <2.10
|
||||
, pretty-show
|
||||
, safe
|
||||
, shakespeare >=2.0 && <2.1
|
||||
|
@ -245,7 +245,7 @@ executable espial
|
|||
, unordered-containers
|
||||
, vector
|
||||
, wai
|
||||
, wai-extra >=3.0 && <3.1
|
||||
, wai-extra >=3.0 && <3.2
|
||||
, wai-logger >=2.2 && <2.4
|
||||
, warp >=3.0 && <3.4
|
||||
, yaml >=0.8 && <0.12
|
||||
|
@ -265,7 +265,7 @@ executable migration
|
|||
Paths_espial
|
||||
hs-source-dirs:
|
||||
app/migration
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents PartialTypeSignatures QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
aeson >=1.4
|
||||
|
@ -303,9 +303,9 @@ executable migration
|
|||
, mtl
|
||||
, optparse-generic >=1.2.3
|
||||
, parser-combinators
|
||||
, persistent >=2.8 && <2.11
|
||||
, persistent >=2.8 && <2.12
|
||||
, persistent-sqlite >=2.6.2
|
||||
, persistent-template >=2.5 && <2.9
|
||||
, persistent-template >=2.5 && <2.10
|
||||
, pretty-show
|
||||
, safe
|
||||
, shakespeare >=2.0 && <2.1
|
||||
|
@ -316,7 +316,7 @@ executable migration
|
|||
, unordered-containers
|
||||
, vector
|
||||
, wai
|
||||
, wai-extra >=3.0 && <3.1
|
||||
, wai-extra >=3.0 && <3.2
|
||||
, wai-logger >=2.2 && <2.4
|
||||
, warp >=3.0 && <3.4
|
||||
, yaml >=0.8 && <0.12
|
||||
|
@ -340,7 +340,7 @@ test-suite test
|
|||
Paths_espial
|
||||
hs-source-dirs:
|
||||
test
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
default-extensions: BangPatterns BlockArguments CPP ConstraintKinds DataKinds DeriveDataTypeable DeriveGeneric DerivingStrategies EmptyDataDecls FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiParamTypeClasses MultiWayIf NoImplicitPrelude OverloadedStrings PolyKinds PolymorphicComponents PartialTypeSignatures QuasiQuotes Rank2Types RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators TypeSynonymInstances UndecidableInstances ViewPatterns
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
aeson >=1.4
|
||||
|
@ -378,9 +378,9 @@ test-suite test
|
|||
, monad-logger >=0.3 && <0.4
|
||||
, mtl
|
||||
, parser-combinators
|
||||
, persistent >=2.8 && <2.11
|
||||
, persistent >=2.8 && <2.12
|
||||
, persistent-sqlite >=2.6.2
|
||||
, persistent-template >=2.5 && <2.9
|
||||
, persistent-template >=2.5 && <2.10
|
||||
, pretty-show
|
||||
, safe
|
||||
, shakespeare >=2.0 && <2.1
|
||||
|
@ -391,7 +391,7 @@ test-suite test
|
|||
, unordered-containers
|
||||
, vector
|
||||
, wai
|
||||
, wai-extra >=3.0 && <3.1
|
||||
, wai-extra >=3.0 && <3.2
|
||||
, wai-logger >=2.2 && <2.4
|
||||
, warp >=3.0 && <3.4
|
||||
, yaml >=0.8 && <0.12
|
||||
|
|
16
package.yaml
16
package.yaml
|
@ -1,6 +1,6 @@
|
|||
name: espial
|
||||
synopsis: Espial is an open-source, web-based bookmarking server.
|
||||
version: "0.0.8"
|
||||
version: "0.0.9"
|
||||
description: ! '
|
||||
|
||||
Espial is an open-source, web-based bookmarking server.
|
||||
|
@ -63,6 +63,7 @@ default-extensions:
|
|||
- OverloadedStrings
|
||||
- PolyKinds
|
||||
- PolymorphicComponents
|
||||
- PartialTypeSignatures
|
||||
- QuasiQuotes
|
||||
- Rank2Types
|
||||
- RankNTypes
|
||||
|
@ -95,22 +96,19 @@ dependencies:
|
|||
- classy-prelude-yesod >=1.4 && <1.6
|
||||
- bytestring >=0.9 && <0.11
|
||||
- text >=0.11 && <2.0
|
||||
- persistent >=2.8 && <2.11
|
||||
# - persistent-postgresql >=2.8 && <2.9
|
||||
- persistent >=2.8 && <2.12
|
||||
- blaze-html >= 0.9 && < 1.0
|
||||
- persistent-template >=2.5 && <2.9
|
||||
- persistent-template >=2.5 && <2.10
|
||||
- template-haskell
|
||||
- shakespeare >=2.0 && <2.1
|
||||
- hjsmin >=0.1 && <0.3
|
||||
# - monad-control >=0.3 && <1.1
|
||||
- wai-extra >=3.0 && <3.1
|
||||
- wai-extra >=3.0 && <3.2
|
||||
- yaml >=0.8 && <0.12
|
||||
- http-client-tls >=0.3 && <0.4
|
||||
- http-conduit >=2.3 && <2.4
|
||||
- directory >=1.1 && <1.4
|
||||
- warp >=3.0 && <3.4
|
||||
- data-default
|
||||
# - aeson >=0.6 && <1.4
|
||||
- conduit >=1.0 && <2.0
|
||||
- monad-logger >=0.3 && <0.4
|
||||
- fast-logger >=2.2 && <4
|
||||
|
@ -129,8 +127,6 @@ dependencies:
|
|||
- attoparsec
|
||||
- bcrypt >= 0.0.8
|
||||
- entropy
|
||||
# - ekg
|
||||
# - ekg-core
|
||||
- esqueleto
|
||||
- hscolour
|
||||
- http-api-data >= 0.3.4
|
||||
|
@ -138,12 +134,10 @@ dependencies:
|
|||
- http-types
|
||||
- iso8601-time >=0.1.3
|
||||
- microlens
|
||||
# - monad-metrics
|
||||
- mtl
|
||||
- persistent-sqlite >=2.6.2
|
||||
- pretty-show
|
||||
- transformers >= 0.2.2
|
||||
# - wai-middleware-metrics
|
||||
- parser-combinators
|
||||
- html-entities
|
||||
- connection
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
|
||||
|
||||
module Application
|
||||
( getApplicationDev
|
||||
|
@ -15,10 +16,10 @@ module Application
|
|||
) where
|
||||
|
||||
import Control.Monad.Logger (liftLoc, runLoggingT)
|
||||
import Database.Persist.Sqlite (createSqlitePool, runSqlPool, sqlDatabase, sqlPoolSize)
|
||||
import Database.Persist.Sqlite (ConnectionPool, mkSqliteConnectionInfo, createSqlitePoolFromInfo, fkEnabled, runSqlPool, sqlDatabase, sqlPoolSize)
|
||||
import Import
|
||||
import Language.Haskell.TH.Syntax (qLocation)
|
||||
-- import Lens.Micro
|
||||
import Lens.Micro
|
||||
import Network.HTTP.Client.TLS
|
||||
import Network.Wai (Middleware)
|
||||
import Network.Wai.Handler.Warp (Settings, defaultSettings, defaultShouldDisplayException, runSettings, setHost, setOnException, setPort, getPort)
|
||||
|
@ -29,11 +30,6 @@ import Network.Wai.Middleware.MethodOverride
|
|||
import Network.Wai.Middleware.RequestLogger (Destination(Logger), IPAddrSource(..), OutputFormat(..), destination, mkRequestLogger, outputFormat)
|
||||
import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, toLogStr)
|
||||
|
||||
-- import qualified Control.Monad.Metrics as MM
|
||||
-- import qualified Network.Wai.Metrics as WM
|
||||
-- import qualified System.Metrics as EKG
|
||||
-- import qualified System.Remote.Monitoring as EKG
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
import Handler.Common
|
||||
|
@ -51,38 +47,37 @@ makeFoundation :: AppSettings -> IO App
|
|||
makeFoundation appSettings = do
|
||||
appHttpManager <- getGlobalManager
|
||||
appLogger <- newStdoutLoggerSet defaultBufSize >>= makeYesodLogger
|
||||
-- store <- EKG.newStore
|
||||
-- EKG.registerGcMetrics store
|
||||
-- appMetrics <- MM.initializeWith store
|
||||
appStatic <-
|
||||
(if appMutableStatic appSettings
|
||||
then staticDevel
|
||||
else static)
|
||||
(appStaticDir appSettings)
|
||||
let mkFoundation appConnPool = App { ..}
|
||||
let mkFoundation appConnPool = App {..}
|
||||
tempFoundation = mkFoundation (error "connPool forced in tempFoundation")
|
||||
logFunc = messageLoggerSource tempFoundation appLogger
|
||||
pool <-
|
||||
flip runLoggingT logFunc $
|
||||
createSqlitePool
|
||||
(sqlDatabase (appDatabaseConf appSettings))
|
||||
(sqlPoolSize (appDatabaseConf appSettings))
|
||||
runLoggingT
|
||||
(runSqlPool runMigrations pool)
|
||||
logFunc
|
||||
pool <- mkPool logFunc True
|
||||
poolMigrations <- mkPool logFunc False
|
||||
runLoggingT (runSqlPool runMigrations poolMigrations) logFunc
|
||||
return (mkFoundation pool)
|
||||
where
|
||||
mkPool :: _ -> Bool -> IO ConnectionPool
|
||||
mkPool logFunc isFkEnabled =
|
||||
flip runLoggingT logFunc $ do
|
||||
let dbPath = sqlDatabase (appDatabaseConf appSettings)
|
||||
poolSize = sqlPoolSize (appDatabaseConf appSettings)
|
||||
connInfo = mkSqliteConnectionInfo dbPath &
|
||||
set fkEnabled isFkEnabled
|
||||
createSqlitePoolFromInfo connInfo poolSize
|
||||
|
||||
|
||||
makeApplication :: App -> IO Application
|
||||
makeApplication foundation = do
|
||||
logWare <- makeLogWare foundation
|
||||
appPlain <- toWaiAppPlain foundation
|
||||
-- let store = appMetrics foundation ^. MM.metricsStore
|
||||
-- waiMetrics <- WM.registerWaiMetrics store
|
||||
return (logWare (makeMiddleware appPlain))
|
||||
|
||||
makeMiddleware :: Middleware
|
||||
makeMiddleware =
|
||||
-- WM.metrics waiMetrics .
|
||||
acceptOverride .
|
||||
autohead .
|
||||
gzip def {gzipFiles = GzipPreCompressed GzipIgnore} .
|
||||
|
@ -126,7 +121,6 @@ getApplicationDev = do
|
|||
foundation <- makeFoundation settings
|
||||
wsettings <- getDevSettings (warpSettings foundation)
|
||||
app <- makeApplication foundation
|
||||
-- forkEKG foundation
|
||||
return (wsettings, app)
|
||||
|
||||
getAppSettings :: IO AppSettings
|
||||
|
@ -136,23 +130,12 @@ getAppSettings = loadYamlSettings [configSettingsYml] [] useEnv
|
|||
develMain :: IO ()
|
||||
develMain = develMainHelper getApplicationDev
|
||||
|
||||
-- forkEKG :: App -> IO ()
|
||||
-- forkEKG foundation =
|
||||
-- let settings = appSettings foundation in
|
||||
-- for_ (appEkgHost settings) \ekgHost ->
|
||||
-- for_ (appEkgPort settings) \ekgPort ->
|
||||
-- EKG.forkServerWith
|
||||
-- (appMetrics foundation ^. MM.metricsStore)
|
||||
-- (encodeUtf8 ekgHost)
|
||||
-- ekgPort
|
||||
|
||||
-- | The @main@ function for an executable running this site.
|
||||
appMain :: IO ()
|
||||
appMain = do
|
||||
settings <- loadYamlSettingsArgs [configSettingsYmlValue] useEnv
|
||||
foundation <- makeFoundation settings
|
||||
app <- makeApplication foundation
|
||||
-- forkEKG foundation
|
||||
runSettings (warpSettings foundation) app
|
||||
|
||||
getApplicationRepl :: IO (Int, App, Application)
|
||||
|
|
|
@ -10,13 +10,9 @@ import Text.Hamlet (hamletFile)
|
|||
import Text.Jasmine (minifym)
|
||||
import PathPiece()
|
||||
|
||||
-- import Yesod.Auth.Dummy
|
||||
|
||||
import Yesod.Default.Util (addStaticContentExternal)
|
||||
import Yesod.Core.Types
|
||||
import Yesod.Auth.Message
|
||||
-- import qualified Network.Wai as NW
|
||||
-- import qualified Control.Monad.Metrics as MM
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import qualified Yesod.Core.Unsafe as Unsafe
|
||||
|
@ -27,7 +23,6 @@ data App = App
|
|||
, appConnPool :: ConnectionPool -- ^ Database connection pool.
|
||||
, appHttpManager :: Manager
|
||||
, appLogger :: Logger
|
||||
-- , appMetrics :: !MM.Metrics
|
||||
} deriving (Typeable)
|
||||
|
||||
mkYesodData "App" $(parseRoutesFile "config/routes")
|
||||
|
@ -58,7 +53,6 @@ instance Yesod App where
|
|||
10080 -- min (7 days)
|
||||
"config/client_session_key.aes"
|
||||
|
||||
-- yesodMiddleware = metricsMiddleware . defaultYesodMiddleware . defaultCsrfMiddleware
|
||||
yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware
|
||||
|
||||
defaultLayout widget = do
|
||||
|
@ -69,7 +63,6 @@ instance Yesod App where
|
|||
musername <- maybeAuthUsername
|
||||
muser <- (fmap.fmap) snd maybeAuthPair
|
||||
mcurrentRoute <- getCurrentRoute
|
||||
-- void $ mapM (incrementRouteEKG req) mcurrentRoute
|
||||
let msourceCodeUri = appSourceCodeUri (appSettings master)
|
||||
pc <- widgetToPageContent do
|
||||
setTitle "Espial"
|
||||
|
@ -140,23 +133,10 @@ popupLayout widget = do
|
|||
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
|
||||
|
||||
|
||||
-- metricsMiddleware :: Handler a -> Handler a
|
||||
-- metricsMiddleware handler = do
|
||||
-- req <- getRequest
|
||||
-- mcurrentRoute <- getCurrentRoute
|
||||
-- void $ mapM (incrementRouteEKG req) mcurrentRoute
|
||||
-- handler
|
||||
|
||||
|
||||
-- incrementRouteEKG :: YesodRequest -> Route App -> Handler ()
|
||||
-- incrementRouteEKG req = MM.increment . (\r -> "route." <> r <> "." <> method) . pack . constrName
|
||||
-- where method = decodeUtf8 $ NW.requestMethod $ reqWaiRequest req
|
||||
|
||||
-- YesodAuth
|
||||
|
||||
instance YesodAuth App where
|
||||
type AuthId App = UserId
|
||||
-- authHttpManager = getHttpManager
|
||||
authPlugins _ = [dbAuthPlugin]
|
||||
authenticate = authenticateCreds
|
||||
loginDest = const HomeR
|
||||
|
@ -170,9 +150,6 @@ instance YesodAuth App where
|
|||
|
||||
instance YesodAuthPersist App
|
||||
|
||||
-- instance MM.MonadMetrics Handler where
|
||||
-- getMetrics = pure . appMetrics =<< getYesod
|
||||
|
||||
-- session keys
|
||||
|
||||
maybeAuthUsername :: Handler (Maybe Text)
|
||||
|
|
|
@ -12,7 +12,6 @@ import qualified Network.HTTP.Client as NH
|
|||
import qualified Network.HTTP.Client.TLS as NH
|
||||
import qualified Network.HTTP.Types.Status as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
-- import qualified Control.Monad.Metrics as MM
|
||||
import HTMLEntities.Decoder (htmlEncodedText)
|
||||
import Data.Text.Lazy.Builder (toLazyText)
|
||||
import Network.Wai (requestHeaderHost)
|
||||
|
@ -44,16 +43,13 @@ archiveBookmarkUrl :: Key Bookmark -> String -> Handler ()
|
|||
archiveBookmarkUrl kbid url =
|
||||
(_fetchArchiveSubmitInfo >>= \case
|
||||
Left e -> do
|
||||
-- MM.increment "archive.fetchSubmitId_noparse"
|
||||
$(logError) (pack e)
|
||||
Right submitInfo -> do
|
||||
userId <- requireAuthId
|
||||
req <- _buildArchiveSubmitRequest submitInfo url
|
||||
-- MM.increment "archive.submit"
|
||||
manager <- getArchiveManager
|
||||
res <- liftIO $ NH.httpLbs req manager
|
||||
let status = NH.responseStatus res
|
||||
-- MM.increment ("archive.submit_status_" <> (pack.show) (NH.statusCode status))
|
||||
let updateArchiveUrl = runDB . updateBookmarkArchiveUrl userId kbid . Just
|
||||
headers = NH.responseHeaders res
|
||||
case status of
|
||||
|
@ -87,11 +83,9 @@ _parseRefreshHeaderUrl h = do
|
|||
|
||||
_fetchArchiveSubmitInfo :: Handler (Either String (String , String))
|
||||
_fetchArchiveSubmitInfo = do
|
||||
-- MM.increment "archive.fetchSubmitId"
|
||||
req <- buildRequest "https://archive.li/"
|
||||
manager <- getArchiveManager
|
||||
res <- liftIO $ NH.httpLbs req manager
|
||||
-- MM.increment ("archive.fetchSubmitId_status_" <> (pack.show) (NH.statusCode (NH.responseStatus res)))
|
||||
let body = LBS.toStrict (responseBody res)
|
||||
action = _parseSubstring (AP8.string "action=\"") (AP8.notChar '"') body
|
||||
submitId = _parseSubstring (AP8.string "submitid\" value=\"") (AP8.notChar '"') body
|
||||
|
@ -110,13 +104,11 @@ _parseSubstring start inner res = do
|
|||
fetchPageTitle :: String -> Handler (Either String Text)
|
||||
fetchPageTitle url =
|
||||
do
|
||||
-- MM.increment "fetchPageTitle"
|
||||
req <- buildRequest url
|
||||
res <- liftIO $ NH.httpLbs req =<< NH.getGlobalManager
|
||||
let body = LBS.toStrict (responseBody res)
|
||||
pure (decodeHtmlBs <$> parseTitle body)
|
||||
`catch` (\(e :: SomeException) -> do
|
||||
-- MM.increment "fetchPageTitle.error"
|
||||
$(logError) $ (pack . show) e
|
||||
pure (Left (show e)))
|
||||
where
|
||||
|
|
10
src/Model.hs
10
src/Model.hs
|
@ -12,7 +12,7 @@ import qualified Data.List.NonEmpty as NE
|
|||
import qualified Data.Time.ISO8601 as TI
|
||||
import qualified Data.Time.Clock.POSIX as TI
|
||||
import qualified Database.Esqueleto as E
|
||||
import Database.Esqueleto.Internal.Sql as E
|
||||
import qualified Database.Esqueleto.Internal.Internal as E (exists, unsafeSqlFunction)
|
||||
import qualified Data.Time as TI
|
||||
import ClassyPrelude.Yesod hiding ((||.))
|
||||
import Control.Monad.Trans.Maybe
|
||||
|
@ -188,7 +188,7 @@ bookmarksQuery userId sharedp filterp tags mquery limit' page =
|
|||
_whereClause b = do
|
||||
where_ $
|
||||
foldl (\expr tag ->
|
||||
expr &&. (exists $ -- each tag becomes an exists constraint
|
||||
expr &&. (E.exists $ -- each tag becomes an exists constraint
|
||||
from \t ->
|
||||
where_ (t ^. BookmarkTagBookmarkId E.==. b ^. BookmarkId &&.
|
||||
(t ^. BookmarkTagTag `E.like` val tag))))
|
||||
|
@ -217,7 +217,7 @@ bookmarksQuery userId sharedp filterp tags mquery limit' page =
|
|||
(toLikeB BookmarkHref term) ||.
|
||||
(toLikeB BookmarkDescription term) ||.
|
||||
(toLikeB BookmarkExtended term) ||.
|
||||
(exists $ from (\t -> where_ $
|
||||
(E.exists $ from (\t -> where_ $
|
||||
(t ^. BookmarkTagBookmarkId E.==. b ^. BookmarkId) &&.
|
||||
(t ^. BookmarkTagTag `E.like` (wild term))))
|
||||
p_onefield = p_url <|> p_title <|> p_description <|> p_tags <|> p_after <|> p_before
|
||||
|
@ -225,7 +225,7 @@ bookmarksQuery userId sharedp filterp tags mquery limit' page =
|
|||
p_url = "url:" *> fmap (toLikeB BookmarkHref) P.takeText
|
||||
p_title = "title:" *> fmap (toLikeB BookmarkDescription) P.takeText
|
||||
p_description = "description:" *> fmap (toLikeB BookmarkExtended) P.takeText
|
||||
p_tags = "tags:" *> fmap (\term' -> exists $ from (\t -> where_ $
|
||||
p_tags = "tags:" *> fmap (\term' -> E.exists $ from (\t -> where_ $
|
||||
(t ^. BookmarkTagBookmarkId E.==. b ^. BookmarkId) &&.
|
||||
(t ^. BookmarkTagTag `E.like` wild term'))) P.takeText
|
||||
p_after = "after:" *> fmap ((b ^. BookmarkTime E.>=.) . val) (parseTimeText =<< P.takeText)
|
||||
|
@ -568,7 +568,7 @@ tagCountRelated user tags =
|
|||
from \t -> do
|
||||
where_ $
|
||||
foldl (\expr tag ->
|
||||
expr &&. (exists $
|
||||
expr &&. (E.exists $
|
||||
from \u ->
|
||||
where_ (u ^. BookmarkTagBookmarkId E.==. t ^. BookmarkTagBookmarkId &&.
|
||||
(u ^. BookmarkTagTag `E.like` val tag))))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
resolver: lts-16.19
|
||||
resolver: lts-17.15
|
||||
# allow-newer: true
|
||||
packages:
|
||||
- '.'
|
||||
|
@ -7,4 +7,5 @@ extra-deps:
|
|||
# - ekg-json-0.1.0.6
|
||||
# - monad-metrics-0.2.1.4
|
||||
# - wai-middleware-metrics-0.2.4
|
||||
- classy-prelude-yesod-1.5.0@sha256:8f7e183bdfd6d2ea9674284c4f285294ab086aff60d9be4e5d7d2f3c1a2b05b7,1330
|
||||
- yesod-newsfeed-1.7.0.0
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages:
|
||||
- completed:
|
||||
hackage: classy-prelude-yesod-1.5.0@sha256:8f7e183bdfd6d2ea9674284c4f285294ab086aff60d9be4e5d7d2f3c1a2b05b7,1330
|
||||
pantry-tree:
|
||||
size: 330
|
||||
sha256: ae84d4cc0e1daf985db6cdcf2ac92319531b8e60f547183cc46480d00aafbe20
|
||||
original:
|
||||
hackage: classy-prelude-yesod-1.5.0@sha256:8f7e183bdfd6d2ea9674284c4f285294ab086aff60d9be4e5d7d2f3c1a2b05b7,1330
|
||||
- completed:
|
||||
hackage: yesod-newsfeed-1.7.0.0@sha256:ba49f9af47fe96c521ed889bf041c559b4bddb60a81f385449f7557f8f4aaef2,1345
|
||||
pantry-tree:
|
||||
|
@ -13,7 +20,7 @@ packages:
|
|||
hackage: yesod-newsfeed-1.7.0.0
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 532177
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/19.yaml
|
||||
sha256: d2b828ecf50386841d0c5700b58d38566992e10d63a062af497ab29ab031faa1
|
||||
original: lts-16.19
|
||||
size: 567679
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/15.yaml
|
||||
sha256: 72e87841a0ab5b72f6f018e8ee692fd972b7bb32a944990f028e10d6eb528e63
|
||||
original: lts-17.15
|
||||
|
|
Loading…
Reference in a new issue