First commit

Describes the base structure for the project, as well as some basic
functions.
TODO: everything really...
This commit is contained in:
Etienne Werly 2022-09-21 18:02:50 +02:00
commit 4bb7d7b140
18 changed files with 399 additions and 0 deletions

2
.ghci Normal file
View file

@ -0,0 +1,2 @@
:set -XQuasiQuotes
:set -XOverloadedStrings

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.stack-work/
*~
_*/
photos/**.jpg

11
CHANGELOG.md Normal file
View file

@ -0,0 +1,11 @@
# Changelog for `etienne-moqueur`
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
## Unreleased
## 0.1.0.0 - 2022-09-12

18
README.md Normal file
View file

@ -0,0 +1,18 @@
# My new attempt at a personal site
It uses Hakyll, a Haskell static site compiler, along with other Haskell libs:
* Shakespeare (Hamlet) to generate html
* Clay to preprocess css
## Building
Build using `stack`:
```
stack build
```
and then to compile the actual site:
```
stack run build
```

2
Setup.hs Normal file
View file

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

18
app/Main.hs Normal file
View file

@ -0,0 +1,18 @@
module Main
( main
) where
import Hakyll
import Core.Compilers
import Core.Routers
main :: IO ()
main = hakyll $ do
match "src/Kit/Pages/*.hs" $ do
route $ moveFromToWithExtension "src/Kit/Pages/" "" "html"
compile runGHC
match "src/Css/*.hs" $ do
route $ moveFromToWithExtension "src/Css/" "css/" "css"
compile runGHC

80
etienne-moqueur.cabal Normal file
View file

@ -0,0 +1,80 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.34.4.
--
-- see: https://github.com/sol/hpack
name: etienne-moqueur
version: 0.1.0.0
author: etienne
maintainer: etienne@moqueur.chat
copyright: 2022 etienne
license: BSD3
build-type: Simple
extra-source-files:
README.md
CHANGELOG.md
library
exposed-modules:
Core.Compilers
Core.Render
Core.Routers
Css.Default
Kit.Atoms.Button
Kit.Pages.Index
Routes
other-modules:
Paths_etienne_moqueur
hs-source-dirs:
src
default-extensions:
OverloadedStrings QuasiQuotes
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
build-depends:
base >=4.7 && <5
, blaze-html
, clay
, hakyll
, shakespeare
, text
default-language: Haskell2010
executable etienne-moqueur-exe
main-is: Main.hs
other-modules:
Paths_etienne_moqueur
hs-source-dirs:
app
default-extensions:
OverloadedStrings QuasiQuotes
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, blaze-html
, clay
, etienne-moqueur
, hakyll
, shakespeare
, text
default-language: Haskell2010
test-suite etienne-moqueur-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_etienne_moqueur
hs-source-dirs:
test
default-extensions:
OverloadedStrings QuasiQuotes
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, blaze-html
, clay
, etienne-moqueur
, hakyll
, shakespeare
, text
default-language: Haskell2010

67
package.yaml Normal file
View file

@ -0,0 +1,67 @@
name: etienne-moqueur
version: 0.1.0.0
license: BSD3
author: "etienne"
maintainer: "etienne@moqueur.chat"
copyright: "2022 etienne"
extra-source-files:
- README.md
- CHANGELOG.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
# description: Please see the README on GitHub at <https://github.com/githubuser/etienne-moqueur#readme>
dependencies:
- base >= 4.7 && < 5
- hakyll
- shakespeare
- clay
- text
- blaze-html
ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints
default-extensions:
OverloadedStrings
QuasiQuotes
library:
source-dirs: src
executables:
etienne-moqueur-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- etienne-moqueur
tests:
etienne-moqueur-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- etienne-moqueur

13
src/Core/Compilers.hs Normal file
View file

@ -0,0 +1,13 @@
module Core.Compilers
( runGHC
) where
import Hakyll
-- Redundant... Those default extensions should be kept in sync with package.yaml, but `stack runghc` won't take those in account.
defaultExtensions :: [String]
defaultExtensions = ["--", "-XQuasiQuotes", "-XOverloadedStrings"]
runGHC :: Compiler (Item String)
runGHC = getResourceString
>>= withItemBody (unixFilter "stack" $ "runghc" : defaultExtensions)

20
src/Core/Render.hs Normal file
View file

@ -0,0 +1,20 @@
module Core.Render
( renderHamlet
, renderClay
) where
import Clay ( Css
, compact
, renderWith
)
import qualified Data.Text.Lazy.IO as T
( putStr )
import Routes
import Text.Blaze.Html.Renderer.String
import Text.Hamlet ( HtmlUrl )
renderHamlet :: HtmlUrl Routes -> IO ()
renderHamlet ham = putStr . renderHtml $ ham render
renderClay :: Css -> IO ()
renderClay = T.putStr . renderWith compact []

18
src/Core/Routers.hs Normal file
View file

@ -0,0 +1,18 @@
module Core.Routers
( (>+)
, moveFromTo
, moveFromToWithExtension
) where
import Data.Char ( toLower )
import Hakyll
(>+) :: Routes -> Routes -> Routes
(>+) = composeRoutes
moveFromTo :: FilePath -> FilePath -> Routes
moveFromTo from to =
gsubRoute from (const to) >+ customRoute (fmap toLower . toFilePath)
moveFromToWithExtension :: FilePath -> FilePath -> String -> Routes
moveFromToWithExtension from to ext = moveFromTo from to >+ setExtension ext

14
src/Css/Default.hs Normal file
View file

@ -0,0 +1,14 @@
module Css.Default
( main
) where
import Clay
import Core.Render ( renderClay )
import Kit.Atoms.Button ( buttonCss )
defaultCss :: Css
defaultCss = do
buttonCss
main :: IO ()
main = renderClay defaultCss

17
src/Kit/Atoms/Button.hs Normal file
View file

@ -0,0 +1,17 @@
module Kit.Atoms.Button (buttonWithText, buttonCss) where
import Routes
import Text.Hamlet
import Clay
buttonWithText :: String -> HtmlUrl Routes
buttonWithText text = [hamlet|
<button>#{text}
|]
buttonCss :: Css
buttonCss = button ? do
backgroundColor blue
color white
fontWeight bold

20
src/Kit/Pages/Index.hs Normal file
View file

@ -0,0 +1,20 @@
module Kit.Pages.Index (main) where
import Routes
import Kit.Atoms.Button
import Core.Render (renderHamlet)
import Text.Hamlet
index :: HtmlUrl Routes
index = [hamlet|
$doctype 5
<html>
<head>
<title>Very first try
<link rel=stylesheet href=@{DefaultStylesheet}>
<body>
^{buttonWithText "Click!"}
|]
main :: IO ()
main = renderHamlet index

13
src/Routes.hs Normal file
View file

@ -0,0 +1,13 @@
module Routes
( Routes(..)
, render
) where
import Text.Hamlet
data Routes = Home
| DefaultStylesheet
render :: Render Routes
render Home _ = "/"
render DefaultStylesheet _ = "/css/default.css"

67
stack.yaml Normal file
View file

@ -0,0 +1,67 @@
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/24.yaml
# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []
# Override default flag values for local packages and extra-deps
# flags: {}
# Extra package databases containing global packages
# extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.7"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor

13
stack.yaml.lock Normal file
View file

@ -0,0 +1,13 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
size: 619403
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/24.yaml
sha256: 98f5bee5bf07ff25263d7061e03c34595bfca543b611f9d3da5c95f2a6c8d723
original:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/24.yaml

2
test/Spec.hs Normal file
View file

@ -0,0 +1,2 @@
main :: IO ()
main = putStrLn "Test suite not yet implemented"