Commit a9ecf320 authored by Nicolas Lenz's avatar Nicolas Lenz ❄️
Browse files

Remove old stuff

parent 3d20f843
Loading
Loading
Loading
Loading
+1 −38
Original line number Diff line number Diff line
@@ -35,37 +35,6 @@ save basePath = mapM_ $ \(path, output) -> do
getNavbarMeta :: [Navitem] -> MetaValue
getNavbarMeta navItems = MetaList $ map (\Navitem{..} -> MetaMap $ Map.fromList [("name", MetaString $ unpack navitemName), ("link", MetaString $ unpack navitemLink)]) navItems

{- -- | Extracts the main navbar links from the Pandocs of the pages.
navbarLinks :: [Pandoc] -> [(Text, FilePath)]
navbarLinks = (("Home", "index.html"):) . map (\pandoc -> (titleString pandoc, getFileName pandoc)) -}

{- writeFile :: (PandocMonad m, MonadIO m) => WriterOptions -> FilePath -> Pandoc -> m ()
writeFile options path pandoc = do
    liftIO $ do
        doesFileExist path >>= \case
            True -> fail "Can't create directory"
            _ -> return ()
        createDirectoryIfMissing True path
    output <- writeHtml5String options pandoc
    liftIO $ writeFileUtf8 (path </> "index.html") output -}

{- Whole processing pipeline
- Load config
- Load templates
- Load articles
- Load pages
- Generate navbar from config
- Generate home page
  - Extract dates from articles (how to sort articles from same day? Name? Additional attribute?)
  - Extract first paragraphs and titles
  - Sort and assemble them (how to handle many articles/multiple pages)
- Generate RSS feed
- [Generate category pages just like home page]
- Search? Embed DDG or something own using JS (maybe using the rss feed)?
- Process all files
- Save all files
-}

data Summary = Summary {
    summaryTitle :: MetaValue,
    summaryDate :: MetaValue,
@@ -73,12 +42,6 @@ data Summary = Summary {
    summaryContent :: MetaValue
} deriving Eq

instance Ord Summary where
    x <= y = summaryDate x < summaryDate y
        || (summaryDate x == summaryDate y && summaryTitle x < summaryTitle y)
        || (summaryDate x == summaryDate y && summaryTitle x == summaryTitle y && summaryLink x < summaryLink y)
        || (summaryDate x == summaryDate y && summaryTitle x == summaryTitle y && summaryLink x == summaryLink y && summaryContent x <= summaryContent y)

read :: (PandocMonad m) => Text -> m Pandoc
read = readMarkdown readerOptions where
    readerOptions = def {readerExtensions = pandocExtensions}
@@ -134,7 +97,7 @@ buildArticles templateArticle templateIndex navbar inputs = do
            return (path, contentW)

generateIndex :: Meta -> [(Path Rel File, Pandoc)] -> Pandoc
generateIndex extraMeta = generateIndex' extraMeta . sortOn Down . map (uncurry generateSummary) where
generateIndex extraMeta = generateIndex' extraMeta . sortOn (Down . summaryDate) . map (uncurry generateSummary) where
    generateIndex' :: Meta -> [Summary] -> Pandoc
    generateIndex' extraMeta summaries = Pandoc meta [] where
        meta = extraMeta <> Meta (Map.fromList [("pagetitle", MetaString "Home"), ("articles", MetaList articles)])