Add a JS script to be copied in the project and loaded in the interface
This commit is contained in:
parent
9d22da4c8b
commit
ce3a061a73
5 changed files with 27 additions and 0 deletions
|
@ -15,6 +15,7 @@ maintainer: tissevert+devel@marvid.fr
|
||||||
-- copyright:
|
-- copyright:
|
||||||
category: Web
|
category: Web
|
||||||
extra-source-files: CHANGELOG.md
|
extra-source-files: CHANGELOG.md
|
||||||
|
data-files: js/main.js
|
||||||
|
|
||||||
executable hablo
|
executable hablo
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
|
@ -24,7 +25,9 @@ executable hablo
|
||||||
, Blog
|
, Blog
|
||||||
, Dom
|
, Dom
|
||||||
, HTML
|
, HTML
|
||||||
|
, JS
|
||||||
, JSON
|
, JSON
|
||||||
|
, Paths_hablo
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: aeson
|
build-depends: aeson
|
||||||
, base ^>=4.12.0.0
|
, base ^>=4.12.0.0
|
||||||
|
|
3
js/main.js
Normal file
3
js/main.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
console.log("Hablo loaded");
|
||||||
|
});
|
|
@ -64,6 +64,7 @@ page aPage =
|
||||||
title_ . toHtml =<< Blog.get name
|
title_ . toHtml =<< Blog.get name
|
||||||
script_ [src_ "/UnitJS/async.js"] empty
|
script_ [src_ "/UnitJS/async.js"] empty
|
||||||
script_ [src_ "/UnitJS/dom.js"] empty
|
script_ [src_ "/UnitJS/dom.js"] empty
|
||||||
|
script_ [src_ "/js/main.js"] empty
|
||||||
maybe (toHtml empty) toHtmlRaw =<< Blog.get customHead
|
maybe (toHtml empty) toHtmlRaw =<< Blog.get customHead
|
||||||
)
|
)
|
||||||
body_ (do
|
body_ (do
|
||||||
|
|
18
src/JS.hs
Normal file
18
src/JS.hs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
module JS (
|
||||||
|
install
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Blog (Blog(..))
|
||||||
|
import qualified Blog (get)
|
||||||
|
import Control.Monad.IO.Class (MonadIO(..))
|
||||||
|
import Control.Monad.Reader (ReaderT)
|
||||||
|
import Paths_hablo (getDataFileName)
|
||||||
|
import System.Directory (copyFile, createDirectoryIfMissing)
|
||||||
|
import System.FilePath ((</>))
|
||||||
|
|
||||||
|
install :: ReaderT Blog IO ()
|
||||||
|
install = do
|
||||||
|
source <- liftIO $ getDataFileName "js/main.js"
|
||||||
|
destinationDir <- (</> "js") <$> Blog.get root
|
||||||
|
liftIO $ createDirectoryIfMissing False destinationDir
|
||||||
|
liftIO $ copyFile source (destinationDir </> "main.js")
|
|
@ -3,6 +3,7 @@ module Main where
|
||||||
import qualified Arguments (get)
|
import qualified Arguments (get)
|
||||||
import qualified Blog (build)
|
import qualified Blog (build)
|
||||||
import qualified HTML (generate)
|
import qualified HTML (generate)
|
||||||
|
import qualified JS (install)
|
||||||
import qualified JSON (generate)
|
import qualified JSON (generate)
|
||||||
import Control.Monad.Reader (runReaderT)
|
import Control.Monad.Reader (runReaderT)
|
||||||
|
|
||||||
|
@ -13,4 +14,5 @@ main = do
|
||||||
>>= runReaderT (do
|
>>= runReaderT (do
|
||||||
HTML.generate
|
HTML.generate
|
||||||
JSON.generate
|
JSON.generate
|
||||||
|
JS.install
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue