aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Resource.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r--compiler/src/Resource.hs58
1 files changed, 58 insertions, 0 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
new file mode 100644
index 0000000..04e315a
--- /dev/null
+++ b/compiler/src/Resource.hs
@@ -0,0 +1,58 @@
1{-# LANGUAGE DuplicateRecordFields, DeriveGeneric, DeriveAnyClass #-}
2
3-- ldgallery - A static generator which turns a collection of tagged
4-- pictures into a searchable web gallery.
5--
6-- Copyright (C) 2019 Pacien TRAN-GIRARD
7--
8-- This program is free software: you can redistribute it and/or modify
9-- it under the terms of the GNU Affero General Public License as
10-- published by the Free Software Foundation, either version 3 of the
11-- License, or (at your option) any later version.
12--
13-- This program is distributed in the hope that it will be useful,
14-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-- GNU Affero General Public License for more details.
17--
18-- You should have received a copy of the GNU Affero General Public License
19-- along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21
22module Resource
23 ( ResourceTree(..)
24 , buildResourceTree
25 ) where
26
27
28import Data.Function ((&))
29import Files
30import Input
31
32
33-- | Tree representing the compiled gallery resources.
34data ResourceTree =
35 ItemResource
36 { sidecar :: Sidecar
37 , path :: Path
38 , itemThumbnailPath :: Path }
39 | DirResource
40 { items :: [ResourceTree]
41 , path :: Path
42 , dirThumbnailPath :: Maybe Path }
43 deriving Show
44
45
46 -- TODO: actually generate compilation strategies
47buildResourceTree :: InputTree -> ResourceTree
48buildResourceTree = resNode
49 where
50 resNode (InputFile path sidecar) =
51 ItemResource sidecar (itemsDir /> path) (thumbnailsDir /> path)
52
53 resNode (InputDir path thumbnailPath items) =
54 map resNode items
55 & \dirItems -> DirResource dirItems (itemsDir /> path) Nothing
56
57 itemsDir = "items"
58 thumbnailsDir = "thumbnails"