From 5a7566eaf7787f00bf8e7b3504183022556de037 Mon Sep 17 00:00:00 2001 From: mynah Date: Wed, 18 Jul 2018 16:04:47 -0500 Subject: [PATCH] en el moras --- lib/Dojo.pm | 1 + lib/Dojo/Controller/Data.pm | 9 +++++ lib/Dojo/Controller/Home.pm | 37 ++++++++++++++---- lib/Dojo/Model/Vuelo.pm | 38 ++++++++++++++++--- .../admin/{radio => }/candySwitch/cssMain.css | 0 .../{radio => }/candySwitch/cssSwitch.css | 0 .../{radio => }/candySwitch/jsCSwitch.js | 2 +- public/home/admin/event/SCHEDULE COMPLETE - , | 0 ... students: \\n\\n\\n\\nHave a nice day..." | 0 public/home/admin/event/[ | 0 "public/home/admin/event/admin\\@," | 0 .../home/admin/event/i.h4d35\\@gmail.com," | 0 public/home/admin/mensajes/jsMsg.js | 2 +- public/home/admin/mensajes/json/qGetInfo.q | 10 +---- public/home/admin/mensajes/qEntries.q | 12 ++---- public/home/admin/radio/jsLoadInfo.js | 4 +- public/home/admin/radio/update/qUpdate.q | 11 +----- .../home/admin/candySwitch.html.ep | 0 .../home/admin/mensajes.html.ep | 10 ++--- .../home/admin/radio.html.ep | 7 +++- templates/home/radio.html.ep | 6 +-- 21 files changed, 94 insertions(+), 55 deletions(-) rename public/home/admin/{radio => }/candySwitch/cssMain.css (100%) rename public/home/admin/{radio => }/candySwitch/cssSwitch.css (100%) rename public/home/admin/{radio => }/candySwitch/jsCSwitch.js (94%) delete mode 100644 public/home/admin/event/SCHEDULE COMPLETE - , delete mode 100644 "public/home/admin/event/Student schedule for today, completed for the following students: \\n\\n\\n\\nHave a nice day..." delete mode 100644 public/home/admin/event/[ delete mode 100644 "public/home/admin/event/admin\\@," delete mode 100644 "public/home/admin/event/i.h4d35\\@gmail.com," rename public/home/admin/radio/candySwitch/htmlCSwitch.html => templates/home/admin/candySwitch.html.ep (100%) rename public/home/admin/mensajes/htmlMensajes.html => templates/home/admin/mensajes.html.ep (70%) rename public/home/admin/radio/htmlAdmin.html => templates/home/admin/radio.html.ep (76%) diff --git a/lib/Dojo.pm b/lib/Dojo.pm index 63a2e89..060bc51 100644 --- a/lib/Dojo.pm +++ b/lib/Dojo.pm @@ -35,6 +35,7 @@ sub startup { $r->any('/json/candy/:command')->to('data#candy'); $r->any('/admin/:section'=> {section =>'home'})->to('home#admin'); + $r->any('/admin/json/:dreq/:id/')->to('data#admin'); $r->any('/login')->to('users#login'); $r->any('/logout')->to('users#logout'); diff --git a/lib/Dojo/Controller/Data.pm b/lib/Dojo/Controller/Data.pm index ed896d4..8687b9a 100644 --- a/lib/Dojo/Controller/Data.pm +++ b/lib/Dojo/Controller/Data.pm @@ -15,6 +15,14 @@ sub simple{ $c->render(json=>$json); } +sub admin{ + my $c=shift; + my $n=$c->param("dreq")//""; + my $json = {status => "304"}; + $json= ($c->dbv->rmsgid($c->param('id')))[0] if ($n =~m/^mensajes$/); + $c->render(json=>$json); +} +#==== candy ===================================================== sub candy{ my $c=shift; my $r="-1"; @@ -57,6 +65,7 @@ sub candy{ } sub disconnectT{ $t->close();} +#========================================================= 1 __END__ diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index 6296466..8a3aa28 100644 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -101,13 +101,36 @@ sub admin{ if ($c->param("hup")=~/Cambiar/){ $c->dbv->umod($c->param('link'),$c->param('update')); }; - my $v=(load_module("home/admin"))[0]; - my ($x,$w)= load_module("home/admin/home"); - $c->stash( merge_hash($x,$v) ); - $c->stash(apend => ["home/admin/home"]); - $c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod}); - - + if ($c->param("section")=~/home/){ + my $v=(load_module("home/admin"))[0]; + my ($x,$w)= load_module("home/admin/home"); + $c->stash( merge_hash($x,$v) ); + $c->stash(apend => ["home/admin/home"]); + $c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod}); + } + elsif ( $c->param("section")=~/radio/ ){ + $c->stash( + merge_hash( (load_module("home/admin"))[0], + merge_hash( (load_module("home/admin/candySwitch"))[0], + (load_module("home/admin/radio"))[0], + ))); + $c->stash(apend => ["home/admin/radio","home/admin/candySwitch"]); + $c->stash(%{($c->dbv->radio)->[0]}); + $c->stash($Dojo::Conf::radio); + } + elsif ( $c->param("section")=~/event/ ){ + } + elsif ( $c->param("section")=~/mensajes/ ){ + $c->stash(merge_hash( + (load_module("home/admin"))[0], + (load_module("home/admin/mensajes"))[0] + )); + $c->stash(apend => ["home/admin/mensajes"]); + my $h = $c->dbv->rmsg; + $c->stash( h=>$h ); + + } + } 1; diff --git a/lib/Dojo/Model/Vuelo.pm b/lib/Dojo/Model/Vuelo.pm index c5b367c..fa9c8f6 100644 --- a/lib/Dojo/Model/Vuelo.pm +++ b/lib/Dojo/Model/Vuelo.pm @@ -17,11 +17,6 @@ sub mod{ return \@{_read($q)}; } -sub umod{ - my $c=shift; - my $q="update casa set contenido = ? where nombre = 'mod' ;"; - return _write($q,@_); -} sub pang{ my ($c,$q)=@_; return {map { basename($_,".md") => load_md("public/$_")}@{$q->{md}}}; @@ -58,6 +53,39 @@ sub radio{ return _read($q); } +sub umod{ + my $c=shift; + my $q="update casa set contenido = ? where nombre = ? ;"; + return _write($q,@_); +} + +sub urmod{ + my $c=shift; + my $q="update casa set contenido = ? where nombre = ? ;"; + return _write($q,@_); +} +sub rmsg{ + my @empty; + my $q= path("public/home/admin/mensajes/qEntries.q")->slurp; + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return $h; +} +sub rmsgid{ + my ($c,@bind)=@_; + my @empty; + my $q= path("public/home/admin/mensajes/json/qGetInfo.q")->slurp; + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return $h; +} + sub _read{ my ($q,@bind)=@_; my (@empty,$arr); diff --git a/public/home/admin/radio/candySwitch/cssMain.css b/public/home/admin/candySwitch/cssMain.css similarity index 100% rename from public/home/admin/radio/candySwitch/cssMain.css rename to public/home/admin/candySwitch/cssMain.css diff --git a/public/home/admin/radio/candySwitch/cssSwitch.css b/public/home/admin/candySwitch/cssSwitch.css similarity index 100% rename from public/home/admin/radio/candySwitch/cssSwitch.css rename to public/home/admin/candySwitch/cssSwitch.css diff --git a/public/home/admin/radio/candySwitch/jsCSwitch.js b/public/home/admin/candySwitch/jsCSwitch.js similarity index 94% rename from public/home/admin/radio/candySwitch/jsCSwitch.js rename to public/home/admin/candySwitch/jsCSwitch.js index 85aabcc..5e8b95f 100755 --- a/public/home/admin/radio/candySwitch/jsCSwitch.js +++ b/public/home/admin/candySwitch/jsCSwitch.js @@ -1,5 +1,5 @@ d3.select("#clink").on("click",function(){ - var newWindow = window.open(' #nav candy','_blank'); + var newWindow = window.open('candy','_blank'); }); var ciface =" #exec candy_loader/candyInterface.pl&v="; diff --git a/public/home/admin/event/SCHEDULE COMPLETE - , b/public/home/admin/event/SCHEDULE COMPLETE - , deleted file mode 100644 index e69de29..0000000 diff --git "a/public/home/admin/event/Student schedule for today, completed for the following students: \\n\\n\\n\\nHave a nice day..." "b/public/home/admin/event/Student schedule for today, completed for the following students: \\n\\n\\n\\nHave a nice day..." deleted file mode 100644 index e69de29..0000000 diff --git a/public/home/admin/event/[ b/public/home/admin/event/[ deleted file mode 100644 index e69de29..0000000 diff --git "a/public/home/admin/event/admin\\@," "b/public/home/admin/event/admin\\@," deleted file mode 100644 index e69de29..0000000 diff --git "a/public/home/admin/event/i.h4d35\\@gmail.com," "b/public/home/admin/event/i.h4d35\\@gmail.com," deleted file mode 100644 index e69de29..0000000 diff --git a/public/home/admin/mensajes/jsMsg.js b/public/home/admin/mensajes/jsMsg.js index dc8dbed..c07732b 100755 --- a/public/home/admin/mensajes/jsMsg.js +++ b/public/home/admin/mensajes/jsMsg.js @@ -1,7 +1,7 @@ d3.select("select#sentry").on("change",function(){ var msg_id=d3.select("select#sentry").node().value; - d3.json(" #data admin/mensajes/json/qGetInfo.q&imid="+msg_id ,function(d){ + d3.json("/admin/json/mensajes/"+msg_id ,function(d){ if(d[0] !=undefined) {if(d[0] != 0){ d3.select("p#fecha").text(d[0].imdate); d3.select("p#correo").text(d[0].imail); diff --git a/public/home/admin/mensajes/json/qGetInfo.q b/public/home/admin/mensajes/json/qGetInfo.q index 656b8b9..649022b 100755 --- a/public/home/admin/mensajes/json/qGetInfo.q +++ b/public/home/admin/mensajes/json/qGetInfo.q @@ -1,11 +1,3 @@ - - /* c#host localhost*/ - /* c#database #dbmsg */ - /* c#user #dbmsg_user */ - /* c#password #dbmsg_pass */ - - - select e.id as imid, concat(day(e.fecha)," de ",m.nombre," ", year(e.fecha)) as imdate, @@ -15,5 +7,5 @@ select from entrada as e inner join vuelo.mes as m on m.id=month(e.fecha) -where e.id= " #imid "; +where e.id= ? ; #imid diff --git a/public/home/admin/mensajes/qEntries.q b/public/home/admin/mensajes/qEntries.q index ae215ea..e534e58 100755 --- a/public/home/admin/mensajes/qEntries.q +++ b/public/home/admin/mensajes/qEntries.q @@ -1,13 +1,7 @@ - - /* c#host localhost*/ - /* c#database #dbmsg */ - /* c#user #dbmsg_user */ - /* c#password #dbmsg_pass */ - -select - "mlist" as tag, +select id as mid, concat(nombre," ",date(fecha)) as "entry" from entrada -order by fecha; +order by fecha desc +limit 100; diff --git a/public/home/admin/radio/jsLoadInfo.js b/public/home/admin/radio/jsLoadInfo.js index 954afef..b0c1db5 100755 --- a/public/home/admin/radio/jsLoadInfo.js +++ b/public/home/admin/radio/jsLoadInfo.js @@ -1,7 +1,7 @@ dataUpdate(); - + // let radio_server = xxx.info; function dataUpdate(){ - d3.json(" #radio_server /status-json.xsl",function(d){ + d3.json(radio_server+"/status-json.xsl",function(d){ if (d.icestats.source != undefined){ d3.select("#now").text(d.icestats.source.title); d3.select("#onAir").style("background-color","green"); diff --git a/public/home/admin/radio/update/qUpdate.q b/public/home/admin/radio/update/qUpdate.q index f34dfbf..6bfd4dc 100755 --- a/public/home/admin/radio/update/qUpdate.q +++ b/public/home/admin/radio/update/qUpdate.q @@ -1,10 +1,3 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_w */ - /* c#password #dbdata_wp */ - /* c#write write*/ - - - update casa set contenido= q#link where nombre = q#update ; +# update casa set contenido= q#link where nombre = q#update ; + update casa set contenido= ? where nombre = ? ; diff --git a/public/home/admin/radio/candySwitch/htmlCSwitch.html b/templates/home/admin/candySwitch.html.ep similarity index 100% rename from public/home/admin/radio/candySwitch/htmlCSwitch.html rename to templates/home/admin/candySwitch.html.ep diff --git a/public/home/admin/mensajes/htmlMensajes.html b/templates/home/admin/mensajes.html.ep similarity index 70% rename from public/home/admin/mensajes/htmlMensajes.html rename to templates/home/admin/mensajes.html.ep index a39359f..f767bb1 100755 --- a/public/home/admin/mensajes/htmlMensajes.html +++ b/templates/home/admin/mensajes.html.ep @@ -1,13 +1,9 @@
diff --git a/public/home/admin/radio/htmlAdmin.html b/templates/home/admin/radio.html.ep similarity index 76% rename from public/home/admin/radio/htmlAdmin.html rename to templates/home/admin/radio.html.ep index c39ba9b..9e4995c 100755 --- a/public/home/admin/radio/htmlAdmin.html +++ b/templates/home/admin/radio.html.ep @@ -13,12 +13,15 @@
-
+ - +
+ diff --git a/templates/home/radio.html.ep b/templates/home/radio.html.ep index e5ad82f..c749d2a 100755 --- a/templates/home/radio.html.ep +++ b/templates/home/radio.html.ep @@ -37,7 +37,7 @@