From f58889a05d970eb61c83fc58536e5628cf5f9357 Mon Sep 17 00:00:00 2001
From: Kevin Jahns <kevin.jahns@rwth-aachen.de>
Date: Wed, 4 Nov 2015 16:53:02 +0100
Subject: [PATCH] outsourced examples

---
 .bowerrc                           |  3 --
 .gitignore                         |  1 +
 Examples/OfflineEditing/index.html | 12 -------
 Examples/OfflineEditing/index.js   | 50 ----------------------------
 Examples/TextBind/index.html       | 12 -------
 Examples/TextBind/index.js         | 47 ---------------------------
 dist                               |  2 +-
 gulpfile.js                        | 52 +++++++++++++++---------------
 package.json                       |  3 +-
 9 files changed, 30 insertions(+), 152 deletions(-)
 delete mode 100644 .bowerrc
 delete mode 100644 Examples/OfflineEditing/index.html
 delete mode 100644 Examples/OfflineEditing/index.js
 delete mode 100644 Examples/TextBind/index.html
 delete mode 100644 Examples/TextBind/index.js

diff --git a/.bowerrc b/.bowerrc
deleted file mode 100644
index 7bbfd373..00000000
--- a/.bowerrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "directory": "../"
-}
diff --git a/.gitignore b/.gitignore
index 863bd291..383bd88b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ build_test
 .validate.json
 /y.js
 /y.js.map
