Skip to content

Commit

Permalink
Add an image gallery (#1)
Browse files Browse the repository at this point in the history
Add an image gallery tab to the website with a few images.
  • Loading branch information
byorgey authored May 5, 2024
1 parent 86885c4 commit a62f267
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
_cache/
_site/
*~
TAGS
6 changes: 6 additions & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
restylers_version: stable
restylers:
- fourmolu:
image: 'restyled/restyler-fourmolu:v0.13.0.0'
arguments:
[]
15 changes: 15 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
indentation: 2
comma-style: leading
record-brace-space: true
indent-wheres: false # 'false' means save space by only half-indenting the 'where' keyword
diff-friendly-import-export: true
let-style: inline
respectful: true
single-constraint-parens: auto
haddock-style: single-line
newlines-between-decls: 1
reexports:
- module Text.Megaparsec exports Control.Applicative
- module Options.Applicative exports Control.Applicative
fixities:
- infixl 9 ".:"
Binary file added gallery/crafting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/crafting.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: An early tutorial level
Binary file added gallery/debugger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/debugger.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Using the debugger
Binary file added gallery/log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/log.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Making a log
Binary file added gallery/main-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/main-menu.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Main menu
Binary file added gallery/tree_harvest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gallery/tree_harvest.png.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
caption: Robot status panel
34 changes: 26 additions & 8 deletions site.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@

{- cabal:
build-depends:
base ^>= 4.18.0.0,
base >= 4.18 && < 4.20,
filepath ^>= 1.4.100.1,
hakyll ^>= 4.16.1.0,
hakyll >= 4.16 && < 4.17,
-}
{-# LANGUAGE OverloadedStrings #-}

import Data.String (String)
import Hakyll
import System.FilePath (dropExtension, takeDirectory, takeFileName, (</>))

main :: IO ()
main = hakyll $ do
match "images/**" $ do
route idRoute
compile copyFileCompiler

match "style.css" $ do
match ("images/**" .||. "gallery/**" .||. "style.css") $ do
route idRoute
compile copyFileCompiler

match "blog/**" $ do
route $ cleanRoute
route cleanRoute
compile $
pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" blogPostContext
Expand All @@ -47,6 +44,27 @@ main = hakyll $ do
>>= applyAsTemplate blogListContext
>>= loadAndApplyTemplate "templates/default.html" defaultContext

create ["gallery.html"] $ do
route cleanRoute
compile $ do
images <- loadAll "gallery/*.png"
imgTpl <- loadBody "templates/gallery-image.html"

-- See https://github.com/jaspervdj/hakyll/issues/717
-- and example in https://github.com/goolord/skyespace/blob/master/src/Main.hs
let imgCtx :: Context CopyFile
imgCtx = metadataField <> urlField "url"
imgs <- applyTemplateList imgTpl imgCtx images

let galleryCtx =
constField "images" imgs
<> constField "title" "Gallery"
<> defaultContext

makeItem ""
>>= loadAndApplyTemplate "templates/gallery.html" galleryCtx
>>= loadAndApplyTemplate "templates/default.html" galleryCtx

match "templates/*" $ compile templateBodyCompiler

cleanRoute :: Routes
Expand Down
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ img {
max-width: 100%;
}

.gallery-img {
margin-top: 2cm;
margin-bottom: 2cm;
}

#logo {
text-align: center;
}
Expand Down
6 changes: 5 additions & 1 deletion templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
} else if (e.key === 'F3') {
window.location.href = "/blog"
e.preventDefault();
} else if (e.key === 'F4') {
window.location.href = "/gallery"
e.preventDefault();
}
});
</script>
Expand All @@ -31,7 +34,8 @@
<div id="navigation">
<a href="/">[F1] Home</a>
<a href="/installing">[F2] Installing</a>
<a href="/blog">[F3] Blog</a>
<a href="/blog">[F3] Blog</a>
<a href="/gallery">[F4] Gallery</a>
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions templates/gallery-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="gallery-img">
<img src="$url$"></img>
<div style="text-align: center"><em>$caption$</em></a>
</div>
5 changes: 5 additions & 0 deletions templates/gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>$title$</h1>
$body$
<div class="gallery">
$images$
</div>

0 comments on commit a62f267

Please sign in to comment.