add artist field to info
This commit is contained in:
parent
984d2b85e7
commit
1029200b24
1 changed files with 15 additions and 0 deletions
|
@ -19,6 +19,7 @@ data Info =
|
|||
Info {
|
||||
date :: !Day,
|
||||
title :: !(Maybe Text),
|
||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||
tags :: ![Text],
|
||||
nsfwTags :: ![Text],
|
||||
description :: !(Maybe Text),
|
||||
|
@ -28,6 +29,13 @@ data Info =
|
|||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
data Artist =
|
||||
Artist {
|
||||
name :: !Text,
|
||||
url :: !(Maybe Text)
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
data Image =
|
||||
Image {
|
||||
label :: !Text,
|
||||
|
@ -49,6 +57,7 @@ instance FromYAML Info where
|
|||
parseYAML = YAML.withMap "info" \m ->
|
||||
Info <$> m .: "date"
|
||||
<*> m .:? "title"
|
||||
<*> m .:? "artist"
|
||||
<*> m .:? "tags" .!= []
|
||||
<*> m .:? "nsfwTags" .!= []
|
||||
<*> m .:? "description"
|
||||
|
@ -56,6 +65,12 @@ instance FromYAML Info where
|
|||
<*> m .: "thumb"
|
||||
<*> m .:? "links" .!= []
|
||||
|
||||
instance FromYAML Artist where
|
||||
parseYAML y = justName y <|> withUrl y where
|
||||
justName = YAML.withStr "name" \name -> pure $ Artist {name, url = Nothing}
|
||||
withUrl = YAML.withMap "full info" \m ->
|
||||
Artist <$> m .: "name" <*> m .:? "url"
|
||||
|
||||
instance FromYAML Image where
|
||||
parseYAML = labelledOptNsfw Image "path" "path"
|
||||
|
||||
|
|
Loading…
Reference in a new issue