aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomivirkki <tomivirkki@users.noreply.github.com>2015-09-18 09:51:11 +0300
committertomivirkki <tomivirkki@users.noreply.github.com>2015-09-18 09:51:11 +0300
commitc499e69fa0cd7853121fed1a5d6039837aebe297 (patch)
tree9c48b21c351e225c753ebe084290ae64c8f3eaf1
parent0df97b50792063bd72e0a921b697e536b0d72340 (diff)
parenta2f691105f32cd22f2fd0fcd5fd31efeb5676baa (diff)
downloadvaadin-core-c499e69fa0cd7853121fed1a5d6039837aebe297.tar.gz
vaadin-core-c499e69fa0cd7853121fed1a5d6039837aebe297.zip
Merge pull request #4 from vaadin/mcm_cdn
Deprecate components-examples and components-apidoc
-rw-r--r--LICENSE.html (renamed from LICENSE.md)0
-rw-r--r--README.md9
-rw-r--r--apidoc/index.html123
-rw-r--r--bower.json5
-rw-r--r--demo/index.html57
-rw-r--r--ga.js18
-rw-r--r--tasks/cdn.js45
-rw-r--r--tasks/config.js6
-rw-r--r--tasks/zip.js13
9 files changed, 248 insertions, 28 deletions
diff --git a/LICENSE.md b/LICENSE.html
index 8469336..8469336 100644
--- a/LICENSE.md
+++ b/LICENSE.html
diff --git a/README.md b/README.md
index 426d409..c57595a 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ View live examples and source code side-by-side for individual custom elements.
| Component | Description |
| --- | --- |
-| [<**vaadin-grid**>](https://github.com/vaadin/vaadin-grid) &middot; [Examples](http://vaadin.github.io/components-examples/vaadin-grid/) &middot; [API](http://vaadin.github.io/components-apidoc/#vaadin-grid) | Data grid for showing large amounts of tabular data. |
+| [<**vaadin-grid**>](https://github.com/vaadin/vaadin-grid) &middot; [Examples](https://cdn.vaadin.com/vaadin-components/latest/vaadin-grid/demo/) &middot; [API](https://cdn.vaadin.com/vaadin-components/latest/vaadin-components/apidoc/#vaadin-grid) | Data grid for showing large amounts of tabular data. |
### Quickstart
@@ -21,7 +21,6 @@ View live examples and source code side-by-side for individual custom elements.
- [Data generated on-the-fly](http://jsfiddle.net/jounik/tvk1235r/)
- [JSON data from a URL](http://jsfiddle.net/jounik/tLour4gv/)
-
### Installation
We offer three ways to use Vaadin Components in your project: Bower, CDN and ZIP archive. The only difference between the options is the URL you use to import the necessary files into your HTML page.
@@ -55,7 +54,7 @@ We offer three ways to use Vaadin Components in your project: Bower, CDN and ZIP
You can use Vaadin Components from CDN (see example below). This is especially convenient for services like JSFiddle, Codepen.io, etc.
- `https://cdn.vaadin.com/vaadin-components/0.3.0-beta8/vaadin-grid/vaadin-grid.html`
+ `https://cdn.vaadin.com/vaadin-components/latest/vaadin-grid/vaadin-grid.html`
_*Note*: that we have a fragment in the url with the version to use, so you could for instance replace it with the snapshot version_
@@ -80,8 +79,8 @@ We offer three ways to use Vaadin Components in your project: Bower, CDN and ZIP
<!-- Import Web Component polyfills and the components that you want -->
<!-- CDN -->
- <script src="https://cdn.vaadin.com/vaadin-components/0.3.0-beta8/webcomponentsjs/webcomponents-lite.js"></script>
- <link href="https://cdn.vaadin.com/vaadin-components/0.3.0-beta8/vaadin-components/vaadin-components.html" rel="import">
+ <script src="https://cdn.vaadin.com/vaadin-components/latest/webcomponentsjs/webcomponents-lite.js"></script>
+ <link href="https://cdn.vaadin.com/vaadin-components/latest/vaadin-grid/vaadin-grid.html" rel="import">
<!-- Bower -->
<!-- <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
diff --git a/apidoc/index.html b/apidoc/index.html
new file mode 100644
index 0000000..afc6729
--- /dev/null
+++ b/apidoc/index.html
@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<html>
+<head lang="en">
+ <meta charset="UTF-8">
+ <title></title>
+
+ <script src="../ga.js"></script>
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
+ <script src="../../lodash/lodash.js"></script>
+ <link rel="import" href="../../polymer/polymer.html">
+ <link rel="import" href="../../hydrolysis/hydrolysis-analyzer.html">
+ <link rel="import" href="../../iron-doc-viewer/iron-doc-viewer.html">
+</head>
+<body>
+ <div id="container" style="display:none">
+ <div id="viewer" style="width: 60%;left: 20%; position: absolute;">
+ <iron-doc-viewer></iron-doc-viewer>
+ </div>
+ </div>
+ <script>
+ window.addEventListener("WebComponentsReady", function() {
+ var hyd = require('hydrolysis');
+
+ function hidePrivateToggle() {
+ document.querySelector('#togglePrivate').setAttribute('style', 'display:none');
+ }
+
+ function hideCollapsedToggle() {
+ var collapsed = document.querySelector('#toggleCollapsed');
+ if(collapsed) {
+ collapsed.setAttribute('style', 'display:none');
+ }
+ }
+
+ function getElementTag() {
+ var elementTag = window.location.search.replace('?', '');
+ if(elementTag === '') {
+ elementTag = 'vaadin-grid';
+ }
+
+ return elementTag;
+ }
+
+ function getPropertyType(type) {
+ return type.textContent.replace('Array.<', '').replace('>', '');
+ }
+
+ function createLinkElement(type) {
+ var a = document.createElement('a');
+ a.textContent = type.textContent;
+ a.setAttribute('href', '?' + getPropertyType(type));
+
+ return a;
+ }
+
+ function addLinkElementsForDocumentedTypes(result) {
+ var types = document.querySelectorAll('.type');
+
+ for(var i=0;i < types.length; i++) {
+ var type = getPropertyType(types[i]);
+
+ if(result.elementsByTagName[type]) {
+ var a = createLinkElement(types[i]);
+
+ types[i].textContent = '';
+ types[i].appendChild(a);
+ }
+ }
+
+ return result;
+ }
+
+ function hidePropertySetterMethods() {
+ var propertyNames = _.map(document.querySelector('#properties').querySelectorAll('.name'), function(p) {
+ return p.textContent;
+ });
+
+ var methods = document.querySelector('#methods').querySelectorAll('iron-doc-property');
+
+ _.forEach(methods, function(m) {
+ if(_.contains(propertyNames, m.querySelector('.name').textContent)) {
+ m.setAttribute('style', 'display:none');
+ }
+ });
+ }
+
+ function hideDefaultValuesForNonPrimitiveTypes(result) {
+ function isPrimitiveType(t) {
+ return /^([Nn]umber|[Bb]oolean|[Ss]tring).*/.test(t);
+ }
+
+ _.forEach(document.querySelector('#properties').querySelectorAll('iron-doc-property'), function(p) {
+ if(!isPrimitiveType(p.querySelector('#type').textContent)) {
+ p.querySelector('#default').setAttribute('style', 'display:none');
+ }
+ });
+
+ return result;
+ }
+
+ function showDocViewer() {
+ document.querySelector('#container').setAttribute('style', 'display:block');
+ }
+
+ //*** Main script starts here. ***//
+
+ hidePrivateToggle();
+ hideCollapsedToggle();
+
+ hyd.Analyzer.analyze('../../vaadin-grid/vaadin-grid-doc.html')
+ .then(function(result) {
+ document.querySelector('iron-doc-viewer').descriptor = result.elementsByTagName[getElementTag()];
+
+ return result;
+ })
+ .then(hideDefaultValuesForNonPrimitiveTypes)
+ .then(addLinkElementsForDocumentedTypes)
+ .then(hidePropertySetterMethods)
+ .then(showDocViewer);
+ });
+</script>
+</body>
+</html>
diff --git a/bower.json b/bower.json
index 734f92c..a07756f 100644
--- a/bower.json
+++ b/bower.json
@@ -20,6 +20,11 @@
"dependencies": {
"vaadin-grid": "vaadin/vaadin-grid#0.9.0-beta1"
},
+ "devDependencies": {
+ "iron-doc-viewer": "polymerelements/iron-doc-viewer#~1.0.3",
+ "hydrolysis": "polymer/hydrolysis#~1.15.1",
+ "lodash": "~3.9.3"
+ },
"resolutions": {
"polymer": "v1.1.1"
}
diff --git a/demo/index.html b/demo/index.html
new file mode 100644
index 0000000..cdc8b74
--- /dev/null
+++ b/demo/index.html
@@ -0,0 +1,57 @@
+<!doctype html>
+<html>
+<head>
+ <title>Vaadin Components Code Examples</title>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="../../marked/lib/marked.js"></script>
+
+ <script src="../../code-example/vendor/prismjs/prism.js"></script>
+ <link rel="stylesheet" href="../../code-example/vendor/prismjs/prism.css">
+ <link rel="stylesheet" href="../../components-demo-resources/demo.css">
+
+ <script src="../ga.js"></script>
+ <style type="text/css">
+ #readme code {
+ font-size: 12px;
+ max-height: none !important;
+ }
+ </style>
+</head>
+<body>
+
+ <section id="readme">
+ </section>
+ <script>
+ var readme = document.getElementById("readme");
+ var xhr = new XMLHttpRequest();
+
+ xhr.onload = function (e) {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ readme.innerHTML = marked(xhr.responseText);
+ [].forEach.call(readme.querySelectorAll("pre"), function(pre) {
+ var code = document.createElement("code");
+ code.innerHTML = pre.innerHTML;
+ var parent = pre.parentElement;
+ parent.insertBefore(code, pre);
+ parent.removeChild(pre);
+
+ code.className = "language-markup";
+ Prism.highlightElement(code);
+ });
+ } else {
+ console.error(xhr.statusText);
+ }
+ }
+ };
+ xhr.onerror = function (e) {
+ console.error(xhr.statusText);
+ };
+ xhr.open("GET", "../README.md");
+ xhr.send();
+
+ </script>
+
+</body>
+</html>
diff --git a/ga.js b/ga.js
new file mode 100644
index 0000000..afd2135
--- /dev/null
+++ b/ga.js
@@ -0,0 +1,18 @@
+// Analytics for Vaadin Components
+
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ga('create', 'UA-658457-6', 'auto');
+
+function locationHashChanged() {
+ if(window.location.hostname === 'vaadin.github.io') {
+ var pageViewUrl = (window.location.pathname + window.location.hash).replace('#', '/');
+ ga('send', 'pageview', pageViewUrl)
+ }
+}
+
+window.onhashchange = locationHashChanged;
+locationHashChanged();
diff --git a/tasks/cdn.js b/tasks/cdn.js
index e5aaeed..01359f2 100644
--- a/tasks/cdn.js
+++ b/tasks/cdn.js
@@ -12,7 +12,9 @@ var args = require('yargs').argv;
var git = require('gulp-git');
var stagingBasePath = config.paths.staging.cdn;
-var version = args.release || args.preRelease || args.autoRevert ? config.version : config.snapshotVersion;
+var version = config.version;
+var host = config.cdnHost;
+var permalink = config.permalink;
var stagingPath = stagingBasePath + '/' + version;
var testPath = process.cwd() + '/' + stagingPath + '/test';
@@ -28,26 +30,21 @@ gulp.task('cdn:stage-bower_components', function() {
});
});
-gulp.task('cdn:stage-vaadin-components', ['clean:cdn'], function() {
- return gulp.src(['README.md', 'LICENSE.md', 'vaadin-components.html'])
- .pipe(markdown())
+gulp.task('cdn:stage-vaadin-components', function() {
+ return gulp.src(['README.md', 'LICENSE.html', 'vaadin-components.html', 'demo/*', 'apidoc/*'], {base:"."})
+ .pipe(replace('https://cdn.vaadin.com/vaadin-components/latest/', '../../'))
.pipe(gulp.dest(stagingPath + "/vaadin-components"));
});
-gulp.task('stage:cdn',
- ['cdn:stage-bower_components',
- 'cdn:stage-vaadin-components']);
+gulp.task('stage:cdn', [ 'clean:cdn', 'cdn:stage-bower_components', 'cdn:stage-vaadin-components' ]);
-gulp.task('deploy:cdn', ['stage:cdn'], function() {
+gulp.task('upload:cdn', ['stage:cdn'], function() {
common.checkArguments(['cdnUsername', 'cdnDestination']);
- var hostName = args.cdnHostname || 'cdn.vaadin.com';
-
- gutil.log('Uploading to cdn (rsync): ' + stagingPath + ' -> '+ args.cdnUsername + '@' + hostName + ':' + args.cdnDestination + version);
-
+ gutil.log('Uploading to cdn (rsync): ' + stagingPath + ' -> '+ args.cdnUsername + '@' + host + ':' + args.cdnDestination + version);
return gulp.src(stagingPath)
.pipe(rsync({
username: args.cdnUsername,
- hostname: hostName,
+ hostname: host,
root: stagingPath,
emptyDirectories: false,
recursive: true,
@@ -57,6 +54,26 @@ gulp.task('deploy:cdn', ['stage:cdn'], function() {
}));
});
+gulp.task('deploy:cdn', ['upload:cdn'], function(done) {
+ if (permalink) {
+ var cmd = 'rm -f ' + args.cdnDestination + permalink + '; ln -s ' + version + ' ' + args.cdnDestination + permalink + '; ls -l ' + args.cdnDestination;
+ gutil.log('Deploying CDN : ssh ' + args.cdnUsername + '@' + host + ' ' + cmd);
+ require('node-ssh-exec')({
+ host: host,
+ username: args.cdnUsername,
+ privateKey: config.paths.privateKey()
+ }, cmd, function (error, response) {
+ if (error) {
+ throw error;
+ }
+ gutil.log(response);
+ done();
+ });
+ } else {
+ done();
+ }
+});
+
gulp.task('cdn-test:clean', function() {
fs.removeSync(stagingPath + '/test');
});
@@ -102,7 +119,7 @@ gulp.task('verify:cdn', ['cdn-test:stage'], function(done) {
gutil.log('Deleting folder ' + args.cdnDestination + version);
require('node-ssh-exec')({
- host: 'cdn.vaadin.com',
+ host: host,
username: args.cdnUsername,
privateKey: config.paths.privateKey()
}, 'rm -rf ' + args.cdnDestination + version, function (error, response) {
diff --git a/tasks/config.js b/tasks/config.js
index bfbf19f..dc48921 100644
--- a/tasks/config.js
+++ b/tasks/config.js
@@ -5,8 +5,10 @@ var userhome = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFI
module.exports = {
components: ['vaadin-grid'],
- snapshotVersion: '0.3.0-snapshot',
- version: args.version || '0.3.0-snapshot',
+ version: args.version || 'master',
+ permalink: args.version ? 'latest' : '',
+ cdnHost: args.cdnHostname || 'cdn.vaadin.com',
+ zipHost: args.zipHostname || 'vaadin.com',
paths: {
staging: {
bower: 'target/bower',
diff --git a/tasks/zip.js b/tasks/zip.js
index fc0f854..f649d98 100644
--- a/tasks/zip.js
+++ b/tasks/zip.js
@@ -12,7 +12,8 @@ var unzip = require('gulp-unzip');
var zip = require('gulp-zip');
var stagingPath = config.paths.staging.zip;
-var version = args.release || args.preRelease ? config.version : config.snapshotVersion;
+var version = config.version;
+var host = config.zipHost;
var filename = 'vaadin-components-' + version + '.zip';
var majorMinorVersion = version.replace(/(\d+\.\d+)(\.|-)(.*)/, '$1');
@@ -29,13 +30,12 @@ gulp.task('stage:zip', ['clean:zip', 'stage:cdn'], function() {
gulp.task('zip:upload', ['stage:zip'], function(done) {
common.checkArguments(['zipUsername', 'zipDestination']);
- var hostName = args.zipHostname || 'vaadin.com';
var path = args.zipDestination + majorMinorVersion + '/' + version + '/' + filename;
- gutil.log('Uploading zip package (scp): ' + stagingPath + '/' + filename + ' -> ' + args.zipUsername + '@' + hostName + ':' + path);
+ gutil.log('Uploading zip package (scp): ' + stagingPath + '/' + filename + ' -> ' + args.zipUsername + '@' + host + ':' + path);
require('scp2').scp(stagingPath + '/' + filename, {
- host: hostName,
+ host: host,
username: args.zipUsername,
privateKey: config.paths.privateKey(),
path: path
@@ -45,11 +45,10 @@ gulp.task('zip:upload', ['stage:zip'], function(done) {
});
function ssh(command, done) {
- var hostName = args.sshHostname || 'vaadin.com';
- gutil.log('SSH: ' + hostName + ' -> ' + command);
+ gutil.log('SSH: ' + host + ' -> ' + command);
require('node-ssh-exec')({
- host: hostName,
+ host: host,
username: args.zipUsername,
privateKey: config.paths.privateKey()
}, command,