From f208307cbdd403d3fa92a1aae1dc9c094c7ec9d8 Mon Sep 17 00:00:00 2001
From: Eric Bidelman
Date: Wed, 11 Jul 2012 10:43:37 -0700
Subject: Bringing in upstream changes
---
scripts/md/README.md | 5 ++++
scripts/md/base.html | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/md/render.py | 53 +++++++++++++++++++++++++++++++++++++++++
scripts/md/slides.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 188 insertions(+)
create mode 100644 scripts/md/README.md
create mode 100644 scripts/md/base.html
create mode 100755 scripts/md/render.py
create mode 100644 scripts/md/slides.md
(limited to 'scripts/md')
diff --git a/scripts/md/README.md b/scripts/md/README.md
new file mode 100644
index 0000000..136e465
--- /dev/null
+++ b/scripts/md/README.md
@@ -0,0 +1,5 @@
+Want to use markdown instead?
+
+`python render.py` can do that for you.
+
+Dependencies: jinja2, markdown.
diff --git a/scripts/md/base.html b/scripts/md/base.html
new file mode 100644
index 0000000..a469806
--- /dev/null
+++ b/scripts/md/base.html
@@ -0,0 +1,66 @@
+
+
+
+
+ Google IO 2012
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% for slide in slides %}
+
+
+ {{ slide.h1 }}
+ {{ slide.title }}
+
+
+ {{ slide.content }}
+
+
+{% endfor %}
+
+
+
+
+
+
+
+
diff --git a/scripts/md/render.py b/scripts/md/render.py
new file mode 100755
index 0000000..c634ea0
--- /dev/null
+++ b/scripts/md/render.py
@@ -0,0 +1,53 @@
+#!/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python
+import codecs
+import re
+import jinja2
+import markdown
+
+def process_slides():
+ with codecs.open('../presentation.html', 'w', encoding='utf8') as outfile:
+ md = codecs.open('slides.md', encoding='utf8').read()
+ md_slides = md.split('\n---\n')
+ print len(md_slides)
+
+ slides = []
+ # Process each slide separately.
+ for md_slide in md_slides:
+ slide = {}
+ sections = md_slide.split('\n\n')
+ # Extract metadata at the beginning of the slide (look for key: value)
+ # pairs.
+ metadata_section = sections[0]
+ metadata = parse_metadata(metadata_section)
+ slide.update(metadata)
+ remainder_index = metadata and 1 or 0
+ # Get the content from the rest of the slide.
+ content_section = '\n\n'.join(sections[remainder_index:])
+ html = markdown.markdown(content_section)
+ slide['content'] = postprocess_html(html, markdown)
+
+ slides.append(slide)
+
+ template = jinja2.Template(open('base.html').read())
+
+ outfile.write(template.render(locals()))
+
+def parse_metadata(section):
+ """Given the first part of a slide, returns metadata associated with it."""
+ metadata = {}
+ metadata_lines = section.split('\n')
+ for line in metadata_lines:
+ colon_index = line.find(':')
+ if colon_index != -1:
+ key = line[:colon_index].strip()
+ val = line[colon_index + 1:].strip()
+ metadata[key] = val
+
+ return metadata
+
+def postprocess_html(html, metadata):
+ """Returns processed HTML to fit into the slide template format."""
+ return html
+
+if __name__ == '__main__':
+ process_slides()
diff --git a/scripts/md/slides.md b/scripts/md/slides.md
new file mode 100644
index 0000000..064b8db
--- /dev/null
+++ b/scripts/md/slides.md
@@ -0,0 +1,64 @@
+title: Slide Title
+class: image
+
+![Mobile vs desktop users](image.png)
+
+---
+
+title: Agenda
+class: big
+
+Things we'll cover:
+
+- Bullet1
+- Bullet2
+- Bullet3
+
+---
+
+title: Today
+class: nobackground fill
+
+![Many kinds of devices.](image.png)
+
+
+
+---
+
+h1: Big Title Slide
+class: title-slide
+
+---
+
+title: Code Example
+
+Media Queries are sweet:
+
+
+@media screen and (max-width: 640px) {
+ #sidebar { display: none; }
+}
+
+
+---
+
+title: Once more, with JavaScript
+
+
+function isSmall() {
+ return window.matchMedia("(min-device-width: ???)").matches;
+}
+
+function hasTouch() {
+ return Modernizr.touch;
+}
+
+function detectFormFactor() {
+ var device = DESKTOP;
+ if (hasTouch()) {
+ device = isSmall() ? PHONE : TABLET;
+ }
+ return device;
+}
+
+
--
cgit v1.2.3