-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
379 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import frontmatter | ||
from jinja2 import Environment, FileSystemLoader | ||
from datetime import datetime # Import datetime | ||
|
||
|
||
def generate_rfc_page(): | ||
""" | ||
Generates an HTML page listing RFC documents using Jinja2 templating. | ||
""" | ||
|
||
rfcs = [] | ||
for root, _, files in os.walk("source/"): | ||
for file in files: | ||
if file.endswith(".md"): | ||
filepath = os.path.join(root, file) | ||
with open(filepath, "r") as f: | ||
post = frontmatter.load(f) | ||
# Get last modified date of the file | ||
last_modified = os.path.getmtime(filepath) | ||
rfcs.append( | ||
{ | ||
"title": post.get("title"), | ||
"abstract": post.get("abstract"), | ||
"sotd": post.get("sotd"), | ||
"shortName": post.get("shortName"), | ||
"editor": post.get("editor"), | ||
"link": filepath.replace("source/", "rfcs/").replace( | ||
".md", ".html" | ||
), | ||
"updated": datetime.fromtimestamp(last_modified).strftime( | ||
"%B %d, %Y" | ||
), | ||
} | ||
) | ||
|
||
# Setup Jinja2 environment | ||
env = Environment(loader=FileSystemLoader(".")) | ||
template = env.get_template("index_template.html") | ||
|
||
# Render the template with the RFC data | ||
html = template.render(rfcs=rfcs) | ||
|
||
with open("index.html", "w") as f: | ||
f.write(html) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_rfc_page() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>RFC Documents</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
|
||
<body class="bg-gray-100 font-sans"> | ||
<div class="container mx-auto p-8"> | ||
<h1 class="text-3xl font-bold mb-6">Request for Comments (RFC) Documents</h1> | ||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> | ||
{% for rfc in rfcs %} | ||
<div class="bg-white rounded-lg shadow-md p-6"> | ||
<h2 class="text-xl font-semibold mb-2">{{ rfc.title }}</h2> | ||
<p class="text-gray-600">Short Name: {{ rfc.shortName }}</p> | ||
<!-- <p class="text-gray-600">Editor: {{ rfc.editor }}</p> --> | ||
<p class="text-gray-600">State of This Document: {{ rfc.sotd }}</p> | ||
<p class="text-gray-600">Updated: {{ rfc.updated }}</p> | ||
<a href="{{ rfc.link }}" | ||
class="mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> | ||
View RFC | ||
</a> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
python-frontmatter | ||
Markdown | ||
latex2mathml | ||
jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.