Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
lib-ical
Commits
2171bbea
Commit
2171bbea
authored
Mar 25, 2013
by
Sebastian Pekarek
Browse files
a little more documentation
parent
70aac8ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
2171bbea
...
...
@@ -2,10 +2,12 @@
ical-generator is a small piece of code which generates ical calendar files. I use this to generate subscriptionable calendar feeds.
## Installation
npm install ical-generator
## Example
```
javascript
...
...
@@ -13,6 +15,8 @@ var ical = require('ical-generator'),
http
=
require
(
'
http
'
),
cal
=
ical
();
cal
.
setDomain
(
'
sebbo.net
'
);
cal
.
addEvent
({
start
:
new
Date
(),
end
:
new
Date
(
new
Date
().
getTime
()
+
3600000
),
...
...
@@ -25,4 +29,82 @@ http.createServer(function(req, res) {
cal
.
serve
(
res
);
}).
listen
(
3000
,
'
127.0.0.1
'
);
console
.
log
(
'
Server running at http://127.0.0.1:3000/
'
);
```
\ No newline at end of file
```
## API
### setDomain(domain)
Use this method to set your server's hostname. It will be used to generate the feed's UID. Default hostname is localhost.
### setProdID(prodID)
This method is used to overwrite the default ProdID:
```
javascript
cal
.
setProdID
({
company
:
'
My Company
'
,
product
:
'
My Product
'
,
language
:
'
EN
'
});
```
### addEvent(options)
Add an event. Options is an plain object, that configure the event.
#### options.uid (String)
Event UID. If not set, an UID will be generated randomly.
#### options.start (Date Object, required)
Appointment date of beginning
#### options.end (Date Object, required)
Appointment date of end
#### options.stamp (Date Object)
Appointment date of creation
#### options.summary (String, required)
Appointment summary
#### options.description (String)
Appointment description
#### options.organizer (Plain Object)
Appointment organizer
```
javascript
cal
.
addEvent
({
start
:
new
Date
(),
end
:
new
Date
(
new
Date
().
getTime
()
+
3600000
),
summary
:
'
Example Event
'
,
description
:
'
Appointment with Organizer
'
,
organizer
:
{
name
:
'
Organizer
\'
s Name
'
,
email
:
'
organizer@example.com
'
}
});
```
#### options.url (String)
Appointment Website
### save(file[, cb])
Save Calendar to disk asynchronously using
[
fs.writeFile
](
http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback
)
### saveSync(file)
Save Calendar to disk synchronously using
[
fs.writeFileSync
](
http://nodejs.org/api/fs.html#fs_fs_writefilesync_filename_data_options
)
### serve(response)
Send Calendar to the User when using HTTP. See example above.
### toString()
Return Calendar as a String.
\ No newline at end of file
example/example.js
→
example/example
_serve
.js
View file @
2171bbea
File moved
example/example_toString.js
0 → 100644
View file @
2171bbea
var
ical
=
require
(
'
../lib/ical-generator.js
'
),
cal
=
ical
();
cal
.
setDomain
(
'
example.com
'
);
cal
.
addEvent
({
start
:
new
Date
(
new
Date
().
getTime
()
+
3600000
),
end
:
new
Date
(
new
Date
().
getTime
()
+
7200000
),
summary
:
'
Example Event
'
,
description
:
'
It works ;)
'
,
organizer
:
{
name
:
'
Organizer
\'
s Name
'
,
email
:
'
organizer@example.com
'
},
url
:
'
http://sebbo.net/
'
});
console
.
log
(
cal
.
toString
());
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment