Code

Project: jvfeatures

jvtypes.h      jvfeatures.h      chessSeg.cpp      jvtypes.cpp      jvtest.cpp      jvfeatures.cpp     

Project: Other

migrateMailbox.scpt.txt     

Project: Infinite HMM Tutorial

run.m      iHMM_tutorial.zip      HDP_HMM.m      README.txt      ConditionalProbabilityTable.m      HDP.m      HMMProblem.m      HMM.m     

Project: RRT

RRT.h      plot_output.py      RRT.tgz      rrt_test.cpp      RRT.cpp      BidirectionalRRT.cpp      AbstractRRT.cpp     

Project: Box2D_friction_mod

WheelConstraint.h      test_TopDownCar.py      b2FrictionJoint.h      python_friction_joint.patch      test_TopDownFrictionJoint.py      TestEntries.cpp      TopDownCar.h      b2FrictionJoint.cpp      box2d_friction_joint.patch     

Project: Dirichlet Process Mixture Tutorial

EM_GM.m      DP_Demo.m      DPMM.m      DP_Tutorial.zip      DirichletProcess.m      gaussian_EM.m     

Project: Arduino_Code

plot_ardunio_data.sh      Arduino_Code.zip      convert_range2D.py      arduino-serial.c      oscilloscope.sh      oscilloscope.pde      motordriver.pde      helicopter_controller.pde      accelerometer_test.pde      ranger_plane_sweep.pde      clodbuster_controller.pde      pwm_manual.pde      ranger_test.pde      servo_test.pde     

Project: ArduCom

arducom.py      setup.py     

Project: support

geshi.php      Protector.php     

Project: Cogent

CodePane.php      NotesPane.php      PicsPane.php      Cogent.php      PubsTable.php     
Click here to download "resources/site-code/Cogent/CodePane.php"

resources/site-code/Cogent/CodePane.php

<?php
require_once("Cogent.php");

/**
* CodePane
* A class for generating HTML links by scanning for source files in
* the specified locations.  Content is displayed in separate divs,
* and a google analytics tracker is installed
*
* Outline:
* CodePane("<directory name>", array_change_key_case('ext1','ext2',...))
* CodePane->run();      // runs HTML output for all images found, organized by album
*
* The CSS id of the top-level div is "pics", in accordance with the formatting scheme that I
* use for my website.  For other applications, just define the "pics" properties as desired
*
* Author: Jonathan Scholz
* 2/3/2010
*/

class CodePane extends Cogent
{
        /*
         * Generates the HTML for this directory listing
         *
         * In this case involves dumping a link to the file, and
         * installing the analytics tracker
         */

        public function generate($dir, $files){
                // write heading for this project
                if ($this->depth == 0) {
                        print '<h3 id="'.$dir.'">Project: '.$dir."</h3>\n";
                }

                // scan project for content (matching provided extensions):
                $files = $this->list_content($this->rootdir."/".$dir);

                // count elements in array
                $numfiles = count($files);

                // loop over files to install url GET link and google analytics tracker
                for ($file=0; $file < $numfiles; $file++) {
                        print '<a href="'.
                                "code.php?targ=$this->rootdir/$dir/$files[$file]".'" '. // set url GET arg
                                'onClick="_gaq.push(["_trackEvent", "Code", "Downloaded", "'.$files[$file].'"]);">'. // install tracker
                                "$files[$file]</a>&nbsp&nbsp&nbsp&nbsp&nbsp\n";
                }
        }
       
        /* Installs the block for handling the _GET url argument, and
         * generates the appropriate html for that file.
         *
         */

        public function handle_anchor() {
                // Add the block that displays the specified file
                if (isset($_GET['targ'])) {
                        $targ = $_GET['targ'];
                       
                        // Extract content from target file
                        $content = "<hr>\n".
                                '<a href="'.$targ.'">Click here to download '.'"'.$targ.'"</a>';
                        $ext = substr(strrchr($targ,'.'),1);
                       
                        // Highlight & enclose in a notes box
                        if ($ext != "zip" && $ext != "tgz" && $ext != "tar") {
                                $content = $content.
                                        '<div class="notesbox">'.
                                        '<h3 style="text-align: center">'.$targ.'</h3>'.
                                        '<div class="scrollbox">'.
                                        $this->highlight($targ, $ext).
                                        "</div></div>\n";
                        }
                        print $content;
                }
        }
       
        public function highlight($targ, $ext) {
                require_once("resources/site-code/support/geshi.php");
                if ($ext == "h" || $ext == "cpp" || $ext == "pde") {
                        $lang = "cpp";
                } elseif ($ext == "py") {
                        $lang = "python";
                } elseif ($ext == "php") {
                        $lang = "php";
                } elseif ($ext == "java") {
                        $lang = "java";
                } elseif ($ext == "m") {
                        $lang = "matlab";
                } else {
                        $lang = "txt";
                }
                $path = "resources/site-code/support/geshi";
                $src = file_get_contents($targ);
                return geshi_highlight($src, $lang, $path, true);
        }
} // End: class CodePane

?>
 

About me

Pic of me