From c1c891155960cd085873f90f93ad281b1a437e2d Mon Sep 17 00:00:00 2001 From: lxsang Date: Thu, 24 Sep 2020 19:18:08 +0200 Subject: [PATCH] cleanup front pages --- grs/main.js | 119 ---------------------------------------------- grs/sendmail.lua | 20 -------- grs/subscribe.lua | 22 --------- index.ls | 5 -- 4 files changed, 166 deletions(-) delete mode 100644 grs/main.js delete mode 100644 grs/sendmail.lua delete mode 100644 grs/subscribe.lua diff --git a/grs/main.js b/grs/main.js deleted file mode 100644 index a5116bd..0000000 --- a/grs/main.js +++ /dev/null @@ -1,119 +0,0 @@ -var scheme = undefined; -String.prototype.__ = function() -{ - return this -} -function subscribe(prefix) -{ - if(scheme) return; - // get scheme - $.get(prefix+"/subscribe.html") - .done(function(d) { - scheme = $.parseHTML(d) - var obs = riot.observable() - $(scheme).css("visibility","hidden") - $("#desktop" ).append(scheme) - obs.on("exit", function(){ - $(scheme).remove() - scheme = undefined - }) - obs.on("rendered", function(d){ - $(".afx-window-title", scheme).html("Subscribe") - $("[data-id='send']", scheme).click(function(){ - var status = $("[data-id='status']", scheme) - status.html(""); - var els = $("[data-class='data']", scheme) - var data = {} - - for(var i = 0; i < els.length; i++) - data[els[i].name] = $(els[i]).val() - if(data.email == "" || data.subject == "" || data.content == "" || data.name == "") - return status.html("Please enter all the fields"); - var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - if(!re.test(String(data.email).toLowerCase())) - return status.html("Email is not correct"); - - $.ajax({ - type: 'POST', - url: prefix + "/subscribe.lua", - contentType: 'application/json', - data: JSON.stringify(data), - dataType: 'json', - success: null - }).done(function(r){ - if(r.error) - alert(r.error) - else - { - obs.trigger("exit") - alert("You have been subscribed. Thanks") - } - }).fail(function(e, s){ - alert("Error: " + e) - }) - }) - $(scheme).css("visibility","visible") - }) - riot.mount(scheme, {observable:obs}) - }) - .fail(function() { - alert( "Cannot get the form" ); - }) -} -function mailtoMe(prefix) -{ - if(scheme) return; - // get scheme - $.get(prefix+"/sendto.html") - .done(function(d) { - scheme = $.parseHTML(d) - var obs = riot.observable() - $(scheme).css("visibility","hidden") - $("#desktop" ).append(scheme) - obs.on("exit", function(){ - $(scheme).remove() - scheme = undefined - }) - obs.on("rendered", function(d){ - $(".afx-window-title", scheme).html("Send me an email") - $("[data-id='send']", scheme).click(function(){ - var status = $("[data-id='status']", scheme) - status.html(""); - var els = $("[data-class='data']", scheme) - var data = {} - - for(var i = 0; i < els.length; i++) - data[els[i].name] = $(els[i]).val() - if(data.email == "" || data.subject == "" || data.content == "" || data.name == "") - return status.html("Please enter all the fields"); - var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - if(!re.test(String(data.email).toLowerCase())) - return status.html("Email is not correct"); - - $.ajax({ - type: 'POST', - url: prefix + "/sendmail.lua", - contentType: 'application/json', - data: JSON.stringify(data), - dataType: 'json', - success: null - }).done(function(r){ - if(r.error) - alert(r.error) - else - { - obs.trigger("exit") - alert("Email sent. Thank") - } - }).fail(function(){ - alert("Service unavailable at the moment") - }) - }) - $(scheme).css("visibility","visible") - }) - riot.mount(scheme, {observable:obs}) - }) - .fail(function() { - alert( "Cannot get the form" ); - }) -} \ No newline at end of file diff --git a/grs/sendmail.lua b/grs/sendmail.lua deleted file mode 100644 index 7166475..0000000 --- a/grs/sendmail.lua +++ /dev/null @@ -1,20 +0,0 @@ - -if not REQUEST.json then - fail("unknown request") -end -local rq = (JSON.decodeString(REQUEST.json)) -local to = "xsang.le@gmail.com" -local from = "From: "..rq.email.."\n" -local suject = "Subject: "..rq.subject.."\n" -local content = "Contact request from:"..rq.name.."\n Email: "..rq.email.."\n"..rq.content.."\n" - -local cmd = 'echo "'..utils.escape(from..suject..content)..'"| sendmail '..to - ---print(cmd) -local r = os.execute(cmd) - -if r then - result(r) -else - fail("Cannot send email at the moment, the service may be down") -end \ No newline at end of file diff --git a/grs/subscribe.lua b/grs/subscribe.lua deleted file mode 100644 index d614b1c..0000000 --- a/grs/subscribe.lua +++ /dev/null @@ -1,22 +0,0 @@ - -if not REQUEST.json then - fail("unknown request") -end -local rq = (JSON.decodeString(REQUEST.json)) -local sample = {name = "toto", email = "toto@mail.fr"} -local db = require("db.model").get("mrsang","subscribers",sample) - -if db then - -- check if email is exist - local data = db:find({exp = { ["="] = { email = rq.email } }}) - if data and #data > 0 then - fail("You are already/previously subscribed") - else - -- save to database - db:insert(rq) - result("Ok") - end - db:close() -else - fail("Cannot subscribe at the moment, the service may be down") -end \ No newline at end of file diff --git a/index.ls b/index.ls index ec9751e..6a092fc 100644 --- a/index.ls +++ b/index.ls @@ -25,10 +25,6 @@ - - - -
@@ -36,7 +32,6 @@