From a4425869ea15234fee79b7d1219a3bea7ffb23a2 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 25 Jun 2021 12:03:55 +0200 Subject: license: make it more obvious for end users --- compiler/app/Main.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/app/Main.hs') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index e71e0db..dc97b38 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-2020 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2021 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 @@ -94,6 +94,7 @@ options = Options } &= summary ("ldgallery v" ++ showVersion version ++ " - a static web gallery generator with tags") + &= details ["This software is distributed under the terms of the GNU Affero General Public License v3.0."] &= program "ldgallery" &= help "Compile a gallery" &= helpArg [explicit, name "h", name "help"] -- cgit v1.2.3 From 671a372d87ff8311956f9158e8885ffc254fe1bc Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 29 Jun 2021 13:14:14 +0200 Subject: compiler: add "portable" target This adds a build flag for generating a portable version of the compiler binary which make it look in its own runtime directory for its assets. This is useful in particular for the portable release tarballs which contain the web viewer at the same location instead of a pre-defined one in the FHS. GitHub: closes #286 --- compiler/app/Main.hs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'compiler/app/Main.hs') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index dc97b38..3e6f254 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -19,7 +19,7 @@ module Main where import GHC.Generics (Generic) -import Paths_ldgallery_compiler (version, getDataFileName) +import Paths_ldgallery_compiler (version) import Control.Monad (when) import Data.Functor ((<&>)) import Data.Maybe (isJust) @@ -31,7 +31,7 @@ import System.Console.CmdArgs import Compiler import Files (readDirectory, copyTo, remove) - +import ViewerDist (viewerDistPath) newtype ViewerConfig = ViewerConfig { galleryRoot :: String @@ -106,10 +106,7 @@ main = do opts <- cmdArgs options buildGallery opts - - when (isJust $ withViewer opts) $ do - viewerDist <- viewerDistPath $ withViewer opts - deployViewer viewerDist opts + deployViewer opts where gallerySubdir :: String @@ -118,11 +115,6 @@ main = viewerConfig :: ViewerConfig viewerConfig = ViewerConfig (gallerySubdir ++ "/") - viewerDistPath :: Maybe FilePath -> IO FilePath - viewerDistPath (Just "") = getDataFileName "viewer" - viewerDistPath (Just dist) = return dist - viewerDistPath Nothing = fail "No viewer distribution" - buildGallery :: Options -> IO () buildGallery opts = checkDistinctPaths (inputDir opts) (outputDir opts) @@ -146,10 +138,11 @@ main = | isJust withViewer = outputDir gallerySubdir | otherwise = outputDir - deployViewer :: FilePath -> Options -> IO () - deployViewer distPath Options{outputDir, cleanOutput} = + deployViewer :: Options -> IO () + deployViewer Options{withViewer = Nothing} = pure () + deployViewer Options{withViewer = Just viewerPath, outputDir, cleanOutput} = when cleanOutput (cleanViewerDir outputDir) - >> copyViewer distPath outputDir + >> viewerDistOr viewerPath >>= deployTo outputDir >> writeJSON (outputDir "config.json") viewerConfig where @@ -159,8 +152,12 @@ main = <&> filter (/= gallerySubdir) >>= mapM_ (remove . (target )) - copyViewer :: FilePath -> FilePath -> IO () - copyViewer dist target = + viewerDistOr :: FilePath -> IO FilePath + viewerDistOr "" = viewerDistPath + viewerDistOr custom = pure custom + + deployTo :: FilePath -> FilePath -> IO () + deployTo target dist = putStrLn "Copying viewer webapp" >> readDirectory dist >>= copyTo target -- cgit v1.2.3