1
0
Fork 0
mirror of https://github.com/infinum/cookies_eu synced 2023-03-27 23:21:16 -04:00

inital commit

This commit is contained in:
Stjepan Hadjic 2013-06-19 12:51:53 +02:00
parent eb7669d7a3
commit cd904ad347
12 changed files with 218 additions and 18 deletions

30
.gitignore vendored
View file

@ -1,16 +1,16 @@
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/.bundle
/vendor/bundle
/log/*
/tmp/*
/db/*.sqlite3
/public/system/*
/coverage/
/spec/tmp/*
**.orig
rerun.txt
pickle-email-*.html
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp

4
Gemfile Normal file
View file

@ -0,0 +1,4 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in cookies_eu.gemspec
gemspec

22
LICENSE.txt Normal file
View file

@ -0,0 +1,22 @@
Copyright (c) 2013 Stjepan Hadjic
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,4 +1,29 @@
cookies_eu
==========
# CookiesEu
Rails gem for eu cookies law
TODO: Write a gem description
## Installation
Add this line to your application's Gemfile:
gem 'cookies_eu'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cookies_eu
## Usage
TODO: Write usage instructions here
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

1
Rakefile Normal file
View file

@ -0,0 +1 @@
require "bundler/gem_tasks"

View file

@ -0,0 +1,8 @@
//= require jquery
//= require jquery.cookie
$('.cookies_eu_ok').click(function(e){
e.preventDefault();
$.cookie('consented', 'true');
$(this).parent().remove();
}

View file

@ -0,0 +1,7 @@
<% if cookie['consented'] != 'true' %>
<div class="cookies_eu" style="background: <%= CookiesEu::BACKGROUND %>; ">
<span><%= t('cookies_eu.span_text') %></span>
<button class="cookies_eu_ok"></button>
<a href="<%= CookiesEu::COOKIES_LINK %>"> <%= t('cookies_eu.learn_more') %> </a>
</div>
<% end %>

24
cookies_eu.gemspec Normal file
View file

@ -0,0 +1,24 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cookies_eu/version'
Gem::Specification.new do |spec|
spec.name = "cookies_eu"
spec.version = CookiesEu::VERSION
spec.authors = ["Stjepan Hadjic"]
spec.email = ["stjepan.hadjic@infinum.hr"]
spec.description = %q{Displays a cookie consent}
spec.summary = %q{Displays a cookie consent. If you dont disable cokkies in settings, we assume you are ok with us using cookies}
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "jquery-rails"
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
end

7
lib/cookies_eu.rb Normal file
View file

@ -0,0 +1,7 @@
require "cookies_eu/version"
require "cookies_eu/engine"
module CookiesEu
BACKGROUND = '#f2f2f2'
LINK = 'www.google.ie'
end

4
lib/cookies_eu/engine.rb Normal file
View file

@ -0,0 +1,4 @@
module CookiesEu
class Engine < ::Rails::Engine
end
end

View file

@ -0,0 +1,3 @@
module CookiesEu
VERSION = "0.0.3"
end

95
vendor/javacripts/jquery.cookie.js vendored Normal file
View file

@ -0,0 +1,95 @@
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery'], factory);
} else {
// Browser globals.
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return decodeURIComponent(s.replace(pluses, ' '));
}
function converted(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
return config.json ? JSON.parse(s) : s;
} catch(er) {}
}
var config = $.cookie = function (key, value, options) {
// write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = config.json ? JSON.stringify(value) : String(value);
return (document.cookie = [
config.raw ? key : encodeURIComponent(key),
'=',
config.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// read
var decode = config.raw ? raw : decoded;
var cookies = document.cookie.split('; ');
var result = key ? undefined : {};
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = decode(parts.join('='));
if (key && key === name) {
result = converted(cookie);
break;
}
if (!key) {
result[name] = converted(cookie);
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) !== undefined) {
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return true;
}
return false;
};
}));