knotify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/knotify.gemspec +25 -0
- data/lib/knotify.rb +8 -0
- data/lib/knotify/version.rb +5 -0
- data/vendor/assets/javascript/knotify.coffee +38 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 875eb4639f8b58c6849023b6294ef80b70061224
|
4
|
+
data.tar.gz: faa813e250df012ccf39b1042f679d003bd21198
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ab327146234a1649f1fdc64632ad5582f121315f69328ac40d1e534c18a5dc73f8cd3d633600ccee633b23bf69e763f6fd3a2dcaa24232e3f79fad169577139
|
7
|
+
data.tar.gz: f520fdf5cb78785412d1825f5b4f409b42676dd123a1203c45aeede3f9d426b9d2ebdf2b5cef34182bf29c6021a04e137f38f9cbf776d461c43e01f6bf1322ea
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brandon Dennis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Knotify
|
2
|
+
|
3
|
+
Knotify is a simple js library for displaying web notifications. [Check browser support](http://caniuse.com/#search=notification)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'knotify'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Add the following directive to your JavaScript manifest file (application.js):
|
16
|
+
|
17
|
+
//= require knotify
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The user has to enable notifications before any can be created. This example has a user click a button labeled ````Enable Notifications````.
|
22
|
+
|
23
|
+
````html
|
24
|
+
<button id='#webkit-permission'>Enable Notifications</button>
|
25
|
+
````
|
26
|
+
|
27
|
+
In your ````.coffee```` file, create a new ````KnotifyPermission```` object, passing it the id of the button. Once the user clicks this button, notifications will be enabled. After that, you can fire off notifications by creating a new ````Knotify```` object passing it a json object with the options for the notification.
|
28
|
+
|
29
|
+
````coffeescript
|
30
|
+
jQuery ->
|
31
|
+
new KnotifyPermission("#webkit-permission")
|
32
|
+
|
33
|
+
options =
|
34
|
+
image: 'my_image.png'
|
35
|
+
title: 'This is a notification'
|
36
|
+
content: 'This is only a test'
|
37
|
+
now: true
|
38
|
+
|
39
|
+
new Knotify(options)
|
40
|
+
````
|
41
|
+
|
42
|
+
_If you don't set_ ````now: true```` _then you'll need to store the notification in a variable and call ````show()```` when you are ready to display it._
|
43
|
+
|
44
|
+
## Knotify Options
|
45
|
+
|
46
|
+
| Key | Description | Default Value |
|
47
|
+
|----------|--------------------------------------------------------|---------------|
|
48
|
+
| onDisplay| function to execute when the notification is displayed | empty function|
|
49
|
+
| onClose | function to execute when the notification is closed | empty function|
|
50
|
+
| onClick | function to execute if the notification is clicked | empty function|
|
51
|
+
| onError | function to execute if an error has occured | empty function|
|
52
|
+
| image | path to an image to use | empty string |
|
53
|
+
| title | title text to be displayed | empty string |
|
54
|
+
| content | the content body to be displayed | empty string |
|
55
|
+
| now | if true, display the notification immediately | undefined |
|
56
|
+
|
57
|
+
_Note: These options are largely based on the spec as implemented by [Chromium](http://www.chromium.org/developers/design-documents/desktop-notifications/api-specification)_
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/knotify.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'knotify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "knotify"
|
8
|
+
spec.version = Knotify::Rails::VERSION
|
9
|
+
spec.authors = ["Brandon Dennis"]
|
10
|
+
spec.email = ["toady00@gmail.com"]
|
11
|
+
spec.description = %q{Web Notification Gem}
|
12
|
+
spec.summary = %q{Knotify is a simple js library for using web notifications.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "railties", ">= 3.0", "< 5.0"
|
25
|
+
end
|
data/lib/knotify.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Knotify
|
2
|
+
constructor: (options = {}) ->
|
3
|
+
@wbktNote = window.webkitNotifications
|
4
|
+
|
5
|
+
@onDisplay = options.onDisplay ? (->)
|
6
|
+
@onClose = options.onClose ? (->)
|
7
|
+
@onClick = options.onClick ? (->)
|
8
|
+
@onError = options.onError ? (->)
|
9
|
+
@img = options.image ? ''
|
10
|
+
@title = options.title ? ''
|
11
|
+
@content = options.content ? ''
|
12
|
+
|
13
|
+
@_createNotification()
|
14
|
+
@show() if options.now?
|
15
|
+
|
16
|
+
show: ->
|
17
|
+
@notification.show()
|
18
|
+
|
19
|
+
_createNotification: ->
|
20
|
+
@notification = @wbktNote.createNotification(@img, @title, @body)
|
21
|
+
@notification.ondisplay = @onDisplay
|
22
|
+
@notification.onclose = @onClose
|
23
|
+
@notification.onclick = @onClick
|
24
|
+
@notification.onerror = @onError
|
25
|
+
|
26
|
+
class KnotifyPermission
|
27
|
+
constructor: (target, event = 'click') ->
|
28
|
+
document.querySelector(target).addEventListener event, ->
|
29
|
+
@_getPermission() unless @_checkPermission() == 0
|
30
|
+
|
31
|
+
_getPermission: ->
|
32
|
+
window.webkitNotifications.requestPermission()
|
33
|
+
|
34
|
+
_checkPermission: ->
|
35
|
+
window.webkitNotifications.checkPermission()
|
36
|
+
|
37
|
+
window.Knotify = Knotify
|
38
|
+
window.KnotifyPermission = KnotifyPermission
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knotify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Dennis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
- - <
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.0'
|
58
|
+
- - <
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.0'
|
61
|
+
description: Web Notification Gem
|
62
|
+
email:
|
63
|
+
- toady00@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- .gitignore
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- knotify.gemspec
|
74
|
+
- lib/knotify.rb
|
75
|
+
- lib/knotify/version.rb
|
76
|
+
- vendor/assets/javascript/knotify.coffee
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.6
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Knotify is a simple js library for using web notifications.
|
101
|
+
test_files: []
|