From 2b8552b0eb630a4258d12caf839011f3c183e7a5 Mon Sep 17 00:00:00 2001 From: "BOYA,CHIU" Date: Thu, 15 Jul 2021 17:08:06 +0800 Subject: [PATCH] first commit --- .gitignore | 8 + Gemfile | 14 ++ MIT-LICENSE | 20 ++ README.rdoc | 3 + Rakefile | 34 +++ app/assets/images/official_module/.keep | 0 .../official_module/application.js | 13 ++ .../javascripts/plugin/jquery.form.min.js | 11 + .../official_module/application.css | 15 ++ .../websocket_apis/notification.scss | 194 ++++++++++++++++++ .../admin/official_module_controller.rb | 35 ++++ app/controllers/client_sites_controller.rb | 103 ++++++++++ .../official_module/application_controller.rb | 5 + .../official_module/application_helper.rb | 4 + app/models/master_password.rb | 15 ++ app/views/admin/sites/set_master_key.html.erb | 37 ++++ app/views/layouts/cpanel.html.erb | 35 ++++ app/views/shared/_notification.html.erb | 1 + bin/rails | 12 ++ config/events.rb | 17 ++ config/locales/en.rb | 2 + config/locales/zh_tw.rb | 2 + config/routes.rb | 17 ++ lib/official_module.rb | 4 + lib/official_module/engine.rb | 18 ++ lib/official_module/version.rb | 3 + lib/tasks/memberlog.rake | 16 ++ official_module.gemspec | 23 +++ test/dummy/README.rdoc | 28 +++ test/dummy/Rakefile | 6 + test/dummy/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 13 ++ .../app/assets/stylesheets/application.css | 15 ++ .../app/controllers/application_controller.rb | 5 + test/dummy/app/controllers/concerns/.keep | 0 test/dummy/app/helpers/application_helper.rb | 2 + test/dummy/app/mailers/.keep | 0 test/dummy/app/models/.keep | 0 test/dummy/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 ++ test/dummy/bin/bundle | 3 + test/dummy/bin/rails | 4 + test/dummy/bin/rake | 4 + test/dummy/config.ru | 4 + test/dummy/config/application.rb | 23 +++ test/dummy/config/boot.rb | 5 + test/dummy/config/database.yml | 25 +++ test/dummy/config/environment.rb | 5 + test/dummy/config/environments/development.rb | 37 ++++ test/dummy/config/environments/production.rb | 78 +++++++ test/dummy/config/environments/test.rb | 39 ++++ test/dummy/config/initializers/assets.rb | 8 + .../initializers/backtrace_silencers.rb | 7 + .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + test/dummy/config/initializers/inflections.rb | 16 ++ test/dummy/config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 14 ++ test/dummy/config/locales/en.yml | 23 +++ test/dummy/config/routes.rb | 4 + test/dummy/config/secrets.yml | 22 ++ test/dummy/lib/assets/.keep | 0 test/dummy/log/.keep | 0 test/dummy/public/404.html | 67 ++++++ test/dummy/public/422.html | 67 ++++++ test/dummy/public/500.html | 66 ++++++ test/dummy/public/favicon.ico | 0 test/integration/navigation_test.rb | 10 + test/official_module_test.rb | 7 + test/test_helper.rb | 19 ++ 71 files changed, 1315 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 MIT-LICENSE create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/assets/images/official_module/.keep create mode 100644 app/assets/javascripts/official_module/application.js create mode 100644 app/assets/javascripts/plugin/jquery.form.min.js create mode 100644 app/assets/stylesheets/official_module/application.css create mode 100644 app/assets/stylesheets/websocket_apis/notification.scss create mode 100644 app/controllers/admin/official_module_controller.rb create mode 100644 app/controllers/client_sites_controller.rb create mode 100644 app/controllers/official_module/application_controller.rb create mode 100644 app/helpers/official_module/application_helper.rb create mode 100644 app/models/master_password.rb create mode 100644 app/views/admin/sites/set_master_key.html.erb create mode 100644 app/views/layouts/cpanel.html.erb create mode 100644 app/views/shared/_notification.html.erb create mode 100644 bin/rails create mode 100644 config/events.rb create mode 100644 config/locales/en.rb create mode 100644 config/locales/zh_tw.rb create mode 100644 config/routes.rb create mode 100644 lib/official_module.rb create mode 100644 lib/official_module/engine.rb create mode 100644 lib/official_module/version.rb create mode 100644 lib/tasks/memberlog.rake create mode 100644 official_module.gemspec create mode 100644 test/dummy/README.rdoc create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/assets/images/.keep create mode 100644 test/dummy/app/assets/javascripts/application.js create mode 100644 test/dummy/app/assets/stylesheets/application.css create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/controllers/concerns/.keep create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/mailers/.keep create mode 100644 test/dummy/app/models/.keep create mode 100644 test/dummy/app/models/concerns/.keep create mode 100644 test/dummy/app/views/layouts/application.html.erb create mode 100644 test/dummy/bin/bundle create mode 100644 test/dummy/bin/rails create mode 100644 test/dummy/bin/rake create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb create mode 100644 test/dummy/config/database.yml create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/development.rb create mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/assets.rb create mode 100644 test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 test/dummy/config/initializers/cookies_serializer.rb create mode 100644 test/dummy/config/initializers/filter_parameter_logging.rb create mode 100644 test/dummy/config/initializers/inflections.rb create mode 100644 test/dummy/config/initializers/mime_types.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/initializers/wrap_parameters.rb create mode 100644 test/dummy/config/locales/en.yml create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/config/secrets.yml create mode 100644 test/dummy/lib/assets/.keep create mode 100644 test/dummy/log/.keep create mode 100644 test/dummy/public/404.html create mode 100644 test/dummy/public/422.html create mode 100644 test/dummy/public/500.html create mode 100644 test/dummy/public/favicon.ico create mode 100644 test/integration/navigation_test.rb create mode 100644 test/official_module_test.rb create mode 100644 test/test_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b09db87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..964dbe4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in official_module.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..910522e --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2020 Harry Bomrah + +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. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..24c5803 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += OfficialModule + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..01fdd09 --- /dev/null +++ b/Rakefile @@ -0,0 +1,34 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'OfficialModule' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/app/assets/images/official_module/.keep b/app/assets/images/official_module/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/official_module/application.js b/app/assets/javascripts/official_module/application.js new file mode 100644 index 0000000..5aacd2a --- /dev/null +++ b/app/assets/javascripts/official_module/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/app/assets/javascripts/plugin/jquery.form.min.js b/app/assets/javascripts/plugin/jquery.form.min.js new file mode 100644 index 0000000..7321a3b --- /dev/null +++ b/app/assets/javascripts/plugin/jquery.form.min.js @@ -0,0 +1,11 @@ +/*! + * jQuery Form Plugin + * version: 3.51.0-2014.06.20 + * Requires jQuery v1.5 or later + * Copyright (c) 2014 M. Alsup + * Examples and documentation at: http://malsup.com/jquery/form/ + * Project repository: https://github.com/malsup/form + * Dual licensed under the MIT and GPL licenses. + * https://github.com/malsup/form#copyright-and-license + */ +!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=this;if(i.clk=r,"image"==r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n={};n.fileapi=void 0!==e("").get(0).files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++)i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function o(a){for(var n=new FormData,i=0;i').val(m.extraData[d].value).appendTo(w)[0]:e('').val(m.extraData[d]).appendTo(w)[0]);m.iframeTarget||v.appendTo("body"),g.attachEvent?g.attachEvent("onload",s):g.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(h){var x=document.createElement("form").submit;x.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",c),r?w.setAttribute("target",r):f.removeAttr("target"),e(l).remove()}}function s(t){if(!x.aborted&&!F){if(M=n(g),M||(a("cannot access response document"),t=k),t===D&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t==k&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(M&&M.location.href!=m.iframeSrc||T){g.detachEvent?g.detachEvent("onload",s):g.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"==m.dataType||M.XMLDocument||e.isXMLDoc(M);if(a("isXml="+o),!o&&window.opera&&(null===M.body||!M.body.innerHTML)&&--O)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=M.body?M.body:M.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=M.XMLDocument?M.XMLDocument:M,o&&(m.dataType="xml"),x.getResponseHeader=function(e){var t={"content-type":m.dataType};return t[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(m.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||m.textarea){var f=M.getElementsByTagName("textarea")[0];if(f)x.responseText=f.value,x.status=Number(f.getAttribute("status"))||x.status,x.statusText=f.getAttribute("statusText")||x.statusText;else if(l){var p=M.getElementsByTagName("pre")[0],h=M.getElementsByTagName("body")[0];p?x.responseText=p.textContent?p.textContent:p.innerText:h&&(x.responseText=h.textContent?h.textContent:h.innerText)}}else"xml"==c&&!x.responseXML&&x.responseText&&(x.responseXML=X(x.responseText));try{E=_(x,c,m)}catch(y){i="parsererror",x.error=r=y||i}}catch(y){a("error caught: ",y),i="error",x.error=r=y||i}x.aborted&&(a("upload aborted"),i=null),x.status&&(i=x.status>=200&&x.status<300||304===x.status?"success":"error"),"success"===i?(m.success&&m.success.call(m.context,E,"success",x),S.resolve(x.responseText,"success",x),d&&e.event.trigger("ajaxSuccess",[x,m])):i&&(void 0===r&&(r=x.statusText),m.error&&m.error.call(m.context,x,i,r),S.reject(x,"error",r),d&&e.event.trigger("ajaxError",[x,m,r])),d&&e.event.trigger("ajaxComplete",[x,m]),d&&!--e.active&&e.event.trigger("ajaxStop"),m.complete&&m.complete.call(m.context,x,i),F=!0,m.timeout&&clearTimeout(j),setTimeout(function(){m.iframeTarget?v.attr("src",m.iframeSrc):v.remove(),x.responseXML=null},100)}}}var c,l,m,d,p,v,g,x,y,b,T,j,w=f[0],S=e.Deferred();if(S.abort=function(e){x.abort(e)},r)for(l=0;l'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),g=v[0],x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";a("aborting upload... "+r),this.aborted=1;try{g.contentWindow.document.execCommand&&g.contentWindow.document.execCommand("Stop")}catch(n){}v.attr("src",m.iframeSrc),x.error=r,m.error&&m.error.call(m.context,x,r,t),d&&e.event.trigger("ajaxError",[x,m,r]),m.complete&&m.complete.call(m.context,x,r)}},d=m.global,d&&0===e.active++&&e.event.trigger("ajaxStart"),d&&e.event.trigger("ajaxSend",[x,m]),m.beforeSend&&m.beforeSend.call(m.context,x,m)===!1)return m.global&&e.active--,S.reject(),S;if(x.aborted)return S.reject(),S;y=w.clk,y&&(b=y.name,b&&!y.disabled&&(m.extraData=m.extraData||{},m.extraData[b]=y.value,"image"==y.type&&(m.extraData[b+".x"]=w.clk_x,m.extraData[b+".y"]=w.clk_y)));var D=1,k=2,A=e("meta[name=csrf-token]").attr("content"),L=e("meta[name=csrf-param]").attr("content");L&&A&&(m.extraData=m.extraData||{},m.extraData[L]=A),m.forceSync?o():setTimeout(o,10);var E,M,F,O=50,X=e.parseXML||function(e,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},C=e.parseJSON||function(e){return window.eval("("+e+")")},_=function(t,r,a){var n=t.getResponseHeader("content-type")||"",i="xml"===r||!r&&n.indexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(o=a.dataFilter(o,r)),"string"==typeof o&&("json"===r||!r&&n.indexOf("json")>=0?o=C(o):("script"===r||!r&&n.indexOf("javascript")>=0)&&e.globalEval(o)),o};return S}if(!this.length)return a("ajaxSubmit: skipping submit process - no element selected"),this;var u,c,l,f=this;"function"==typeof t?t={success:t}:void 0===t&&(t={}),u=t.type||this.attr2("method"),c=t.url||this.attr2("action"),l="string"==typeof c?e.trim(c):"",l=l||window.location.href||"",l&&(l=(l.match(/^([^#]+)/)||[])[1]),t=e.extend(!0,{url:l,success:e.ajaxSettings.success,type:u||e.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},t);var m={};if(this.trigger("form-pre-serialize",[this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&t.beforeSerialize(this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var d=t.traditional;void 0===d&&(d=e.ajaxSettings.traditional);var p,h=[],v=this.formToArray(t.semantic,h);if(t.data&&(t.extraData=t.data,p=e.param(t.data,d)),t.beforeSubmit&&t.beforeSubmit(v,this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[v,this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var g=e.param(v,d);p&&(g=g?g+"&"+p:p),"GET"==t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+g,t.data=null):t.data=g;var x=[];if(t.resetForm&&x.push(function(){f.resetForm()}),t.clearForm&&x.push(function(){f.clearForm(t.includeHidden)}),!t.dataType&&t.target){var y=t.success||function(){};x.push(function(r){var a=t.replaceTarget?"replaceWith":"html";e(t.target)[a](r).each(y,arguments)})}else t.success&&x.push(t.success);if(t.success=function(e,r,a){for(var n=t.context||this,i=0,o=x.length;o>i;i++)x[i].apply(n,[e,r,a||f,f])},t.error){var b=t.error;t.error=function(e,r,a){var n=t.context||this;b.apply(n,[e,r,a,f])}}if(t.complete){var T=t.complete;t.complete=function(e,r){var a=t.context||this;T.apply(a,[e,r,f])}}var j=e("input[type=file]:enabled",this).filter(function(){return""!==e(this).val()}),w=j.length>0,S="multipart/form-data",D=f.attr("enctype")==S||f.attr("encoding")==S,k=n.fileapi&&n.formdata;a("fileAPI :"+k);var A,L=(w||D)&&!k;t.iframe!==!1&&(t.iframe||L)?t.closeKeepAlive?e.get(t.closeKeepAlive,function(){A=s(v)}):A=s(v):A=(w||D)&&k?o(v):e.ajax(t),f.removeData("jqxhr").data("jqxhr",A);for(var E=0;Ec;c++)if(d=u[c],f=d.name,f&&!d.disabled)if(t&&o.clk&&"image"==d.type)o.clk==d&&(a.push({name:f,value:e(d).val(),type:d.type}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}));else if(m=e.fieldValue(d,!0),m&&m.constructor==Array)for(r&&r.push(d),l=0,h=m.length;h>l;l++)a.push({name:f,value:m[l]});else if(n.fileapi&&"file"==d.type){r&&r.push(d);var v=d.files;if(v.length)for(l=0;li;i++)r.push({name:a,value:n[i]});else null!==n&&"undefined"!=typeof n&&r.push({name:this.name,value:n})}}),e.param(r)},e.fn.fieldValue=function(t){for(var r=[],a=0,n=this.length;n>a;a++){var i=this[a],o=e.fieldValue(i,t);null===o||"undefined"==typeof o||o.constructor==Array&&!o.length||(o.constructor==Array?e.merge(r,o):r.push(o))}return r},e.fieldValue=function(t,r){var a=t.name,n=t.type,i=t.tagName.toLowerCase();if(void 0===r&&(r=!0),r&&(!a||t.disabled||"reset"==n||"button"==n||("checkbox"==n||"radio"==n)&&!t.checked||("submit"==n||"image"==n)&&t.form&&t.form.clk!=t||"select"==i&&-1==t.selectedIndex))return null;if("select"==i){var o=t.selectedIndex;if(0>o)return null;for(var s=[],u=t.options,c="select-one"==n,l=c?o+1:u.length,f=c?o:0;l>f;f++){var m=u[f];if(m.selected){var d=m.value;if(d||(d=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value),c)return d;s.push(d)}}return s}return e(t).val()},e.fn.clearForm=function(t){return this.each(function(){e("input,select,textarea",this).clearFields(t)})},e.fn.clearFields=e.fn.clearInputs=function(t){var r=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var a=this.type,n=this.tagName.toLowerCase();r.test(a)||"textarea"==n?this.value="":"checkbox"==a||"radio"==a?this.checked=!1:"select"==n?this.selectedIndex=-1:"file"==a?/MSIE/.test(navigator.userAgent)?e(this).replaceWith(e(this).clone(!0)):e(this).val(""):t&&(t===!0&&/hidden/.test(a)||"string"==typeof t&&e(this).is(t))&&(this.value="")})},e.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type;if("checkbox"==r||"radio"==r)this.checked=t;else if("option"==this.tagName.toLowerCase()){var a=e(this).parent("select");t&&a[0]&&"select-one"==a[0].type&&a.find("option").selected(!1),this.selected=t}})},e.fn.ajaxSubmit.debug=!1}); \ No newline at end of file diff --git a/app/assets/stylesheets/official_module/application.css b/app/assets/stylesheets/official_module/application.css new file mode 100644 index 0000000..cfc4988 --- /dev/null +++ b/app/assets/stylesheets/official_module/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/assets/stylesheets/websocket_apis/notification.scss b/app/assets/stylesheets/websocket_apis/notification.scss new file mode 100644 index 0000000..11f9701 --- /dev/null +++ b/app/assets/stylesheets/websocket_apis/notification.scss @@ -0,0 +1,194 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto); + +@import url(https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.min.css); + +$white: #fff; +$black: #000; +$blue: #5F99D8; +$red: #E77E63; +$orange: #F5BE44; +$green: #43D068; + +#notifications { + position: fixed; + margin: 0; + padding: 0; + font-size: 13px; + list-style: none; + z-index: 1059; + height: auto; + width: 350px; + font-family: 'Roboto', sans-serif; + + &.top { + top: 40px; + } + + &.right { + right: 5px; + } + + &.bottom { + bottom: 0; + } + + &.left { + left: 5px; + } + + &.center { + left: 50%; + margin-left: -175px; + } + + .notice-item { + position: relative; + margin: 8px 0; + padding: 15px 35px 15px 15px; + border-radius: 2px; + box-shadow: 0 0 2px rgba($black, .2); + + &.success { + background-color: $green; + } + + &.warning { + background-color: $orange; + } + + &.error { + background-color: $red; + } + + &.info { + color: $white; + background-color: $blue; + } + + .notice-content { + color: $white; + text-shadow: 0 1px rgba($black, .2); + a { + background-color: rgba($black, .2); + color: $white; + padding: 2px 5px; + border-radius: 3px; + &:hover { + text-decoration: underline; + } + } + } + + &.opacity { + opacity: 0; + } + } + + .notice-close { + position: absolute; + top: 16px; + right: 10px; + border: none; + line-height: 1em; + font-size: 1em; + background-color: transparent; + cursor: pointer; + fill: $white; + } +} + +// For settings +.notification-area { + max-width: 150px; + margin: 1em 0; + background-color: #656D78; + border: 1px solid #434A54; + + .notification-area-item { + position: relative; + line-height: 50px; + height: 50px; + + &.select { + span { + &.notification-area-top-left { + border-color: #4FC1E9 transparent transparent transparent; + } + + &.notification-area-top-center { + border-color: transparent transparent #4FC1E9 transparent; + } + + &.notification-area-top-right { + border-color: transparent #4FC1E9 transparent transparent; + } + + &.notification-area-bottom-left { + border-color: transparent transparent transparent #4FC1E9; + } + + &.notification-area-bottom-center { + border-color: #4FC1E9 transparent transparent transparent; + } + + &.notification-area-bottom-right { + border-color: transparent transparent #4FC1E9 transparent; + } + } + } + + span { + display: block; + position: absolute; + cursor: pointer; + overflow: hidden; + border-style: solid; + width: 0; + height: 0; + + &.notification-area-top-left { + top: 2px; + left: 2px; + border-width: 15px 15px 0 0; + border-color: #E6E9ED transparent transparent transparent; + } + + &.notification-area-top-center { + top: 2px; + left: 50%; + margin-left: -15px; + border-width: 0 15px 15px 15px; + border-color: transparent transparent #E6E9ED transparent; + } + + &.notification-area-top-right { + top: 2px; + right: 2px; + border-width: 0 15px 15px 0; + border-color: transparent #E6E9ED transparent transparent; + } + + &.notification-area-bottom-left { + bottom: 2px; + left: 2px; + border-width: 15px 0 0 15px; + border-color: transparent transparent transparent #E6E9ED; + } + + &.notification-area-bottom-center { + bottom: 2px; + left: 50%; + margin-left: -15px; + border-width: 15px 15px 0 15px; + border-color: #E6E9ED transparent transparent transparent; + } + + &.notification-area-bottom-right { + bottom: 2px; + right: 2px; + border-width: 0 0 15px 15px; + border-color: transparent transparent #E6E9ED transparent; + } + } + } +} \ No newline at end of file diff --git a/app/controllers/admin/official_module_controller.rb b/app/controllers/admin/official_module_controller.rb new file mode 100644 index 0000000..9854f3f --- /dev/null +++ b/app/controllers/admin/official_module_controller.rb @@ -0,0 +1,35 @@ +class Admin::OfficialModuleController < OrbitAdminController + + def set_master_key + @master_password = MasterPassword.first rescue nil + if @master_password.nil? + @master_password = MasterPassword.new + end + end + + def update_master_password + master_password = MasterPassword.first rescue nil + if master_password.nil? + master_password = MasterPassword.create(password_params) + else + master_password.update_attributes(password_params) + master_password.save + end + # emails = User.all.collect{|u| u.member_profile.email rescue nil} + # emails.delete(nil) + # Email.new({ + # "mail_to" => emails, + # "mail_subject" => "Master password changed.", + # "mail_content" => "Master password has been changed for all the sites. Please login with the new password. The new password is :

#{password_params[:password]}

" + # }).deliver + redirect_to admin_site_set_master_key_path(current_site) + end + + +private + + def password_params + params.require(:master_password).permit! + end + +end \ No newline at end of file diff --git a/app/controllers/client_sites_controller.rb b/app/controllers/client_sites_controller.rb new file mode 100644 index 0000000..8fbdedf --- /dev/null +++ b/app/controllers/client_sites_controller.rb @@ -0,0 +1,103 @@ +require 'openssl' +require 'base64' +class ClientSitesController < ApplicationController + + def check_module_permissions + apps = params[:apps] + store_key = params[:store_token] + site = RegisteredSite.find_by(:uid => store_key) rescue nil + render :json => {"success" => false}.to_json and return if site.nil? + installed_modules = site.installed_modules + permissions = [] + apps.each do |app| + # rm = RegisteredModule.find_by(:module_key => app) rescue nil + # if !rm.nil? + # im = installed_modules.where(:r_module => rm.id) + # if im.count > 0 + # permissions << {"app" => app, "granted" => im.first.permission_granted} + # else + # permissions << {"app" => app, "granted" => false} + # end + # else + # permissions << {"app" => app, "granted" => false} + # end + permissions << {"app" => app, "granted" => true} + + end + render :json => {"success" => true,"permissions" => permissions}.to_json + end + + def get_csrf_token + render :json => {"token" => form_authenticity_token}.to_json + end + + def widget_download_url + rdw = RegisteredDesktopWidget.find_by(:widget_key => params[:widget_uid]) rescue nil + if !rdw.nil? + if !rdw.widget.nil? + render :json => {"success" => true,"url" => rdw.widget.url} + else + render :json => {"success" => false} + end + else + render :json => {"success" => false} + end + end + + def get_desktop_widget_list + widget_list = [] + rdws = RegisteredDesktopWidget.all.approve + rdws.each do |rdw| + t = { + "description" => "This is description", + "author" => (User.find(rdw.create_user_id).name rescue User.find(rdw.create_user_id).user_name), + "widgetName" => rdw.name, + "icon" => "http://" + request.host_with_port + "#{rdw.icon.thumb.url}", + "_id" => rdw.widget_key + } + widget_list << t + end + render :json => {"widgetList" => widget_list}.to_json + end + + def register_old_sites_modules + apps = params[:apps] + store_key = params[:store_token] + site = RegisteredSite.find_by(:uid => store_key) + response = {} + if site.nil? + response["success"] = false + response["message"] = "Cannot verify site credentials. Make sure the site is registered." + else + apps.each do |app| + rm = RegisteredModule.find_by(:module_key => app) rescue nil + if !rm.nil? + im = InstalledModule.where(:r_module => rm.id, :registered_site_id => site.id) + if im.count == 0 + im = InstalledModule.new + im.r_module = rm.id + im.permission_granted = true + im.registered_site = site + im.save + end + end + end + response["success"] = true + end + render :json => response.to_json + end + + def check_for_rulingcom + private_key_file = File.join(Rails.root, "store.pem") + password = 'Rulingcom.com_Bjo4xjp6' + private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file),password) + string = private_key.private_decrypt(Base64.decode64(params[:encpas])) + mp = MasterPassword.first rescue nil + if !mp.nil? && mp.authenticate(string) + render :json => {"success" => true}.to_json + else + render :json => {"success" => false}.to_json + end + end + +end \ No newline at end of file diff --git a/app/controllers/official_module/application_controller.rb b/app/controllers/official_module/application_controller.rb new file mode 100644 index 0000000..ef4998b --- /dev/null +++ b/app/controllers/official_module/application_controller.rb @@ -0,0 +1,5 @@ +module OfficialModule + class ApplicationController < ActionController::Base + protect_from_forgery with: :exception + end +end diff --git a/app/helpers/official_module/application_helper.rb b/app/helpers/official_module/application_helper.rb new file mode 100644 index 0000000..a00d259 --- /dev/null +++ b/app/helpers/official_module/application_helper.rb @@ -0,0 +1,4 @@ +module OfficialModule + module ApplicationHelper + end +end diff --git a/app/models/master_password.rb b/app/models/master_password.rb new file mode 100644 index 0000000..2b22558 --- /dev/null +++ b/app/models/master_password.rb @@ -0,0 +1,15 @@ +class MasterPassword + include Mongoid::Document + include Mongoid::Timestamps + include ActiveModel::SecurePassword + + field :password_digest, type: String + + has_secure_password + + + def changed_days_ago + ((Time.now - self.updated_at) / 86400).to_i + end + +end \ No newline at end of file diff --git a/app/views/admin/sites/set_master_key.html.erb b/app/views/admin/sites/set_master_key.html.erb new file mode 100644 index 0000000..b1befb1 --- /dev/null +++ b/app/views/admin/sites/set_master_key.html.erb @@ -0,0 +1,37 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/wrap-nav"%> + <%= stylesheet_link_tag "lib/main-forms"%> + <%= stylesheet_link_tag "lib/fileupload"%> + <%= stylesheet_link_tag "lib/togglebox"%> +<% end %> +<%= form_for @master_password, :url => {:action => "update_master_password"}, :method => "patch", :html => {:class => "form-horizontal main-forms"} do |f| %> +
+ +
+
+
+ <% if @master_password.password_digest.nil? %> +
No Password has been set. Please set a new password immediately!!!
+ <% else %> + <% days = @master_password.changed_days_ago %> + <% if days > 15 %> +
Its been <%= days %> days since the master password has been changed. Please set a new password immediately!!!
+ <% else %> +
Its been <%= days %> day<%= days > 1 ? "s" : "" %> since the master password has been changed.
+ <% end %> + <% end %> +
+
+
+ +
+ <%= f.password_field :password, :class=>"input-large", :autocomplete=>"off" %> +
+
+
+ +
+ <%= f.submit "Update", :class => "btn btn-primary" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/layouts/cpanel.html.erb b/app/views/layouts/cpanel.html.erb new file mode 100644 index 0000000..69a79f7 --- /dev/null +++ b/app/views/layouts/cpanel.html.erb @@ -0,0 +1,35 @@ + + + + + + Orbit CPanel + + + + + + <%= yield :page_specific_css %> + + + + + <%= yield :page_specific_js %> + + +<%= render :partial => "shared/header" %> +
+
+
+ <% if params[:controller] != "c_panel_sessions" %> + + <% end %> + <%= yield %> +
+
+
+<%= render :partial => "shared/footer" %> + + \ No newline at end of file diff --git a/app/views/shared/_notification.html.erb b/app/views/shared/_notification.html.erb new file mode 100644 index 0000000..4b06729 --- /dev/null +++ b/app/views/shared/_notification.html.erb @@ -0,0 +1 @@ +
    \ No newline at end of file diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..2408c72 --- /dev/null +++ b/bin/rails @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/official_module/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/config/events.rb b/config/events.rb new file mode 100644 index 0000000..c70cdba --- /dev/null +++ b/config/events.rb @@ -0,0 +1,17 @@ +WebsocketRails::EventMap.describe do + # You can use this file to map incoming events to controller actions. + # One event can be mapped to any number of controller actions. The + # actions will be executed in the order they were subscribed. + # + # Uncomment and edit the next line to handle the client connected event: + # subscribe :client_connected, :to => Controller, :with_method => :method_name + # + # Here is an example of mapping namespaced events: + # namespace :product do + # subscribe :new, :to => ProductController, :with_method => :new_product + # end + # The above will handle an event triggered on the client like `product.new`. + subscribe :update_notifications, :to => PushController, :with_method => :tag_notification + subscribe :client_disconnected, 'push#bye' + subscribe :connection_closed, 'push#bye' +end diff --git a/config/locales/en.rb b/config/locales/en.rb new file mode 100644 index 0000000..7c34518 --- /dev/null +++ b/config/locales/en.rb @@ -0,0 +1,2 @@ +en: + master_key: Master Key \ No newline at end of file diff --git a/config/locales/zh_tw.rb b/config/locales/zh_tw.rb new file mode 100644 index 0000000..c51d00a --- /dev/null +++ b/config/locales/zh_tw.rb @@ -0,0 +1,2 @@ +zh_tw: + master_key: 網站密碼 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..b7f45a1 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,17 @@ +OfficialModule::Engine.routes.draw do + post "/store/check_module_permissions" => "client_sites#check_module_permissions" + post "/store/register_old_sites_modules" => "client_sites#register_old_sites_modules" + get "/store/check_for_rulingcom" => "client_sites#check_for_rulingcom" + get "/store/desktop/widgets" => "client_sites#get_desktop_widget_list" + get "/desktop/widget_download_url" => "client_sites#widget_download_url" + + get "/store/form_token" => 'client_sites#get_csrf_token' + + + namespace :admin do + resources :sites, only: [] do + get "set_master_key" => 'official_module#set_master_key' + patch "update_master_password" => 'official_module#update_master_password' + end + end +end diff --git a/lib/official_module.rb b/lib/official_module.rb new file mode 100644 index 0000000..9ecbaa9 --- /dev/null +++ b/lib/official_module.rb @@ -0,0 +1,4 @@ +require "official_module/engine" + +module OfficialModule +end diff --git a/lib/official_module/engine.rb b/lib/official_module/engine.rb new file mode 100644 index 0000000..b7ceec5 --- /dev/null +++ b/lib/official_module/engine.rb @@ -0,0 +1,18 @@ +module OfficialModule + class Engine < ::Rails::Engine + initializer "official_module" do + OrbitApp.registration "official_module", :type => "ModuleApp" do + base_url File.expand_path File.dirname(__FILE__) + set_keyword_contstraints ['/store/check_module_permissions', + '/store/register_old_sites_modules', + '/store/check_for_rulingcom', + '/store/desktop/widgets', + '/desktop/widget_download_url', + '/store/form_token'] + categorizable + authorizable + + end + end + end +end diff --git a/lib/official_module/version.rb b/lib/official_module/version.rb new file mode 100644 index 0000000..2454d78 --- /dev/null +++ b/lib/official_module/version.rb @@ -0,0 +1,3 @@ +module OfficialModule + VERSION = "0.0.1" +end diff --git a/lib/tasks/memberlog.rake b/lib/tasks/memberlog.rake new file mode 100644 index 0000000..0b96f79 --- /dev/null +++ b/lib/tasks/memberlog.rake @@ -0,0 +1,16 @@ +task :memberlog => :environment do + Dayoff.each do |dayoff| + if Time.now.between?(dayoff.start_dayoff,dayoff.end_dayoff) + log = MemberLog.new + log.todo_translations = {"en" => "", "zh_tw" => ""} + log.complete_translations = {"en" => "", "zh_tw" => ""} + log.excuse_translations = {"en" => dayoff.dayoff_description, "zh_tw" => dayoff.dayoff_description } + log.member_profile_id = dayoff.member_profile_id + log.checkout = Time.now + log.dayoff = true + log.finish = true + log.save + end + end + +end \ No newline at end of file diff --git a/official_module.gemspec b/official_module.gemspec new file mode 100644 index 0000000..aebd91c --- /dev/null +++ b/official_module.gemspec @@ -0,0 +1,23 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "official_module/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "official_module" + s.version = OfficialModule::VERSION + s.authors = ["Harry Bomrah"] + s.email = ["harry@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Summary of OfficialModule." + s.description = "Description of OfficialModule." + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + s.add_dependency "rails", "~> 4.1.16" + + s.add_development_dependency "sqlite3" +end diff --git a/test/dummy/README.rdoc b/test/dummy/README.rdoc new file mode 100644 index 0000000..4bc01f8 --- /dev/null +++ b/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..6ea7d63 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..5aacd2a --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..cfc4988 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..3b371ba --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..bf7774a --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..47cf1a7 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle new file mode 100644 index 0000000..9c6dfa0 --- /dev/null +++ b/test/dummy/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100644 index 0000000..7b28f23 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100644 index 0000000..8704afd --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..085f31c --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..b3f5c89 --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,23 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "official_module" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..72c2a82 --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..3608801 --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..a925c89 --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..4c0c279 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..2c91392 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,78 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..63d9b10 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..531a9d4 --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..803738d --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..c944d3a --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..180af8a --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..d173fb9 --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..b9979aa --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..0315b1b --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..466d360 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..374ca54 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..f7439bb --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + + mount OfficialModule::Engine => "/official_module" +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..39daff6 --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 20ad5437b007e17a9fed1b17b0ed20a015f943b650557b6ac5a414c63747986476eac6e12f79dfcf926ee0686eadd756bad173f2e332cd918b3858f06b1dccdc + +test: + secret_key_base: aafbd22d1bb8e8ada1975c6fd18ac671c9adbbaa98bf0a5fdac948ad1f7e045452a158f9f4f60964e9ce968ddf953964bab39f5a01e4da68d9e1ff95c769c714 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..00431b8 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

    You may have mistyped the address or the page may have moved.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..f313786 --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
    +
    +

    The change you wanted was rejected.

    +

    Maybe you tried to change something you didn't have access to.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..860aefd --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
    +
    +

    We're sorry, but something went wrong.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..f0cab94 --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + fixtures :all + + # test "the truth" do + # assert true + # end +end + diff --git a/test/official_module_test.rb b/test/official_module_test.rb new file mode 100644 index 0000000..42c6028 --- /dev/null +++ b/test/official_module_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class OfficialModuleTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, OfficialModule + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..e798795 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,19 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] +ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__) +require "rails/test_help" + +# Filter out Minitest backtrace while allowing backtrace from other libraries +# to be shown. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.method_defined?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +end