mirror of
https://code.naskya.net/repos/ndqEd
synced 2025-01-10 16:16:46 +09:00
Replace JS minifier with a custom all-discarding one
This commit is contained in:
parent
6e2a8b259d
commit
ae03aee099
2 changed files with 45 additions and 2 deletions
42
src/Text/Jasmine/Local.hs
Normal file
42
src/Text/Jasmine/Local.hs
Normal file
|
@ -0,0 +1,42 @@
|
|||
{- This file is part of Vervis.
|
||||
-
|
||||
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||
-
|
||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||
-
|
||||
- The author(s) have dedicated all copyright and related and neighboring
|
||||
- rights to this software to the public domain worldwide. This software is
|
||||
- distributed without any warranty.
|
||||
-
|
||||
- You should have received a copy of the CC0 Public Domain Dedication along
|
||||
- with this software. If not, see
|
||||
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
-}
|
||||
|
||||
-- | Some of the handler and widget utilities Yesod provides include snippets
|
||||
-- of Javascript which gets inserted into the page. Usually there is no way to
|
||||
-- tell these utilities not to include the script. When you don't want it to be
|
||||
-- included, one way to avoid it to maintain modified versions of the
|
||||
-- utilities. Another, much easier way, is to use a modified Javascript
|
||||
-- minifier.
|
||||
--
|
||||
-- I don't know whether a modified minifier can be a good filter which discards
|
||||
-- some scripts and enables others, but there's definitely one case in which it
|
||||
-- works well: Discarding all scripts.
|
||||
--
|
||||
-- This module collects such modified minifiers.
|
||||
module Text.Jasmine.Local
|
||||
( discardm
|
||||
, reportm
|
||||
)
|
||||
where
|
||||
|
||||
import Prelude
|
||||
|
||||
import qualified Data.ByteString.Lazy as BL (ByteString, empty)
|
||||
|
||||
discardm :: BL.ByteString -> Either String BL.ByteString
|
||||
discardm _ = Right BL.empty
|
||||
|
||||
reportm :: BL.ByteString -> Either String BL.ByteString
|
||||
reportm _ = Left "The app disables all JS through the minifier"
|
|
@ -19,7 +19,7 @@ import Prelude (init, last)
|
|||
|
||||
import Database.Persist.Sql (ConnectionPool, runSqlPool)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import Text.Jasmine (minifym)
|
||||
--import Text.Jasmine (minifym)
|
||||
import Yesod.Auth.HashDB (authHashDB)
|
||||
import Yesod.Auth.Message (AuthMessage (IdentifierNotFound))
|
||||
import Yesod.Default.Util (addStaticContentExternal)
|
||||
|
@ -30,6 +30,7 @@ import qualified Yesod.Core.Unsafe as Unsafe
|
|||
import Data.Text as T (pack)
|
||||
--import qualified Data.Text.Encoding as TE
|
||||
|
||||
import Text.Jasmine.Local (discardm)
|
||||
import Vervis.Import.NoFoundation hiding (last)
|
||||
import Vervis.Widget (breadcrumbBar)
|
||||
|
||||
|
@ -137,7 +138,7 @@ instance Yesod App where
|
|||
master <- getYesod
|
||||
let staticDir = appStaticDir $ appSettings master
|
||||
addStaticContentExternal
|
||||
minifym
|
||||
discardm
|
||||
genFileName
|
||||
staticDir
|
||||
(StaticR . flip StaticRoute [])
|
||||
|
|
Loading…
Reference in a new issue