From 11e8e923012d6f266b971e15767fd6b8c54df679 Mon Sep 17 00:00:00 2001 From: vrom911 Date: Sat, 12 Aug 2017 12:56:41 +0300 Subject: [PATCH 1/6] Use fmt-0.4.0 with renewed operators +| |+ --- .gitignore | 1 + guide.cabal | 2 +- src/Imports.hs | 48 ++---------------------------------------------- stack.yaml | 2 +- 4 files changed, 5 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index e268c2d..ef9c384 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ tags # JavaScript guidejs/node_modules/ +static/js/ diff --git a/guide.cabal b/guide.cabal index 02cd2b2..0ee176a 100644 --- a/guide.cabal +++ b/guide.cabal @@ -103,7 +103,7 @@ library , feed >= 0.3.11 && < 0.4 , filemanip == 0.3.6.* , filepath - , fmt == 0.2.* + , fmt == 0.4.* , focus , friendly-time == 0.4.* , fsnotify == 0.2.* diff --git a/src/Imports.hs b/src/Imports.hs index 67992d7..d9c66fc 100644 --- a/src/Imports.hs +++ b/src/Imports.hs @@ -8,15 +8,7 @@ the "Prelude".) module Imports ( module X, - LByteString, - (+|), - (|+), - (+||), - (||+), - (|++|), - (||++||), - (|++||), - (||++|) + LByteString ) where @@ -48,44 +40,8 @@ import Data.Hashable as X -- Lazy bytestring import qualified Data.ByteString.Lazy as BSL -- Formatting -import Fmt as X hiding (( #| ), ( #|| ), (|#), (|##|), - (|##||), (||#), (||##|), (||##||)) -import qualified Fmt as FMT (( #| ), ( #|| ), (|#), (|##|), (|##||), - (||#), (||##|), (||##||)) -import Fmt.Internal (FromBuilder) +import Fmt as X type LByteString = BSL.ByteString -- LText is already provided by Data.Text.All - -infixr 1 +| -(+|) :: FromBuilder b => Builder -> Builder -> b -(+|) = (FMT.#|) - -infixr 1 |+ -(|+) :: (Buildable a, FromBuilder b) => a -> Builder -> b -(|+) = (FMT.|#) - -infixr 1 +|| -(+||) :: FromBuilder b => Builder -> Builder -> b -(+||) = (FMT.#||) - -infixr 1 ||+ -(||+) :: (Show a, FromBuilder b) => a -> Builder -> b -(||+) = (FMT.||#) - -infixr 1 |++| -(|++|) :: (Buildable a, FromBuilder b) => a -> Builder -> b -(|++|) = (FMT.|##|) - -infixr 1 ||++|| -(||++||) :: (Show a, FromBuilder b) => a -> Builder -> b -(||++||) = (FMT.||##||) - -infixr 1 ||++| -(|++||) :: (Show a, FromBuilder b) => a -> Builder -> b -(|++||) = (FMT.|##||) - -infixr 1 |++|| -(||++|) :: (Buildable a, FromBuilder b) => a -> Builder -> b -(||++|) = (FMT.||##|) diff --git a/stack.yaml b/stack.yaml index 6d5f8d1..d942061 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,6 +15,6 @@ extra-deps: - text-all-0.4.1.0 - cmark-sections-0.1.0.3 - patches-vector-0.1.5.4 -- fmt-0.2.0.0 +- fmt-0.4.0.0 - Spock-digestive-0.3.0.0 - digestive-functors-0.8.2.0 From 4b070105b493e7b02914af112e1c3c3f678c2d75 Mon Sep 17 00:00:00 2001 From: Artyom Date: Sun, 13 Aug 2017 15:40:32 +0300 Subject: [PATCH 2/6] Fix all routes because they all were broken --- src/Guide/Routes.hs | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/Guide/Routes.hs b/src/Guide/Routes.hs index beebd78..2c79ac6 100644 --- a/src/Guide/Routes.hs +++ b/src/Guide/Routes.hs @@ -1,44 +1,48 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DataKinds #-} -module Guide.Routes - ( addRoute - , adminRoute - , authRoute - , deleteRoute - , haskellRoute - , feedRoute - , moveRoute - , renderRoute - , setRoute - ) where -import Web.Spock (Path) +module Guide.Routes +( + addRoute, + adminRoute, + authRoute, + deleteRoute, + haskellRoute, + feedRoute, + moveRoute, + renderRoute, + setRoute, +) where + + +import Web.Spock (Path, ()) import Web.Routing.Combinators (PathState(Open)) + haskellRoute :: Path '[] 'Open haskellRoute = "haskell" authRoute :: Path '[] 'Open -authRoute = "auth" +authRoute = haskellRoute "auth" setRoute :: Path '[] 'Open -setRoute = "set" +setRoute = haskellRoute "set" addRoute :: Path '[] 'Open -addRoute = "add" +addRoute = haskellRoute "add" moveRoute :: Path '[] 'Open -moveRoute = "move" +moveRoute = haskellRoute "move" deleteRoute :: Path '[] 'Open -deleteRoute = "delete" +deleteRoute = haskellRoute "delete" feedRoute :: Path '[] 'Open -feedRoute = "feed" +feedRoute = haskellRoute "feed" renderRoute :: Path '[] 'Open -renderRoute = "render" +renderRoute = haskellRoute "render" adminRoute :: Path '[] 'Open -adminRoute = "admin" +adminRoute = haskellRoute "admin" From 22fa7e9fd070e12a9ad1a1cbca198c2329997ebe Mon Sep 17 00:00:00 2001 From: Artyom Date: Sun, 13 Aug 2017 15:59:57 +0300 Subject: [PATCH 3/6] [travis] Install Chrome --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0a20e41..cf1f8c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ addons: - libgmp-dev # Selenium - xvfb + chrome: stable cache: directories: From e6b3409d29aaec9c4428193a4f889503429790b2 Mon Sep 17 00:00:00 2001 From: Artyom Date: Sun, 13 Aug 2017 16:07:48 +0300 Subject: [PATCH 4/6] [travis] Use newer Selenium and chromedriver --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf1f8c3..4aa4e74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: - export PATH=$HOME/.local/bin:$PATH - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' -- wget http://chromedriver.storage.googleapis.com/2.9/chromedriver_linux64.zip +- wget http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - chmod +x chromedriver - sudo mv -f chromedriver /usr/local/share/chromedriver @@ -39,8 +39,8 @@ before_install: before_script: - sh -e /etc/init.d/xvfb start - export DISPLAY=:99.0 -- travis_retry wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar -- java -jar selenium-server-standalone-2.53.1.jar 2> /dev/null & +- travis_retry wget http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar +- java -jar selenium-server-standalone-3.0.1.jar 2> /dev/null & - sleep 15 script: From 4ad47ec6f9c81e5b0f04cc8d1ddc539b46ca6234 Mon Sep 17 00:00:00 2001 From: Artyom Date: Sun, 13 Aug 2017 19:40:43 +0300 Subject: [PATCH 5/6] [travis] Build the JS part --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4aa4e74..4c28e59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ before_script: - sleep 15 script: + - scripts/buildjs.sh - stack $ARGS --no-terminal --install-ghc build --test - scripts/test-official.sh $ARGS From a98c3eb7575c79f86ff8e43b8d9f2d14bfd9af66 Mon Sep 17 00:00:00 2001 From: Artyom Date: Sun, 13 Aug 2017 20:10:51 +0300 Subject: [PATCH 6/6] Roll back some overzealous route fixing Not all routes need /haskell/ --- src/Guide/Main.hs | 6 +++--- src/Guide/Routes.hs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Guide/Main.hs b/src/Guide/Main.hs index 0371f3b..afd16b9 100644 --- a/src/Guide/Main.hs +++ b/src/Guide/Main.hs @@ -314,13 +314,13 @@ guideApp waiMetrics = do -- plain "/auth" logs out a logged-in user and lets a logged-out user -- log in (this is not the best idea, granted, and we should just - -- shot logged-in users a “logout” link and logged-out users a + -- show logged-in users a “logout” link and logged-out users a -- “login” link instead) Spock.get (authRoute root) $ do user <- getLoggedInUser if isJust user - then Spock.redirect "auth/logout" - else Spock.redirect "auth/login" + then Spock.redirect "/auth/logout" + else Spock.redirect "/auth/login" Spock.getpost (authRoute "login") $ authRedirect "/" loginAction Spock.get (authRoute "logout") logoutAction Spock.getpost (authRoute "register") $ authRedirect "/" signupAction diff --git a/src/Guide/Routes.hs b/src/Guide/Routes.hs index 2c79ac6..219bfeb 100644 --- a/src/Guide/Routes.hs +++ b/src/Guide/Routes.hs @@ -24,7 +24,7 @@ haskellRoute :: Path '[] 'Open haskellRoute = "haskell" authRoute :: Path '[] 'Open -authRoute = haskellRoute "auth" +authRoute = "auth" setRoute :: Path '[] 'Open setRoute = haskellRoute "set" @@ -45,4 +45,4 @@ renderRoute :: Path '[] 'Open renderRoute = haskellRoute "render" adminRoute :: Path '[] 'Open -adminRoute = haskellRoute "admin" +adminRoute = "admin"