apprise-me 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_STORE
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in apprise-me.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # apprise-me
2
+
3
+ This gem utilizes apprise confirms for any link_to with confirm as a parameter. It uses the apprise project found at https://github.com/ThrivingKings/Apprise for the Rails asset pipeline (available since Rails 3.1).
4
+
5
+ ### Usage
6
+
7
+ To make use of this project add the following lines to 'app/assets/javascripts/application.js':
8
+
9
+ //= require apprise-me
10
+
11
+ $(document).ready(function({
12
+ $("a[data-apprise-confirm]").appriseConfirm()
13
+ })
14
+
15
+ and add the following line to 'app/assets/stylesheets/application.css'
16
+
17
+ *= require apprise-me
18
+
19
+ This will activate apprise confirms for any link_to made with the confirm parameter:
20
+
21
+ = link_to 'Remove User', user_path, :method => 'delete', :confirm => "Remove this user?"
22
+
23
+ ### Installation
24
+
25
+ In your Gemfile, add this line:
26
+
27
+ gem "apprise-me"
28
+
29
+ Then, run `bundle install`.
30
+
31
+ ### Options
32
+
33
+ You can pass any apprise options to appriseConfirm. I use this as a default:
34
+
35
+ $("a[data-apprise-confirm]").appriseConfirm({ verify: true, animate: 200 })
36
+
37
+ Any link_to can override apprise options with data attributes. Like this:
38
+
39
+ = link_to 'Remove User', user_path, :method => 'delete', :confirm => "Remove this user?", 'data-animate' => 1000, "data-text-yes" => 'Oh yeah', "data-text-no" => 'Nah'
40
+
41
+ You can find list of apprise options at the apprise project homepage: http://thrivingkings.com/apprise/
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "apprise-me/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "apprise-me"
7
+ s.version = AppriseMe::VERSION
8
+ s.authors = ["John Colvin"]
9
+ s.email = ["colvin.john@gmail.com"]
10
+ s.homepage = "https://github.com/johncolvin/apprise-rails"
11
+ s.summary = %q{Replaces confirms with apprise style confirms}
12
+ s.description = %q{Automatically uses apprise for confirms sent as a parameter to link_to}
13
+
14
+ s.rubyforge_project = "apprise-me"
15
+
16
+ s.add_dependency "apprise-rails"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ end
@@ -0,0 +1,6 @@
1
+ module AppriseMe
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ require 'apprise-me/view_helpers'
2
+ module AppriseMe
3
+ class Railtie < Rails::Railtie
4
+ initializer "apprise_me.view_helpers" do
5
+ ActionView::Base.send :include, ViewHelpers
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module AppriseMe
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ module AppriseMe
2
+ module ViewHelpers
3
+ def link_to(*args, &block)
4
+ html_options = args[block_given? ? 1 : 2] || {}
5
+ html_options['data-apprise-confirm'] = html_options.delete(:confirm) if html_options[:confirm]
6
+ super *args, &block
7
+ end
8
+ end
9
+ end
10
+
data/lib/apprise-me.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'apprise-rails'
2
+ require "apprise-me/version"
3
+ require 'apprise-me/railtie'
4
+ require 'apprise-me/rails/engine'
@@ -0,0 +1,34 @@
1
+ //= require apprise-min
2
+
3
+ (function( $ ) {
4
+ $.fn.appriseConfirm = function(options) {
5
+ defaultAppriseOptions = options;
6
+
7
+ this.click(function(event) {
8
+ $linkToVerify = $(this)
9
+
10
+ var appriseOptions = defaultAppriseOptions
11
+ $.each($linkToVerify.data(), function(key, val){
12
+ if ($.inArray(key, ['confirm', 'verify', 'textNo', 'textYes', 'textCancel', 'textOk', 'animate']) >= 0) {
13
+ appriseOptions[key] = val
14
+ if (key == 'verify') {
15
+ appriseOptions['confirm'] = false
16
+ }
17
+ }
18
+ })
19
+
20
+ if (appriseOptions['confirm'] == undefined && appriseOptions['verify'] == undefined) {
21
+ appriseOptions['confirm'] = true
22
+ }
23
+
24
+ message = $linkToVerify.attr('data-apprise-confirm')
25
+ apprise(message, appriseOptions, function(r){
26
+ if (r) { $.rails.handleMethod($linkToVerify) }
27
+ })
28
+
29
+ event.preventDefault();
30
+ return false;
31
+ });
32
+ return this;
33
+ }
34
+ })( jQuery );
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require apprise
3
+ */
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apprise-me
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - John Colvin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-07 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: apprise-rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Automatically uses apprise for confirms sent as a parameter to link_to
35
+ email:
36
+ - colvin.john@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - README.md
47
+ - Rakefile
48
+ - apprise-me.gemspec
49
+ - lib/apprise-me.rb
50
+ - lib/apprise-me/rails/engine.rb
51
+ - lib/apprise-me/railtie.rb
52
+ - lib/apprise-me/version.rb
53
+ - lib/apprise-me/view_helpers.rb
54
+ - lib/assets/javascripts/apprise-me.js
55
+ - lib/assets/stylesheets/apprise-me.css
56
+ homepage: https://github.com/johncolvin/apprise-rails
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project: apprise-me
85
+ rubygems_version: 1.8.15
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Replaces confirms with apprise style confirms
89
+ test_files: []
90
+