Skip to content

Commit

Permalink
preparing v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Zornada committed Jun 16, 2016
1 parent 44d7da2 commit 7969968
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 32 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.12"
before_install:
- "npm install -g bower"
- "bower install"
- "npm install -g web-component-tester"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script: "wct"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# polymer-cookie Changelog

## 1.1.1 - 2016.06.16

* quickfix on the `createCookie` method
* introducing web-component-tester for CI
* TravisCI
* documentation update

## 1.1.0 - 2016.06.15

* introducing Domain
Expand Down
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Andrea SonnY
Copyright (c) 2015-2016 Andrea SonnY

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# polymer-cookie
# \<polymer-cookie\>

> Cookie Web Component for Polymer 1.x
[![Bower version](https://badge.fury.io/bo/polymer-cookie.svg)](https://badge.fury.io/bo/polymer-cookie)
[![npm](https://img.shields.io/npm/v/polymer-cookie.svg?maxAge=86400)]()
[![Bower](https://img.shields.io/bower/v/polymer-cookie.svg?maxAge=86400)]()
[![Build Status](https://travis-ci.org/andreasonny83/generator-polymer.svg?branch=master)](https://travis-ci.org/andreasonny83/generator-polymer)

![](http://benschwarz.github.io/bower-badges/[email protected])

Cookie Web Component for Polymer 1.0
Cookie Web Component for Polymer 1.x

```html
<polymer-cookie
Expand Down Expand Up @@ -174,9 +176,13 @@ $ npm install -g polymer-cli

### Run the demo

To run the element demo:
First install all the project dependencies with:

Run polymer serve from the repo directory:
```shell
$ bower install
```

Then, run Polymer serve from the repo directory with:

```shell
$ polymer serve
Expand All @@ -189,9 +195,6 @@ For more information about Polymer CLI have a look at the

## Contributing

A special thanks to [Cameron](https://github.com/cameronwp)
and [Pascal](https://github.com/MeTaNoV) for their contributions.

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
Expand Down
16 changes: 13 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<!doctype html>
<html>
<!--
Copyright (c) 2015 Andrea SonnY. All rights reserved.
This code may only be used under the MIT license found at https://github.com/andreasonny83/polymer-cookie/blob/master/LICENSE
-->
<head>
<title>polymer-cookie demo page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../polymer-cookie.html">
</head>
<body>
<h1>polymer-cookie</h1>
<div class="vertical-section-container centered">
<h3>polymer-cookie Demo</h3>

<p>Open your browser's code inspector to see the cookie status.</p>
<p>This 'test_cookie' will expire in 10 seconds.</p>
</div>

<polymer-cookie
id="test_cookie"
name="test_cookie"
Expand All @@ -16,7 +28,5 @@ <h1>polymer-cookie</h1>
auto-set>
</polymer-cookie>

<p>Open your browser's code inspector to see the cookie status.</p>
<p>This 'test_cookie' will expire in 10 seconds.</p>
</body>
</html>
64 changes: 45 additions & 19 deletions polymer-cookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@

properties: {
/**
* The cookie name.
* The cookie name
*
* @type {String}
*/
name: {
type: String,
Expand All @@ -52,7 +54,7 @@
},

/**
* The cookie value.
* The cookie value
*/
value: {
type: String,
Expand All @@ -61,7 +63,9 @@
},

/**
* The cookie domain.
* The cookie domain
*
* @type {String}
*/
domain: {
type: String,
Expand All @@ -70,7 +74,9 @@
},

/**
* The cookie path.
* The cookie path
*
* @type {String}
*/
path: {
type: String,
Expand All @@ -80,7 +86,8 @@

/**
* The expiration time
* @type [Number]
*
* @type {Number}
* Default: 1
* 0 : Expiration time is set in the past
* -1: Never expires
Expand All @@ -93,7 +100,8 @@

/**
* Contains the expiration format
* @type [String] optional
*
* @type {String} optional
* Default :'d'
* 's' : seconds
* 'm' : minutes
Expand All @@ -109,7 +117,8 @@
/**
* Using the Secure option you can tell the browser (or other http clients)
* to only send the cookie over SSL connections
* @type [Boolean]
*
* @type {Boolean}
*/
secure: {
type: Boolean,
Expand All @@ -120,7 +129,7 @@
/**
* HttpOnly
*
* @type [Boolean]
* @type {Boolean}
*/
httpOnly: {
type: Boolean,
Expand All @@ -130,7 +139,8 @@

/**
* Create the cookie automatically as the element is rendered on the DOM
* @type [Boolean]
*
* @type {Boolean}
*/
autoSet: {
type: Boolean,
Expand All @@ -139,12 +149,36 @@
}
},

/**
* _setCookie
* private method that returns a valid cookie string
*
* @param {String} expires the cookie expiration time in UTC format
*
* @return {String} The formatted cookie ready to be
* sent into the document
*/
_setCookie: function(expires) {
return [
this.name, '=', this.value,
';expires=' + expires,
this.path && ';path=' + this.path,
this.domain && ";domain=" + this.domain,
this.secure ? ';secure' : '',
this.httpOnly ? ';HttpOnly' : '',
';'
].join('');
},

ready: function() {
if (!!this.autoSet) {
this.createCookie();
}
},

/**
* Create a cookie
*/
createCookie: function() {
var FOREVER = 'Fri, 31 Dec 9999 23:59:59 GMT';
var date = new Date();
Expand All @@ -171,20 +205,12 @@

expires = this.time === -1 ? FOREVER : date.toUTCString();

document.cookie = [
this.name, '=', this.value,
';expires=' + expires,
!!this.path && ';path=' + this.path,
!!this.domain && ";domain=" + this.domain,
this.secure ? ';secure' : '',
this.httpOnly ? ';HttpOnly' : '',
';'
].join('');
document.cookie = this._setCookie(expires);
},

/**
* Read the cookie value
* @return [String] Return the cookie value in a string format
* @return {String} Return the cookie value in a string format
*/
readCookie: function() {
var reg = new RegExp('(?:(?:^|.*;\\s*)' +
Expand Down
31 changes: 31 additions & 0 deletions test/polymer-cookie_test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>polymer-cookie test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>

<link rel="import" href="../polymer-cookie.html">
</head>
<body>

<test-fixture id="basic">
<template>
<polymer-cookie></polymer-cookie>
</template>
</test-fixture>

<script>
suite('polymer-cookie', function() {

test('instantiating the element works', function() {
let element = fixture('basic');
assert.equal(element.is, 'polymer-cookie');
});

});
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions wct.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"verbose": false,
"plugins": {
"local": {
"browsers": ["chrome", "firefox"]
}
}
}

0 comments on commit 7969968

Please sign in to comment.