+/y-*
diff --git a/Examples/OfflineEditing/index.html b/Examples/OfflineEditing/index.html
deleted file mode 100644
index 9bfd4525..00000000
--- a/Examples/OfflineEditing/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-  <button id="button">Disconnect</button>
-  <h1 id="contenteditable" contentEditable></h1>
-  <textarea style="width:80%;" rows=40 id="textfield"></textarea>
-
-  <script src="../../node_modules/simplewebrtc/simplewebrtc.bundle.js"></script>
-  <script src="../../y.js"></script>
-  <script src="./index.js"></script>
-</body>
-</html>
diff --git a/Examples/OfflineEditing/index.js b/Examples/OfflineEditing/index.js
deleted file mode 100644
index 78a347b7..00000000
--- a/Examples/OfflineEditing/index.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/* global Y */
-
-// create a shared object. This function call will return a promise!
-Y({
-  db: {
-    name: 'IndexedDB',
-    namespace: 'offlineEditingDemo'
-  },
-  connector: {
-    name: 'WebRTC',
-    room: 'offlineEditingDemo',
-    debug: true
-  }
-}).then(function (yconfig) {
-  // yconfig holds all the information about the shared object
-  window.yconfig = yconfig
-  // yconfig.root holds the shared element
-  window.y = yconfig.root
-
-  // now we bind the textarea and the contenteditable h1 element
-  // to a shared element
-  var textarea = document.getElementById('textfield')
-  var contenteditable = document.getElementById('contenteditable')
-  yconfig.root.observePath(['text'], function (text) {
-    // every time the 'text' property of the yconfig.root changes,
-    // this function is called. Then we bind it to the html elements
-    if (text != null) {
-      // when the text property is deleted, text may be undefined!
-      // This is why we have to check if text exists..
-      text.bind(textarea)
-      text.bind(contenteditable)
-    }
-  })
-  // create a shared TextBind
-  var textpromise = yconfig.root.get('text')
-  if (textpromise == null) {
-    yconfig.root.set('text', Y.TextBind)
-  }
-  // We also provide a button for disconnecting/reconnecting the shared element
-  var button = document.querySelector('#button')
-  button.onclick = function () {
-    if (button.innerText === 'Disconnect') {
-      yconfig.disconnect()
-      button.innerText = 'Reconnect'
-    } else {
-      yconfig.reconnect()
-      button.innerText = 'Disconnect'
-    }
-  }
-})
diff --git a/Examples/TextBind/index.html b/Examples/TextBind/index.html
deleted file mode 100644
index 9bfd4525..00000000
--- a/Examples/TextBind/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-  <button id="button">Disconnect</button>
-  <h1 id="contenteditable" contentEditable></h1>
-  <textarea style="width:80%;" rows=40 id="textfield"></textarea>
-
-  <script src="../../node_modules/simplewebrtc/simplewebrtc.bundle.js"></script>
-  <script src="../../y.js"></script>
-  <script src="./index.js"></script>
-</body>
-</html>
diff --git a/Examples/TextBind/index.js b/Examples/TextBind/index.js
deleted file mode 100644
index d489a02a..00000000
--- a/Examples/TextBind/index.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/* global Y */
-
-// create a shared object. This function call will return a promise!
-Y({
-  db: {
-    name: 'Memory'
-  },
-  connector: {
-    name: 'WebRTC',
-    room: 'TextBindDemo',
-    debug: true
-  }
-}).then(function (yconfig) {
-  // yconfig holds all the information about the shared object
-  window.yconfig = yconfig
-  // yconfig.root holds the shared element
-  window.y = yconfig.root
-
-  // now we bind the textarea and the contenteditable h1 element
-  // to a shared element
-  var textarea = document.getElementById('textfield')
-  var contenteditable = document.getElementById('contenteditable')
-  yconfig.root.observePath(['text'], function (text) {
-    // every time the 'text' property of the yconfig.root changes,
-    // this function is called. Then we bind it to the html elements
-    if (text != null) {
-      // when the text property is deleted, text may be undefined!
-      // This is why we have to check if text exists..
-      text.bind(textarea)
-      text.bind(contenteditable)
-    }
-  })
-  // create a shared TextBind
-  yconfig.root.set('text', Y.TextBind)
-
-  // We also provide a button for disconnecting/reconnecting the shared element
-  var button = document.querySelector('#button')
-  button.onclick = function () {
-    if (button.innerText === 'Disconnect') {
-      yconfig.disconnect()
-      button.innerText = 'Reconnect'
-    } else {
-      yconfig.reconnect()
-      button.innerText = 'Disconnect'
-    }
-  }
-})
diff --git a/dist b/dist
index 33b75884..e2e89e19 160000
--- a/dist
+++ b/dist
@@ -1 +1 @@
-Subproject commit 33b7588497538d07a514b3be4cfe53e26fc366a4
+Subproject commit e2e89e198f47689fe6df908c0ea1cef6d800be0d
diff --git a/gulpfile.js b/gulpfile.js
index 2b6feccb..ea244435 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -44,15 +44,8 @@
 */
 
 var gulp = require('gulp')
-var sourcemaps = require('gulp-sourcemaps')
-var babel = require('gulp-babel')
-var uglify = require('gulp-uglify')
 var minimist = require('minimist')
-var jasmine = require('gulp-jasmine')
-var jasmineBrowser = require('gulp-jasmine-browser')
 var concat = require('gulp-concat')
