concat inferno
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package Dojo::Model::Vuelo;
|
||||
use Mojo::File 'path';
|
||||
use Mojo::JSON qw(decode_json encode_json);
|
||||
use Dojo::Support qw{ dmph merge_hash load_module get_names};
|
||||
use Dojo::Support qw{ log dmph merge_hash load_module get_names};
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
|
||||
use File::Basename;
|
||||
use Text::Markdown qw{ markdown };
|
||||
@@ -12,128 +14,150 @@ use Dojo::Conf;
|
||||
sub new { bless {}, shift };
|
||||
|
||||
|
||||
sub mod{
|
||||
my $q="select nombre,contenido from casa;";
|
||||
return \@{_read($q)};
|
||||
}
|
||||
# Read vdg user ===============================================================
|
||||
sub mod{
|
||||
my $q="select nombre,contenido from casa;";
|
||||
my %h=map{ $_->{nombre} => $_->{contenido}}@{_read($q)};
|
||||
return %h;
|
||||
}
|
||||
|
||||
sub pang{
|
||||
my ($c,$q)=@_;
|
||||
return {map { basename($_,".md") => load_md("public/$_")}@{$q->{md}}};
|
||||
}
|
||||
sub cal {
|
||||
my $block=_read (path("public/home/cal/q1Block.q")->slurp);
|
||||
my $data=_read (path("public/home/cal/q3Event.q")->slurp);
|
||||
return ($data,$block);
|
||||
}
|
||||
sub md_to_hash{
|
||||
my ($self,@filelist)=@_;
|
||||
return {map { basename($_,".md") => load_md("public/$_")}@filelist};
|
||||
}
|
||||
|
||||
sub event{
|
||||
my ($self,$id)=@_;
|
||||
return _read (path("public/home/event/qEvent.q")->slurp,$id);
|
||||
}
|
||||
sub calendar_monthblock {
|
||||
return _read (path("public/home/cal/q1Block.q")->slurp);
|
||||
}
|
||||
sub calendar_events {
|
||||
return _read (path("public/home/cal/q3Event.q")->slurp);
|
||||
}
|
||||
|
||||
sub store{
|
||||
return _read (path("public/home/store/qStore.q")->slurp);
|
||||
}
|
||||
sub event{
|
||||
my ($self,$id)=@_;
|
||||
return shift @{ _read (path("public/home/event/qEvent.q")->slurp,$id)};
|
||||
}
|
||||
sub store{
|
||||
return _read (path("public/home/store/qStore.q")->slurp);
|
||||
}
|
||||
sub tv_videos{
|
||||
return _read (path("public/home/tv/qSeries.q")->slurp); #group,name
|
||||
}
|
||||
sub tv_series{
|
||||
return _read (path("public/home/tv/qTable.q")->slurp); #name,order,group
|
||||
}
|
||||
sub podcast_txt{
|
||||
return path("public/home/podcast/text.txt")->slurp;
|
||||
}
|
||||
sub podcast_infoHash{
|
||||
return decode_json path("public/home/podcast/jsonPod.json")->slurp;
|
||||
}
|
||||
sub conf_radio{
|
||||
return $Dojo::Conf::radio;
|
||||
}
|
||||
#==============================================================================
|
||||
|
||||
sub tv{
|
||||
my $series = _read (path("public/home/tv/qSeries.q")->slurp); #group,name
|
||||
my $table = _read (path("public/home/tv/qTable.q")->slurp); #name,order,group
|
||||
return ($series,$table);
|
||||
}
|
||||
# Read vdg admin ==============================================================
|
||||
sub msg_heads{
|
||||
my ($self,@bind)=@_;
|
||||
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 podcast{
|
||||
my $txt = path("public/home/podcast/text.txt")->slurp;
|
||||
my $hash = decode_json path("public/home/podcast/jsonPod.json")->slurp;
|
||||
return ($txt,$hash);
|
||||
}
|
||||
sub msg{
|
||||
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 shift @$h;
|
||||
}
|
||||
sub courses{ return _read("select nombre as name, id from curso;")}
|
||||
sub course { return shift @{_read(path("public/home/admin/event/json/qCourse.q")->slurp,pop)}}
|
||||
sub places { return _read("select nombre as name, id from lugar;")}
|
||||
sub place { return shift @{_read(path("public/home/admin/event/json/qPlace.q")->slurp,pop)}}
|
||||
sub months { return _read("select nombre as name, id from mes;")};
|
||||
sub events { return _read(path("public/home/admin/event/qEprev.q")->slurp)}
|
||||
sub eventa { return shift @{_read(path("public/home/admin/event/json/qEvent.q")->slurp,pop)}}
|
||||
sub eimgList{ return [get_names("public/home/cal/img/")] }
|
||||
#==============================================================================
|
||||
# Write vdg admin ==============================================================
|
||||
sub umod{
|
||||
my $c=shift;
|
||||
my $q="update casa set contenido = ? where nombre = ? ;";
|
||||
return _write($q,@_);
|
||||
}
|
||||
|
||||
sub radio{
|
||||
my $q="select contenido as rmod from casa where nombre='rmod';";
|
||||
return _read($q);
|
||||
}
|
||||
sub event_del { return _write("delete from evento where id = ?;",pop);}
|
||||
sub course_del{ return _write("delete from curso where id = ?;",pop); }
|
||||
sub place_del { return _write("delete from lugar where id = ?;",pop); }
|
||||
|
||||
sub event_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qPup.q")->slurp,@bind);
|
||||
}
|
||||
sub event_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qPup.q")->slurp,@bind);
|
||||
}
|
||||
|
||||
|
||||
sub umod{
|
||||
my $c=shift;
|
||||
my $q="update casa set contenido = ? where nombre = ? ;";
|
||||
return _write($q,@_);
|
||||
}
|
||||
# admin =================================0
|
||||
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 admevent{
|
||||
my $h = {
|
||||
ecourse=>_read("select nombre as name, id from curso;"),
|
||||
eplace =>_read("select nombre as name, id from lugar;"),
|
||||
emini =>_read("select nombre as name, id from mes;"),
|
||||
ilist => [get_names("public/home/cal/img/")],
|
||||
eprev =>_read(path("public/home/admin/event/qEprev.q")->slurp),
|
||||
};
|
||||
return $h
|
||||
}
|
||||
# json ======
|
||||
sub ecourse{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qEvent.q")->slurp,@id);
|
||||
}
|
||||
sub qcourse{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qCourse.q")->slurp,@id);
|
||||
}
|
||||
sub qplace{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qPlace.q")->slurp,@id);
|
||||
}
|
||||
#============
|
||||
#Change =====
|
||||
|
||||
|
||||
#============
|
||||
#==============================================================================
|
||||
|
||||
#ayudas =====================================
|
||||
sub tst{
|
||||
|
||||
my $c=shift;
|
||||
my $d=$c->param('n');
|
||||
log("------log-------");
|
||||
log("$d");
|
||||
log("------log-------");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub _read{
|
||||
my ($q,@bind)=@_;
|
||||
my (@empty,$arr);
|
||||
my @empty;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UR,Dojo::Conf::VUELODB_URP);
|
||||
return \@empty unless($dbh);
|
||||
#$dbh->do(qq{SET NAMES 'utf8'});
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub _write{
|
||||
my $q=shift;
|
||||
my ($q,@bind)=@_;
|
||||
my (@empty);
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UW,Dojo::Conf::VUELODB_UWP);
|
||||
return 0 unless($dbh);
|
||||
my $h=$dbh->do($q,{ Slice => {} },@_);
|
||||
my $h=$dbh->do($q,{ Slice => {} },@bind);
|
||||
$dbh->disconnect();
|
||||
log("db write: $h");
|
||||
return $h;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user