extra rss items for big updates
This commit is contained in:
parent
7328346502
commit
9ee9b17526
2 changed files with 21 additions and 10 deletions
|
@ -7,7 +7,7 @@ module Info
|
||||||
allImages, sfwImages, nsfwImages,
|
allImages, sfwImages, nsfwImages,
|
||||||
thumb, latestDateFor, latestYearFor,
|
thumb, latestDateFor, latestYearFor,
|
||||||
sfwLinks, nsfwLinks, sfwUpdates, nsfwUpdates,
|
sfwLinks, nsfwLinks, sfwUpdates, nsfwUpdates,
|
||||||
updatesFor, hasUpdatesFor, lastUpdateFor,
|
updatesFor, bigUpdatesFor, hasUpdatesFor, lastUpdateFor,
|
||||||
tagsFor, descFor, imagesFor, linksFor,
|
tagsFor, descFor, imagesFor, linksFor,
|
||||||
|
|
||||||
CompareKey (..), compareKeyFor, compareFor, sortFor,
|
CompareKey (..), compareKeyFor, compareFor, sortFor,
|
||||||
|
@ -182,6 +182,9 @@ updatesWith p i = mapMaybe (traverse $ filterNE p) i.updates
|
||||||
updatesFor :: Bool -> Info -> [(Date, NonEmpty Update)]
|
updatesFor :: Bool -> Info -> [(Date, NonEmpty Update)]
|
||||||
updatesFor nsfw = updatesWith \u -> nsfw || u.sfw
|
updatesFor nsfw = updatesWith \u -> nsfw || u.sfw
|
||||||
|
|
||||||
|
bigUpdatesFor :: Bool -> Info -> [(Date, NonEmpty Update)]
|
||||||
|
bigUpdatesFor nsfw = updatesWith \u -> not u.ignoreSort && (nsfw || u.sfw)
|
||||||
|
|
||||||
sfwUpdates, nsfwUpdates :: Info -> [(Date, NonEmpty Update)]
|
sfwUpdates, nsfwUpdates :: Info -> [(Date, NonEmpty Update)]
|
||||||
sfwUpdates = updatesWith (.sfw)
|
sfwUpdates = updatesWith (.sfw)
|
||||||
nsfwUpdates = updatesWith (.nsfw)
|
nsfwUpdates = updatesWith (.nsfw)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Info
|
||||||
import BuilderQQ
|
import BuilderQQ
|
||||||
|
|
||||||
import Data.List (sortBy, intersperse)
|
import Data.List (sortBy, intersperse)
|
||||||
import Data.Maybe (catMaybes)
|
import Data.Maybe (catMaybes, fromMaybe)
|
||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import qualified Data.Text as Strict
|
import qualified Data.Text as Strict
|
||||||
import qualified Data.Text.Lazy as Lazy
|
import qualified Data.Text.Lazy as Lazy
|
||||||
|
@ -41,21 +41,28 @@ make' root name ginfo@(GalleryInfo {title, desc, prefix}) output infos = [b|
|
||||||
where
|
where
|
||||||
link = [b|$root/$prefix|]
|
link = [b|$root/$prefix|]
|
||||||
nsfw = ginfo.nsfw
|
nsfw = ginfo.nsfw
|
||||||
items = map (uncurry $ makeItem root prefix nsfw) $
|
items = concatMap (uncurry $ makeItems root prefix nsfw) $
|
||||||
sortBy (flip (compareFor nsfw `on` snd)) $
|
sortBy (flip (compareFor nsfw `on` snd)) $
|
||||||
filter (not . (.unlisted) . snd) infos
|
filter (not . (.unlisted) . snd) infos
|
||||||
selflink = case output of
|
selflink = case output of
|
||||||
Nothing -> ""
|
Nothing -> ""
|
||||||
Just o -> [b|<atom:link href="$link/$o" rel="self" />|]
|
Just o -> [b|<atom:link href="$link/$o" rel="self" />|]
|
||||||
|
|
||||||
makeItem :: Strict.Text -> FilePath -> Bool -> FilePath -> Info -> Builder
|
makeItems :: Strict.Text -> FilePath -> Bool -> FilePath -> Info -> [Builder]
|
||||||
makeItem root prefix nsfw path info@(Info {title}) = [b|
|
makeItems root prefix nsfw path info =
|
||||||
|
makeItem root prefix nsfw path info Nothing :
|
||||||
|
map (makeItem root prefix nsfw path info . Just . fst)
|
||||||
|
(bigUpdatesFor nsfw info)
|
||||||
|
|
||||||
|
makeItem :: Strict.Text -> FilePath -> Bool -> FilePath ->
|
||||||
|
Info -> Maybe Date -> Builder
|
||||||
|
makeItem root prefix nsfw path info@(Info {title}) date = [b|
|
||||||
<item>
|
<item>
|
||||||
<title><![CDATA[$title$suffix]]></title>
|
<title><![CDATA[$title$suffix]]></title>
|
||||||
<link>$link</link>
|
<link>$link</link>
|
||||||
<guid>$link</guid>
|
<guid>$link$guidSuffix</guid>
|
||||||
<dc:creator><![CDATA[$creator]]></dc:creator>
|
<dc:creator><![CDATA[$creator]]></dc:creator>
|
||||||
<pubDate>$date</pubDate>
|
<pubDate>$dateStr</pubDate>
|
||||||
$body
|
$body
|
||||||
</item>
|
</item>
|
||||||
|]
|
|]
|
||||||
|
@ -70,8 +77,9 @@ makeItem root prefix nsfw path info@(Info {title}) = [b|
|
||||||
|
|
||||||
suffix = if null parts then ""
|
suffix = if null parts then ""
|
||||||
else " (" <> mconcat (intersperse ", " parts) <> ")"
|
else " (" <> mconcat (intersperse ", " parts) <> ")"
|
||||||
|
guidSuffix = maybe "" (("?" <>) . show) date
|
||||||
parts = catMaybes [o18, cnt, up]
|
parts = catMaybes [o18, cnt, up]
|
||||||
up = do guard $ hasUpdatesFor nsfw info; Just "updated"
|
up = "updated" <$ date
|
||||||
o18 = do guard $ nsfw && anyNsfw info; Just "🔞"
|
o18 = do guard $ nsfw && anyNsfw info; Just "🔞"
|
||||||
cnt = do let len = maybe 0 length $ allImages <$> imagesFor nsfw info
|
cnt = do let len = maybe 0 length $ allImages <$> imagesFor nsfw info
|
||||||
guard $ len /= 1; Just [b|$len images|]
|
guard $ len /= 1; Just [b|$len images|]
|
||||||
|
@ -81,7 +89,7 @@ makeItem root prefix nsfw path info@(Info {title}) = [b|
|
||||||
|
|
||||||
creator = maybe "niss" (.name) info.artist
|
creator = maybe "niss" (.name) info.artist
|
||||||
|
|
||||||
date = formatRSS $ latestDateFor nsfw info
|
dateStr = formatRSS $ fromMaybe info.date date
|
||||||
artist = ifJust info.artist \case
|
artist = ifJust info.artist \case
|
||||||
Artist name Nothing -> [b|<p>by $name|]
|
Artist name Nothing -> [b|<p>by $name|]
|
||||||
Artist name (Just url) -> [b|<p>by <a href="$url">$name</a>|]
|
Artist name (Just url) -> [b|<p>by <a href="$url">$name</a>|]
|
||||||
|
|
Loading…
Add table
Reference in a new issue