Files
dojo/lib/Dojo/Controller/Home.pm

245 lines
6.8 KiB
Perl
Raw Normal View History

2018-07-13 19:06:08 -05:00
package Dojo::Controller::Home;
use Mojo::Base 'Mojolicious::Controller';
2018-07-18 04:28:26 -05:00
use Mojo::Template;
2018-07-19 03:45:46 -05:00
use Dojo::Support qw{ log dmph merge_hash load_module get_names};
2018-07-13 19:06:08 -05:00
use Dojo::Conf;
sub tst{
my $c=shift;
2018-07-18 04:28:26 -05:00
# $c->stash( merge_hash(
# (load_module("home/tst"))[0],
# (load_module("home/contact"))[0]
#));
# $c->stash(apend => ["home/contact"]);
2018-07-27 16:45:29 -05:00
#$c->stash( (load_module("home/tst"))[0] );
#$c->stash(layout=> "defaultContact");
#my $x = [get_names("public/home/cal/img/")];
#log("@$x");
#$c->stash( ilist => $x);
#$c->dbv->tst;
$c->render(text=> $c->config->{radio}{'channel'});
2018-07-19 03:45:46 -05:00
2018-07-13 19:06:08 -05:00
}
2018-07-20 05:16:47 -05:00
# User ========================================================================
2018-07-27 16:45:29 -05:00
sub home_ {
my $c = shift;
$c->redirect_to("/home") ;
}
2018-07-20 05:16:47 -05:00
sub home {
my $c = shift;
$c->stash((load_module("home/home"))[0]);
$c->stash( $c->dbv->mod) ;
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub pang {
my $c = shift;
my ($v,$w)=load_module("home/pang");
$c->stash($v);
$c->stash( $c->dbv->md_to_hash(@{$w->{'md'}}) );
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub cal {
my $c = shift;
$c->stash((load_module("home/cal"))[0]);
my $data=$c->dbv->calendar_events;
my $block=$c->dbv->calendar_monthblock;
my %hdata;
map{ push @{ $hdata{$_->{bid}} },$_; }(@$data);
$c->stash( r=>\%hdata, b=>$block);
}
2018-07-18 04:28:26 -05:00
2018-07-20 05:16:47 -05:00
sub event{
my $c = shift;
$c->stash((load_module("home/event"))[0]);
$c->stash(layout=> "defaultContact");
$c->stash($c->dbv->event($c->param("id")));
2018-07-13 19:06:08 -05:00
}
2018-07-20 05:16:47 -05:00
sub contact{
my $c = shift;
if ($c->param("mup")){
$c->flash(mname => $c->param("mname"));
$c->redirect_to('contact2');
}else{
$c->stash((load_module("home/contact"))[0]);
}
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub contact2{
my $c = shift;
$c->redirect_to("home") unless $c->flash('mname');
$c->stash( mname=>$c->flash('mname'));
$c->stash((load_module("home/contact2"))[0]);
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub store{
my $c = shift;
$c->stash((load_module("home/store"))[0]);
$c->stash( r=>$c->dbv->store);
$c->stash(layout=> "defaultContact");
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub tv{
my $c = shift;
$c->stash( merge_hash(
(load_module("home/tv"))[0],
(load_module("home/tv/trans"))[0]
));
$c->stash( videos=>$c->dbv->tv_videos, table=>$c->dbv->tv_series);
$c->stash(layout=> "defaultContact");
}
2018-07-13 19:06:08 -05:00
2018-07-20 05:16:47 -05:00
sub podcast{
my $c = shift;
$c->stash((load_module("home/podcast"))[0]);
$c->stash(layout=> "defaultContact");
$c->stash( t=>$c->dbv->podcast_txt, pod=>$c->dbv->podcast_infoHash);
}
2018-07-13 19:06:08 -05:00
2018-07-27 16:45:29 -05:00
sub bcast{
my $c = shift;
$c->stash((load_module("home/bcast"))[0]);
$c->stash( $c->dbv->conf_bcast);
}
2018-07-20 05:16:47 -05:00
sub radio{
my $c=shift;
$c->stash((load_module("home/radio"))[0]);
$c->stash(layout=> "defaultContact");
$c->stash($c->dbv->mod);
$c->stash($c->dbv->conf_radio);
$c->stash(nick=>$c->session("nick"));
2018-07-19 03:45:46 -05:00
}
2018-07-25 20:48:58 +00:00
sub candy{
my $c=shift;
$c->stash( css=>["/ext/candy/libs.min.css","/home/candy/default.css"]);
$c->stash( js=>["/home/candy/loader.js","/ext/candy/libs.min.js","/ext/candy/candy.min.js"]);
$c->stash(layout=> "clean");
$c->stash($c->dbv->conf_chat);
$c->stash(nick=>$c->session("nick"));
}
2018-07-20 05:16:47 -05:00
#==============================================================================
2018-07-19 03:45:46 -05:00
2018-07-20 05:16:47 -05:00
# Admin =======================================================================
2018-07-25 19:07:29 -05:00
sub admin{
my $c= shift;
$c->redirect_to('/admin/home');
}
2018-07-20 05:16:47 -05:00
sub admin_home{
my $c=shift;
$c->dbv->umod($c->param('link'),$c->param('update'))
if (($c->param("hup") // " " )=~/Cambiar/);
$c->stash((load_module("home/admin/home"))[0]);
$c->stash(template=>"home/admin/home");
$c->stash(layout=>"admin");
$c->stash( $c->dbv->mod);
2018-07-19 03:45:46 -05:00
}
2018-07-20 05:16:47 -05:00
sub admin_radio{
my $c=shift;
$c->dbv->umod($c->param('link'),'rmod')
if (($c->param("hup") // " " )=~/Cambiar/);
$c->stash($c->dbv->mod);
$c->stash($c->dbv->conf_radio);
2018-07-19 03:45:46 -05:00
$c->stash( merge_hash(
(load_module("home/admin/radio"))[0],
(load_module("home/admin/candySwitch"))[0],
));
2018-07-20 05:16:47 -05:00
$c->stash(apend => ["home/admin/candySwitch"]);
$c->stash(template=>"home/admin/radio");
$c->stash(layout=>"admin");
2018-07-18 16:04:47 -05:00
}
2018-07-20 05:16:47 -05:00
sub admin_mensajes{
my $c=shift;
$c->stash((load_module("home/admin/mensajes"))[0]);
$c->stash( h=>$c->dbv->msg_heads);
$c->stash(template=>"home/admin/mensajes");
$c->stash(layout=>"admin");
}
sub admin_eventos{
my $c=shift;
if ( (my $t=$c->param('type') // "") =~/[ecp]/){
my $id=$c->param('id');
my $req=$c->param('req');
if ( $req eq "Eliminar"){
$c->dbv->event_del($id) if ($t eq 'e');
$c->dbv->course_del($id) if ($t eq 'c');
$c->dbv->place_del($id) if ($t eq 'p');
}
elsif( $req eq "Aceptar"){
if($t eq 'e'){
my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/;
$c->dbv->event_up(@list) if ($id ==0);
$c->dbv->event_ch(@list) if ($id >0);
}
if($t eq 'c'){
my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/;
$c->dbv->course_up(@list) if ($id ==0);
$c->dbv->course_ch(@list) if ($id >0);
}
if($t eq 'p'){
my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/;
$c->dbv->place_up(@list) if ($id ==0);
$c->dbv->place_ch(@list) if ($id >0);
}
2018-07-18 16:04:47 -05:00
2018-07-20 05:16:47 -05:00
}
$c->redirect_to("/admin/eventos");
}
$c->stash(
courses=>$c->dbv->courses,
places=>$c->dbv->places,
months=>$c->dbv->months,
events=>$c->dbv->events,
img=>$c->dbv->eimgList,
);
$c->stash((load_module("home/admin/event"))[0]);
$c->stash(template=>"home/admin/event");
$c->stash(layout=>"admin");
2018-07-18 16:04:47 -05:00
}
2018-07-20 05:16:47 -05:00
sub admin_json{
my $c=shift;
my $id = $c->param('id');
my $req = $c->param('dreq');
my $json = "304";
$json = $c->dbv->msg($id) if $req=~/mensaje/;
$json = $c->dbv->course($id) if $req=~/course/;
$json = $c->dbv->place($id) if $req=~/place/;
$json = $c->dbv->eventa($id) if $req=~/event/;
$c->render(json=>$json);
2018-07-19 03:45:46 -05:00
}
2018-07-20 05:16:47 -05:00
# if (($c->param("id") // " " ) eq "0") {
# $c->dbv->eup if (($c->param("eup") // " " ) =~/Aceptar/);
# $c->dbv->cup if (($c->param("cup") // " " ) =~/Aceptar/);
# $c->dbv->pup if (($c->param("pup") // " " ) =~/Aceptar/);
# }
# else{
# if (($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cch; }
# elsif (($c->param("eup") // " " )=~/Aceptar/){ $c->dbv->ech; }
# elsif (($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pch; }
# elsif (($c->param("edel") // " " )=~/Eliminar/){ $c->dbv->edel; }
# elsif (($c->param("cdel") // " " )=~/Eliminar/){ $c->dbv->cdel; }
# elsif (($c->param("pdel") // " " )=~/Eliminar/){ $c->dbv->pdel; }
#}};
#}
#}
#==============================================================================
2018-07-18 04:28:26 -05:00
2018-07-13 19:06:08 -05:00
1;