bye bye github

This commit is contained in:
mynah
2018-07-13 19:06:08 -05:00
commit ee47c30aca
241 changed files with 26451 additions and 0 deletions

62
lib/Dojo/Support.pm Normal file
View File

@@ -0,0 +1,62 @@
package Dojo::Support;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw/ dmph merge_hash load_module /;
use Mojo::Base 'Mojolicious';
use File::Basename;
use Mojo::File 'path';
use Path::Class;
use Encode qw{ decode_utf8 };
use Hash::Merge;
use Dojo::Conf;
sub get_names{
my $dir = shift;
my @file_name;
opendir(DIR, $dir) or die "error opening dir: $dir \n$!";
while (my $file = readdir(DIR)) {
next unless ( $file =~m/^[\w\d]/);
next unless (-f "$dir/$file");
push(@file_name,$file);
}
closedir(DIR);
return sort @file_name;
};
sub merge_hash{
my ($v,$w)=@_;
my $merger = Hash::Merge->new('LEFT_PRECEDENT');
return $merger->merge( $v, $w );
}
sub load_module{
my $c=shift;
my $dir=shift //"$c->{stash}{controller}/$c->{stash}{action}";
my $lpath= Dojo::Conf::MOD."/$dir";
my $h; $h->{js}=[]; $h->{css}=[]; #no me gusta!!!
$h->{layout} = "default";
my $q;
my @s= get_names($lpath);
foreach (@s) {
push(@{$h->{$1}}, "/$dir/$_") if /.*\.(css|js)$/;
push(@{$q->{$1}}, "/$dir/$_") if /.*\.(q|json|txt|md)$/;
}
return ($h,$q);
};
sub dmph{
my $x = shift;
my $y=" ";
foreach (sort(keys %$x)) {
$y= "$y $_ = $x->{$_} \n";
}
return $y;
}
1;