Created
June 20, 2022 01:43
-
-
Save s1037989/a3caae353c5bfb231179652f3af31202 to your computer and use it in GitHub Desktop.
organize files dropped into a single dropbox folder based on their validated tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
dropbox => { | |
'cpa file' => '^sdk/SDKv\d+\.\d+\+\d{8}\.\d+\.tar(\.gz)?$', | |
'cpa file' => '^tk/TK-\d+\.\d+\+\d{8}\.\d+\.tar(\.gz)?$', | |
'cpa release file' => '^rc_bundles/XX\d_\d{4}\.\d{2}(\.\d+)?_rc\d+/.*?\.tar(\.gz)?$', | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite -signatures; | |
use Mojo::File qw(path); | |
plugin 'Config'; | |
helper dropbox => sub ($c) { | |
foreach my $tags (keys %{$c->app->config->{dropbox}}) { | |
my @tags = split /\s+/, $tags; | |
my $re = $c->app->config->{dropbox}->{$tags}; | |
my $path = path(grep { defined } map { $c->param($_) } @tags); | |
return $c->render(text => $c->app->home->child($tags[0], $path)."\n") if $path =~ qr($re); | |
} | |
}; | |
get '/*file' => sub ($c) { $c->dropbox or $c->reply->not_found }; | |
app->start; | |
__DATA__ | |
@@ not_found.html.ep | |
404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment