예제 #1
0
def get_home_html():
    with open("home/home.md") as home:
        home = home.read()
    home_html = site_utilities.md_to_html(home)
    header_html = _get_home_header_html()
    browser_title_html = "<title>samerv.in</title>"
    return header_html + browser_title_html + home_html
예제 #2
0
def get_resume_html():
    with open("resume/resume.md") as resume:
        resume = resume.read()
    resume_html = site_utilities.md_to_html(resume)
    header_html = _get_resume_header_html()
    browser_title_html = "<title>resume | samerv.in</title>"
    return header_html + browser_title_html + resume_html
예제 #3
0
def get_blog_post_html(post_name):
    with open("blog/posts/{}.md".format(post_name)) as post_file:
        post_md = post_file.read()
    post_html = site_utilities.md_with_metadata_to_html(post_md)
    post_title = post_html.metadata.get("title")
    raw_datetime = dt.strptime(post_html.metadata.get("datetime"),
                               "%Y-%m-%d %H:%M")
    browser_title_html = "<title>{} | samerv.in</title>".format(post_title)
    blog_title_html = site_utilities.md_to_html("## {}".format(post_title))
    blog_date = raw_datetime.strftime("<i>%b %d %Y</i>")
    footer_html = _get_blog_post_footer_html(post_name)
    header = _get_blog_header_html()
    return (header + browser_title_html + blog_title_html + blog_date +
            post_html + footer_html)
예제 #4
0
def get_blog_home_html():
    with open("blog/blog_home.md") as blog_home:
        blog_opener = blog_home.read()
    post_list = _get_blog_posts_list()
    post_list.reverse()
    post_list_str = ""
    for post in post_list:
        raw_datetime = dt.strptime(post.datetime, "%Y-%m-%d %H:%M")
        pretty_datetime = raw_datetime.strftime("<i>%b %d %Y</i>")
        post_list_str += "\n- [{}]({}) ({})".format(post.title, post.url_slug,
                                                    pretty_datetime)
    header = _get_blog_header_html()
    browser_title_html = "<title>blog | samerv.in</title>"
    content = site_utilities.md_to_html(blog_opener + post_list_str)
    return header + browser_title_html + content
예제 #5
0
def _get_resume_header_html():
    with open("resume/resume_header.md") as resume_header:
        content = resume_header.read()
    return site_utilities.md_to_html(content)
예제 #6
0
def error_500(e):
    with open("meta/500.md") as file_500:
        md_500 = file_500.read()
    html_500 = site_utilities.md_to_html(md_500)
    return _create_html_page(html_500), 500
예제 #7
0
def error_404(e):
    with open("meta/404.md") as file_404:
        md_404 = file_404.read()
    html_404 = site_utilities.md_to_html(md_404)
    return _create_html_page(html_404), 404
예제 #8
0
def _get_home_header_html():
    with open("home/home_header.md") as home_header:
        content = home_header.read()
    return site_utilities.md_to_html(content)
예제 #9
0
def _get_blog_header_html():
    with open("blog/blog_header.md") as blog_header:
        content = blog_header.read()
    return site_utilities.md_to_html(content)