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 {
|
Info {
|
||||||
date :: !Day,
|
date :: !Day,
|
||||||
title :: !(Maybe Text),
|
title :: !(Maybe Text),
|
||||||
|
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||||
tags :: ![Text],
|
tags :: ![Text],
|
||||||
nsfwTags :: ![Text],
|
nsfwTags :: ![Text],
|
||||||
description :: !(Maybe Text),
|
description :: !(Maybe Text),
|
||||||
|
@ -28,6 +29,13 @@ data Info =
|
||||||
}
|
}
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
data Artist =
|
||||||
|
Artist {
|
||||||
|
name :: !Text,
|
||||||
|
url :: !(Maybe Text)
|
||||||
|
}
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data Image =
|
data Image =
|
||||||
Image {
|
Image {
|
||||||
label :: !Text,
|
label :: !Text,
|
||||||
|
@ -49,6 +57,7 @@ instance FromYAML Info where
|
||||||
parseYAML = YAML.withMap "info" \m ->
|
parseYAML = YAML.withMap "info" \m ->
|
||||||
Info <$> m .: "date"
|
Info <$> m .: "date"
|
||||||
<*> m .:? "title"
|
<*> m .:? "title"
|
||||||
|
<*> m .:? "artist"
|
||||||
<*> m .:? "tags" .!= []
|
<*> m .:? "tags" .!= []
|
||||||
<*> m .:? "nsfwTags" .!= []
|
<*> m .:? "nsfwTags" .!= []
|
||||||
<*> m .:? "description"
|
<*> m .:? "description"
|
||||||
|
@ -56,6 +65,12 @@ instance FromYAML Info where
|
||||||
<*> m .: "thumb"
|
<*> m .: "thumb"
|
||||||
<*> m .:? "links" .!= []
|
<*> 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
|
instance FromYAML Image where
|
||||||
parseYAML = labelledOptNsfw Image "path" "path"
|
parseYAML = labelledOptNsfw Image "path" "path"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue