Skip to content

Instantly share code, notes, and snippets.

@SoulFireMage
Created January 13, 2016 13:53
Show Gist options
  • Save SoulFireMage/6d52d7a75c49038e670c to your computer and use it in GitHub Desktop.
Save SoulFireMage/6d52d7a75c49038e670c to your computer and use it in GitHub Desktop.
World's most basic HTML blog generator.
//Might be the world's simplest HTML page generator, however, I got fedup of tracking all the markup I needed to make one of my typical pages.
let NL = System.Environment.NewLine
let Tab = " "
[<Literal>]
let head = """<!--Template for blog -->
<!DOCTYPE html5>
<html>
<head>
<!-- Painstakingly hand written using VSCode, BlueGriffon and Stylizer -->
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>Advent 2015 - Monogame SnowFlakes</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" media="screen">
<link type="text/css" rel="stylesheet" href="css/lesson.css">
<link type="text/css" rel="stylesheet" href="css/main.css">
</head>
<body>
"""
let tail = """
</body>
</html>"""
let navBox = """
<!--Navigation-->
<div class="box">
<nav class="navbar navbar-full navbar-dark bg-inverse">
<ul class="nav navbar-nav">
<li class="nav-item"> <a class="nav-link" href="index.html"><img src="images/RightAktarian75.jpg"/>Home<img src="images/LeftAktarian75.jpg"/></a></li>
</ul>
</nav>
</div>
<!--End Navigation-->
"""
let titleBox = """
<!--Title-->
<div class="box" id="Top">
<div class="row row-centered">
<div class="col-xs-3 col-centered" align="center"> <img src="images/RightAktarian75.jpg"> </div>
<div class="col-xs-6 col-centered" align="center">
<h3>Title Here</h3>
</div>
<div class="col-xs-3 col-centered" align="center"> <img src="images/LeftAktarian75.jpg"> </div>
</div>
</div>
<!--end Title-->
"""
let navToTopLink = NL + Tab + """<div class="col-xs-12 col-centered" align="right"><a href="#Top">Top</a></div>""" + NL
let commenter counter = """<!-- Begin Section """ + counter + """-->""" + NL
let divBox s index = commenter (index.ToString()) + """<div class="box-black">""" + NL + Tab + s + navToTopLink + """</div>"""
let endComment = NL + """<!-- End section -->""" + NL
//Add content here: each section can have full html markup.
let box1 = """Section Content"""
let box2 = """Section Content"""
let box3 = """Section Content"""
let box4 = """Section Content"""
let box5 = """Section Content"""
let box6 = """Section Content"""
let allBoxs = [box1;box2;box3;box4;box5;box6]|>List.mapi(fun s a -> (a , s)) |> List.fold(fun a x -> let content, index = x
a + NL + divBox content index + endComment) ""
let finalPage = head + navBox + titleBox + allBoxs + tail
printfn "%A" finalPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment