Browse Source

Add footer

master
scratchyone 2 months ago
parent
commit
f7387fe213
No known key found for this signature in database GPG Key ID: 6D7D2C6860A90C02
3 changed files with 31 additions and 3 deletions
  1. +23
    -1
      app/Main.hs
  2. +4
    -2
      static/style.css
  3. +4
    -0
      template.html

+ 23
- 1
app/Main.hs View File

@ -1,7 +1,9 @@
module Main where
import Data.Char (isDigit)
import Data.Functor.Identity (Identity)
import Data.String.Utils
import GHC.OldList (intercalate)
import Shelly (cp_r, shelly)
import System.Directory (canonicalizePath, createDirectory, listDirectory, removePathForcibly)
import System.FilePath.Posix
@ -140,16 +142,36 @@ getAbsDirectoryContents dir =
processManpage :: FilePath -> IO ()
processManpage path = do
files <- getAbsDirectoryContents "manpages"
markdown <- readFile path
template <- readFile "template.html"
let groups = fromRight' $ parse manpage path markdown
print groups
let html = generateHTML groups
let combined = replace "{{maincontent}}" html template
let combined = replace "{{footer}}" (genFooter files) (replace "{{maincontent}}" html template)
-- Write file to out/name.html
let outPath = replaceDirectory (path -<.> "html") "out"
writeFile outPath combined
genFooter :: [FilePath] -> String
genFooter x = intercalate ", " (map genFooterItem x)
genFooterItem :: FilePath -> String
genFooterItem item = do
let name = takeFileName item
let base =
parse
( do
n <- many1Till letter (char '.')
v <- many1 digit
return $ Link n (read v)
)
"name"
name
generateHTMLBlock $ fromRight' base
main :: IO ()
main = do
-- Prepare output directory


+ 4
- 2
static/style.css View File

@ -5,7 +5,8 @@ body {
}
main,
header {
header,
footer {
padding: 16px;
padding-top: 32px;
margin: auto;
@ -33,7 +34,8 @@ nav > a:hover {
background-color: #999;
}
header {
header,
main {
margin-bottom: 12px;
}
pre,


+ 4
- 0
template.html View File

@ -14,5 +14,9 @@
</nav>
</header>
<main>{{maincontent}}</main>
<footer>
<h2>Pages</h2>
{{footer}}
</footer>
</body>
</html>

Loading…
Cancel
Save