Render image list on client
This commit is contained in:
parent
ec32870b98
commit
e58b7bb839
3 changed files with 5 additions and 22 deletions
23
fotostore.pl
23
fotostore.pl
|
@ -54,7 +54,7 @@ plugin 'authentication', {
|
||||||
my $digest = $sha->add($password);
|
my $digest = $sha->add($password);
|
||||||
|
|
||||||
my $user_id = $db->check_user( $username, $digest->hexdigest() );
|
my $user_id = $db->check_user( $username, $digest->hexdigest() );
|
||||||
$self->app->log->debug("user id: [$user_id]");
|
# $self->app->log->debug("user id: [$user_id]");
|
||||||
|
|
||||||
return $user_id;
|
return $user_id;
|
||||||
},
|
},
|
||||||
|
@ -126,22 +126,6 @@ get '/' => sub {
|
||||||
|
|
||||||
my $current_user = $self->current_user;
|
my $current_user = $self->current_user;
|
||||||
|
|
||||||
my $files_list = $db->get_files($current_user->{'user_id'}, 20);
|
|
||||||
|
|
||||||
my $thumbs_dir = File::Spec->catfile( $IMAGE_DIR, $current_user->{'user_id'}, $thumbs_size );
|
|
||||||
|
|
||||||
my @images = map { $_->{'file_name'} } @$files_list;
|
|
||||||
|
|
||||||
# Render
|
|
||||||
return $self->render(
|
|
||||||
images => \@images,
|
|
||||||
image_base => $IMAGE_BASE,
|
|
||||||
orig => $ORIG_DIR,
|
|
||||||
thumbs_size => $thumbs_size,
|
|
||||||
scales => \@scale_width,
|
|
||||||
user_id => $current_user->{'user_id'},
|
|
||||||
);
|
|
||||||
|
|
||||||
} => 'index';
|
} => 'index';
|
||||||
|
|
||||||
get '/get_images' => ( authenticated => 1 ) => sub {
|
get '/get_images' => ( authenticated => 1 ) => sub {
|
||||||
|
@ -163,10 +147,13 @@ get '/get_images' => ( authenticated => 1 ) => sub {
|
||||||
$img_hash->{'original_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $ORIG_DIR, $file );
|
$img_hash->{'original_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $ORIG_DIR, $file );
|
||||||
$img_hash->{'thumbnail_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $thumbs_size, $file );
|
$img_hash->{'thumbnail_url'} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $thumbs_size, $file );
|
||||||
|
|
||||||
|
my @scaled = ();
|
||||||
for my $scale (@scale_width) {
|
for my $scale (@scale_width) {
|
||||||
$img_hash->{$scale} = File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $scale, $file );
|
push(@scaled, {'size' => $scale, 'url' => File::Spec->catfile( '/', $IMAGE_BASE, $current_user->{'user_id'}, $scale, $file )}) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$img_hash->{'scales'} = \@scaled;
|
||||||
|
|
||||||
push(@$images, $img_hash);
|
push(@$images, $img_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ sub new {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_user ($self, $nickname, $password) {
|
sub check_user ($self, $nickname, $password) {
|
||||||
print STDERR "[$nickname][$password]";
|
|
||||||
my ($user_id) = $self->{'dbh'}->selectrow_array(q~select user_id from users where nickname=? and password=?~, undef, ($nickname, $password));
|
my ($user_id) = $self->{'dbh'}->selectrow_array(q~select user_id from users where nickname=? and password=?~, undef, ($nickname, $password));
|
||||||
return $user_id;
|
return $user_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
<script src="https://vuejs.org/js/vue.min.js"></script>
|
<script src="https://vuejs.org/js/vue.min.js"></script>
|
||||||
|
|
||||||
<!-- CSS adjustments for browsers with JavaScript disabled -->
|
|
||||||
<noscript><link rel="stylesheet" href="/file_uploader/css/jquery.fileupload-noscript.css"></noscript>
|
|
||||||
<noscript><link rel="stylesheet" href="/file_uploader/css/jquery.fileupload-ui-noscript.css"></noscript>
|
|
||||||
<style>
|
<style>
|
||||||
.bar {
|
.bar {
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
|
Loading…
Reference in a new issue