add TOC
[tools.git] / index.php
blob:a/index.php -> blob:b/index.php
--- a/index.php
+++ b/index.php
@@ -1,3 +1,10 @@
+<?php
+$wordpress = false;
+if (isset($_REQUEST["wordpress"])) $wordpress = true;
+
+if (!$wordpress) {
+
+?>
 <!DOCTYPE html>
 <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
 <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
@@ -24,13 +31,27 @@
         <!-- Add your site or application content here -->
         <div id="toc"></div>
         <div id="wrapper">
-            <div id="items">
-            </div>
+        <section>
 <?php
+}
 include_once "php-markdown/markdown.php";
-echo Markdown(file_get_contents("index.md"));
+$content = Markdown(file_get_contents("index.md"));
+$content = str_replace("<h1","</div><div><h1",$content);
+$content = str_replace("</div><div><h1>GovHack","<div><h1>GovHack",$content);
+$content .= "</div>";
+if ($wordpress) {
+    $content = str_replace("<div><h1>","<div>[toggle title=\"",$content);
+    $content = str_replace("</div>","[/toggle]</div>",$content);
+    $content = str_replace("</h1>","\"]",$content);
+
+    $content = str_replace("<img","<img width=\"300\" class=\"alignright size-medium\"",$content);
+    $content = str_replace("img/","http://www.govhack.org/wp-content/uploads/",$content);
+}
+echo  $content;
+if (!$wordpress) {
 ?>
 </div>
+        </section>
         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
         <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
         <script src="js/plugins.js"></script>
@@ -42,8 +63,10 @@
                 'selectors': 'h1'
             });
             $(function(){
-                $("#items").stoc({
-                    search: "#wrapper"
+
+                $('<div class="items"></div>').insertAfter('h1');
+                $(".items").each(function() {
+                    $(this).stoc();
                 });
             });
         </script>
@@ -56,4 +79,6 @@
         </script>
     </body>
 </html>
-
+<?php
+}
+?>