-var watch = require('gulp-watch')
-var shell = require('gulp-shell')
 var $ = require('gulp-load-plugins')()
 
 var options = minimist(process.argv.slice(2), {
@@ -102,16 +95,16 @@ if (options.regenerator) {
 
 gulp.task('deploy:build', function () {
   return gulp.src(files.src)
-    .pipe(sourcemaps.init())
+    .pipe($.sourcemaps.init())
     .pipe(concat('y.js'))
-    .pipe(babel({
+    .pipe($.babel({
       loose: 'all',
       modules: 'ignore',
       experimental: true
     }))
-    .pipe(uglify())
-    .pipe(sourcemaps.write('.'))
-    .pipe(gulp.dest('.'))
+    .pipe($.uglify())
+    .pipe($.sourcemaps.write('./dist/'))
+    .pipe(gulp.dest('./dist/'))
 })
 
 gulp.task('deploy:updateSubmodule', function () {
@@ -119,19 +112,19 @@ gulp.task('deploy:updateSubmodule', function () {
 })
 
 gulp.task('deploy:copy', function () {
-  return gulp.src(['./y.js', './y.js.map', './README.md', 'package.json', 'LICENSE'])
-    .pipe(gulp.dest('./dist/'))
+  return gulp.src(['README.md'], {base: '.'})
+    .pipe(gulp.dest('dist/'))
 })
 
 gulp.task('deploy:bump', function () {
-  return gulp.src('./package.json')
+  return gulp.src(['./package.json', './dist/package.json'], {base: '.'})
     .pipe($.bump({type: 'patch'}))
     .pipe(gulp.dest('./'))
 })
 
 gulp.task('deploy', ['test', 'deploy:updateSubmodule', 'deploy:bump', 'deploy:build', 'deploy:copy'], function () {
   return gulp.src('./package.json', {read: false})
-    .pipe(shell([
+    .pipe($.shell([
       'standard',
       'echo "Deploying version <%= getVersion(file.path) %>"',
       'git pull',
@@ -161,16 +154,16 @@ gulp.task('build:test', function () {
     babelOptions.blacklist = 'regenerator'
   }
   gulp.src(files.src)
-    .pipe(sourcemaps.init())
+    .pipe($.sourcemaps.init())
     .pipe(concat('y.js'))
-    .pipe(babel(babelOptions))
-    .pipe(sourcemaps.write())
+    .pipe($.babel(babelOptions))
+    .pipe($.sourcemaps.write())
     .pipe(gulp.dest('.'))
 
   return gulp.src('src/**/*.js')
-    .pipe(sourcemaps.init())
-    .pipe(babel(babelOptions))
-    .pipe(sourcemaps.write())
+    .pipe($.sourcemaps.init())
+    .pipe($.babel(babelOptions))
+    .pipe($.sourcemaps.write())
     .pipe(gulp.dest('build'))
 })
 
@@ -182,9 +175,9 @@ gulp.task('dev:browser', ['build:test'], function () {
   gulp.watch('src/**/*.js', ['build:test'])
 
   gulp.src(files.test)
-    .pipe(watch(['build/**/*.js']))
-    .pipe(jasmineBrowser.specRunner())
-    .pipe(jasmineBrowser.server({port: options.testport}))
+    .pipe($.watch(['build/**/*.js']))
+    .pipe($.jasmineBrowser.specRunner())
+    .pipe($.jasmineBrowser.server({port: options.testport}))
 })
 
 gulp.task('dev', ['build:test'], function () {
@@ -192,13 +185,20 @@ gulp.task('dev', ['build:test'], function () {
   gulp.start('dev:node')
 })
 
+gulp.task('copy:dist', ['deploy:build'])
+
+gulp.task('dev:Examples', ['copy:dist'], function () {
+  gulp.watch('src/**/*.js', ['copy:dist'])
+  return $.serve('dist/Examples')()
+})
+
 gulp.task('test', ['build:test'], function () {
   var testfiles = files.test
   if (typeof Promise === 'undefined') {
     testfiles.concat(['src/polyfills.js'])
   }
   return gulp.src(testfiles)
-    .pipe(jasmine({
+    .pipe($.jasmine({
       verbose: true,
       includeStuckTrace: true
     }))
diff --git a/package.json b/package.json
index eb34c5fb..904ea969 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "yjs",
-  "version": "0.6.23",
+  "version": "0.6.25",
   "description": "A framework for real-time p2p shared editing on arbitrary complex data types",
   "main": "y.js",
   "scripts": {
@@ -52,6 +52,7 @@
     "gulp-jasmine": "^2.0.1",
     "gulp-jasmine-browser": "^0.2.3",
     "gulp-load-plugins": "^1.0.0",
+    "gulp-serve": "^1.2.0",
     "gulp-shell": "^0.5.1",
     "gulp-sourcemaps": "^1.5.2",
     "gulp-tag-version": "^1.3.0",
-- 
GitLab