Some refactoring, added Swagger documentation

This commit is contained in:
2015-11-20 21:43:14 +01:00
parent d322d09604
commit 7adf048438
13 changed files with 122 additions and 333 deletions

View File

@ -20,6 +20,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
float: right;
font-size: 60%;
}
.paper-font-body2 {
white-space: pre-wrap;
}
@ -41,7 +42,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
<script>
(function() {
(function () {
'use strict';
Polymer({
@ -59,16 +60,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
server: {
type: String,
value: 'http://localhost:8080',
value: location.port === 5000 ? 'http://localhost:8080/' : '',
notify: true
}
},
toDate: function(timestamp) {
toDate: function (timestamp) {
return new Date(timestamp * 1000).toLocaleString();
},
getUrl: function(server, address) {
return server + '/read/' + address;
getUrl: function (server, address) {
console.log(server + 'read/' + address);
return server + 'read/' + address;
}
});
})();

View File

@ -1,44 +0,0 @@
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="my-greeting">
<template>
<style include="shared-styles"></style>
<style>
:host {
display: block;
}
</style>
<h2 class="page-title"><span>{{greeting}}</span></h2>
<span class="paper-font-body2">Update text to change the greeting.</span>
<!-- Listens for "input" event and sets greeting to <input>.value -->
<input class="paper-font-body2" value="{{greeting::input}}">
</template>
<script>
(function() {
'use strict';
Polymer({
is: 'my-greeting',
properties: {
greeting: {
type: String,
value: 'Welcome!',
notify: true
}
}
});
})();
</script>
</dom-module>

View File

@ -1,52 +0,0 @@
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="my-list">
<template>
<style>
:host {
display: block;
}
</style>
<ul>
<template is="dom-repeat" items="{{items}}">
<li><span class="paper-font-body1">{{item}}</span></li>
</template>
</ul>
</template>
<script>
(function () {
'use strict';
Polymer({
is: 'my-list',
properties: {
items: {
type: Array,
notify: true,
}
},
ready: function() {
this.items = [
'Responsive Web App boilerplate',
'Iron Elements and Paper Elements',
'End-to-end Build Tooling (including Vulcanize)',
'Unit testing with Web Component Tester',
'Routing with Page.js',
'Offline support with the Platinum Service Worker Elements'
];
}
});
})();
</script>
</dom-module>

View File

@ -34,6 +34,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
page('/read/:address', scrollToTop, function(data) {
app.route = 'message-list';
app.params = data.params;
console.log(data);
});
// add #! before urls

View File

@ -16,9 +16,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var app = document.querySelector('#app');
app.join = function() {
var index = 0;
var result = '';
for (index = 0; index < arguments.length; index++) {
for (var index = 0; index < arguments.length; index++) {
result += arguments[index];
}
return result;

View File

@ -1,32 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Elements Test Runner</title>
<meta charset="UTF-8">
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="../../bower_components/web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites(['my-greeting-basic.html', 'my-list-basic.html']);
</script>
</body>
</html>

View File

@ -1,52 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>my-greeting-basic</title>
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="../../bower_components/web-component-tester/browser.js"></script>
<script src="../../bower_components/test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../../bower_components/test-fixture/test-fixture.html">
<!-- Import the element to test -->
<link rel="import" href="../elements/my-greeting/my-greeting.html">
</head>
<body>
<test-fixture id="basic">
<template>
<my-greeting></my-greeting>
</template>
</test-fixture>
<script>
suite('my-greeting tests', function() {
var greeting, header;
setup(function() {
greeting = fixture('basic');
});
test('Welcome!', function() {
header = greeting.querySelector('h2');
assert.equal(header.textContent, 'Welcome!');
});
});
</script>
</body>
</html>

View File

@ -1,67 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>my-list-basic</title>
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="../../bower_components/web-component-tester/browser.js"></script>
<script src="../../bower_components/test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../../bower_components/test-fixture/test-fixture.html">
<!-- Import the element to test -->
<link rel="import" href="../elements/my-list/my-list.html">
</head>
<body>
<test-fixture id="basic">
<template>
<my-list></my-list>
</template>
</test-fixture>
<script>
suite('my-list tests', function() {
var list, listItems;
setup(function() {
list = fixture('basic');
});
test('Item lengths should be equalled', function(done) {
// Test a property
// TODO: Fix list.items.push('Foo') causing a WeakMap exception
// Invalid value used as weak map key
list.items = [
'Responsive Web App boilerplate',
'Iron Elements and Paper Elements',
'End-to-end Build Tooling (including Vulcanize)',
'Unit testing with Web Component Tester',
'Routing with Page.js',
'Offline support with the Platinum Service Worker Elements'
];
// Data bindings will stamp out new DOM asynchronously
// so wait to check for updates
flush(function() {
listItems = list.querySelectorAll('li');
assert.equal(list.items.length, listItems.length);
done();
});
})
});
</script>
</body>
</html>