Commit b4abf0cd authored by Sebastian's avatar Sebastian
Browse files

ICalCalendar.url()

parent 2c4853de
......@@ -163,6 +163,15 @@ cal.prodId('//My Company//My Product//EN');
Use this method to set your feed's name. Is used to fill `X-WR-CALNAME` in your iCal file.
#### url([_String_ url])
Use this method to set your feed's URL.
```javascript
var cal = ical().url('https://example.com/calendar.ical');
```
#### timezone([_String_ timezone])
Use this method to set your feed's timezone. Is used to fill `X-WR-TIMEZONE` in your iCal.
......
......@@ -8,7 +8,7 @@
*/
var ICalCalendar = function(_data) {
var data = {},
attributes = ['domain', 'prodId', 'name', 'timezone', 'events'],
attributes = ['domain', 'prodId', 'name', 'timezone', 'ttl', 'url', 'events'],
generate,
i;
......@@ -23,6 +23,11 @@ var ICalCalendar = function(_data) {
// PRODID
g += 'PRODID:-' + data.prodid + '\r\n';
// URL
if(data.url) {
g += 'URL:' + data.url + '\r\n';
}
// NAME
if(data.name) {
g += 'X-WR-CALNAME:' + data.name + '\r\n';
......@@ -224,6 +229,24 @@ var ICalCalendar = function(_data) {
};
/**
* Set/Get your feed's URL
*
* @param [url] URL
* @example cal.url('http://example.com/my/feed.ical');
* @since 0.2.5
* @returns {ICalCalendar}
*/
this.url = function(url) {
if(!url) {
return data.url;
}
data.url = url || null;
return this;
};
/**
* Set/Get your feed's TTL.
* Used to set `X-PUBLISHED-TTL` and `REFRESH-INTERVAL`.
......
......@@ -180,6 +180,28 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe('url()', function() {
it('setter should return this', function() {
var cal = ical();
assert.deepEqual(cal, cal.url('https://example.com/calendar.ical'));
});
it('getter should return value', function() {
var cal = ical().url('https://example.com/calendar.ical');
assert.equal(cal.url(), 'https://example.com/calendar.ical');
});
it('should change something', function() {
var cal = ical().url('https://example.com/calendar.ical');
cal.createEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event'
});
assert.ok(cal.toString().indexOf('https://example.com/calendar.ical') > -1);
});
});
describe('createEvent()', function() {
it('should return a ICalEvent instance', function() {
var cal = ical(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment