Skip to content

Commit

Permalink
Add favicon.svg (#67)
Browse files Browse the repository at this point in the history
* Add favicon.svg

* Move some type definitions around
  • Loading branch information
tchoutri authored Feb 23, 2022
1 parent d46e6b6 commit 2dbd19b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 35 deletions.
9 changes: 8 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2021 Théophile Choutri
Copyright 2022 Théophile Choutri

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand All @@ -9,3 +9,10 @@ Redistribution and use in source and binary forms, with or without modification,
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--
favicon.svg

Copyright 2022 Gustave Choutri

Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ test: ## Run the test suite

watch-test: ## Load the tests in ghcid and reload them on file change
./scripts/run-tests.sh --watch


watch-server: ## Start flora-server in ghcid
@ghcid --target=flora-server --restart="src" --test 'FloraWeb.Server.runFlora'
Expand Down
22 changes: 22 additions & 0 deletions assets/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const esbuild = require("esbuild");
const copyDest = "../static"

const minify = false;
const sourcemap = true;
const watch_fs = true;

if (process.env.NODE_ENV === 'prod') {
minify = true;
sourcemap = false;
watch_fs = false;
}

esbuild.build({
entryPoints: ['./js/app.js'],
outfile: `${copyDest}/js/app.js`,
bundle: true,
sourcemap: sourcemap,
minify: minify,
target: "es2016",
watch: watch_fs,
})
1 change: 1 addition & 0 deletions assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"concurrently": "^6.4.0",
"cssnano": "^5.0.10",
"esbuild": "^0.13.13",
"esbuild-copy-static-files": "^0.1.0",
"postcss": "^8.3.11",
"postcss-cli": "^9.0.2",
"postcss-copy": "^7.1.0",
Expand All @@ -17,7 +18,7 @@
"scripts": {
"watch": "concurrently \"yarn:watch-css\" \"yarn:watch-js\"",
"build": "concurrently \"yarn:build-css\" \"yarn:build-js\"",
"watch-js": "esbuild js/app.js --bundle --sourcemap=inline --target=es2016 --outfile=../static/js/app.js --watch",
"watch-js": "node esbuild.config.js",
"build-js": "esbuild js/app.js --asset-names=[name]-[hash].js --bundle --minify --target=es2016 --outdir=../static/js/",
"watch-css": "postcss css/app.css -o ../static/css/app.css -w",
"build-css": "NODE_BUILD=prod postcss css/app.css -o ../static/css/app.css"
Expand Down
14 changes: 14 additions & 0 deletions assets/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz#3fc3ff0bab76fe35dd237476b5d2b32bb20a3d44"
integrity sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==

esbuild-copy-static-files@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/esbuild-copy-static-files/-/esbuild-copy-static-files-0.1.0.tgz#4bb4987b5b554d2fc122a45f077d74663b4dbcf0"
integrity sha512-KlpmYqANA1t2nZavEdItfcOjJC6wbHA21v35HJWN32DddGTWKNNGDKljUzbCPojmpD+wAw8/DXr5abJ4jFCE0w==

[email protected]:
version "0.13.15"
resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz#8e9169c16baf444eacec60d09b24d11b255a8e72"
Expand Down Expand Up @@ -1742,6 +1747,15 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.0.2, postcss-value-parser@^
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==

postcss@^6.0.3:
version "6.0.23"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324"
integrity sha512-soOk1h6J3VMTZtVeVpv15/Hpdl2cBLX3CAw4TAbkpTJiNPk9YP/zWcD1ND+xEtvyuuvKzbxliTOIyvkSeSJ6ag==
dependencies:
chalk "^2.4.1"
source-map "^0.6.1"
supports-color "^5.4.0"

postcss@^8.3.11, postcss@^8.3.5:
version "8.4.5"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.5.tgz#bae665764dfd4c6fcc24dc0fdf7e7aa00cc77f95"
Expand Down
18 changes: 0 additions & 18 deletions flora.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,14 @@ library
, colourista ^>=0.1
, containers ^>=0.6
, cookie ^>=0.4
, directory ^>=1.3
, envparse ^>=0.5
, exceptions
, http-api-data ^>=0.4
, http-types ^>=0.12
, lucid ^>=2.11
, lucid-alpine ^>=0.1
, lucid-svg ^>=0.7
, mtl ^>=2.2
, optics-core ^>=0.4
, optparse-applicative ^>=0.16
, password ^>=3.0
, password-types ^>=1.0
, pcre2 ^>=2.0
Expand Down Expand Up @@ -205,28 +202,18 @@ executable flora-cli
, optics-core
, optparse-applicative ^>=0.16
, pg-entity
, pg-transact
, postgresql-simple
, text
, text-display
, typed-process
, uuid

library flora-test-fixtures
import: common-extensions
import: common-ghc-options
hs-source-dirs: test/fixtures
build-depends:
, aeson
, base
, Cabal
, flora
, optics-core
, password
, pg-entity
, time
, uuid
, vector

exposed-modules: Flora.UserFixtures

Expand All @@ -238,17 +225,13 @@ test-suite flora-test
main-is: Main.hs
hs-source-dirs: test
build-depends:
, aeson
, base
, Cabal
, containers
, exceptions
, flora
, flora-test-fixtures
, hedgehog
, hspec
, http-client ==0.7.10
, mtl
, optics-core
, password
, pg-entity
Expand All @@ -265,7 +248,6 @@ test-suite flora-test
, tasty-hunit
, text
, time
, tmp-postgres
, transformers
, uuid
, vector
Expand Down
23 changes: 12 additions & 11 deletions src/FloraWeb/Server/Auth/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@ import Flora.Model.PersistentSession
import Flora.Model.User
import FloraWeb.Types

type instance AuthServerData (AuthProtect "optional-cookie-auth") = (Headers '[Header "Set-Cookie" SetCookie] (Session 'Visitor))

type instance AuthServerData (AuthProtect "cookie-auth") = (Headers '[Header "Set-Cookie" SetCookie] (Session 'Authenticated))

