123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- (local header "<div id=\"preamble\" class=\"status\">
- <header id=\"banner\">
- <h1><a href=\"/home.html\">Kevin \"The Nuclear\" Bloom</a></h1>
- <hr />
- <nav><ul>
- <li><a href=\"/contact.html\">Contact</a></li>
- <li><a href=\"/blog.html\">Blog</a></li>
- <li><a href=\"/projects.html\">Projects</a></li>
- <li><a href=\"/about-me.html\">About Me</a></li>
- </ul></nav>
- </header>
- </div>
- ")
- (local footer "<div id=\"footer\">
- <hr />
- <a href=\"https://anybrowser.org/campaign/\">
- <img src=\"/img/any-browser.png\" alt=\"Viewable with any browser! No JS, no cookies, no bullshit!\" />
- </a>
- <p>
- Copyright © 2017-2020 Kevin \"The Nuclear\" Bloom
- </p>
- </div>
- ")
- (fn top-stuff [title]
- (..
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>
- <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
- \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
- <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
- <head>
- "
- title
- "<link rel=\"shortcut icon\" type=\"image/png\" href=\"/img/guy-in-space.png\"/>
- <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />
- <meta name=\"generator\" content=\"Org mode\" />
- <meta name=\"author\" content=\"Kevin "The Nuclear" Bloom\" />
- <link rel='stylesheet' href='/styles/main.css' />
- </head>
- "))
- ;; -- From my str.fnl lib -----------------------
- (fn drop [s ind]
- (string.sub s ind))
- (fn take [s ind]
- (string.sub s 1 ind))
- (fn substring-between [s fir lst]
- "Returns a substring of S defined by 2 strings, FIR and LST.
- The benefit of this is that if there are other instances of LST before the
- instance you want, they won't get caught.
- I.e.: You wish to get the value of the second line of \"this \n is a \n test\",
- You would just use (string-between str \"is a\" \"\n\")"
- (let [fir-pos (string.find s fir)
- up-to-fir (drop s fir-pos)
- lst-pos (string.find up-to-fir lst)]
- (take up-to-fir lst-pos)))
- ;; -- end -----------------------------------------
- (fn generate-page [file-name]
- (let [file-port (io.open file-name "r")
- full-file (file-port:read "*a")
- title (.. (substring-between full-file "<title>" "</title>") "/title>\n")
- body (substring-between full-file "<body>" "\n</body>")]
- (file-port:close)
- (print (.. (top-stuff title)
- header
- body
- footer
- "</body>\n"
- "</html>"))))
- (generate-page (. arg 1))
|