bamboolab_cookies 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/bamboolab_cookies +30 -0
- data/lib/action_switch.rb +24 -0
- data/lib/bamboolab_cookies.rb +31 -0
- data/lib/css/footer.scss +1 -0
- data/lib/destroy_cookies.rb +22 -0
- data/lib/generate_cookies.rb +29 -0
- data/lib/js/footer.js +44 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: cf34c50d8349c5080289245fc32b03079dc96b55
|
|
4
|
+
data.tar.gz: 39ebdf5adba2fd11117d25a27736c989369f411d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ce1e8a91625b7d724bb8590237a92c60bc19ba4d80d36858e7b27b7b1962c39f074878c86a31a5c48a2ca543cc731b64394f5c8eceee19ab3e6210d8f9192637
|
|
7
|
+
data.tar.gz: 95780460840aaede1386f465238b6cf266222164cb8a0cc823a87d06b40a5011796ec44e4f03e5b4153987ed623dcd14d25a4511f92f1b8fa9fdd0d250b63280
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative 'action_switch.rb'
|
|
4
|
+
ARGV.each do|arg|
|
|
5
|
+
action, type = arg.gsub(/(\w+):(\w+)/, '\1'), arg.gsub(/(\w+):(\w+)/, '\2')
|
|
6
|
+
begin
|
|
7
|
+
ActionSwitch.send(action, type || nil)
|
|
8
|
+
rescue
|
|
9
|
+
ActionSwitch.help
|
|
10
|
+
end
|
|
11
|
+
end.empty? and begin
|
|
12
|
+
ActionSwitch.help
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def bamboolab_cookies(*args)
|
|
16
|
+
if args.length != 0
|
|
17
|
+
button = args[0][:button] || "OK"
|
|
18
|
+
text = args[0][:text] || "Cookies help us deliver our services. By using our services, you agree to our use of cookies."
|
|
19
|
+
more_text = args[0][:more_text] || "Learn more"
|
|
20
|
+
more_link = args[0][:more_link] || "http://www.aboutcookies.org/"
|
|
21
|
+
else
|
|
22
|
+
button = "OK"
|
|
23
|
+
text = "Cookies help us deliver our services. By using our services, you agree to our use of cookies."
|
|
24
|
+
more_text = "Learn more"
|
|
25
|
+
more_link = "http://www.aboutcookies.org/"
|
|
26
|
+
end
|
|
27
|
+
div ="<script>
|
|
28
|
+
bamboolabCookies({button: \"#{button}\", text: \"#{text}\", more: [ \"#{more_text}\" , \"#{more_link}\"] });
|
|
29
|
+
</script>"
|
|
30
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require_relative 'generate_cookies.rb'
|
|
2
|
+
require_relative 'destroy_cookies.rb'
|
|
3
|
+
class ActionSwitch
|
|
4
|
+
def self.generate(type)
|
|
5
|
+
begin
|
|
6
|
+
GenerateCookies.send(type)
|
|
7
|
+
rescue
|
|
8
|
+
GenerateCookies.help
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.destroy(type)
|
|
13
|
+
DestroyCookies.destroy
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.help
|
|
17
|
+
puts "Available actions at this time are generate and distroy"
|
|
18
|
+
puts " generate:footer"
|
|
19
|
+
puts " destroy"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
singleton_class.send(:alias_method, :g, :generate)
|
|
23
|
+
singleton_class.send(:alias_method, :d, :destroy)
|
|
24
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative 'action_switch.rb'
|
|
2
|
+
ARGV.each do|arg|
|
|
3
|
+
action, type = arg.gsub(/(\w+):(\w+)/, '\1'), arg.gsub(/(\w+):(\w+)/, '\2')
|
|
4
|
+
begin
|
|
5
|
+
ActionSwitch.send(action, type || nil)
|
|
6
|
+
rescue
|
|
7
|
+
ActionSwitch.help
|
|
8
|
+
end
|
|
9
|
+
end.empty? and begin
|
|
10
|
+
ActionSwitch.help
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def bamboolab_cookies(*args)
|
|
14
|
+
if args.length != 0
|
|
15
|
+
button = args[0][:button] || "OK"
|
|
16
|
+
text = args[0][:text] || "Cookies help us deliver our services. By using our services, you agree to our use of cookies."
|
|
17
|
+
more_text = args[0][:more_text] || "Learn more"
|
|
18
|
+
more_link = args[0][:more_link] || "http://www.aboutcookies.org/"
|
|
19
|
+
else
|
|
20
|
+
button = "OK"
|
|
21
|
+
text = "Cookies help us deliver our services. By using our services, you agree to our use of cookies."
|
|
22
|
+
more_text = "Learn more"
|
|
23
|
+
more_link = "http://www.aboutcookies.org/"
|
|
24
|
+
end
|
|
25
|
+
div ="<script>
|
|
26
|
+
bamboolabCookies({button: \"#{button}\", text: \"#{text}\", more: [ \"#{more_text}\" , \"#{more_link}\"] });
|
|
27
|
+
</script>"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#until this is not gem use this in application controller require_relative '../../bamboolab_cookies/bamboolab_cookies.rb'
|
|
31
|
+
|
data/lib/css/footer.scss
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Cookies styles */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class DestroyCookies
|
|
2
|
+
def self.run(name)
|
|
3
|
+
folder = name.gsub(/(\w+).(\w+)/, '\2') == "js" ? "javascripts" : "stylesheets"
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
File.delete("app/assets/#{folder}/#{name}")
|
|
7
|
+
puts "#{name} removed!"
|
|
8
|
+
return true
|
|
9
|
+
rescue
|
|
10
|
+
puts "Couldn't find file #{name}!"
|
|
11
|
+
return false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.destroy
|
|
16
|
+
js_deleted = run("bamboolab_cookies.js")
|
|
17
|
+
css_deleted = run("bamboolab_cookies.scss")
|
|
18
|
+
if js_deleted and css_deleted
|
|
19
|
+
puts "Don't forget to remove:\n\n <%= bamboolab_cookies.html_safe %>\n\n or\n\n <%= raw bamboolab_cookies %>\n\nfrom your views folder.\n\n"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class GenerateCookies
|
|
2
|
+
def self.run(js_file, css_file)
|
|
3
|
+
|
|
4
|
+
js_code = File.open("lib/js/#{js_file}.js", 'r') { |f| f.read }
|
|
5
|
+
File.open("app/assets/javascripts/bamboolab_cookies.js", "w+") {|f| f.write(js_code) }
|
|
6
|
+
|
|
7
|
+
scss_code = File.open("lib/css/#{css_file}.scss", 'r') { |f| f.read }
|
|
8
|
+
File.open("app/assets/stylesheets/bamboolab_cookies.scss", "w+") {|f| f.write(scss_code) }
|
|
9
|
+
|
|
10
|
+
puts "Add:\n\n <%= bamboolab_cookies.html_safe %>\n\n or\n\n <%= raw bamboolab_cookies %>\n\nto your view file that should have cookies.\n\n"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.footer
|
|
14
|
+
run("footer", "footer")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
=begin
|
|
18
|
+
def self.new_files
|
|
19
|
+
run("new_js", "new_css")
|
|
20
|
+
end
|
|
21
|
+
=end
|
|
22
|
+
|
|
23
|
+
def self.help
|
|
24
|
+
puts "Only available generator at this time is:"
|
|
25
|
+
puts " generate:footer"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
data/lib/js/footer.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function bamboolabCookies(configs) {
|
|
2
|
+
function getCookie(name) {
|
|
3
|
+
return (name = (document.cookie + ';').match(new RegExp(name + '=.*;'))) && name[0].split(/=|;/)[1];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (!getCookie("bamboo_cookie")) {
|
|
7
|
+
//create main div
|
|
8
|
+
var div = document.createElement("div");
|
|
9
|
+
div.setAttribute('class', 'cookies_wraper');
|
|
10
|
+
|
|
11
|
+
//create two span tags
|
|
12
|
+
var spanInfo = document.createElement("span");
|
|
13
|
+
spanInfo.setAttribute('class', 'cookies_content');
|
|
14
|
+
spanInfo.innerHTML = configs.text;
|
|
15
|
+
|
|
16
|
+
var spanAction = document.createElement("span");
|
|
17
|
+
spanAction.setAttribute('class', 'cookies_content');
|
|
18
|
+
|
|
19
|
+
//crete button
|
|
20
|
+
var button = document.createElement("button");
|
|
21
|
+
button.setAttribute('class', 'cookies_button');
|
|
22
|
+
button.setAttribute('id', 'cookies_button');
|
|
23
|
+
button.textContent = configs.button;
|
|
24
|
+
|
|
25
|
+
//crete link
|
|
26
|
+
var link = document.createElement("a");
|
|
27
|
+
link.setAttribute('class', 'cookies_link');
|
|
28
|
+
link.href = configs.more[1];
|
|
29
|
+
link.textContent = configs.more[0];
|
|
30
|
+
|
|
31
|
+
//appending
|
|
32
|
+
spanAction.appendChild(button);
|
|
33
|
+
spanAction.appendChild(link);
|
|
34
|
+
div.appendChild(spanInfo);
|
|
35
|
+
div.appendChild(spanAction);
|
|
36
|
+
document.body.appendChild(div);
|
|
37
|
+
|
|
38
|
+
//event and removing
|
|
39
|
+
button.addEventListener("click", function(){
|
|
40
|
+
document.cookie = "bamboo_cookie=true;expires="+new Date((new Date()).getTime() + (1000 * 86400000)).toUTCString();
|
|
41
|
+
div.remove();
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
};
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bamboolab_cookies
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mislav Kvesić
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: It makes cookies warning
|
|
14
|
+
email: kvesic.mislav@gmail.com
|
|
15
|
+
executables:
|
|
16
|
+
- bamboolab_cookies
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/bamboolab_cookies
|
|
21
|
+
- lib/action_switch.rb
|
|
22
|
+
- lib/bamboolab_cookies.rb
|
|
23
|
+
- lib/css/footer.scss
|
|
24
|
+
- lib/destroy_cookies.rb
|
|
25
|
+
- lib/generate_cookies.rb
|
|
26
|
+
- lib/js/footer.js
|
|
27
|
+
homepage: http://rubygems.org/gems/bamboolab_link
|
|
28
|
+
licenses:
|
|
29
|
+
- Bamboolab
|
|
30
|
+
metadata: {}
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubyforge_project:
|
|
47
|
+
rubygems_version: 2.5.1
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: Bamboolab
|
|
51
|
+
test_files: []
|