Remove OpenLayers 2, as discussed with @ahocevar, @elemoine and @tschaub
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
This directory contains tools used in the packaging or deployment of OpenLayers.
|
||||
|
||||
Javascript minimizing tools:
|
||||
|
||||
* jsmin.c, jsmin.py:
|
||||
jsmin.py is a direct translation of the jsmin.c code into Python. jsmin.py
|
||||
will therefore run anyplace Python runs... but at significantly slower speed.
|
||||
|
||||
* shrinksafe.py
|
||||
shrinksafe.py calls out to a third party javascript shrinking service. This
|
||||
creates file sizes about 4% smaller (as of commit 501) of the OpenLayers
|
||||
code. However, this also has the side effect of making you dependant on the
|
||||
web service -- and since that service sometimes goes dead, it's risky to
|
||||
depend on it.
|
||||
@@ -1,71 +0,0 @@
|
||||
# Copyright 2010 The Closure Library Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Utility to use the Closure Compiler CLI from Python."""
|
||||
|
||||
import distutils.version
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
|
||||
# Pulls a version number from the first line of 'java -version'
|
||||
# See http://java.sun.com/j2se/versioning_naming.html to learn more about the
|
||||
# command's output format.
|
||||
_VERSION_REGEX = re.compile('"([0-9][.0-9]*)')
|
||||
|
||||
|
||||
def _GetJavaVersion():
|
||||
"""Returns the string for the current version of Java installed."""
|
||||
proc = subprocess.Popen(['java', '-version'], stderr=subprocess.PIPE)
|
||||
unused_stdoutdata, stderrdata = proc.communicate()
|
||||
version_line = stderrdata.splitlines()[0]
|
||||
return _VERSION_REGEX.search(version_line).group(1)
|
||||
|
||||
|
||||
def Compile(compiler_jar_path, source_paths, flags=None):
|
||||
"""Prepares command-line call to Closure Compiler.
|
||||
|
||||
Args:
|
||||
compiler_jar_path: Path to the Closure compiler .jar file.
|
||||
source_paths: Source paths to build, in order.
|
||||
flags: A list of additional flags to pass on to Closure Compiler.
|
||||
|
||||
Returns:
|
||||
The compiled source, as a string, or None if compilation failed.
|
||||
"""
|
||||
|
||||
# User friendly version check.
|
||||
if not (distutils.version.LooseVersion(_GetJavaVersion()) >=
|
||||
distutils.version.LooseVersion('1.6')):
|
||||
logging.error('Closure Compiler requires Java 1.6 or higher. '
|
||||
'Please visit http://www.java.com/getjava')
|
||||
return
|
||||
|
||||
args = ['java', '-jar', compiler_jar_path]
|
||||
for path in source_paths:
|
||||
args += ['--js', path]
|
||||
|
||||
if flags:
|
||||
args += flags
|
||||
|
||||
logging.info('Compiling with the following command: %s', ' '.join(args))
|
||||
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
stdoutdata, unused_stderrdata = proc.communicate()
|
||||
|
||||
if proc.returncode != 0:
|
||||
return
|
||||
|
||||
return stdoutdata
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import httplib, urllib, sys
|
||||
import time
|
||||
# Define the parameters for the POST request and encode them in
|
||||
# a URL-safe format.
|
||||
|
||||
def minimize(code):
|
||||
|
||||
params = urllib.urlencode([
|
||||
('js_code', code),
|
||||
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
|
||||
('output_format', 'text'),
|
||||
('output_info', 'compiled_code'),
|
||||
])
|
||||
|
||||
t = time.time()
|
||||
# Always use the following value for the Content-type header.
|
||||
headers = { "Content-type": "application/x-www-form-urlencoded" }
|
||||
conn = httplib.HTTPConnection('closure-compiler.appspot.com')
|
||||
conn.request('POST', '/compile', params, headers)
|
||||
response = conn.getresponse()
|
||||
data = response.read()
|
||||
conn.close()
|
||||
if data.startswith("Error"):
|
||||
raise Exception(data)
|
||||
print "%.3f seconds to compile" % (time.time() - t)
|
||||
return data
|
||||
@@ -1,251 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from xml.dom.minidom import Document
|
||||
|
||||
try:
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
except ImportError:
|
||||
try:
|
||||
import cElementTree as ElementTree
|
||||
except ImportError:
|
||||
try:
|
||||
import elementtree.ElementTree as ElementTree
|
||||
except ImportError:
|
||||
import lxml.etree as ElementTree
|
||||
|
||||
missing_deps = False
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError, E:
|
||||
missing_deps = E
|
||||
|
||||
try:
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
except ImportError, E:
|
||||
missing_deps = E
|
||||
|
||||
feedName = "example-list.xml"
|
||||
feedPath = "http://openlayers.org/dev/examples/"
|
||||
|
||||
def getListOfExamples(relPath):
|
||||
"""
|
||||
returns list of .html filenames within a given path - excludes example-list.html
|
||||
"""
|
||||
examples = os.listdir(relPath)
|
||||
examples = [example for example in examples if example.endswith('.html') and example != "example-list.html"]
|
||||
return examples
|
||||
|
||||
|
||||
def getExampleHtml(path):
|
||||
"""
|
||||
returns html of a specific example
|
||||
"""
|
||||
print '.',
|
||||
f = open(path)
|
||||
html = f.read()
|
||||
f.close()
|
||||
return html
|
||||
|
||||
|
||||
def extractById(soup, tagId, value=None):
|
||||
"""
|
||||
returns full contents of a particular tag id
|
||||
"""
|
||||
beautifulTag = soup.find(id=tagId)
|
||||
if beautifulTag:
|
||||
if beautifulTag.contents:
|
||||
value = str(beautifulTag.renderContents()).strip()
|
||||
value = value.replace('\t','')
|
||||
value = value.replace('\n','')
|
||||
return value
|
||||
|
||||
def getRelatedClasses(html):
|
||||
"""
|
||||
parses the html, and returns a list of all OpenLayers Classes
|
||||
used within (ie what parts of OL the javascript uses).
|
||||
"""
|
||||
rawstr = r'''(?P<class>OpenLayers\..*?)\('''
|
||||
return re.findall(rawstr, html)
|
||||
|
||||
def parseHtml(html,ids):
|
||||
"""
|
||||
returns dictionary of items of interest
|
||||
"""
|
||||
soup = BeautifulSoup(html)
|
||||
d = {}
|
||||
for tagId in ids:
|
||||
d[tagId] = extractById(soup,tagId)
|
||||
#classes should eventually be parsed from docs - not automatically created.
|
||||
classes = getRelatedClasses(html)
|
||||
d['classes'] = classes
|
||||
return d
|
||||
|
||||
def getGitInfo(exampleDir, exampleName):
|
||||
orig = os.getcwd()
|
||||
os.chdir(exampleDir)
|
||||
h = os.popen("git log -n 1 --pretty=format:'%an|%ai' " + exampleName)
|
||||
os.chdir(orig)
|
||||
log = h.read()
|
||||
h.close()
|
||||
d = {}
|
||||
parts = log.split("|")
|
||||
d["author"] = parts[0]
|
||||
# compensate for spaces in git log time
|
||||
td = parts[1].split(" ")
|
||||
td.insert(1, "T")
|
||||
d["date"] = "".join(td)
|
||||
return d
|
||||
|
||||
def createFeed(examples):
|
||||
doc = Document()
|
||||
atomuri = "http://www.w3.org/2005/Atom"
|
||||
feed = doc.createElementNS(atomuri, "feed")
|
||||
feed.setAttribute("xmlns", atomuri)
|
||||
title = doc.createElementNS(atomuri, "title")
|
||||
title.appendChild(doc.createTextNode("OpenLayers Examples"))
|
||||
feed.appendChild(title)
|
||||
link = doc.createElementNS(atomuri, "link")
|
||||
link.setAttribute("rel", "self")
|
||||
link.setAttribute("href", feedPath + feedName)
|
||||
|
||||
modtime = time.strftime("%Y-%m-%dT%I:%M:%SZ", time.gmtime())
|
||||
id = doc.createElementNS(atomuri, "id")
|
||||
id.appendChild(doc.createTextNode("%s%s#%s" % (feedPath, feedName, modtime)))
|
||||
feed.appendChild(id)
|
||||
|
||||
updated = doc.createElementNS(atomuri, "updated")
|
||||
updated.appendChild(doc.createTextNode(modtime))
|
||||
feed.appendChild(updated)
|
||||
|
||||
examples.sort(key=lambda x:x["modified"])
|
||||
for example in sorted(examples, key=lambda x:x["modified"], reverse=True):
|
||||
entry = doc.createElementNS(atomuri, "entry")
|
||||
|
||||
title = doc.createElementNS(atomuri, "title")
|
||||
title.appendChild(doc.createTextNode(example["title"] or example["example"]))
|
||||
entry.appendChild(title)
|
||||
|
||||
tags = doc.createElementNS(atomuri, "tags")
|
||||
tags.appendChild(doc.createTextNode(example["tags"] or example["example"]))
|
||||
entry.appendChild(tags)
|
||||
|
||||
link = doc.createElementNS(atomuri, "link")
|
||||
link.setAttribute("href", "%s%s" % (feedPath, example["example"]))
|
||||
entry.appendChild(link)
|
||||
|
||||
summary = doc.createElementNS(atomuri, "summary")
|
||||
summary.appendChild(doc.createTextNode(example["shortdesc"] or example["example"]))
|
||||
entry.appendChild(summary)
|
||||
|
||||
updated = doc.createElementNS(atomuri, "updated")
|
||||
updated.appendChild(doc.createTextNode(example["modified"]))
|
||||
entry.appendChild(updated)
|
||||
|
||||
author = doc.createElementNS(atomuri, "author")
|
||||
name = doc.createElementNS(atomuri, "name")
|
||||
name.appendChild(doc.createTextNode(example["author"]))
|
||||
author.appendChild(name)
|
||||
entry.appendChild(author)
|
||||
|
||||
id = doc.createElementNS(atomuri, "id")
|
||||
id.appendChild(doc.createTextNode("%s%s#%s" % (feedPath, example["example"], example["modified"])))
|
||||
entry.appendChild(id)
|
||||
|
||||
feed.appendChild(entry)
|
||||
|
||||
doc.appendChild(feed)
|
||||
return doc
|
||||
|
||||
def wordIndex(examples):
|
||||
"""
|
||||
Create an inverted index based on words in title and shortdesc. Keys are
|
||||
lower cased words. Values are dictionaries with example index keys and
|
||||
count values.
|
||||
"""
|
||||
index = {}
|
||||
unword = re.compile("\\W+")
|
||||
keys = ["shortdesc", "title", "tags"]
|
||||
for i in range(len(examples)):
|
||||
for key in keys:
|
||||
text = examples[i][key]
|
||||
if text:
|
||||
words = unword.split(text)
|
||||
for word in words:
|
||||
if word:
|
||||
word = word.lower()
|
||||
if index.has_key(word):
|
||||
if index[word].has_key(i):
|
||||
index[word][i] += 1
|
||||
else:
|
||||
index[word][i] = 1
|
||||
else:
|
||||
index[word] = {i: 1}
|
||||
return index
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if missing_deps:
|
||||
print "This script requires json or simplejson and BeautifulSoup. You don't have them. \n(%s)" % E
|
||||
sys.exit()
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
inExampleDir = sys.argv[1]
|
||||
outExampleDir = sys.argv[2]
|
||||
else:
|
||||
inExampleDir = "../examples"
|
||||
outExampleDir = "../examples"
|
||||
|
||||
outFile = open(os.path.join(outExampleDir, "example-list.js"), "w")
|
||||
|
||||
print 'Reading examples from %s and writing out to %s' % (inExampleDir, outFile.name)
|
||||
|
||||
exampleList = []
|
||||
docIds = ['title','shortdesc','tags']
|
||||
|
||||
examples = getListOfExamples(inExampleDir)
|
||||
|
||||
modtime = time.strftime("%Y-%m-%dT%I:%M:%SZ", time.gmtime())
|
||||
|
||||
for example in examples:
|
||||
path = os.path.join(inExampleDir, example)
|
||||
html = getExampleHtml(path)
|
||||
tagvalues = parseHtml(html,docIds)
|
||||
tagvalues['example'] = example
|
||||
# add in author/date info
|
||||
d = getGitInfo(inExampleDir, example)
|
||||
tagvalues["author"] = d["author"] or "anonymous"
|
||||
tagvalues["modified"] = d["date"] or modtime
|
||||
tagvalues['link'] = example
|
||||
|
||||
exampleList.append(tagvalues)
|
||||
|
||||
print
|
||||
|
||||
exampleList.sort(key=lambda x:x['example'].lower())
|
||||
|
||||
index = wordIndex(exampleList)
|
||||
|
||||
json = json.dumps({"examples": exampleList, "index": index})
|
||||
#give the json a global variable we can use in our js. This should be replaced or made optional.
|
||||
json = 'var info=' + json
|
||||
outFile.write(json)
|
||||
outFile.close()
|
||||
|
||||
outFeedPath = os.path.join(outExampleDir, feedName);
|
||||
print "writing feed to %s " % outFeedPath
|
||||
atom = open(outFeedPath, 'w')
|
||||
doc = createFeed(exampleList)
|
||||
atom.write(doc.toxml())
|
||||
atom.close()
|
||||
|
||||
|
||||
print 'complete'
|
||||
|
||||
|
||||
272
tools/jsmin.c
272
tools/jsmin.c
@@ -1,272 +0,0 @@
|
||||
/* jsmin.c
|
||||
2006-05-04
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int theA;
|
||||
static int theB;
|
||||
static int theLookahead = EOF;
|
||||
|
||||
|
||||
/* isAlphanum -- return true if the character is a letter, digit, underscore,
|
||||
dollar sign, or non-ASCII character.
|
||||
*/
|
||||
|
||||
static int
|
||||
isAlphanum(int c)
|
||||
{
|
||||
return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
|
||||
(c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c == '\\' ||
|
||||
c > 126);
|
||||
}
|
||||
|
||||
|
||||
/* get -- return the next character from stdin. Watch out for lookahead. If
|
||||
the character is a control character, translate it to a space or
|
||||
linefeed.
|
||||
*/
|
||||
|
||||
static int
|
||||
get()
|
||||
{
|
||||
int c = theLookahead;
|
||||
theLookahead = EOF;
|
||||
if (c == EOF) {
|
||||
c = getc(stdin);
|
||||
}
|
||||
if (c >= ' ' || c == '\n' || c == EOF) {
|
||||
return c;
|
||||
}
|
||||
if (c == '\r') {
|
||||
return '\n';
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
|
||||
|
||||
/* peek -- get the next character without getting it.
|
||||
*/
|
||||
|
||||
static int
|
||||
peek()
|
||||
{
|
||||
theLookahead = get();
|
||||
return theLookahead;
|
||||
}
|
||||
|
||||
|
||||
/* next -- get the next character, excluding comments. peek() is used to see
|
||||
if a '/' is followed by a '/' or '*'.
|
||||
*/
|
||||
|
||||
static int
|
||||
next()
|
||||
{
|
||||
int c = get();
|
||||
if (c == '/') {
|
||||
switch (peek()) {
|
||||
case '/':
|
||||
for (;;) {
|
||||
c = get();
|
||||
if (c <= '\n') {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
case '*':
|
||||
get();
|
||||
for (;;) {
|
||||
switch (get()) {
|
||||
case '*':
|
||||
if (peek() == '/') {
|
||||
get();
|
||||
return ' ';
|
||||
}
|
||||
break;
|
||||
case EOF:
|
||||
fprintf(stderr, "Error: JSMIN Unterminated comment.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
default:
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/* action -- do something! What you do is determined by the argument:
|
||||
1 Output A. Copy B to A. Get the next B.
|
||||
2 Copy B to A. Get the next B. (Delete A).
|
||||
3 Get the next B. (Delete B).
|
||||
action treats a string as a single character. Wow!
|
||||
action recognizes a regular expression if it is preceded by ( or , or =.
|
||||
*/
|
||||
|
||||
static void
|
||||
action(int d)
|
||||
{
|
||||
switch (d) {
|
||||
case 1:
|
||||
putc(theA, stdout);
|
||||
case 2:
|
||||
theA = theB;
|
||||
if (theA == '\'' || theA == '"') {
|
||||
for (;;) {
|
||||
putc(theA, stdout);
|
||||
theA = get();
|
||||
if (theA == theB) {
|
||||
break;
|
||||
}
|
||||
if (theA <= '\n') {
|
||||
fprintf(stderr,
|
||||
"Error: JSMIN unterminated string literal: %c\n", theA);
|
||||
exit(1);
|
||||
}
|
||||
if (theA == '\\') {
|
||||
putc(theA, stdout);
|
||||
theA = get();
|
||||
}
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
theB = next();
|
||||
if (theB == '/' && (theA == '(' || theA == ',' || theA == '=' ||
|
||||
theA == ':' || theA == '[' || theA == '!' || theA == '&' ||
|
||||
theA == '|')) {
|
||||
putc(theA, stdout);
|
||||
putc(theB, stdout);
|
||||
for (;;) {
|
||||
theA = get();
|
||||
if (theA == '/') {
|
||||
break;
|
||||
} else if (theA =='\\') {
|
||||
putc(theA, stdout);
|
||||
theA = get();
|
||||
} else if (theA <= '\n') {
|
||||
fprintf(stderr,
|
||||
"Error: JSMIN unterminated Regular Expression literal.\n", theA);
|
||||
exit(1);
|
||||
}
|
||||
putc(theA, stdout);
|
||||
}
|
||||
theB = next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* jsmin -- Copy the input to the output, deleting the characters which are
|
||||
insignificant to JavaScript. Comments will be removed. Tabs will be
|
||||
replaced with spaces. Carriage returns will be replaced with linefeeds.
|
||||
Most spaces and linefeeds will be removed.
|
||||
*/
|
||||
|
||||
static void
|
||||
jsmin()
|
||||
{
|
||||
theA = '\n';
|
||||
action(3);
|
||||
while (theA != EOF) {
|
||||
switch (theA) {
|
||||
case ' ':
|
||||
if (isAlphanum(theB)) {
|
||||
action(1);
|
||||
} else {
|
||||
action(2);
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
switch (theB) {
|
||||
case '{':
|
||||
case '[':
|
||||
case '(':
|
||||
case '+':
|
||||
case '-':
|
||||
action(1);
|
||||
break;
|
||||
case ' ':
|
||||
action(3);
|
||||
break;
|
||||
default:
|
||||
if (isAlphanum(theB)) {
|
||||
action(1);
|
||||
} else {
|
||||
action(2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (theB) {
|
||||
case ' ':
|
||||
if (isAlphanum(theA)) {
|
||||
action(1);
|
||||
break;
|
||||
}
|
||||
action(3);
|
||||
break;
|
||||
case '\n':
|
||||
switch (theA) {
|
||||
case '}':
|
||||
case ']':
|
||||
case ')':
|
||||
case '+':
|
||||
case '-':
|
||||
case '"':
|
||||
case '\'':
|
||||
action(1);
|
||||
break;
|
||||
default:
|
||||
if (isAlphanum(theA)) {
|
||||
action(1);
|
||||
} else {
|
||||
action(3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
action(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* main -- Output any command line arguments as comments
|
||||
and then minify the input.
|
||||
*/
|
||||
extern int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i += 1) {
|
||||
fprintf(stdout, "// %s\n", argv[i]);
|
||||
}
|
||||
jsmin();
|
||||
return 0;
|
||||
}
|
||||
216
tools/jsmin.py
216
tools/jsmin.py
@@ -1,216 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# This code is original from jsmin by Douglas Crockford, it was translated to
|
||||
# Python by Baruch Even. The original code had the following copyright and
|
||||
# license.
|
||||
#
|
||||
# /* jsmin.c
|
||||
# 2007-01-08
|
||||
#
|
||||
# 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.
|
||||
# */
|
||||
|
||||
from StringIO import StringIO
|
||||
|
||||
def jsmin(js):
|
||||
ins = StringIO(js)
|
||||
outs = StringIO()
|
||||
JavascriptMinify().minify(ins, outs)
|
||||
str = outs.getvalue()
|
||||
if len(str) > 0 and str[0] == '\n':
|
||||
str = str[1:]
|
||||
return str
|
||||
|
||||
def isAlphanum(c):
|
||||
"""return true if the character is a letter, digit, underscore,
|
||||
dollar sign, or non-ASCII character.
|
||||
"""
|
||||
return ((c >= 'a' and c <= 'z') or (c >= '0' and c <= '9') or
|
||||
(c >= 'A' and c <= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) > 126));
|
||||
|
||||
class UnterminatedComment(Exception):
|
||||
pass
|
||||
|
||||
class UnterminatedStringLiteral(Exception):
|
||||
pass
|
||||
|
||||
class UnterminatedRegularExpression(Exception):
|
||||
pass
|
||||
|
||||
class JavascriptMinify(object):
|
||||
|
||||
def _outA(self):
|
||||
self.outstream.write(self.theA)
|
||||
def _outB(self):
|
||||
self.outstream.write(self.theB)
|
||||
|
||||
def _get(self):
|
||||
"""return the next character from stdin. Watch out for lookahead. If
|
||||
the character is a control character, translate it to a space or
|
||||
linefeed.
|
||||
"""
|
||||
c = self.theLookahead
|
||||
self.theLookahead = None
|
||||
if c == None:
|
||||
c = self.instream.read(1)
|
||||
if c >= ' ' or c == '\n':
|
||||
return c
|
||||
if c == '': # EOF
|
||||
return '\000'
|
||||
if c == '\r':
|
||||
return '\n'
|
||||
return ' '
|
||||
|
||||
def _peek(self):
|
||||
self.theLookahead = self._get()
|
||||
return self.theLookahead
|
||||
|
||||
def _next(self):
|
||||
"""get the next character, excluding comments. peek() is used to see
|
||||
if a '/' is followed by a '/' or '*'.
|
||||
"""
|
||||
c = self._get()
|
||||
if c == '/':
|
||||
p = self._peek()
|
||||
if p == '/':
|
||||
c = self._get()
|
||||
while c > '\n':
|
||||
c = self._get()
|
||||
return c
|
||||
if p == '*':
|
||||
c = self._get()
|
||||
while 1:
|
||||
c = self._get()
|
||||
if c == '*':
|
||||
if self._peek() == '/':
|
||||
self._get()
|
||||
return ' '
|
||||
if c == '\000':
|
||||
raise UnterminatedComment()
|
||||
|
||||
return c
|
||||
|
||||
def _action(self, action):
|
||||
"""do something! What you do is determined by the argument:
|
||||
1 Output A. Copy B to A. Get the next B.
|
||||
2 Copy B to A. Get the next B. (Delete A).
|
||||
3 Get the next B. (Delete B).
|
||||
action treats a string as a single character. Wow!
|
||||
action recognizes a regular expression if it is preceded by ( or , or =.
|
||||
"""
|
||||
if action <= 1:
|
||||
self._outA()
|
||||
|
||||
if action <= 2:
|
||||
self.theA = self.theB
|
||||
if self.theA == "'" or self.theA == '"':
|
||||
while 1:
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
if self.theA == self.theB:
|
||||
break
|
||||
if self.theA <= '\n':
|
||||
raise UnterminatedStringLiteral()
|
||||
if self.theA == '\\':
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
|
||||
|
||||
if action <= 3:
|
||||
self.theB = self._next()
|
||||
if self.theB == '/' and (self.theA == '(' or self.theA == ',' or
|
||||
self.theA == '=' or self.theA == ':' or
|
||||
self.theA == '[' or self.theA == '?' or
|
||||
self.theA == '!' or self.theA == '&' or
|
||||
self.theA == '|'):
|
||||
self._outA()
|
||||
self._outB()
|
||||
while 1:
|
||||
self.theA = self._get()
|
||||
if self.theA == '/':
|
||||
break
|
||||
elif self.theA == '\\':
|
||||
self._outA()
|
||||
self.theA = self._get()
|
||||
elif self.theA <= '\n':
|
||||
raise UnterminatedRegularExpression()
|
||||
self._outA()
|
||||
self.theB = self._next()
|
||||
|
||||
|
||||
def _jsmin(self):
|
||||
"""Copy the input to the output, deleting the characters which are
|
||||
insignificant to JavaScript. Comments will be removed. Tabs will be
|
||||
replaced with spaces. Carriage returns will be replaced with linefeeds.
|
||||
Most spaces and linefeeds will be removed.
|
||||
"""
|
||||
self.theA = '\n'
|
||||
self._action(3)
|
||||
|
||||
while self.theA != '\000':
|
||||
if self.theA == ' ':
|
||||
if isAlphanum(self.theB):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(2)
|
||||
elif self.theA == '\n':
|
||||
if self.theB in ['{', '[', '(', '+', '-']:
|
||||
self._action(1)
|
||||
elif self.theB == ' ':
|
||||
self._action(3)
|
||||
else:
|
||||
if isAlphanum(self.theB):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(2)
|
||||
else:
|
||||
if self.theB == ' ':
|
||||
if isAlphanum(self.theA):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(3)
|
||||
elif self.theB == '\n':
|
||||
if self.theA in ['}', ']', ')', '+', '-', '"', '\'']:
|
||||
self._action(1)
|
||||
else:
|
||||
if isAlphanum(self.theA):
|
||||
self._action(1)
|
||||
else:
|
||||
self._action(3)
|
||||
else:
|
||||
self._action(1)
|
||||
|
||||
def minify(self, instream, outstream):
|
||||
self.instream = instream
|
||||
self.outstream = outstream
|
||||
self.theA = None
|
||||
self.thaB = None
|
||||
self.theLookahead = None
|
||||
|
||||
self._jsmin()
|
||||
self.instream.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
jsm = JavascriptMinify()
|
||||
jsm.minify(sys.stdin, sys.stdout)
|
||||
287
tools/mergejs.py
287
tools/mergejs.py
@@ -1,287 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Merge multiple JavaScript source code files into one.
|
||||
#
|
||||
# Usage:
|
||||
# This script requires source files to have dependencies specified in them.
|
||||
#
|
||||
# Dependencies are specified with a comment of the form:
|
||||
#
|
||||
# // @requires <file path>
|
||||
#
|
||||
# e.g.
|
||||
#
|
||||
# // @requires Geo/DataSource.js
|
||||
#
|
||||
# This script should be executed like so:
|
||||
#
|
||||
# mergejs.py <output.js> <directory> [...]
|
||||
#
|
||||
# e.g.
|
||||
#
|
||||
# mergejs.py openlayers.js Geo/ CrossBrowser/
|
||||
#
|
||||
# This example will cause the script to walk the `Geo` and
|
||||
# `CrossBrowser` directories--and subdirectories thereof--and import
|
||||
# all `*.js` files encountered. The dependency declarations will be extracted
|
||||
# and then the source code from imported files will be output to
|
||||
# a file named `openlayers.js` in an order which fulfils the dependencies
|
||||
# specified.
|
||||
#
|
||||
#
|
||||
# Note: This is a very rough initial version of this code.
|
||||
#
|
||||
# -- Copyright 2005-2012 OpenLayers contributors / OpenLayers project --
|
||||
#
|
||||
|
||||
# TODO: Allow files to be excluded. e.g. `Crossbrowser/DebugMode.js`?
|
||||
# TODO: Report error when dependency can not be found rather than KeyError.
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
SUFFIX_JAVASCRIPT = ".js"
|
||||
|
||||
RE_REQUIRE = "@requires?:?\s+(\S*)\s*\n" # TODO: Ensure in comment?
|
||||
|
||||
class MissingImport(Exception):
|
||||
"""Exception raised when a listed import is not found in the lib."""
|
||||
|
||||
class SourceFile:
|
||||
"""
|
||||
Represents a Javascript source code file.
|
||||
"""
|
||||
|
||||
def __init__(self, filepath, source, cfgExclude):
|
||||
"""
|
||||
"""
|
||||
self.filepath = filepath
|
||||
self.source = source
|
||||
|
||||
self.excludedFiles = []
|
||||
self.requiredFiles = []
|
||||
auxReq = re.findall(RE_REQUIRE, self.source)
|
||||
for filename in auxReq:
|
||||
if undesired(filename, cfgExclude):
|
||||
self.excludedFiles.append(filename)
|
||||
else:
|
||||
self.requiredFiles.append(filename)
|
||||
|
||||
self.requiredBy = []
|
||||
|
||||
|
||||
def _getRequirements(self):
|
||||
"""
|
||||
Extracts the dependencies specified in the source code and returns
|
||||
a list of them.
|
||||
"""
|
||||
return self.requiredFiles
|
||||
|
||||
requires = property(fget=_getRequirements, doc="")
|
||||
|
||||
|
||||
|
||||
def usage(filename):
|
||||
"""
|
||||
Displays a usage message.
|
||||
"""
|
||||
print "%s [-c <config file>] <output.js> <directory> [...]" % filename
|
||||
|
||||
|
||||
class Config:
|
||||
"""
|
||||
Represents a parsed configuration file.
|
||||
|
||||
A configuration file should be of the following form:
|
||||
|
||||
[first]
|
||||
3rd/prototype.js
|
||||
core/application.js
|
||||
core/params.js
|
||||
# A comment
|
||||
|
||||
[last]
|
||||
core/api.js # Another comment
|
||||
|
||||
[exclude]
|
||||
3rd/logger.js
|
||||
exclude/this/dir
|
||||
|
||||
All headings are required.
|
||||
|
||||
The files listed in the `first` section will be forced to load
|
||||
*before* all other files (in the order listed). The files in `last`
|
||||
section will be forced to load *after* all the other files (in the
|
||||
order listed).
|
||||
|
||||
The files list in the `exclude` section will not be imported.
|
||||
|
||||
Any text appearing after a # symbol indicates a comment.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
"""
|
||||
Parses the content of the named file and stores the values.
|
||||
"""
|
||||
lines = [re.sub("#.*?$", "", line).strip() # Assumes end-of-line character is present
|
||||
for line in open(filename)
|
||||
if line.strip() and not line.strip().startswith("#")] # Skip blank lines and comments
|
||||
|
||||
self.forceFirst = lines[lines.index("[first]") + 1:lines.index("[last]")]
|
||||
|
||||
self.forceLast = lines[lines.index("[last]") + 1:lines.index("[include]")]
|
||||
self.include = lines[lines.index("[include]") + 1:lines.index("[exclude]")]
|
||||
self.exclude = lines[lines.index("[exclude]") + 1:]
|
||||
|
||||
def undesired(filepath, excludes):
|
||||
# exclude file if listed
|
||||
exclude = filepath in excludes
|
||||
if not exclude:
|
||||
# check if directory is listed
|
||||
for excludepath in excludes:
|
||||
if not excludepath.endswith("/"):
|
||||
excludepath += "/"
|
||||
if filepath.startswith(excludepath):
|
||||
exclude = True
|
||||
break
|
||||
return exclude
|
||||
|
||||
|
||||
def getNames (sourceDirectory, configFile = None):
|
||||
return run(sourceDirectory, None, configFile, True)
|
||||
|
||||
|
||||
def run (sourceDirectory, outputFilename = None, configFile = None,
|
||||
returnAsListOfNames = False):
|
||||
cfg = None
|
||||
if configFile:
|
||||
cfg = Config(configFile)
|
||||
|
||||
allFiles = []
|
||||
|
||||
## Find all the Javascript source files
|
||||
for root, dirs, files in os.walk(sourceDirectory):
|
||||
for filename in files:
|
||||
if filename.endswith(SUFFIX_JAVASCRIPT) and not filename.startswith("."):
|
||||
filepath = os.path.join(root, filename)[len(sourceDirectory)+1:]
|
||||
filepath = filepath.replace("\\", "/")
|
||||
if cfg and cfg.include:
|
||||
if filepath in cfg.include or filepath in cfg.forceFirst:
|
||||
allFiles.append(filepath)
|
||||
elif (not cfg) or (not undesired(filepath, cfg.exclude)):
|
||||
allFiles.append(filepath)
|
||||
|
||||
## Header inserted at the start of each file in the output
|
||||
HEADER = "/* " + "=" * 70 + "\n %s\n" + " " + "=" * 70 + " */\n\n"
|
||||
|
||||
files = {}
|
||||
|
||||
## Import file source code
|
||||
## TODO: Do import when we walk the directories above?
|
||||
for filepath in allFiles:
|
||||
print "Importing: %s" % filepath
|
||||
fullpath = os.path.join(sourceDirectory, filepath).strip()
|
||||
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
|
||||
files[filepath] = SourceFile(filepath, content, cfg.exclude) # TODO: Chop path?
|
||||
|
||||
print
|
||||
|
||||
from toposort import toposort
|
||||
|
||||
complete = False
|
||||
resolution_pass = 1
|
||||
|
||||
while not complete:
|
||||
complete = True
|
||||
|
||||
## Resolve the dependencies
|
||||
print "Resolution pass %s... " % resolution_pass
|
||||
resolution_pass += 1
|
||||
|
||||
for filepath, info in files.items():
|
||||
for path in info.requires:
|
||||
if not files.has_key(path):
|
||||
complete = False
|
||||
fullpath = os.path.join(sourceDirectory, path).strip()
|
||||
if os.path.exists(fullpath):
|
||||
print "Importing: %s" % path
|
||||
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
|
||||
files[path] = SourceFile(path, content, cfg.exclude) # TODO: Chop path?
|
||||
else:
|
||||
raise MissingImport("File '%s' not found (required by '%s')." % (path, filepath))
|
||||
|
||||
# create dictionary of dependencies
|
||||
dependencies = {}
|
||||
for filepath, info in files.items():
|
||||
dependencies[filepath] = info.requires
|
||||
|
||||
print "Sorting..."
|
||||
order = toposort(dependencies) #[x for x in toposort(dependencies)]
|
||||
|
||||
## Move forced first and last files to the required position
|
||||
if cfg:
|
||||
print "Re-ordering files..."
|
||||
order = cfg.forceFirst + [item
|
||||
for item in order
|
||||
if ((item not in cfg.forceFirst) and
|
||||
(item not in cfg.forceLast))] + cfg.forceLast
|
||||
|
||||
print
|
||||
## Output the files in the determined order
|
||||
result = []
|
||||
|
||||
# Return as a list of filenames
|
||||
if returnAsListOfNames:
|
||||
for fp in order:
|
||||
fName = os.path.normpath(os.path.join(sourceDirectory, fp)).replace("\\","/")
|
||||
print "Append: ", fName
|
||||
f = files[fp]
|
||||
for fExclude in f.excludedFiles:
|
||||
print " Required file \"%s\" is excluded." % fExclude
|
||||
result.append(fName)
|
||||
print "\nTotal files: %d " % len(result)
|
||||
return result
|
||||
|
||||
# Return as merged source code
|
||||
for fp in order:
|
||||
f = files[fp]
|
||||
print "Exporting: ", f.filepath
|
||||
for fExclude in f.excludedFiles:
|
||||
print " Required file \"%s\" is excluded." % fExclude
|
||||
result.append(HEADER % f.filepath)
|
||||
source = f.source
|
||||
result.append(source)
|
||||
if not source.endswith("\n"):
|
||||
result.append("\n")
|
||||
|
||||
print "\nTotal files merged: %d " % len(files)
|
||||
|
||||
if outputFilename:
|
||||
print "\nGenerating: %s" % (outputFilename)
|
||||
open(outputFilename, "w").write("".join(result))
|
||||
return "".join(result)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import getopt
|
||||
|
||||
options, args = getopt.getopt(sys.argv[1:], "-c:")
|
||||
|
||||
try:
|
||||
outputFilename = args[0]
|
||||
except IndexError:
|
||||
usage(sys.argv[0])
|
||||
raise SystemExit
|
||||
else:
|
||||
sourceDirectory = args[1]
|
||||
if not sourceDirectory:
|
||||
usage(sys.argv[0])
|
||||
raise SystemExit
|
||||
|
||||
configFile = None
|
||||
if options and options[0][0] == "-c":
|
||||
configFile = options[0][1]
|
||||
print "Parsing configuration file: %s" % filename
|
||||
|
||||
run( sourceDirectory, outputFilename, configFile )
|
||||
@@ -1,47 +0,0 @@
|
||||
# Minimal Python Minimizer
|
||||
# Copyright 2008, Christopher Schmidt
|
||||
# Released under the MIT License
|
||||
#
|
||||
# Taken from: http://svn.crschmidt.net/personal/python/minimize.py
|
||||
# $Id: minimize.py 6 2008-01-03 06:33:35Z crschmidt $
|
||||
#
|
||||
# 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 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.
|
||||
|
||||
import re
|
||||
|
||||
def strip_comments_helper(data):
|
||||
"""remove all /* */ format comments and surrounding whitespace."""
|
||||
p = re.compile(r'[\s]*/\*.*?\*/[\s]*', re.DOTALL)
|
||||
return p.sub('',data)
|
||||
|
||||
def minimize(data, exclude=None):
|
||||
"""Central function call. This will call all other compression
|
||||
functions. To add further compression algorithms, simply add
|
||||
functions whose names end in _helper which take a string as input
|
||||
and return a more compressed string as output."""
|
||||
for key, item in globals().iteritems():
|
||||
if key.endswith("_helper"):
|
||||
func_key = key[:-7]
|
||||
if not exclude or not func_key in exclude:
|
||||
data = item(data)
|
||||
return data
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
print minimize(open(sys.argv[1]).read())
|
||||
@@ -1,43 +0,0 @@
|
||||
import re
|
||||
import os
|
||||
def run():
|
||||
sourceDirectory = "../lib/OpenLayers"
|
||||
allFiles = []
|
||||
SUFFIX_JAVASCRIPT = ".js"
|
||||
## Find all the Javascript source files
|
||||
for root, dirs, files in os.walk(sourceDirectory):
|
||||
for filename in files:
|
||||
if filename.endswith(SUFFIX_JAVASCRIPT) and not filename.startswith("."):
|
||||
filepath = os.path.join(root, filename)[len(sourceDirectory)+1:]
|
||||
filepath = filepath.replace("\\", "/")
|
||||
data = open(os.path.join(sourceDirectory, filepath)).read()
|
||||
parents = re.search("OpenLayers.Class\((.*?){", data,
|
||||
re.DOTALL)
|
||||
if parents:
|
||||
parents = [x.strip() for x in parents.group(1).strip().strip(",").split(",")]
|
||||
else:
|
||||
parents = []
|
||||
cls = "OpenLayers.%s" % filepath.strip(".js").replace("/", ".")
|
||||
allFiles.append([cls, parents])
|
||||
return allFiles
|
||||
print """
|
||||
digraph name {
|
||||
fontname = "Helvetica"
|
||||
fontsize = 8
|
||||
K = 0.6
|
||||
|
||||
node [
|
||||
fontname = "Helvetica"
|
||||
fontsize = 8
|
||||
shape = "plaintext"
|
||||
]
|
||||
"""
|
||||
|
||||
for i in run():
|
||||
print i[0].replace(".", "_")
|
||||
for item in i[1]:
|
||||
if not item: continue
|
||||
print "%s -> %s" % (i[0].replace(".","_"), item.replace(".", "_"))
|
||||
print "; "
|
||||
|
||||
print """}"""
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
#
|
||||
# Usage:
|
||||
# $ ./release.sh <release_number>
|
||||
#
|
||||
# Example:
|
||||
# $ ./release.sh 2.12-rc7
|
||||
#
|
||||
# This script should be run on the www.openlayers.org server.
|
||||
#
|
||||
# What the script does:
|
||||
#
|
||||
# 1. Download release tarball from from GitHub.
|
||||
# 2. Create builds using the Closure Compiler.
|
||||
# 3. Run the exampleparser.py script to create the examples index.
|
||||
# 4. Run csstidy for each CSS file in theme/default.
|
||||
# 5. Publish builds and resources on api.openlayers.org.
|
||||
# 6. Build the API docs.
|
||||
# 7. Create release archives
|
||||
# 8. Make the release archives available on openlayers.org/downloads.
|
||||
#
|
||||
#
|
||||
|
||||
VERSION=$1
|
||||
|
||||
wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip
|
||||
unzip compiler-latest.zip
|
||||
|
||||
wget -O release-${VERSION}.tar.gz https://github.com/openlayers/openlayers/tarball/release-${VERSION}
|
||||
tar xvzf release-${VERSION}.tar.gz
|
||||
mv openlayers-openlayers-* OpenLayers-${VERSION}
|
||||
cd OpenLayers-${VERSION}/build
|
||||
|
||||
mv ../../compiler.jar ../tools/closure-compiler.jar
|
||||
./build.py -c closure full
|
||||
./build.py -c closure mobile OpenLayers.mobile.js
|
||||
./build.py -c closure light OpenLayers.light.js
|
||||
./build.py -c none full OpenLayers.debug.js
|
||||
./build.py -c none mobile OpenLayers.mobile.debug.js
|
||||
./build.py -c none light OpenLayers.light.debug.js
|
||||
mv OpenLayers*.js ../
|
||||
rm -rf closure-compiler
|
||||
rm closure*.py
|
||||
rm ../tools/closure-compiler.jar
|
||||
|
||||
cd ..
|
||||
cd tools
|
||||
python exampleparser.py
|
||||
cd ..
|
||||
for i in google ie6-style style style.mobile; do
|
||||
csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css
|
||||
done
|
||||
|
||||
mkdir -p doc/devdocs
|
||||
mkdir -p doc/apidocs
|
||||
rm tools/*.pyc
|
||||
|
||||
mkdir -p /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||
cp OpenLayers*.js /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||
cp -a img/ /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||
cp -a theme/ /osgeo/openlayers/sites/openlayers.org/api/$VERSION
|
||||
|
||||
cd ..
|
||||
|
||||
naturaldocs -i OpenLayers-$VERSION/lib -o HTML OpenLayers-$VERSION/doc/devdocs -p OpenLayers-$VERSION/doc_config -s Small OL
|
||||
naturaldocs -i OpenLayers-$VERSION/lib -o HTML OpenLayers-$VERSION/doc/apidocs -p OpenLayers-$VERSION/apidoc_config -s Small OL
|
||||
|
||||
tar cvfz OpenLayers-$VERSION.tar.gz OpenLayers-$VERSION/
|
||||
zip -9r OpenLayers-$VERSION.zip OpenLayers-$VERSION/
|
||||
|
||||
cp OpenLayers-$VERSION.* /osgeo/openlayers/sites/openlayers.org/download
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Script to provide a wrapper around the ShrinkSafe "web service"
|
||||
# <http://shrinksafe.dojotoolkit.org/>
|
||||
#
|
||||
|
||||
#
|
||||
# We use this script for two reasons:
|
||||
#
|
||||
# * This avoids having to install and configure Java and the standalone
|
||||
# ShrinkSafe utility.
|
||||
#
|
||||
# * The current ShrinkSafe standalone utility was broken when we last
|
||||
# used it.
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
URL_SHRINK_SAFE = "http://shrinksafe.dojotoolkit.org/shrinksafe.php"
|
||||
|
||||
# This would normally be dynamically generated:
|
||||
BOUNDARY_MARKER = "---------------------------72288400411964641492083565382"
|
||||
|
||||
if __name__ == "__main__":
|
||||
## Grab the source code
|
||||
try:
|
||||
sourceFilename = sys.argv[1]
|
||||
except:
|
||||
print "Usage: %s (<source filename>|-)" % sys.argv[0]
|
||||
raise SystemExit
|
||||
|
||||
if sourceFilename == "-":
|
||||
sourceCode = sys.stdin.read()
|
||||
sourceFilename = "stdin.js"
|
||||
else:
|
||||
sourceCode = open(sourceFilename).read()
|
||||
|
||||
## Create the request replicating posting of the form from the web page
|
||||
request = urllib2.Request(url=URL_SHRINK_SAFE)
|
||||
request.add_header("Content-Type",
|
||||
"multipart/form-data; boundary=%s" % BOUNDARY_MARKER)
|
||||
request.add_data("""
|
||||
--%s
|
||||
Content-Disposition: form-data; name="shrinkfile[]"; filename="%s"
|
||||
Content-Type: application/x-javascript
|
||||
|
||||
%s
|
||||
""" % (BOUNDARY_MARKER, sourceFilename, sourceCode))
|
||||
|
||||
## Deliver the result
|
||||
print urllib2.urlopen(request).read(),
|
||||
@@ -1,35 +0,0 @@
|
||||
"""
|
||||
toposort.py
|
||||
Sorts dictionary keys based on lists of dependencies.
|
||||
"""
|
||||
|
||||
class MissingDependency(Exception):
|
||||
"""Exception raised when a listed dependency is not in the dictionary."""
|
||||
|
||||
class Sorter(object):
|
||||
def __init__(self, dependencies):
|
||||
self.dependencies = dependencies
|
||||
self.visited = set()
|
||||
self.sorted = ()
|
||||
|
||||
def sort(self):
|
||||
for key in self.dependencies:
|
||||
self._visit(key)
|
||||
return self.sorted
|
||||
|
||||
def _visit(self, key):
|
||||
if key not in self.visited:
|
||||
self.visited.add(key)
|
||||
if not self.dependencies.has_key(key):
|
||||
raise MissingDependency(key)
|
||||
for depends in self.dependencies[key]:
|
||||
self._visit(depends)
|
||||
self.sorted += (key,)
|
||||
|
||||
def toposort(dependencies):
|
||||
"""Returns a tuple of the dependencies dictionary keys sorted by entries
|
||||
in the dependency lists. Given circular dependencies, sort will impose
|
||||
an order. Raises MissingDependency if a key is not found.
|
||||
"""
|
||||
s = Sorter(dependencies)
|
||||
return s.sort()
|
||||
@@ -1,103 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# check to see if the hosted examples or API docs need an update
|
||||
cd /osgeo/openlayers/repos/openlayers
|
||||
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/openlayers/ | grep HEAD | awk '{print $1}'`
|
||||
LOCAL_HEAD=`git rev-parse HEAD`
|
||||
|
||||
# if there's something different in the remote, update and build
|
||||
if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
|
||||
|
||||
git checkout master
|
||||
git clean -f
|
||||
git pull origin master
|
||||
|
||||
# copy everything over to the dev dir within the website (keep the clone clean)
|
||||
rsync -r --exclude=.git . /osgeo/openlayers/sites/openlayers.org/dev
|
||||
|
||||
# make examples use built lib
|
||||
cd /osgeo/openlayers/sites/openlayers.org/dev/tools
|
||||
|
||||
python exampleparser.py /osgeo/openlayers/repos/openlayers/examples /osgeo/openlayers/sites/openlayers.org/dev/examples
|
||||
|
||||
if [ ! -f closure-compiler.jar ]; then
|
||||
wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip
|
||||
unzip compiler-latest.zip
|
||||
mv compiler.jar closure-compiler.jar
|
||||
fi
|
||||
|
||||
cd /osgeo/openlayers/sites/openlayers.org/dev/build
|
||||
./build.py -c closure tests.cfg
|
||||
./build.py -c closure mobile.cfg OpenLayers.mobile.js
|
||||
./build.py -c closure light.cfg OpenLayers.light.js
|
||||
./build.py -c none tests.cfg OpenLayers.debug.js
|
||||
./build.py -c none mobile.cfg OpenLayers.mobile.debug.js
|
||||
./build.py -c none light.cfg OpenLayers.light.debug.js
|
||||
cp OpenLayers*.js ..
|
||||
|
||||
cd /osgeo/openlayers/sites/openlayers.org/dev
|
||||
sed -i -e 's!../lib/OpenLayers.js?mobile!../OpenLayers.mobile.js!' examples/*.html
|
||||
sed -i -e 's!../lib/OpenLayers.js!../OpenLayers.js!' examples/*.html
|
||||
|
||||
# update the API docs
|
||||
if [ ! -d /osgeo/openlayers/sites/dev.openlayers.org/apidocs ]; then
|
||||
mkdir -p /osgeo/openlayers/sites/dev.openlayers.org/apidocs
|
||||
fi
|
||||
if [ ! -d /osgeo/openlayers/sites/dev.openlayers.org/docs ]; then
|
||||
mkdir -p /osgeo/openlayers/sites/dev.openlayers.org/docs
|
||||
fi
|
||||
naturaldocs --input lib --output HTML /osgeo/openlayers/sites/dev.openlayers.org/apidocs -p apidoc_config -s Default OL
|
||||
naturaldocs --input lib --output HTML /osgeo/openlayers/sites/dev.openlayers.org/docs -p doc_config -s Default OL
|
||||
|
||||
fi
|
||||
|
||||
# check to see if the website needs an update
|
||||
cd /osgeo/openlayers/repos/website
|
||||
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/website/ | grep HEAD | awk '{print $1}'`
|
||||
LOCAL_HEAD=`git rev-parse HEAD`
|
||||
|
||||
# if there's something different in the remote, update the clone
|
||||
if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
|
||||
|
||||
git checkout master
|
||||
git clean -f
|
||||
git pull origin master
|
||||
|
||||
# copy everything over to the website dir (keep the clone clean)
|
||||
# can't use --delete here because of nested dev dir from above
|
||||
rsync -r --exclude=.git . /osgeo/openlayers/sites/openlayers.org
|
||||
|
||||
fi
|
||||
|
||||
# check to see if prose docs need an update
|
||||
cd /osgeo/openlayers/repos/docs
|
||||
REMOTE_HEAD=`git ls-remote https://github.com/openlayers/docs/ | grep HEAD | awk '{print $1}'`
|
||||
LOCAL_HEAD=`git rev-parse HEAD`
|
||||
|
||||
# if there's something different in the remote, update the clone
|
||||
if [ ! o$REMOTE_HEAD = o$LOCAL_HEAD ]; then
|
||||
|
||||
git checkout master
|
||||
git clean -f
|
||||
git pull origin master
|
||||
|
||||
mkdir -p /osgeo/openlayers/sites/docs.openlayers.org /tmp/ol/docs/build/doctrees
|
||||
sphinx-build -b html -d /tmp/ol/docs/build/doctrees . /osgeo/openlayers/sites/docs.openlayers.org
|
||||
|
||||
fi
|
||||
|
||||
## UPDATES FROM THE OLD SVN REPO
|
||||
|
||||
# Get current 'Last Changed Rev'
|
||||
SVNREV=`svn info http://svn.openlayers.org/ | grep 'Revision' | awk '{print $2}'`
|
||||
|
||||
# Get the last svn rev
|
||||
touch /tmp/ol_svn_rev
|
||||
OLD_SVNREV="o`cat /tmp/ol_svn_rev`"
|
||||
|
||||
# If they're not equal, do some work.
|
||||
if [ ! o$SVNREV = $OLD_SVNREV ]; then
|
||||
svn up /osgeo/openlayers/repos/old_svn_repo/
|
||||
# Record the revision
|
||||
echo -n $SVNREV > /tmp/ol_svn_rev
|
||||
fi
|
||||
Reference in New Issue
Block a user