Skip to content

Commit cd904ad

Browse files
committed
inital commit
1 parent eb7669d commit cd904ad

File tree

12 files changed

+218
-18
lines changed

12 files changed

+218
-18
lines changed

.gitignore

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
*.rbc
2-
*.sassc
3-
.sass-cache
4-
capybara-*.html
5-
.rspec
6-
/.bundle
7-
/vendor/bundle
8-
/log/*
9-
/tmp/*
10-
/db/*.sqlite3
11-
/public/system/*
12-
/coverage/
13-
/spec/tmp/*
14-
**.orig
15-
rerun.txt
16-
pickle-email-*.html
2+
.bundle
3+
.config
4+
.yardoc
5+
Gemfile.lock
6+
InstalledFiles
7+
_yardoc
8+
coverage
9+
doc/
10+
lib/bundler/man
11+
pkg
12+
rdoc
13+
spec/reports
14+
test/tmp
15+
test/version_tmp
16+
tmp

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in cookies_eu.gemspec
4+
gemspec

LICENSE.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2013 Stjepan Hadjic
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.

README.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
cookies_eu
2-
==========
1+
# CookiesEu
32

4-
Rails gem for eu cookies law
3+
TODO: Write a gem description
4+
5+
## Installation
6+
7+
Add this line to your application's Gemfile:
8+
9+
gem 'cookies_eu'
10+
11+
And then execute:
12+
13+
$ bundle
14+
15+
Or install it yourself as:
16+
17+
$ gem install cookies_eu
18+
19+
## Usage
20+
21+
TODO: Write usage instructions here
22+
23+
## Contributing
24+
25+
1. Fork it
26+
2. Create your feature branch (`git checkout -b my-new-feature`)
27+
3. Commit your changes (`git commit -am 'Add some feature'`)
28+
4. Push to the branch (`git push origin my-new-feature`)
29+
5. Create new Pull Request

Rakefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "bundler/gem_tasks"

app/assets/javascripts/cookies_eu.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//= require jquery
2+
//= require jquery.cookie
3+
4+
$('.cookies_eu_ok').click(function(e){
5+
e.preventDefault();
6+
$.cookie('consented', 'true');
7+
$(this).parent().remove();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<% if cookie['consented'] != 'true' %>
2+
<div class="cookies_eu" style="background: <%= CookiesEu::BACKGROUND %>; ">
3+
<span><%= t('cookies_eu.span_text') %></span>
4+
<button class="cookies_eu_ok"></button>
5+
<a href="<%= CookiesEu::COOKIES_LINK %>"> <%= t('cookies_eu.learn_more') %> </a>
6+
</div>
7+
<% end %>

cookies_eu.gemspec

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require 'cookies_eu/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "cookies_eu"
8+
spec.version = CookiesEu::VERSION
9+
spec.authors = ["Stjepan Hadjic"]
10+
spec.email = ["[email protected]"]
11+
spec.description = %q{Displays a cookie consent}
12+
spec.summary = %q{Displays a cookie consent. If you dont disable cokkies in settings, we assume you are ok with us using cookies}
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 "jquery-rails"
22+
spec.add_development_dependency "bundler", "~> 1.3"
23+
spec.add_development_dependency "rake"
24+
end

lib/cookies_eu.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require "cookies_eu/version"
2+
require "cookies_eu/engine"
3+
4+
module CookiesEu
5+
BACKGROUND = '#f2f2f2'
6+
LINK = 'www.google.ie'
7+
end

lib/cookies_eu/engine.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module CookiesEu
2+
class Engine < ::Rails::Engine
3+
end
4+
end

lib/cookies_eu/version.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CookiesEu
2+
VERSION = "0.0.3"
3+
end

vendor/javacripts/jquery.cookie.js

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*!
2+
* jQuery Cookie Plugin v1.3.1
3+
* https://github.com/carhartl/jquery-cookie
4+
*
5+
* Copyright 2013 Klaus Hartl
6+
* Released under the MIT license
7+
*/
8+
(function (factory) {
9+
if (typeof define === 'function' && define.amd) {
10+
// AMD. Register as anonymous module.
11+
define(['jquery'], factory);
12+
} else {
13+
// Browser globals.
14+
factory(jQuery);
15+
}
16+
}(function ($) {
17+
18+
var pluses = /\+/g;
19+
20+
function raw(s) {
21+
return s;
22+
}
23+
24+
function decoded(s) {
25+
return decodeURIComponent(s.replace(pluses, ' '));
26+
}
27+
28+
function converted(s) {
29+
if (s.indexOf('"') === 0) {
30+
// This is a quoted cookie as according to RFC2068, unescape
31+
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
32+
}
33+
try {
34+
return config.json ? JSON.parse(s) : s;
35+
} catch(er) {}
36+
}
37+
38+
var config = $.cookie = function (key, value, options) {
39+
40+
// write
41+
if (value !== undefined) {
42+
options = $.extend({}, config.defaults, options);
43+
44+
if (typeof options.expires === 'number') {
45+
var days = options.expires, t = options.expires = new Date();
46+
t.setDate(t.getDate() + days);
47+
}
48+
49+
value = config.json ? JSON.stringify(value) : String(value);
50+
51+
return (document.cookie = [
52+
config.raw ? key : encodeURIComponent(key),
53+
'=',
54+
config.raw ? value : encodeURIComponent(value),
55+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
56+
options.path ? '; path=' + options.path : '',
57+
options.domain ? '; domain=' + options.domain : '',
58+
options.secure ? '; secure' : ''
59+
].join(''));
60+
}
61+
62+
// read
63+
var decode = config.raw ? raw : decoded;
64+
var cookies = document.cookie.split('; ');
65+
var result = key ? undefined : {};
66+
for (var i = 0, l = cookies.length; i < l; i++) {
67+
var parts = cookies[i].split('=');
68+
var name = decode(parts.shift());
69+
var cookie = decode(parts.join('='));
70+
71+
if (key && key === name) {
72+
result = converted(cookie);
73+
break;
74+
}
75+
76+
if (!key) {
77+
result[name] = converted(cookie);
78+
}
79+
}
80+
81+
return result;
82+
};
83+
84+
config.defaults = {};
85+
86+
$.removeCookie = function (key, options) {
87+
if ($.cookie(key) !== undefined) {
88+
// Must not alter options, thus extending a fresh object...
89+
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
90+
return true;
91+
}
92+
return false;
93+
};
94+
95+
}));

0 commit comments

Comments
 (0)