Merge pull request #63 from elemoine/hosted-examples

A step toward hosted examples on gh-pages
This commit is contained in:
Éric Lemoine
2012-10-16 13:59:31 -07:00
7 changed files with 61 additions and 7 deletions

View File

@@ -109,6 +109,14 @@ build/jsdoc-$(BRANCH)-timestamp: $(SRC) $(shell find doc/template -type f)
$(JSDOC) -t doc/template -r src -d build/gh-pages/$(BRANCH)/apidoc
touch $@
.PHONY: hostexamples
hostexamples: build examples
mkdir -p build/gh-pages/$(BRANCH)/examples
mkdir -p build/gh-pages/$(BRANCH)/build
cp $(EXAMPLES) $(subst .html,.js,$(EXAMPLES)) examples/style.css build/gh-pages/$(BRANCH)/examples/
cp build/loader_hosted_examples.js build/gh-pages/$(BRANCH)/examples/loader.js
cp build/ol.js build/ol.css build/gh-pages/$(BRANCH)/build/
.PHONY: test
test: $(INTERNAL_SRC)
$(PHANTOMJS) test/phantom-jasmine/run_jasmine_test.coffee test/ol.html

View File

@@ -0,0 +1,46 @@
/**
*
* Loader to add ol.css, ol.js and the example-specific js file to the
* documents.
*
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
* ol.css and ol.js are built with Plovr/Closure, based build/ol.json.
* (`make build` should build them). They are located in the ../build/
* directory, relatively to this script.
*
* The script should be named loader.js. So it needs to be renamed to
* loader.js from loader_hosted_examples.js.
*
* Usage:
*
* <script src="../loader.js?id=my-demo"></script>
*/
(function() {
var scripts = document.getElementsByTagName('script');
var i, src, index, search, chunks, pair, params = {};
for (i = scripts.length - 1; i >= 0; --i) {
src = scripts[i].getAttribute('src');
if (~(index = src.indexOf('loader.js?'))) {
search = src.substr(index + 10);
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
break;
}
}
document.write('<link rel="stylesheet" href="../build/ol.css" '+
'type="text/css">');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="../build/ol.js">' +
'</scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="' + encodeURIComponent(params.id) + '.js">' +
'</scr' + 'ipt>');
}());

View File

@@ -12,7 +12,6 @@
height: 100%;
}
</style>
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<title>ol3 full-screen demo</title>
</head>
<body>

View File

@@ -1,10 +1,12 @@
/**
* Loader to add the plovr generated script to the document. The following
* default values may be overridden with query string parameters:
* Loader to add the plovr generated script and ol.css to the document.
*
* * hostname - the current hostname
* The following default values may be overridden with query string
* parameters:
*
* * hostname - the current hostname (window.location.hostname)
* * port - 9810
* * mode - ADVANCED
* * id - id param in loader.js query string; defaults to 'ol' if not set
@@ -54,6 +56,8 @@
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
}
document.write('<link rel="stylesheet" href="../css/ol.css" ' +
'type="text/css">');
var url = 'http://' + host + '/compile?' + pairs.join('&');
document.write('<script type="text/javascript" src="' + url + '"></script>');
}());

View File

@@ -66,7 +66,6 @@
margin-left: -13px;
}
</style>
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<title>ol3 overlay-and-popup demo</title>
</head>
<body>

View File

@@ -2,7 +2,6 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
.map {

View File

@@ -2,7 +2,6 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
.map {