Added index page and index page generator for all solutions.
This commit is contained in:
0
html/EulerProblem001.html
Executable file → Normal file
0
html/EulerProblem001.html
Executable file → Normal file
11696
html/EulerProblem002.html
Executable file → Normal file
11696
html/EulerProblem002.html
Executable file → Normal file
File diff suppressed because one or more lines are too long
29
html/render.py
Normal file
29
html/render.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import jinja2
|
||||
import os
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
def file_name_to_solution(name):
|
||||
number = int(name.replace("EulerProblem", "").replace(".html", ""))
|
||||
file_name = name
|
||||
display_name = name.replace("EulerProblem", "Problem ").replace(".html", "")
|
||||
return (number, file_name, display_name)
|
||||
|
||||
|
||||
def get_solution_list(directory="./"):
|
||||
l = [file_name_to_solution(f) for f in os.listdir(directory)
|
||||
if f.endswith(".html") and f.startswith("EulerProblem")]
|
||||
l.sort(key=itemgetter(0))
|
||||
return l
|
||||
|
||||
|
||||
def render_solutions(solutions):
|
||||
loader = jinja2.FileSystemLoader(searchpath="./")
|
||||
env = jinja2.Environment(loader=loader)
|
||||
template = env.get_template("template.html")
|
||||
d = {"solutions": solutions}
|
||||
with open("index.html", 'w') as f:
|
||||
f.write(template.render(**d))
|
||||
|
||||
|
||||
render_solutions(get_solution_list())
|
||||
53
html/template.html
Normal file
53
html/template.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
|
||||
<title>Project Euler Solutions</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<div class="navbar navbar-dark bg-dark box-shadow">
|
||||
<div class="container d-flex justify-content-between">
|
||||
<a href="#" class="navbar-brand d-flex align-items-center">
|
||||
<strong>My Project Euler Solutions</strong>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main role="main">
|
||||
<div class="container">
|
||||
|
||||
<div class="row" style="padding-top: 40px;">
|
||||
<div class="col">
|
||||
<ul>
|
||||
{% for _, a, t in solutions %}
|
||||
<li><a href="{{a}}">{{t}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" style="padding-top: 40px;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user