[Mapbender-commits] r2110 - in trunk: . build

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Feb 19 13:32:05 EST 2008


Author: christoph
Date: 2008-02-19 13:32:05 -0500 (Tue, 19 Feb 2008)
New Revision: 2110

Added:
   trunk/build/
   trunk/build/build.sh
   trunk/build/jsmin-1.1.0.php
   trunk/build/jsmin.php
Log:
build script

Added: trunk/build/build.sh
===================================================================
--- trunk/build/build.sh	                        (rev 0)
+++ trunk/build/build.sh	2008-02-19 18:32:05 UTC (rev 2110)
@@ -0,0 +1,99 @@
+#!/bin/bash
+#
+# expecting three input params
+# $1 - the name of the release branch at 
+#      https://svn.osgeo.org/mapbender/branches, for example 2.4.5
+# $2 - the SVN username for https://svn.osgeo.org/mapbender
+# $3 - the SVN password for https://svn.osgeo.org/mapbender
+
+#
+#set constants
+#
+
+# the name of the folder where the build process happens
+TODAY=`date +%Y-%m-%d_%H.%M.%S`
+FOLDER="build_$TODAY"
+
+# URL to version that is being built
+SVN_URL="https://svn.osgeo.org/mapbender/branches"
+
+# path to jsdoc.pl
+JSDOC_PATH="JSDoc"
+
+# path to "javascript" folder in Mapbender
+JS_PATH="http/javascripts"
+
+# path to "extension" folder in Mapbender
+EXT_PATH="http/extensions"
+
+# array of javascript files for JSDoc
+JSDOC_F=("$JS_PATH/geometry.js" "$JS_PATH/point.js" "$JS_PATH/map.js" "$JS_PATH/map_obj.js" "$EXT_PATH/wz_jsgraphics.js")
+
+# array of javascript files for JSMin
+JSMIN_F=("$JS_PATH/geometry.js" "$JS_PATH/point.js" "$JS_PATH/map.js" "$JS_PATH/map_obj.js" "$EXT_PATH/jquery.js" "$EXT_PATH/wz_jsgraphics.js")
+
+
+# ------------------------
+#
+# ACTUAL BUILD BEGINS HERE
+#
+# ------------------------
+
+echo "Building Mapbender $1 ... let's see if this works ..."
+
+# create folder for build
+mkdir $FOLDER 2>/dev/null
+
+#check out from SVN
+echo "checking out from $SVN_URL/$1 ..."
+svn co -q $SVN_URL/$1 $FOLDER/
+
+#compile JSDoc
+echo "compiling JSDoc ..."
+for name in ${JSDOC_F[@]}
+do
+	echo "extracting doc from $FOLDER/$name"
+	perl $JSDOC_PATH/jsdoc.pl $FOLDER/$name 
+done
+
+#move JSDoc to folder
+mkdir $FOLDER/documents 2>/dev/null
+mkdir $FOLDER/documents/jsdoc 2>/dev/null
+mv js_docs_out/* $FOLDER/documents/jsdoc/ 2>/dev/null
+rm -rf js_docs_out 2>/dev/null
+
+#check in JSDOC
+echo "committing JSDoc ..."
+svn add -q $FOLDER/documents/
+svn commit -q -m updated_documentation --username $2 --password $3 $FOLDER/documents/
+
+#compile PHPDoc
+# (to do)
+
+#check in PHPDoc
+# (to do)
+
+# compress JS files
+echo "compressing JS ..."
+for name in ${JSMIN_F[@]}
+do
+	echo "minifying $FOLDER/$name ..."
+	ORIG=$name"_orig"
+	mv $FOLDER/$name $FOLDER/$ORIG 2>/dev/null
+	php5 jsmin.php $FOLDER/$ORIG > $FOLDER/$name
+	rm $FOLDER/$ORIG 2>/dev/null
+done
+
+# remove SVN metadata
+echo "deleting SVN metadata ..."
+cd $FOLDER 2>/dev/null
+rm -rf `find . -type d -name .svn` 2>/dev/null
+cd .. 2>/dev/null
+
+# zip build folder
+echo "creating zip file ..."
+ZIP_FILENAME="mapbender_$1_$TODAY.zip"
+zip -rq $ZIP_FILENAME $FOLDER/*
+
+# remove build folder
+rm -rf $FOLDER 2>/dev/null
\ No newline at end of file


Property changes on: trunk/build/build.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/build/jsmin-1.1.0.php
===================================================================
--- trunk/build/jsmin-1.1.0.php	                        (rev 0)
+++ trunk/build/jsmin-1.1.0.php	2008-02-19 18:32:05 UTC (rev 2110)
@@ -0,0 +1,296 @@
+<?php
+/**
+ * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
+ *
+ * This is pretty much a direct port of jsmin.c to PHP with just a few
+ * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
+ * outputs to stdout, this library accepts a string as input and returns another
+ * string as output.
+ *
+ * PHP 5 or higher is required.
+ *
+ * Permission is hereby granted to use this version of the library under the
+ * same terms as jsmin.c, which has the following license:
+ *
+ * --
+ * Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * --
+ *
+ * @package JSMin
+ * @author Ryan Grove <ryan at wonko.com>
+ * @copyright 2002 Douglas Crockford <douglas at crockford.com> (jsmin.c)
+ * @copyright 2007 Ryan Grove <ryan at wonko.com> (PHP port)
+ * @license http://opensource.org/licenses/mit-license.php MIT License
+ * @version 1.1.0 (2007-06-01)
+ * @link http://code.google.com/p/jsmin-php/
+ */
+
+class JSMin {
+  const ORD_LF    = 10;
+  const ORD_SPACE = 32;
+
+  protected $a           = '';
+  protected $b           = '';
+  protected $input       = '';
+  protected $inputIndex  = 0;
+  protected $inputLength = 0;
+  protected $lookAhead   = null;
+  protected $output      = array();
+
+  // -- Public Static Methods --------------------------------------------------
+
+  public static function minify($js) {
+    $jsmin = new JSMin($js);
+    return $jsmin->min();
+  }
+
+  // -- Public Instance Methods ------------------------------------------------
+
+  public function __construct($input) {
+    $this->input       = str_replace("\r\n", "\n", $input);
+    $this->inputLength = strlen($this->input);
+  }
+
+  // -- Protected Instance Methods ---------------------------------------------
+
+  protected function action($d) {
+    switch($d) {
+      case 1:
+        $this->output[] = $this->a;
+
+      case 2:
+        $this->a = $this->b;
+
+        if ($this->a === "'" || $this->a === '"') {
+          for (;;) {
+            $this->output[] = $this->a;
+            $this->a        = $this->get();
+
+            if ($this->a === $this->b) {
+              break;
+            }
+
+            if (ord($this->a) <= self::ORD_LF) {
+              throw new JSMinException('Unterminated string literal.');
+            }
+
+            if ($this->a === '\\') {
+              $this->output[] = $this->a;
+              $this->a        = $this->get();
+            }
+          }
+        }
+
+      case 3:
+        $this->b = $this->next();
+
+        if ($this->b === '/' && (
+            $this->a === '(' || $this->a === ',' || $this->a === '=' ||
+            $this->a === ':' || $this->a === '[' || $this->a === '!' ||
+            $this->a === '&' || $this->a === '|' || $this->a === '?')) {
+
+          $this->output[] = $this->a;
+          $this->output[] = $this->b;
+
+          for (;;) {
+            $this->a = $this->get();
+
+            if ($this->a === '/') {
+              break;
+            }
+            elseif ($this->a === '\\') {
+              $this->output[] = $this->a;
+              $this->a        = $this->get();
+            }
+            elseif (ord($this->a) <= self::ORD_LF) {
+              throw new JSMinException('Unterminated regular expression '.
+                  'literal.');
+            }
+
+            $this->output[] = $this->a;
+          }
+
+          $this->b = $this->next();
+        }
+    }
+  }
+
+  protected function get() {
+    $c = $this->lookAhead;
+    $this->lookAhead = null;
+
+    if ($c === null) {
+      if ($this->inputIndex < $this->inputLength) {
+        $c = $this->input[$this->inputIndex];
+        $this->inputIndex += 1;
+      }
+      else {
+        $c = null;
+      }
+    }
+
+    if ($c === "\r") {
+      return "\n";
+    }
+
+    if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
+      return $c;
+    }
+
+    return ' ';
+  }
+
+  protected function isAlphaNum($c) {
+    return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
+  }
+
+  protected function min() {
+    $this->a = "\n";
+    $this->action(3);
+
+    while ($this->a !== null) {
+      switch ($this->a) {
+        case ' ':
+          if ($this->isAlphaNum($this->b)) {
+            $this->action(1);
+          }
+          else {
+            $this->action(2);
+          }
+          break;
+
+        case "\n":
+          switch ($this->b) {
+            case '{':
+            case '[':
+            case '(':
+            case '+':
+            case '-':
+              $this->action(1);
+              break;
+
+            case ' ':
+              $this->action(3);
+              break;
+
+            default:
+              if ($this->isAlphaNum($this->b)) {
+                $this->action(1);
+              }
+              else {
+                $this->action(2);
+              }
+          }
+          break;
+
+        default:
+          switch ($this->b) {
+            case ' ':
+              if ($this->isAlphaNum($this->a)) {
+                $this->action(1);
+                break;
+              }
+
+              $this->action(3);
+              break;
+
+            case "\n":
+              switch ($this->a) {
+                case '}':
+                case ']':
+                case ')':
+                case '+':
+                case '-':
+                case '"':
+                case "'":
+                  $this->action(1);
+                  break;
+
+                default:
+                  if ($this->isAlphaNum($this->a)) {
+                    $this->action(1);
+                  }
+                  else {
+                    $this->action(3);
+                  }
+              }
+              break;
+
+            default:
+              $this->action(1);
+              break;
+          }
+      }
+    }
+
+    return implode('', $this->output);
+  }
+
+  protected function next() {
+    $c = $this->get();
+
+    if ($c === '/') {
+      switch($this->peek()) {
+        case '/':
+          for (;;) {
+            $c = $this->get();
+
+            if (ord($c) <= self::ORD_LF) {
+              return $c;
+            }
+          }
+
+        case '*':
+          $this->get();
+
+          for (;;) {
+            switch($this->get()) {
+              case '*':
+                if ($this->peek() === '/') {
+                  $this->get();
+                  return ' ';
+                }
+                break;
+
+              case null:
+                throw new JSMinException('Unterminated comment.');
+            }
+          }
+
+        default:
+          return $c;
+      }
+    }
+
+    return $c;
+  }
+
+  protected function peek() {
+    $this->lookAhead = $this->get();
+    return $this->lookAhead;
+  }
+}
+
+// -- Exceptions ---------------------------------------------------------------
+class JSMinException extends Exception {}
+?>
\ No newline at end of file

Added: trunk/build/jsmin.php
===================================================================
--- trunk/build/jsmin.php	                        (rev 0)
+++ trunk/build/jsmin.php	2008-02-19 18:32:05 UTC (rev 2110)
@@ -0,0 +1,6 @@
+<?php
+require("jsmin-1.1.0.php");
+
+$file = $_SERVER["argv"][1];
+echo JSMin::minify(file_get_contents($file));
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list