diff --git a/app/assets/javascripts/beta-alert.js b/app/assets/javascripts/beta-alert.js new file mode 100644 index 0000000..c9d3dff --- /dev/null +++ b/app/assets/javascripts/beta-alert.js @@ -0,0 +1,6 @@ +$(function() { + if(Cookies.get('access') == undefined) { + Cookies.set('access', 'on', { expires: 7 }); + $('#beta-alert-modal').modal() + } +}); diff --git a/app/views/application/_beta_alert_modal.haml b/app/views/application/_beta_alert_modal.haml new file mode 100644 index 0000000..2ca3160 --- /dev/null +++ b/app/views/application/_beta_alert_modal.haml @@ -0,0 +1,28 @@ +.modal{:role => "dialog", :tabindex => "-1", :id => "beta-alert-modal" } + .modal-dialog{:role => "document"} + .modal-content + .modal-header + %h5.modal-title 〜 お知らせ 〜 + %button.close{"aria-label" => "閉じる", "data-dismiss" => "modal", :type => "button"} + %span{"aria-hidden" => "true"} × + .modal-body + %p + このサイトは、まだテスト公開中の段階です。 + %br + 十分注意はしていますが、予期しないバグなどが発生する場合があります。 + %p + また、このサイトは人間と同じく、 6時間以上睡眠を取らないと動かなくなるようになっています。 + %br + そのため、以下の時間帯は、このサイトにアクセスすることはできなくしています。 + %ul + %li 1:00 AM ~ 7:00 AM + + %p ご迷惑を色々とおかけしますが、よろしくお願いします。 + + %p + なお、旧サイトは + = link_to 'こちら', 'https://www.coderdojo.jp/' + です。 + + .modal-footer + %button.btn.btn-secondary{"data-dismiss" => "modal", :type => "button"} 閉じる diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4926a36..eaae441 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -22,6 +22,7 @@ %meta{:coderdojo => "1881439892127060", :property => "fb:pages"}/ %meta{:content => "CoderDojo 岡山 岡南", :name => "author"}/ %body + = render 'beta_alert_modal' = render 'header' = yield = render 'footer' diff --git a/app/views/layouts/pages.html.haml b/app/views/layouts/pages.html.haml index 684647d..60a1148 100644 --- a/app/views/layouts/pages.html.haml +++ b/app/views/layouts/pages.html.haml @@ -27,6 +27,7 @@ %link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/ %body#page-top + = render 'beta_alert_modal' = render 'header' %article %section#page-content diff --git a/app/views/layouts/staticpages.html.haml b/app/views/layouts/staticpages.html.haml index cb627e6..01cad88 100644 --- a/app/views/layouts/staticpages.html.haml +++ b/app/views/layouts/staticpages.html.haml @@ -24,6 +24,7 @@ %link{:href => "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800", :rel => "stylesheet", :type => "text/css"}/ %link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/ %body#page-top + = render 'beta_alert_modal' = render 'header' = yield = render 'footer' diff --git a/vendor/assets/javascripts/js.cookie.js b/vendor/assets/javascripts/js.cookie.js new file mode 100644 index 0000000..9a0945e --- /dev/null +++ b/vendor/assets/javascripts/js.cookie.js @@ -0,0 +1,165 @@ +/*! + * JavaScript Cookie v2.2.0 + * https://github.com/js-cookie/js-cookie + * + * Copyright 2006, 2015 Klaus Hartl & Fagner Brack + * Released under the MIT license + */ +;(function (factory) { + var registeredInModuleLoader = false; + if (typeof define === 'function' && define.amd) { + define(factory); + registeredInModuleLoader = true; + } + if (typeof exports === 'object') { + module.exports = factory(); + registeredInModuleLoader = true; + } + if (!registeredInModuleLoader) { + var OldCookies = window.Cookies; + var api = window.Cookies = factory(); + api.noConflict = function () { + window.Cookies = OldCookies; + return api; + }; + } +}(function () { + function extend () { + var i = 0; + var result = {}; + for (; i < arguments.length; i++) { + var attributes = arguments[ i ]; + for (var key in attributes) { + result[key] = attributes[key]; + } + } + return result; + } + + function init (converter) { + function api (key, value, attributes) { + var result; + if (typeof document === 'undefined') { + return; + } + + // Write + + if (arguments.length > 1) { + attributes = extend({ + path: '/' + }, api.defaults, attributes); + + if (typeof attributes.expires === 'number') { + var expires = new Date(); + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); + attributes.expires = expires; + } + + // We're using "expires" because "max-age" is not supported by IE + attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; + + try { + result = JSON.stringify(value); + if (/^[\{\[]/.test(result)) { + value = result; + } + } catch (e) {} + + if (!converter.write) { + value = encodeURIComponent(String(value)) + .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); + } else { + value = converter.write(value, key); + } + + key = encodeURIComponent(String(key)); + key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); + key = key.replace(/[\(\)]/g, escape); + + var stringifiedAttributes = ''; + + for (var attributeName in attributes) { + if (!attributes[attributeName]) { + continue; + } + stringifiedAttributes += '; ' + attributeName; + if (attributes[attributeName] === true) { + continue; + } + stringifiedAttributes += '=' + attributes[attributeName]; + } + return (document.cookie = key + '=' + value + stringifiedAttributes); + } + + // Read + + if (!key) { + result = {}; + } + + // To prevent the for loop in the first place assign an empty array + // in case there are no cookies at all. Also prevents odd result when + // calling "get()" + var cookies = document.cookie ? document.cookie.split('; ') : []; + var rdecode = /(%[0-9A-Z]{2})+/g; + var i = 0; + + for (; i < cookies.length; i++) { + var parts = cookies[i].split('='); + var cookie = parts.slice(1).join('='); + + if (!this.json && cookie.charAt(0) === '"') { + cookie = cookie.slice(1, -1); + } + + try { + var name = parts[0].replace(rdecode, decodeURIComponent); + cookie = converter.read ? + converter.read(cookie, name) : converter(cookie, name) || + cookie.replace(rdecode, decodeURIComponent); + + if (this.json) { + try { + cookie = JSON.parse(cookie); + } catch (e) {} + } + + if (key === name) { + result = cookie; + break; + } + + if (!key) { + result[name] = cookie; + } + } catch (e) {} + } + + return result; + } + + api.set = api; + api.get = function (key) { + return api.call(api, key); + }; + api.getJSON = function () { + return api.apply({ + json: true + }, [].slice.call(arguments)); + }; + api.defaults = {}; + + api.remove = function (key, attributes) { + api(key, '', extend(attributes, { + expires: -1 + })); + }; + + api.withConverter = init; + + return api; + } + + return init(function () {}); +}));