diff --git a/src/app.py b/src/app.py index 3bf7d90..ae80921 100644 --- a/src/app.py +++ b/src/app.py @@ -12,10 +12,25 @@ import info from post import Post +INDEX_TEMPLATE = open("index-template.htm", "rb").read().decode("utf-8") POST_TEMPLATE = open("post-template.htm", "rb").read().decode("utf-8") RSS_TEMPLATE = open("rss-template.xml", "rb").read().decode("utf-8") +def render_index_page(posts): + template_params = { + "posts": [post.to_dict() for post in posts], + "displayed_post": { + "title": None, + "async_scripts": [], + "stylesheets": [] + }, + "upcoming_post": info.upcoming_post, + } + renderer = pystache.Renderer(missing_tags="strict") + return renderer.render(INDEX_TEMPLATE, template_params) + + def render_post_page(posts, current_post_index): """Renders a single post page. @@ -76,6 +91,10 @@ def main(output_directory): # Make a posts directory in our output directory os.mkdir(os.path.join(output_directory, "posts")) + # Create the home page + with open(os.path.join(output_directory, "index.htm"), "wb") as f: + f.write(render_index_page(posts).encode("utf-8")) + # Go through and create all the post pages for index, post in enumerate(posts): output_path = os.path.join(output_directory, "posts", @@ -85,11 +104,6 @@ def main(output_directory): with open(output_path, "wb") as f: f.write(rendered_post.encode("utf-8")) - # If this is the current post, we also make it the index page - if index == 0: - with open(os.path.join(output_directory, "index.htm"), "wb") as f: - f.write(rendered_post.encode("utf-8")) - # Create the RSS feed with open(os.path.join(output_directory, "rss.xml"), "wb") as f: f.write(render_rss_page(posts).encode("utf-8")) diff --git a/src/footer.mustache b/src/footer.mustache new file mode 100644 index 0000000..909b16b --- /dev/null +++ b/src/footer.mustache @@ -0,0 +1,39 @@ + + + diff --git a/src/header.mustache b/src/header.mustache new file mode 100644 index 0000000..ebf31ec --- /dev/null +++ b/src/header.mustache @@ -0,0 +1,27 @@ + + + + + {{#displayed_post.title}} + {{displayed_post.title}} | + {{/displayed_post.title}} + Khan Academy Engineering + + + + + + + + + + + {{#displayed_post.async_scripts}} + + {{/displayed_post.async_scripts}} + + {{#displayed_post.stylesheets}} + + {{/displayed_post.stylesheets}} + + diff --git a/src/index-template.htm b/src/index-template.htm new file mode 100644 index 0000000..bbb810f --- /dev/null +++ b/src/index-template.htm @@ -0,0 +1,21 @@ +{{> header }} +{{> sidebar }} + +
+
+

Latest posts

+ {{#posts}} +
+

+ {{title}} +

+
+ + {{author.display_as}} on {{{published_on_html}}} +
+
+ {{/posts}} +
+
+ +{{> footer }} diff --git a/src/post-template.htm b/src/post-template.htm index 63e62d0..bfc8d22 100644 --- a/src/post-template.htm +++ b/src/post-template.htm @@ -1,151 +1,38 @@ - - - - {{displayed_post.title}} | Khan Academy Engineering - - - - - - - - - - {{#displayed_post.async_scripts}} +{{> header }} +{{> sidebar }} + +
+
+

{{displayed_post.title}}

+
+ + by {{displayed_post.author.display_as}} on {{{displayed_post.published_on_html}}} +
+
+ {{{html_content}}} +
+
+ {{#displayed_post.postcontent_scripts}} - {{/displayed_post.async_scripts}} - - {{#displayed_post.stylesheets}} - - {{/displayed_post.stylesheets}} - - -
-

- KA Engineering -

-

- - - - KA Engineering - -

-
- We're the engineers behind Khan Academy. We're building a free, world-class education for anyone, anywhere. -
-
-

Subscribe

- -
- {{#upcoming_post}} -
-

Upcoming fortnightly post

-
-

{{upcoming_post.title}}

-
- - by {{upcoming_post.author.display_as}} on {{{upcoming_post.published_on_html}}} -
+ {{/displayed_post.postcontent_scripts}} +
+
+ {{#previous_post}} + -
- {{/upcoming_post}} -
-

Latest posts

- {{#posts}} -
-

- {{title}} -

-
- - {{author.display_as}} on {{{published_on_html}}} -
-
- {{/posts}} -
-
-

Meta

- -
-
-
- - {{#displayed_post.postcontent_scripts}} - - {{/displayed_post.postcontent_scripts}} -
-
- {{#previous_post}} - - {{/previous_post}} -
-
- {{#next_post}} - - {{/next_post}} + {{/previous_post}} +
+
+ {{#next_post}} + + {{/next_post}}
-
- - - +{{> footer }} diff --git a/src/sidebar.mustache b/src/sidebar.mustache new file mode 100644 index 0000000..529dd19 --- /dev/null +++ b/src/sidebar.mustache @@ -0,0 +1,43 @@ +
+

+ KA Engineering +

+

+ + + + KA Engineering + +

+
+ We're the engineers behind Khan Academy. We're building a free, world-class education for anyone, anywhere. +
+
+

Subscribe

+ +
+ {{#upcoming_post}} +
+

Upcoming fortnightly post

+
+

{{upcoming_post.title}}

+
+ + by {{upcoming_post.author.display_as}} on {{{upcoming_post.published_on_html}}} +
+
+
+ {{/upcoming_post}} +
+

Meta

+ +
+
diff --git a/src/styles/post-template.less b/src/styles/post-template.less index fe421fa..d7228c6 100644 --- a/src/styles/post-template.less +++ b/src/styles/post-template.less @@ -345,6 +345,71 @@ body { } } + .post-blurb { + margin-top: 30px; + padding-bottom: 4px; + border-left: 1px solid transparent; + padding-left: 10px; + margin-left: -10px; + + @media (max-width: @doubleColumnMaxWidth) { + border-left: 10px solid transparent; + padding-left: 17px; + margin-left: -26px; + } + + &:first-of-type { + margin-top: 20px; + } + + &.team-infrastructure { + border-color: @infrastructureColor; + } + + &.team-web-frontend { + border-color: @frontendColor; + } + + &.team-eng-leads { + border-color: @engLeadsColor; + } + + &.team-design { + border-color: @designColor; + } + + .title { + font-size: 18px; + line-height: 22px; + font-weight: 400; + margin: 0 0 9px 0; + + a { + color: @contentTextColor; + text-decoration: none; + } + + a:hover { + text-decoration: underline; + } + } + + .info { + font-size: 12px; + + .author-link { + color: @contentTextColor; + text-decoration: none; + font-weight: bold; + font-size: 11px; + } + + .author-link:hover { + text-decoration: underline; + } + } + } + .keep-reading-buttons { display: table; margin-top: 30px;