Skip to content

Instantly share code, notes, and snippets.

@s1037989
Created June 20, 2022 01:43
Show Gist options
  • Save s1037989/a3caae353c5bfb231179652f3af31202 to your computer and use it in GitHub Desktop.
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
{
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)?$',
}
}
#!/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