-- | Datatypes used for every route that doesn't *need* an authenticated user
type FloraPageM = ReaderT (Headers '[Header "Set-Cookie" SetCookie] (Session 'Visitor)) Handler

-- | Datatypes used for routes that *need* an admin
type FloraAdminM = ReaderT (Headers '[Header "Set-Cookie" SetCookie] (Session 'Admin)) Handler

data ProtectionLevel = Visitor | Authenticated | Admin
deriving stock (Eq, Show, Generic)

type role Session nominal

data Session (protectionLevel :: ProtectionLevel) = Session
{ sessionId :: PersistentSessionId
, mUser :: Maybe User
, webEnvStore :: WebEnvStore
} deriving stock (Generic)

-- | Datatypes used for every route that doesn't *need* an authenticated user
type FloraPageM = ReaderT (Headers '[Header "Set-Cookie" SetCookie] (Session 'Visitor)) Handler

-- | Datatypes used for routes that *need* an admin
type FloraAdminM = ReaderT (Headers '[Header "Set-Cookie" SetCookie] (Session 'Admin)) Handler

type instance AuthServerData (AuthProtect "optional-cookie-auth") =
(Headers '[Header "Set-Cookie" SetCookie] (Session 'Visitor))

type instance AuthServerData (AuthProtect "cookie-auth") =
(Headers '[Header "Set-Cookie" SetCookie] (Session 'Authenticated))

getUnauthenticatedUser :: Session 'Visitor -> Maybe User
getUnauthenticatedUser session = session ^. #mUser

Expand Down
1 change: 0 additions & 1 deletion src/FloraWeb/Server/Pages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import FloraWeb.Session
import FloraWeb.Templates
import qualified FloraWeb.Templates.Pages.Home as Home


server :: ServerT Routes FloraPageM
server = Routes'
{ home = homeHandler
Expand Down
3 changes: 1 addition & 2 deletions src/FloraWeb/Templates/Layout/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ header = do
meta_ [name_ "description", content_ "A package repository for the Haskell ecosystem"]
ogTags
theme
link_ [rel_ "icon", href_ "/favicon.ico"]
link_ [rel_ "icon", href_ "/favicon.svg", type_ "image/svg+xml"]
link_ [rel_ "icon", href_ "/static/favicon.svg", type_ "image/svg+xml"]
-- link_ [rel_ "canonical", href_ $ getCanonicalURL assigns]
meta_ [name_ "twitter:dnt", content_ "on"]

Expand Down

0 comments on commit 2dbd19b

Please sign in to comment.