From bbae6ddb97c0825f6b0b689f4d9eeac67515d1c1 Mon Sep 17 00:00:00 2001
From: pacien
Date: Sat, 21 Dec 2019 19:28:58 +0100
Subject: compiler: init stack project
---
compiler/app/Main.hs | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 compiler/app/Main.hs
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
new file mode 100644
index 0000000..de1c1ab
--- /dev/null
+++ b/compiler/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import Lib
+
+main :: IO ()
+main = someFunc
--
cgit v1.2.3
From 8de4411269ae85789c1cc7d81a9ecf0facbe78ff Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 23 Dec 2019 05:09:25 +0100
Subject: compiler: add base structures and encoding
---
compiler/app/Main.hs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index de1c1ab..ac9b441 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -3,4 +3,4 @@ module Main where
import Lib
main :: IO ()
-main = someFunc
+main = testRun
--
cgit v1.2.3
From eb7a652b2244ffa4dd5ba2440b7879127e7c6078 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 27 Dec 2019 10:08:19 +0100
Subject: compiler: implement resource processing
but break directory cleanup
---
compiler/app/Main.hs | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index ac9b441..2511998 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -1,6 +1,30 @@
+-- ldgallery - A static generator which turns a collection of tagged
+-- pictures into a searchable web gallery.
+--
+-- Copyright (C) 2019 Pacien TRAN-GIRARD
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero General Public License as
+-- published by the Free Software Foundation, either version 3 of the
+-- License, or (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Affero General Public License for more details.
+--
+-- You should have received a copy of the GNU Affero General Public License
+-- along with this program. If not, see .
+
+{-# LANGUAGE
+ DuplicateRecordFields
+ , DeriveGeneric
+ , DeriveAnyClass
+#-}
+
module Main where
-import Lib
+import Compiler
main :: IO ()
-main = testRun
+main = compileGallery "../../example" "../../out"
--
cgit v1.2.3
From c3f1d45743e274f588e5a23ba25e1fc124728c11 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 27 Dec 2019 11:07:58 +0100
Subject: compiler: add command line interface
---
compiler/app/Main.hs | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 2511998..be57c82 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -17,14 +17,41 @@
-- along with this program. If not, see .
{-# LANGUAGE
- DuplicateRecordFields
- , DeriveGeneric
- , DeriveAnyClass
+ RecordWildCards
+ , ApplicativeDo
#-}
module Main where
+import Options.Applicative
+import Data.Semigroup ((<>))
import Compiler
+data Args = Args
+ { inputDir :: String
+ , outputDir :: String }
+
+args :: Parser Args
+args = Args
+ <$> strOption
+ ( long "input"
+ <> short 'i'
+ <> metavar "INPUT DIR"
+ <> help "Gallery source directory" )
+ <*> strOption
+ ( long "output"
+ <> short 'o'
+ <> metavar "OUTPUT DIR"
+ <> help "Generated gallery output path, outside of the input directory" )
+
main :: IO ()
-main = compileGallery "../../example" "../../out"
+main =
+ do
+ options <- execParser opts
+ compileGallery (inputDir options) (outputDir options)
+
+ where
+ opts = info (args <**> helper)
+ ( fullDesc
+ <> progDesc "Compile a picture gallery"
+ <> header "ldgallery - A static generator which turns a collection of tagged pictures into a searchable web gallery.")
--
cgit v1.2.3
From 1e57d76eadb2192be2b3d9343d4ddfeccc996bcb Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 27 Dec 2019 13:38:47 +0100
Subject: compiler: exclude output dir from input
---
compiler/app/Main.hs | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index be57c82..d9b019a 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -29,29 +29,38 @@ import Compiler
data Args = Args
{ inputDir :: String
- , outputDir :: String }
+ , outputDir :: String
+ , rebuild :: Bool }
args :: Parser Args
args = Args
<$> strOption
( long "input"
<> short 'i'
- <> metavar "INPUT DIR"
+ <> metavar "SOURCE DIR"
+ <> value "./"
+ <> showDefault
<> help "Gallery source directory" )
<*> strOption
( long "output"
<> short 'o'
<> metavar "OUTPUT DIR"
- <> help "Generated gallery output path, outside of the input directory" )
+ <> value "./out"
+ <> showDefault
+ <> help "Generated gallery output path" )
+ <*> switch
+ ( long "rebuild"
+ <> short 'r'
+ <> help "Invalidate cache and recompile everything" )
main :: IO ()
main =
do
options <- execParser opts
- compileGallery (inputDir options) (outputDir options)
+ compileGallery (inputDir options) (outputDir options) (rebuild options)
where
opts = info (args <**> helper)
( fullDesc
- <> progDesc "Compile a picture gallery"
- <> header "ldgallery - A static generator which turns a collection of tagged pictures into a searchable web gallery.")
+ <> progDesc "Compile a gallery"
+ <> header "ldgallery - a static gallery generator with tags" )
--
cgit v1.2.3
From 45df822904cd1759ea4be4bf0c125d8fb6542479 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 27 Dec 2019 14:44:07 +0100
Subject: compiler: switch to cmdargs
---
compiler/app/Main.hs | 60 +++++++++++++++++++++++-----------------------------
1 file changed, 26 insertions(+), 34 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index d9b019a..1773073 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -17,50 +17,42 @@
-- along with this program. If not, see .
{-# LANGUAGE
- RecordWildCards
- , ApplicativeDo
+ DeriveDataTypeable
#-}
module Main where
-import Options.Applicative
-import Data.Semigroup ((<>))
+import Paths_ldgallery_compiler (version)
+import Data.Version (showVersion)
+import System.Console.CmdArgs
import Compiler
-data Args = Args
+
+data Options = Options
{ inputDir :: String
, outputDir :: String
- , rebuild :: Bool }
+ , rebuild :: Bool
+ } deriving (Show, Data, Typeable)
+
+options = Options
+ { inputDir = "./"
+ &= typDir
+ &= help "Gallery source directory (default=./)"
+ , outputDir = "./out"
+ &= typDir
+ &= help "Generated gallery output path (default=./out)"
+ , rebuild = False
+ &= help "Invalidate cache and recompile everything"
+ }
+ &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static gallery generator with tags")
+ &= program "ldgallery"
+ &= help "Compile a gallery"
+ &= helpArg [explicit, name "h", name "help"]
+ &= versionArg [explicit, name "v", name "version"]
-args :: Parser Args
-args = Args
- <$> strOption
- ( long "input"
- <> short 'i'
- <> metavar "SOURCE DIR"
- <> value "./"
- <> showDefault
- <> help "Gallery source directory" )
- <*> strOption
- ( long "output"
- <> short 'o'
- <> metavar "OUTPUT DIR"
- <> value "./out"
- <> showDefault
- <> help "Generated gallery output path" )
- <*> switch
- ( long "rebuild"
- <> short 'r'
- <> help "Invalidate cache and recompile everything" )
main :: IO ()
main =
do
- options <- execParser opts
- compileGallery (inputDir options) (outputDir options) (rebuild options)
-
- where
- opts = info (args <**> helper)
- ( fullDesc
- <> progDesc "Compile a gallery"
- <> header "ldgallery - a static gallery generator with tags" )
+ opts <- cmdArgs options
+ compileGallery (inputDir opts) (outputDir opts) (rebuild opts)
--
cgit v1.2.3
From 641ea85d4da795cb2c67d9777cb3db3dfede1d8b Mon Sep 17 00:00:00 2001
From: pacien
Date: Tue, 31 Dec 2019 06:58:53 +0100
Subject: compiler: add option to include static web app in the output
GitHub: closes #6
---
compiler/app/Main.hs | 54 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 9 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 1773073..24d8aad 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -22,37 +22,73 @@
module Main where
-import Paths_ldgallery_compiler (version)
+import Paths_ldgallery_compiler (version, getDataFileName)
import Data.Version (showVersion)
+import System.FilePath ((>))
import System.Console.CmdArgs
+
import Compiler
+import Files (readDirectory, copyTo)
data Options = Options
{ inputDir :: String
, outputDir :: String
- , rebuild :: Bool
+ , rebuilAll :: Bool
+ , withViewer :: Bool
} deriving (Show, Data, Typeable)
options = Options
{ inputDir = "./"
&= typDir
+ &= explicit
+ &= name "i"
+ &= name "input-dir"
&= help "Gallery source directory (default=./)"
, outputDir = "./out"
&= typDir
+ &= explicit
+ &= name "o"
+ &= name "output-dir"
&= help "Generated gallery output path (default=./out)"
- , rebuild = False
+ , rebuilAll = False
+ &= explicit
+ &= name "r"
+ &= name "rebuild-all"
&= help "Invalidate cache and recompile everything"
+ , withViewer = False
+ &= explicit
+ &= name "w"
+ &= name "with-viewer"
+ &= help "Include the static web viewer in the output"
}
- &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static gallery generator with tags")
- &= program "ldgallery"
- &= help "Compile a gallery"
- &= helpArg [explicit, name "h", name "help"]
- &= versionArg [explicit, name "v", name "version"]
+
+ &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static gallery generator with tags")
+ &= program "ldgallery"
+ &= help "Compile a gallery"
+ &= helpArg [explicit, name "h", name "help"]
+ &= versionArg [explicit, name "version"]
main :: IO ()
main =
do
opts <- cmdArgs options
- compileGallery (inputDir opts) (outputDir opts) (rebuild opts)
+ compileGallery (inputDir opts) (galleryOutputDir "gallery" opts) (rebuilAll opts)
+ if (withViewer opts) then copyViewer (outputDir opts) else noop
+
+ where
+ galleryOutputDir :: FilePath -> Options -> FilePath
+ galleryOutputDir gallerySubdir opts =
+ if withViewer opts then outputBase > gallerySubdir else outputBase
+ where outputBase = outputDir opts
+
+ copyViewer :: FilePath -> IO ()
+ copyViewer target =
+ putStrLn "Copying viewer webapp"
+ >> getDataFileName "viewer"
+ >>= readDirectory
+ >>= copyTo target
+
+ noop :: IO ()
+ noop = return ()
--
cgit v1.2.3
From 5367781f0c7fd1ce274492ba91895fef9d44dab3 Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 5 Jan 2020 10:43:48 +0100
Subject: add manual
---
compiler/app/Main.hs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 24d8aad..319e984 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -41,29 +41,29 @@ data Options = Options
options = Options
{ inputDir = "./"
&= typDir
- &= explicit
&= name "i"
&= name "input-dir"
+ &= explicit
&= help "Gallery source directory (default=./)"
, outputDir = "./out"
&= typDir
- &= explicit
&= name "o"
&= name "output-dir"
+ &= explicit
&= help "Generated gallery output path (default=./out)"
, rebuilAll = False
- &= explicit
&= name "r"
&= name "rebuild-all"
+ &= explicit
&= help "Invalidate cache and recompile everything"
, withViewer = False
- &= explicit
&= name "w"
&= name "with-viewer"
+ &= explicit
&= help "Include the static web viewer in the output"
}
- &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static gallery generator with tags")
+ &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static web gallery generator with tags")
&= program "ldgallery"
&= help "Compile a gallery"
&= helpArg [explicit, name "h", name "help"]
--
cgit v1.2.3
From 9dd271504160b624284dbc438cdc867b6ca0d0e7 Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 5 Jan 2020 16:24:02 +0100
Subject: compiler: enable warnings and fix them
GitHub: fixes #9
---
compiler/app/Main.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 319e984..43a8aeb 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -1,7 +1,7 @@
-- ldgallery - A static generator which turns a collection of tagged
-- pictures into a searchable web gallery.
--
--- Copyright (C) 2019 Pacien TRAN-GIRARD
+-- Copyright (C) 2019-2020 Pacien TRAN-GIRARD
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
@@ -38,6 +38,7 @@ data Options = Options
, withViewer :: Bool
} deriving (Show, Data, Typeable)
+options :: Options
options = Options
{ inputDir = "./"
&= typDir
--
cgit v1.2.3
From ee222b40569b9f40c482dd9df518f6445c1c304d Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 5 Jan 2020 16:42:09 +0100
Subject: compiler: enable language extensions on whole project
---
compiler/app/Main.hs | 4 ----
1 file changed, 4 deletions(-)
(limited to 'compiler/app')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 43a8aeb..1a42abf 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -16,10 +16,6 @@
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see .
-{-# LANGUAGE
- DeriveDataTypeable
-#-}
-
module Main where
import Paths_ldgallery_compiler (version, getDataFileName)
--
cgit v1.2.3