mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
chore(docs): use GAE and Google CDN for docs
Short summary: if you use local node server everything should work as before, if you use GAE, everything should work now as well, but we pull assets from CDN. - GAE doesn't support ':' in filenames, so I had to replace it with '_' but only in the filename, all servers were reconfigured to rewrite the urls from : to _ when doing file lookup - We now pull angular assets from google CDN when deployed on GAE (locally or in production). When running on a non GAE server we pull assets from ../ directory as before - Since only certain versions of Angular are available on CDN and we want to be able to autodeploy docs, I had to pin down the Angular files to a "stable" version when running on GAE
This commit is contained in:
parent
cd7e58ba41
commit
60a12b4161
9 changed files with 157 additions and 6 deletions
13
Rakefile
13
Rakefile
|
|
@ -19,12 +19,13 @@ task :init do
|
|||
v = YAML::load( File.open( 'version.yaml' ) )
|
||||
match = v['version'].match(/^([^-]*)(-snapshot)?$/)
|
||||
|
||||
NG_VERSION = Struct.new(:full, :major, :minor, :dot, :codename).
|
||||
NG_VERSION = Struct.new(:full, :major, :minor, :dot, :codename, :stable).
|
||||
new(match[1] + (match[2] ? ('-' + %x(git rev-parse HEAD)[0..7]) : ''),
|
||||
match[1].split('.')[0],
|
||||
match[1].split('.')[1],
|
||||
match[1].split('.')[2].sub(/\D+.*$/, ''),
|
||||
v['codename'])
|
||||
v['codename'],
|
||||
v['stable'])
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -115,6 +116,14 @@ task :docs => [:init] do
|
|||
rewrite_file(path_to('docs/.htaccess')) do |content|
|
||||
content.sub!('"NG_VERSION_FULL"', NG_VERSION.full)
|
||||
end
|
||||
rewrite_file(path_to('docs/index.html')) do |content|
|
||||
content.sub!('"NG_VERSION_FULL"', NG_VERSION.full).
|
||||
sub!('"NG_VERSION_STABLE"', NG_VERSION.stable)
|
||||
end
|
||||
rewrite_file(path_to('docs/docs-scenario.html')) do |content|
|
||||
content.sub!('"NG_VERSION_FULL"', NG_VERSION.full).
|
||||
sub!('"NG_VERSION_STABLE"', NG_VERSION.stable)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ writer.makeDir('build/docs/syntaxhighlighter').then(function() {
|
|||
var fileFutures = [];
|
||||
docs.forEach(function(doc){
|
||||
// this hack is here because on OSX angular.module and angular.Module map to the same file.
|
||||
var id = doc.id.replace('angular.Module', 'angular.IModule');
|
||||
var id = doc.id.replace('angular.Module', 'angular.IModule').
|
||||
replace(':', '_'); // rewrite : to _ to be GAE-friendly
|
||||
fileFutures.push(writer.output('partials/' + doc.section + '/' + id + '.html', doc.html()));
|
||||
});
|
||||
|
||||
|
|
@ -89,6 +90,10 @@ function writeTheRest(writesFuture) {
|
|||
writesFuture.push(writer.copyTpl('font/fontawesome-webfont.svgz'));
|
||||
writesFuture.push(writer.copyTpl('font/fontawesome-webfont.ttf'));
|
||||
writesFuture.push(writer.copyTpl('font/fontawesome-webfont.woff'));
|
||||
|
||||
writesFuture.push(writer.copyTpl('app.yaml'));
|
||||
writesFuture.push(writer.copyTpl('index.yaml'));
|
||||
writesFuture.push(writer.copyTpl('favicon.ico'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
66
docs/src/templates/app.yaml
Normal file
66
docs/src/templates/app.yaml
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
application: docs-angularjs-org
|
||||
version: 1
|
||||
runtime: python27
|
||||
api_version: 1
|
||||
threadsafe: yes
|
||||
default_expiration: "2h"
|
||||
|
||||
handlers:
|
||||
- url: /
|
||||
static_files: index.html
|
||||
upload: index.html
|
||||
|
||||
- url: /appcache.manifest
|
||||
static_files: appcache.manifest
|
||||
upload: appcache\.manifest
|
||||
|
||||
- url: /docs-scenario.html
|
||||
static_files: docs-scenario.html
|
||||
upload: docs-scenario\.html
|
||||
|
||||
- url: /docs-scenario.js
|
||||
static_files: docs-scenario.js
|
||||
upload: docs-scenario\.js
|
||||
|
||||
- url: /favicon\.ico
|
||||
static_files: favicon.ico
|
||||
upload: favicon\.ico
|
||||
|
||||
- url: /robots.txt
|
||||
static_files: robots.txt
|
||||
upload: robots\.txt
|
||||
|
||||
- url: /sitemap.xml
|
||||
static_files: sitemap.xml
|
||||
upload: sitemap\.xml
|
||||
|
||||
- url: /css
|
||||
static_dir: css
|
||||
|
||||
- url: /font
|
||||
static_dir: font
|
||||
|
||||
- url: /img
|
||||
static_dir: img
|
||||
|
||||
- url: /js
|
||||
static_dir: js
|
||||
|
||||
- url: /partials/(.+):(.+)
|
||||
static_files: partials/\1_\2
|
||||
upload: partials/.*
|
||||
|
||||
- url: /partials
|
||||
static_dir: partials
|
||||
|
||||
- url: /syntaxhighlighter
|
||||
static_dir: syntaxhighlighter
|
||||
|
||||
- url: /.*
|
||||
static_files: index.html
|
||||
upload: index.html
|
||||
|
||||
|
||||
libraries:
|
||||
- name: webapp2
|
||||
version: "2.5.1"
|
||||
|
|
@ -2,8 +2,43 @@
|
|||
<html xmlns:ng="http://angularjs.org">
|
||||
<head>
|
||||
<title>AngularJS Docs E2E Test Runner</title>
|
||||
<script type="text/javascript" src="../angular-scenario.js" ng:autotest></script>
|
||||
<script type="text/javascript" src="docs-scenario.js"></script>
|
||||
<script>
|
||||
var gae = (location.pathname.split('/').length == 2),
|
||||
headEl = document.head,
|
||||
angularVersion = {
|
||||
current: '"NG_VERSION_FULL"', // rewrite during build
|
||||
stable: '"NG_VERSION_STABLE"'
|
||||
};
|
||||
|
||||
addTag('script', {src: path('angular-scenario.js')}, function() {
|
||||
addTag('script', {src: 'docs-scenario.js'}, function() {
|
||||
angular.scenario.setUpAndRun();
|
||||
});
|
||||
});
|
||||
|
||||
function addTag(name, attributes, callback) {
|
||||
var el = document.createElement(name),
|
||||
attrName;
|
||||
|
||||
for (attrName in attributes) {
|
||||
el.setAttribute(attrName, attributes[attrName]);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
el.onload = callback;
|
||||
}
|
||||
|
||||
headEl.appendChild(el);
|
||||
}
|
||||
|
||||
|
||||
function path(name) {
|
||||
return gae
|
||||
? 'http://code.angularjs.org/' + angularVersion.stable + '/' +
|
||||
name.replace(/\.js$/, '-' + angularVersion.stable + '.js')
|
||||
: '../' + name;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
|
|
|||
BIN
docs/src/templates/favicon.ico
Normal file
BIN
docs/src/templates/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -22,8 +22,13 @@
|
|||
baseUrl = location.href.replace(rUrl, indexFile),
|
||||
jQuery = /index-jq[^\.]*\.html$/.test(baseUrl),
|
||||
debug = /index[^\.]*-debug\.html$/.test(baseUrl),
|
||||
gae = (baseUrl.split('/').length == 4),
|
||||
headEl = document.getElementsByTagName('head')[0],
|
||||
sync = true;
|
||||
sync = true,
|
||||
angularVersion = {
|
||||
current: '"NG_VERSION_FULL"', // rewrite during build
|
||||
stable: '"NG_VERSION_STABLE"'
|
||||
};
|
||||
|
||||
addTag('base', {href: baseUrl});
|
||||
addTag('link', {rel: 'stylesheet', href: 'css/bootstrap.min.css', type: 'text/css'});
|
||||
|
|
@ -40,6 +45,20 @@
|
|||
addTag('script', {src: 'js/docs-keywords.js'}, sync);
|
||||
|
||||
function path(name) {
|
||||
if (gae) {
|
||||
if (name.match(/^angular(-\w+)?\.js/) && !name.match(/bootstrap/)) {
|
||||
name = '//ajax.googleapis.com/ajax/libs/angularjs/' +
|
||||
angularVersion.stable +
|
||||
'/' +
|
||||
name.replace(/\.js$/, '.min.js');
|
||||
} else {
|
||||
name = 'http://code.angularjs.org/' +
|
||||
angularVersion.stable +
|
||||
'/' +
|
||||
name.replace(/\.js$/, '-' + angularVersion.stable +'.min.js');
|
||||
}
|
||||
return name;
|
||||
}
|
||||
return '../' + name.replace(/\.js$/, debug ? '.js' : '.min.js');
|
||||
}
|
||||
|
||||
|
|
|
|||
12
docs/src/templates/index.yaml
Normal file
12
docs/src/templates/index.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
indexes:
|
||||
|
||||
# AUTOGENERATED
|
||||
|
||||
# This index.yaml is automatically updated whenever the dev_appserver
|
||||
# detects that a new type of query is run. If you want to manage the
|
||||
# index.yaml file manually, remove the above marker line (the line
|
||||
# saying "# AUTOGENERATED"). If you want to manage some indexes
|
||||
# manually, move them above the marker line. The index.yaml file is
|
||||
# automatically uploaded to the admin console when you next deploy
|
||||
# your application using appcfg.py.
|
||||
|
||||
|
|
@ -108,6 +108,10 @@ StaticServlet.prototype.handleRequest = function(req, res) {
|
|||
path = path.replace(match[0], '/index.html');
|
||||
sys.puts('Rewrite to ' + path);
|
||||
}
|
||||
|
||||
// rewrite : to _ to be GAE-friendly
|
||||
path = path.replace(':', '_');
|
||||
|
||||
// end of docs rewriting
|
||||
|
||||
fs.stat(path, function(err, stat) {
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@
|
|||
---
|
||||
version: 1.0.2-snapshot
|
||||
codename: debilitating-awesomeness
|
||||
stable: 1.0.1
|
||||
|
|
|
|||
Loading…
Reference in a new issue