Use the site name in opengraph tags
…which involves passing around the index file to a lot more places
This commit is contained in:
parent
73cd0ca74e
commit
f51ea184bb
5 changed files with 45 additions and 31 deletions
20
Makefile
20
Makefile
|
@ -147,17 +147,19 @@ endef
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# 1. gallery prefix
|
# 1. gallery prefix
|
||||||
# 2. build dir
|
# 2. index filename
|
||||||
# 3. data dir
|
# 3. build dir
|
||||||
# 4. other flags
|
# 4. data dir
|
||||||
|
# 5. other flags
|
||||||
define depend-single
|
define depend-single
|
||||||
echo "[deps] "$@
|
echo "[deps] "$@
|
||||||
mkdir -p "$(dir $@)"
|
mkdir -p "$(dir $@)"
|
||||||
$(MAKEPAGES) $(MPFLAGS) depend-single $(4) \
|
$(MAKEPAGES) $(MPFLAGS) depend-single $(5) \
|
||||||
--output "$@" \
|
--output "$@" \
|
||||||
--prefix "$(1)" \
|
--prefix "$(1)" \
|
||||||
--build-dir "$(2)" \
|
--index "$(2)" \
|
||||||
--data-dir "$(3)" $<
|
--build-dir "$(3)" \
|
||||||
|
--data-dir "$(4)" $<
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# args
|
# args
|
||||||
|
@ -178,14 +180,16 @@ endef
|
||||||
# args:
|
# args:
|
||||||
# 1. data dir
|
# 1. data dir
|
||||||
# 2. gallery prefix
|
# 2. gallery prefix
|
||||||
# 3. other flags
|
# 3. index file
|
||||||
|
# 4. other flags
|
||||||
define single
|
define single
|
||||||
echo "[single] "$@
|
echo "[single] "$@
|
||||||
mkdir -p "$(dir $@)"
|
mkdir -p "$(dir $@)"
|
||||||
$(MAKEPAGES) $(MPFLAGS) single $(3) \
|
$(MAKEPAGES) $(MPFLAGS) single $(4) \
|
||||||
--root $(ROOT) \
|
--root $(ROOT) \
|
||||||
--data-dir "$(1)" \
|
--data-dir "$(1)" \
|
||||||
--prefix "$(2)" \
|
--prefix "$(2)" \
|
||||||
|
--index "$(3)" \
|
||||||
--output "$@" \
|
--output "$@" \
|
||||||
$<
|
$<
|
||||||
endef
|
endef
|
||||||
|
|
|
@ -13,17 +13,19 @@ import System.FilePath
|
||||||
|
|
||||||
|
|
||||||
dependSingle :: FilePath -- ^ yaml file name (relative to data dir!)
|
dependSingle :: FilePath -- ^ yaml file name (relative to data dir!)
|
||||||
|
-> FilePath -- ^ index file name
|
||||||
-> Info
|
-> Info
|
||||||
-> FilePath -- ^ output prefix
|
-> FilePath -- ^ output prefix
|
||||||
-> FilePath -- ^ build dir
|
-> FilePath -- ^ build dir
|
||||||
-> Bool -- ^ include nsfw?
|
-> Bool -- ^ include nsfw?
|
||||||
-> Text
|
-> Text
|
||||||
dependSingle yamlDir info prefix build nsfw =
|
dependSingle yamlDir indexFile info prefix build nsfw =
|
||||||
toLazyText $ dependSingle' yamlDir info prefix build nsfw
|
toLazyText $ dependSingle' yamlDir indexFile info prefix build nsfw
|
||||||
|
|
||||||
dependSingle' :: FilePath -> Info -> FilePath -> FilePath -> Bool -> Builder
|
dependSingle' :: FilePath -> FilePath -> Info -> FilePath -> FilePath -> Bool
|
||||||
dependSingle' yamlDir info prefix build nsfw =
|
-> Builder
|
||||||
[b|$page: $deps $$(MAKEPAGES)|]
|
dependSingle' yamlDir indexFile info prefix build nsfw =
|
||||||
|
[b|$page: $deps $indexFile $$(MAKEPAGES)|]
|
||||||
where
|
where
|
||||||
images = #all if nsfw then #images info else #sfwImages info
|
images = #all if nsfw then #images info else #sfwImages info
|
||||||
|
|
||||||
|
@ -79,24 +81,25 @@ dependGallery' (GalleryInfo {prefix, filters})
|
||||||
gallery = build </> prefix </> "index.html"
|
gallery = build </> prefix </> "index.html"
|
||||||
rss = build </> prefix </> "rss.xml"
|
rss = build </> prefix </> "rss.xml"
|
||||||
|
|
||||||
rules = makeRules prefix filters build data_ tmp
|
rules = makeRules prefix indexFile filters build data_ tmp
|
||||||
|
|
||||||
inc d = tmp </> prefix </> takeDirectory d <.> "mk"
|
inc d = tmp </> prefix </> takeDirectory d <.> "mk"
|
||||||
incFiles = unwords $ map inc files
|
incFiles = unwords $ map inc files
|
||||||
incs = if null infos then "" else [b|include $incFiles|]
|
incs = if null infos then "" else [b|include $incFiles|]
|
||||||
|
|
||||||
makeRules :: FilePath -- ^ prefix
|
makeRules :: FilePath -- ^ prefix
|
||||||
|
-> FilePath -- ^ index file
|
||||||
-> GalleryFilters
|
-> GalleryFilters
|
||||||
-> FilePath -- ^ build dir
|
-> FilePath -- ^ build dir
|
||||||
-> FilePath -- ^ data dir
|
-> FilePath -- ^ data dir
|
||||||
-> FilePath -- ^ tmp dir
|
-> FilePath -- ^ tmp dir
|
||||||
-> Builder
|
-> Builder
|
||||||
makeRules prefix filters build data_ tmp = [b|@0
|
makeRules prefix indexFile filters build data_ tmp = [b|@0
|
||||||
$buildPrefix/%/index.html: $data_/%/info.yaml $$(MAKEPAGES)
|
$buildPrefix/%/index.html: $data_/%/info.yaml $$(MAKEPAGES)
|
||||||
$$(call single,$data_,$prefix,$flags)
|
$$(call single,$data_,$prefix,$indexFile,$flags)
|
||||||
|
|
||||||
$tmpPrefix/%.mk: $data_/%/info.yaml $$(MAKEPAGES)
|
$tmpPrefix/%.mk: $data_/%/info.yaml $$(MAKEPAGES)
|
||||||
$$(call depend-single,$prefix,$build,$data_,$flags)
|
$$(call depend-single,$prefix,$indexFile,$build,$data_,$flags)
|
||||||
|
|
||||||
$buildPrefix/%: $tmp/%
|
$buildPrefix/%: $tmp/%
|
||||||
$$(call copy,-l)
|
$$(call copy,-l)
|
||||||
|
|
|
@ -47,11 +47,12 @@ main = do
|
||||||
main2 mode
|
main2 mode
|
||||||
|
|
||||||
main2 :: HasVerbose => ModeOptions -> IO ()
|
main2 :: HasVerbose => ModeOptions -> IO ()
|
||||||
main2 (SinglePage {root, file, prefix, dataDir, nsfw, output}) = do
|
main2 (SinglePage {root, file, prefix, index, dataDir, nsfw, output}) = do
|
||||||
|
siteName <- #title <$> readYAML @IndexInfo index
|
||||||
info <- readYAML file
|
info <- readYAML file
|
||||||
printV $ "contents" := info
|
printV $ "contents" := info
|
||||||
let dir = takeDirectory $ makeRelative dataDir file
|
let dir = takeDirectory $ makeRelative dataDir file
|
||||||
page <- SinglePage.make root prefix nsfw dataDir dir info
|
page <- SinglePage.make root siteName prefix nsfw dataDir dir info
|
||||||
writeOutput output page
|
writeOutput output page
|
||||||
|
|
||||||
main2 (GalleryPage {root, files, prefix, index, output, dataDir}) = do
|
main2 (GalleryPage {root, files, prefix, index, output, dataDir}) = do
|
||||||
|
@ -77,12 +78,12 @@ main2 (RSS {files, root, index, prefix, output, dataDir}) = do
|
||||||
let rss = RSS.make root ginfo output' infos
|
let rss = RSS.make root ginfo output' infos
|
||||||
writeOutput output rss
|
writeOutput output rss
|
||||||
|
|
||||||
main2 (DependSingle {file, nsfw, output, prefix, buildDir, dataDir}) = do
|
main2 (DependSingle {index, file, nsfw, output, prefix, buildDir, dataDir}) = do
|
||||||
info <- readYAML file
|
info <- readYAML file
|
||||||
printV $ "contents" := info
|
printV $ "contents" := info
|
||||||
let dir = takeDirectory $ makeRelative dataDir file
|
let dir = takeDirectory $ makeRelative dataDir file
|
||||||
printV $ "dir" := dir
|
printV $ "dir" := dir
|
||||||
let deps = dependSingle dir info prefix buildDir nsfw
|
let deps = dependSingle dir index info prefix buildDir nsfw
|
||||||
writeOutput output deps
|
writeOutput output deps
|
||||||
|
|
||||||
main2 (DependGallery {file, output, buildDir, dataDir, tmpDir, infoName}) = do
|
main2 (DependGallery {file, output, buildDir, dataDir, tmpDir, infoName}) = do
|
||||||
|
|
|
@ -15,6 +15,7 @@ data ModeOptions =
|
||||||
root :: Text,
|
root :: Text,
|
||||||
file :: FilePath,
|
file :: FilePath,
|
||||||
prefix :: FilePath,
|
prefix :: FilePath,
|
||||||
|
index :: FilePath,
|
||||||
dataDir :: FilePath,
|
dataDir :: FilePath,
|
||||||
nsfw :: Bool,
|
nsfw :: Bool,
|
||||||
output :: Maybe FilePath
|
output :: Maybe FilePath
|
||||||
|
@ -45,6 +46,7 @@ data ModeOptions =
|
||||||
nsfw :: Bool,
|
nsfw :: Bool,
|
||||||
output :: Maybe FilePath,
|
output :: Maybe FilePath,
|
||||||
prefix :: FilePath,
|
prefix :: FilePath,
|
||||||
|
index :: FilePath,
|
||||||
buildDir :: FilePath,
|
buildDir :: FilePath,
|
||||||
dataDir :: FilePath
|
dataDir :: FilePath
|
||||||
}
|
}
|
||||||
|
@ -80,7 +82,8 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
|
|
||||||
single = command "single" $ singleOpts `info` singleInfo
|
single = command "single" $ singleOpts `info` singleInfo
|
||||||
singleOpts =
|
singleOpts =
|
||||||
SinglePage <$> root <*> file <*> prefix <*> dataDir <*> nsfwS <*> output
|
SinglePage <$> root <*> file <*> prefix <*> indexFile
|
||||||
|
<*> dataDir <*> nsfwS <*> output
|
||||||
root = strOption $
|
root = strOption $
|
||||||
short 'R' <> long "root" <> metavar "URL" <>
|
short 'R' <> long "root" <> metavar "URL" <>
|
||||||
help "website root (no trailing slash)"
|
help "website root (no trailing slash)"
|
||||||
|
@ -90,6 +93,9 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
short 'p' <> long "prefix" <> metavar "DIR" <>
|
short 'p' <> long "prefix" <> metavar "DIR" <>
|
||||||
value "" <>
|
value "" <>
|
||||||
help "gallery directory prefix"
|
help "gallery directory prefix"
|
||||||
|
indexFile = strOption $
|
||||||
|
short 'i' <> long "index" <> metavar "FILE" <>
|
||||||
|
help "path to index file"
|
||||||
nsfwS = switch $
|
nsfwS = switch $
|
||||||
short 'n' <> long "nsfw" <>
|
short 'n' <> long "nsfw" <>
|
||||||
help "include nsfw versions"
|
help "include nsfw versions"
|
||||||
|
@ -107,9 +113,6 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
galleryOpts =
|
galleryOpts =
|
||||||
GalleryPage <$> root <*> files <*> prefix
|
GalleryPage <$> root <*> files <*> prefix
|
||||||
<*> indexFile <*> output <*> dataDir
|
<*> indexFile <*> output <*> dataDir
|
||||||
indexFile = strOption $
|
|
||||||
short 'i' <> long "index" <> metavar "FILE" <>
|
|
||||||
help "path to index file"
|
|
||||||
files = many $ strArgument $
|
files = many $ strArgument $
|
||||||
metavar "FILE..." <> help "yaml files to read"
|
metavar "FILE..." <> help "yaml files to read"
|
||||||
galleryInfo = progDesc "generate a gallery page"
|
galleryInfo = progDesc "generate a gallery page"
|
||||||
|
@ -122,7 +125,7 @@ optionsParser = globalOpts `info` mainInfo where
|
||||||
dependSingle = command "depend-single" $ dsOpts `info` dsInfo
|
dependSingle = command "depend-single" $ dsOpts `info` dsInfo
|
||||||
dsOpts =
|
dsOpts =
|
||||||
DependSingle <$> file <*> nsfwS <*> output <*> prefix
|
DependSingle <$> file <*> nsfwS <*> output <*> prefix
|
||||||
<*> buildDir <*> dataDir
|
<*> indexFile <*> buildDir <*> dataDir
|
||||||
buildDir = strOption $
|
buildDir = strOption $
|
||||||
short 'B' <> long "build-dir" <> metavar "DIR" <> value "_build" <>
|
short 'B' <> long "build-dir" <> metavar "DIR" <> value "_build" <>
|
||||||
help "build directory (default: _build)"
|
help "build directory (default: _build)"
|
||||||
|
|
|
@ -28,16 +28,19 @@ instance Show NoEligibleImages where
|
||||||
|
|
||||||
|
|
||||||
make :: Text -- ^ website root
|
make :: Text -- ^ website root
|
||||||
|
-> Text -- ^ website name
|
||||||
-> FilePath -- ^ gallery prefix
|
-> FilePath -- ^ gallery prefix
|
||||||
-> Bool -- ^ nsfw?
|
-> Bool -- ^ nsfw?
|
||||||
-> FilePath -- ^ data dir
|
-> FilePath -- ^ data dir
|
||||||
-> FilePath -- ^ subdir of datadir containing this @info.yaml@
|
-> FilePath -- ^ subdir of datadir containing this @info.yaml@
|
||||||
-> Info -> IO Lazy.Text
|
-> Info -> IO Lazy.Text
|
||||||
make root prefix nsfw dataDir dir info =
|
make root siteName prefix nsfw dataDir dir info =
|
||||||
toLazyText <$> make' root prefix nsfw dataDir dir info
|
toLazyText <$> make' root siteName prefix nsfw dataDir dir info
|
||||||
|
|
||||||
make' :: Text -> FilePath -> Bool -> FilePath -> FilePath -> Info -> IO Builder
|
make' :: Text -> Text -> FilePath -> Bool -> FilePath -> FilePath -> Info
|
||||||
make' root prefix nsfw _dataDir dir info@(Info {date, title, artist, bg}) = do
|
-> IO Builder
|
||||||
|
make' root siteName prefix nsfw _dataDir dir
|
||||||
|
info@(Info {date, title, artist, bg}) = do
|
||||||
let images = imagesFor nsfw info
|
let images = imagesFor nsfw info
|
||||||
|
|
||||||
let undir = joinPath (replicate (length (splitPath dir)) "..")
|
let undir = joinPath (replicate (length (splitPath dir)) "..")
|
||||||
|
@ -104,7 +107,7 @@ make' root prefix nsfw _dataDir dir info@(Info {date, title, artist, bg}) = do
|
||||||
|
|
||||||
<meta property=og:type content=og:website>
|
<meta property=og:type content=og:website>
|
||||||
<meta property=og:title content="$title">
|
<meta property=og:title content="$title">
|
||||||
<meta property=og:site_name content="$title">
|
<meta property=og:site_name content="$siteName">
|
||||||
<meta property=og:description content="$desc">
|
<meta property=og:description content="$desc">
|
||||||
<meta property=og:image content="$url/$thumb">
|
<meta property=og:image content="$url/$thumb">
|
||||||
<meta property=og:url content="$url">
|
<meta property=og:url content="$url">
|
||||||
|
|
Loading…
Reference in a new issue