Mercurial > codedump
comparison generatehtml.py @ 87:4271918c4561
Update generatehtml.py
committer: GitHub <noreply@github.com>
| author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
|---|---|
| date | Thu, 28 Jul 2022 19:53:49 -0400 |
| parents | fe7933e0bf13 |
| children | 4b8fd5492092 |
comparison
equal
deleted
inserted
replaced
| 86:fe7933e0bf13 | 87:4271918c4561 |
|---|---|
| 2 | 2 |
| 3 import os | 3 import os |
| 4 import sys | 4 import sys |
| 5 import html | 5 import html |
| 6 | 6 |
| 7 title = "Paper's blog" | 7 title = "Blog - Paper's website" |
| 8 | 8 |
| 9 def addtitle(out_str, title): | 9 def addtitle(out_str, title): |
| 10 # add stuff here | 10 # add stuff here |
| 11 # The title in question: | 11 # The title in question: |
| 12 out_str += """ <div class="entry">\n <h1>%s</h1>\n <pre>\n""" % html.escape(title.strip()) | 12 out_str += """ <div class="entry">\n <h1>%s</h1>\n <div class="pre">\n""" % html.escape(title.strip()) |
| 13 return out_str | 13 return out_str |
| 14 | 14 |
| 15 def main(argv): | 15 def main(argv): |
| 16 file = open(argv[1], 'r') | 16 file = open(argv[1], 'r') |
| 17 out = open(argv[2], 'w') | 17 out = open(argv[2], 'w') |
| 19 """<!DOCTYPE html> | 19 """<!DOCTYPE html> |
| 20 <head> | 20 <head> |
| 21 <title>%s</title> | 21 <title>%s</title> |
| 22 <meta name="viewport" content="width=device-width;initial-scale=1.0" /> | 22 <meta name="viewport" content="width=device-width;initial-scale=1.0" /> |
| 23 <link rel="stylesheet" type="text/css" href="blog.css" /> | 23 <link rel="stylesheet" type="text/css" href="blog.css" /> |
| 24 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" media="screen"> | |
| 24 </head> | 25 </head> |
| 25 <body> | 26 <body> |
| 27 <div class="navbar-wrapper"> | |
| 28 <div class="container-fluid" style="width: 98%%;margin-top:1%%;"> | |
| 29 <div class="navbar navbar-inverse" style="box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5)"> | |
| 30 <div class="navbar-inner"> | |
| 31 <a class="brand" href="#">Paper's website</a> | |
| 32 <ul class="nav"> | |
| 33 <li><a href="../">Home</a></li> | |
| 34 <li><a href="../music.html">Music</a></li> | |
| 35 <li><a href="../projects.html">Projects</a></li> | |
| 36 <li class="active"><a href="#">Blog</a></li> | |
| 37 </ul> | |
| 38 </div> | |
| 39 </div> | |
| 40 </div> | |
| 41 </div> | |
| 26 """ % (title)) | 42 """ % (title)) |
| 27 lines = file.readlines() | 43 lines = file.readlines() |
| 28 for line in range(len(lines)): | 44 for line in range(len(lines)): |
| 29 if lines[line][0] == "#": | 45 if lines[line][0] == "#": |
| 30 out_str = addtitle(out_str, lines[line][1:]) | 46 out_str = addtitle(out_str, lines[line][1:]) |
| 31 continue | 47 continue |
| 32 # this sucks. | 48 # this sucks. |
| 33 if lines[line][0:3] == "---": | 49 if lines[line][0:3] == "---": |
| 34 out_str += " </pre>\n </div>\n" | 50 out_str += " </div>\n </div>\n" |
| 35 continue | 51 continue |
| 36 out_str += """%s\n""" % html.escape(lines[line].strip()) | 52 out_str += """%s\n""" % html.escape(lines[line].strip()) |
| 37 out_str += "</body>" | 53 out_str += "</body>" |
| 38 print(out_str, file=out) | 54 print(out_str, file=out) |
| 39 | 55 |
