com web/pres2: Add script to generate a reveal.js presentation from pres2 xml: .gitmodules pres2reveal reveal.js reveal_template.php samdark.css
[email protected] (Rasmus Lerdorf)
| Newsgroups | php.pres |
|---|---|
| Message-ID | <[email protected]> |
Commit: f7f04df4d7c59a964eaecf412eaa2e6367da6364 Author: Rasmus Lerdorf <[email protected]> Mon, 10 Mar 2014 18:03:58 -0700 Parents: c56eda6ac251e8c3b8f3ccc76a7b8ca897135fb0 Branches: master Link: http://git.php.net/?p=web/pres2.git;a=commitdiff;h=f7f04df4d7c59a964eaecf412eaa2e6367da6364 Log: Add script to generate a reveal.js presentation from pres2 xml Changed paths: A .gitmodules A pres2reveal A reveal.js A reveal_template.php A samdark.css
diff_f7f04df4d7c59a964eaecf412eaa2e6367da6364.txt
(text/plain, 11.3 KB)
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..12123b5
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "reveal.js"]
+ path = reveal.js
+ url = https://github.com/hakimel/reveal.js.git
diff --git a/pres2reveal b/pres2reveal
new file mode 100755
index 0000000..ebfbc1b
--- /dev/null
+++ b/pres2reveal
@@ -0,0 +1,128 @@
+#!/usr/bin/env php
+<?php
+if($argc<2) {
+ echo "Usage: {$argv[0]} <presentation.xml> [<reveal_template.php>]\n";
+ exit(1);
+}
+$pres_xml = $argv[1];
+if(!file_exists($argv[1])) {
+ echo "Unable to open {$argv[1]}\n";
+ exit(1);
+}
+$base_path = dirname($pres_xml);
+if(!empty($argv[2])) $reveal_template = $argv[2];
+else $reveal_template = "./reveal_template.php";
+
+// Massive shortcut!
+extract((array)simplexml_load_file($pres_xml));
+$slides = '';
+
+// Now do the real work
+foreach($slide as $sld) {
+ $s = simplexml_load_file($base_path.'/'.$sld);
+ $slide_path = dirname($base_path.'/'.$sld);
+
+ // The titlepage is the first section in the reveal template
+ if($s['template'] == 'titlepage') continue;
+
+ $bgcolor = '';
+ $vertical = false;
+
+ if(!empty($s['body_style'])) {
+ foreach(explode(';',$s['body_style']) as $str) {
+ // Add support for other body styles here
+ if(preg_match('/background:(.*[^;])/', $str, $regs)) {
+ $bgcolor = $regs[1];
+ }
+ }
+ }
+ $slides .= "\t<section";
+ if(!empty($bgcolor)) $slides .= " data-background=\"$bgcolor\"";
+ if(!empty($s['data-transition'])) $slides .= " data-transition=\"{$s['data-transition']}\"";
+ $slides .= ">\n";
+
+ if(!empty($s['section'])) {
+ $slides .= "\t\t<section id=\"{$s['section']}\">\n";
+ $vertical = true;
+ }
+ if(!empty($s['title'])) $slides .= "\t\t<h2 margin-bottom=\"2em\">{$s['title']}</h2><br>\n";
+ foreach($s as $k=>$e) {
+ switch($k) {
+ case 'image':
+ case 'blurb':
+ case 'example':
+ $fnc ="render_$k";
+ if(is_array(e)) {
+ foreach($e as $ee) {
+ $slides .= $fnc($ee);
+ }
+ } else {
+ $slides .= $fnc($e);
+ }
+ break;
+ case 'list':
+ $slides .= render_list($e);
+ break;
+ case 'title':
+ if(empty($s['title']) && !empty($e['title']))
+ $slides .= "\t\t<h2 margin-bottom=\"2em\">{$e['title']}</h2><br>\n";
+ break;
+ case 'break':
+ if($vertical && !empty($e['section'])) {
+ $slides .= "\t\t</section>\n";
+ $slides .= "<section id=\"{$e['section']}\">\n";
+ }
+ break;
+ }
+ }
+
+ if($vertical) $slides .= "\t\t</section>";
+ $slides .= "\t</section>\n";
+}
+
+// And plug everything into the Reveal template
+include $reveal_template;
+
+function render_image($e, $style="border:0px") {
+ global $slide_path;
+ return <<<EOB
+ <img src="/{$slide_path}/{$e[filename]}" width="{$e[width]}" height="{$e[height]}" style="$style">
+
+EOB;
+}
+
+function render_blurb($e) {
+ $size = (int)$e['fontsize'];
+ $style = '';
+ if($size >= 8) $tag = 'h2';
+ else if($size >= 6) { $tag = 'h3'; $style = " style=\"text-align:left;\""; }
+ else if($size >= 4) { $tag = 'h4'; $style = " style=\"text-align:left;\""; }
+ else { $tag = 'p'; $style = " style=\"text-align:left;\""; }
+ return "\t\t<$tag{$style}>$e</$tag>\n";
+}
+
+function render_list($e) {
+ $ret = "\t\t<ul>\n";
+ foreach($e->item as $v) {
+ $ret .= "\t\t\t<li>$v</li>\n";
+ }
+ $ret .= "\t\t</ul>\n";
+ return $ret;
+}
+
+function render_example($e) {
+ $ret = '';
+ $code = (string)$e;
+ if(substr($code,0,5)=="<?php") {
+ $code = substr($code,5);
+ }
+ if(empty($e['hide'])) $ret .= "\t\t<pre><code data-trim class=\"php\">$code</code></pre>\n";
+ if(!empty($e['result'])) {
+ $ret .= "\t\t<pre><code data-trim class=\"php\">";
+ ob_start();
+ eval("?>$code");
+ $ret .= ob_get_clean();
+ $ret .= "\t\t</code></pre>";
+ }
+ return $ret;
+}
diff --git a/reveal.js b/reveal.js
new file mode 160000
index 0000000..08fb6cb
--- /dev/null
+++ b/reveal.js
@@ -0,0 +1 @@
+Subproject commit 08fb6cb2f96a6d97aaa21c35a925ebb59b0b0070
diff --git a/reveal_template.php b/reveal_template.php
new file mode 100644
index 0000000..4e75446
--- /dev/null
+++ b/reveal_template.php
@@ -0,0 +1,92 @@
+<!doctype html>
+<html lang="en">
+
+ <head>
+ <meta charset="utf-8">
+
+ <title><?=$title?></title>
+
+ <meta name="description" content="<?=$title?>">
+ <meta name="author" content="<?=$speaker?>">
+
+ <meta name="apple-mobile-web-app-capable" content="yes" />
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
+
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+
+ <link rel="stylesheet" href="/reveal.js/css/reveal.min.css">
+ <link rel="stylesheet" href="/samdark.css" id="theme">
+
+ <!-- For syntax highlighting -->
+ <link rel="stylesheet" href="lib/css/zenburn.css">
+
+ <!-- If the query includes 'print-pdf', include the PDF print sheet -->
+ <script>
+ if( window.location.search.match( /print-pdf/gi ) ) {
+ var link = document.createElement( 'link' );
+ link.rel = 'stylesheet';
+ link.type = 'text/css';
+ link.href = '/reveal.js/css/print/pdf.css';
+ document.getElementsByTagName( 'head' )[0].appendChild( link );
+ }
+ </script>
+
+ <!--[if lt IE 9]>
+ <script src="lib/js/html5shiv.js"></script>
+ <![endif]-->
+ </head>
+
+ <body>
+
+ <div class="reveal">
+
+ <!-- Any section element inside of this container is displayed as a slide -->
+ <div class="slides">
+ <section>
+ <h1><?=$title?></h1>
+ <h3><?=$event?></h3>
+ <h3><?=$location?></h3>
+ <h3><?=$date?></h3>
+ <a href="<?=$url?>"><?=$url?></a><br><br>
+ <p><?=$speaker?><br>
+ <small><a href="http://twitter.com/<?=$twitter?>"><?=$twitter?></a></small>
+ </p>
+ </section>
+ <?=$slides?>
+ </div>
+
+ </div>
+
+ <script src="/reveal.js/lib/js/head.min.js"></script>
+ <script src="/reveal.js/js/reveal.min.js"></script>
+
+ <script>
+
+ // Full list of configuration options available here:
+ // https://github.com/hakimel/reveal.js#configuration
+ Reveal.initialize({
+ controls: true,
+ progress: true,
+ history: true,
+ center: true,
+
+ theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
+ transition: Reveal.getQueryHash().transition || 'none', // default/cube/page/concave/zoom/linear/fade/none
+
+ // Parallax scrolling
+ // parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
+ // parallaxBackgroundSize: '2100px 900px',
+
+ // Optional libraries used to extend on reveal.js
+ dependencies: [
+ { src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
+ { src: '/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
+ { src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } },
+ { src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
+ ]
+ });
+
+ </script>
+
+ </body>
+</html>
diff --git a/samdark.css b/samdark.css
new file mode 100644
index 0000000..15373a3
--- /dev/null
+++ b/samdark.css
@@ -0,0 +1,191 @@
+@import url(../../../fonts/stylesheet.css);
+/**
+ * samdark theme for reveal.js.
+ */
+.reveal table {
+ table-layout: fixed;
+}
+.reveal table th {
+ font-weight: bold;
+}
+.reveal table th, .reveal table td {
+ padding: 10px;
+}
+
+.reveal code {
+ font-family: Monaco, consolas, monospace;
+}
+
+.reveal pre.big code {
+ font-size: 200%;
+}
+
+.reveal section img {
+ border: none !important;
+ box-shadow: none !important;
+}
+
+.reveal ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+}
+.reveal ul ul {
+ list-style: none;
+ padding: 0;
+ margin: 1em 0 0 0;
+ color: #777;
+}
+.reveal li {
+ padding-left: 1em;
+ margin-bottom: .2em;
+}
+.reveal li:before {
+ content: "\2014";
+ padding-right: 7px;
+ color: #aaa;
+}
+
+/*********************************************
+ * GLOBAL STYLES
+ *********************************************/
+body {
+ background: white;
+ background-color: white;
+}
+
+.reveal {
+ font-family: "PT Sans";
+ font-size: 36px;
+ font-weight: 200;
+ letter-spacing: -0.02em;
+ color: #666666;
+}
+
+::selection {
+ color: white;
+ background: #ff5e99;
+ text-shadow: none;
+}
+
+/*********************************************
+ * HEADERS
+ *********************************************/
+.reveal h1,
+.reveal h2,
+.reveal h3,
+.reveal h4,
+.reveal h5,
+.reveal h6 {
+ margin: 0 0 20px 0;
+ color: #333333;
+ font-family: "PT Sans Caption";
+ line-height: 0.9em;
+ letter-spacing: 0.02em;
+ text-transform: none;
+ text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2);
+}
+
+.reveal h1 {
+ text-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2);
+}
+
+/*********************************************
+ * LINKS
+ *********************************************/
+.reveal a:not(.image) {
+ color: darkblue;
+ text-decoration: none;
+ -webkit-transition: color 0.15s ease;
+ -moz-transition: color 0.15s ease;
+ -ms-transition: color 0.15s ease;
+ -o-transition: color 0.15s ease;
+ transition: color 0.15s ease;
+}
+
+.reveal a:not(.image):hover {
+ color: #0000f1;
+ text-shadow: none;
+ border: none;
+}
+
+.reveal .roll span:after {
+ color: #fff;
+ background: #00003f;
+}
+
+/*********************************************
+ * IMAGES
+ *********************************************/
+.reveal section img {
+ margin: 15px 0px;
+ background: rgba(255, 255, 255, 0.12);
+ border: 4px solid #666666;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
+ -webkit-transition: all 0.2s linear;
+ -moz-transition: all 0.2s linear;
+ -ms-transition: all 0.2s linear;
+ -o-transition: all 0.2s linear;
+ transition: all 0.2s linear;
+}
+
+.reveal a:hover img {
+ background: rgba(255, 255, 255, 0.2);
+ border-color: darkblue;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.55);
+}
+
+/*********************************************
+ * NAVIGATION CONTROLS
+ *********************************************/
+.reveal .controls div.navigate-left,
+.reveal .controls div.navigate-left.enabled {
+ border-right-color: darkblue;
+}
+
+.reveal .controls div.navigate-right,
+.reveal .controls div.navigate-right.enabled {
+ border-left-color: darkblue;
+}
+
+.reveal .controls div.navigate-up,
+.reveal .controls div.navigate-up.enabled {
+ border-bottom-color: darkblue;
+}
+
+.reveal .controls div.navigate-down,
+.reveal .controls div.navigate-down.enabled {
+ border-top-color: darkblue;
+}
+
+.reveal .controls div.navigate-left.enabled:hover {
+ border-right-color: #0000f1;
+}
+
+.reveal .controls div.navigate-right.enabled:hover {
+ border-left-color: #0000f1;
+}
+
+.reveal .controls div.navigate-up.enabled:hover {
+ border-bottom-color: #0000f1;
+}
+
+.reveal .controls div.navigate-down.enabled:hover {
+ border-top-color: #0000f1;
+}
+
+/*********************************************
+ * PROGRESS BAR
+ *********************************************/
+.reveal .progress {
+ background: rgba(0, 0, 0, 0.2);
+}
+
+.reveal .progress span {
+ background: darkblue;
+ -webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
+ -moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
+ -ms-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
+ -o-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
+ transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
+}