add more details (and the image‼) to rss
This commit is contained in:
parent
969cdc938d
commit
fa0b826c26
5 changed files with 69 additions and 45 deletions
|
@ -8,6 +8,7 @@ import Data.List (intersperse)
|
|||
import qualified Data.List as List
|
||||
import Data.Text.Lazy (Text)
|
||||
import Data.Text.Lazy.Builder (toLazyText)
|
||||
import qualified Data.Text as Strict
|
||||
import qualified Data.Text.Lazy.IO as Text
|
||||
import qualified Data.YAML as YAML
|
||||
import System.FilePath (makeRelative, takeDirectory, takeFileName)
|
||||
|
@ -56,7 +57,7 @@ main2 (SinglePage {root, file, prefix, index, dataDir, nsfw, output}) = do
|
|||
writeOutput output page
|
||||
|
||||
main2 (GalleryPage {root, files, prefix, index, output, dataDir}) = do
|
||||
ginfo <- galleryFromIndex index prefix
|
||||
(_, ginfo) <- galleryFromIndex index prefix
|
||||
printV $ "gallery_info" := ginfo
|
||||
infos <- mapM (infoYAML dataDir) files
|
||||
printV $ "infos" := infos
|
||||
|
@ -70,12 +71,12 @@ main2 (IndexPage {root, file, output}) = do
|
|||
writeOutput output page
|
||||
|
||||
main2 (RSS {files, root, index, prefix, output, dataDir}) = do
|
||||
ginfo <- galleryFromIndex index prefix
|
||||
(name, ginfo) <- galleryFromIndex index prefix
|
||||
printV $ "gallery_info" := ginfo
|
||||
infos <- mapM (infoYAML dataDir) files
|
||||
printV $ "infos" := infos
|
||||
let output' = takeFileName <$> output
|
||||
let rss = RSS.make root ginfo output' infos
|
||||
let rss = RSS.make root name ginfo output' infos
|
||||
writeOutput output rss
|
||||
|
||||
main2 (DependSingle {index, file, nsfw, output, prefix, buildDir, dataDir}) = do
|
||||
|
@ -117,10 +118,10 @@ findInfos dataDir infoName =
|
|||
readYAML :: YAML.FromYAML a => FilePath -> IO a
|
||||
readYAML file = ByteString.readFile file >>= decode1Must file
|
||||
|
||||
galleryFromIndex :: FilePath -> FilePath -> IO GalleryInfo
|
||||
galleryFromIndex :: FilePath -> FilePath -> IO (Strict.Text, GalleryInfo)
|
||||
galleryFromIndex file prefix = do
|
||||
IndexInfo {galleries} <- readYAML file
|
||||
maybe (fail $ "no gallery with prefix " ++ prefix) pure $
|
||||
IndexInfo {title, galleries} <- readYAML file
|
||||
maybe (fail $ "no gallery with prefix " ++ prefix) (pure . (title,)) $
|
||||
List.find (\g -> g.prefix == prefix) galleries
|
||||
|
||||
decode1Must :: YAML.FromYAML a => FilePath -> ByteString -> IO a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue