Original fn field #5
8 changed files with 46 additions and 17 deletions
|
@ -144,6 +144,7 @@ get '/get_images' => ( authenticated => 1 ) => sub {
|
|||
for my $img_item (@$files_list) {
|
||||
my $file = $img_item->{'file_name'};
|
||||
my $img_hash = {};
|
||||
$img_hash->{'filename'} = $img_item->{'original_filename'};
|
||||
$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 );
|
||||
|
||||
|
@ -233,7 +234,7 @@ post '/upload' => ( authenticated => 1 ) => sub {
|
|||
or die $scaled->errstr;
|
||||
}
|
||||
|
||||
if ( !$db->add_file( $user->{'user_id'}, $filename ) ) {
|
||||
if ( !$db->add_file( $user->{'user_id'}, $filename, $image->filename) ) {
|
||||
|
||||
#TODO: Send error msg
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ sub add_user($self, $username, $password, $fullname) {
|
|||
}
|
||||
|
||||
|
||||
sub add_file($self, $user_id, $filename) {
|
||||
my $rows = $self->{'dbh'}->do(q~insert into images (owner_id, file_name) values (?, ?)~, undef, ($user_id, $filename));
|
||||
sub add_file($self, $user_id, $filename, $original_filename) {
|
||||
my $rows = $self->{'dbh'}->do(q~insert into images (owner_id, file_name, original_filename) values (?, ?, ?)~, undef, ($user_id, $filename, $original_filename));
|
||||
if ($self->{'dbh'}->errstr) {
|
||||
die $self->{'dbh'}->errstr;
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@
|
|||
width: 32px;
|
||||
height: 32px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
|
@ -2,16 +2,6 @@
|
|||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE images (
|
||||
file_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
owner_id INTEGER NOT NULL,
|
||||
file_name TEXT NOT NULL,
|
||||
created_time DATETIME NOT NULL
|
||||
DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (
|
||||
owner_id
|
||||
)
|
||||
REFERENCES users (user_id) ON DELETE CASCADE
|
||||
);
|
||||
ALTER TABLE images ADD COLUMN original_filename TEXT NOT NULL DEFAULT "Unknown";
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1,7 +1,40 @@
|
|||
-- Revert fotostore:images from sqlite
|
||||
-- Deploy fotostore:images to sqlite
|
||||
|
||||
BEGIN;
|
||||
|
||||
PRAGMA foreign_keys = 0;
|
||||
|
||||
CREATE TABLE images_rever_temp_table AS SELECT *
|
||||
FROM images;
|
||||
|
||||
DROP TABLE images;
|
||||
|
||||
CREATE TABLE images (
|
||||
file_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
owner_id INTEGER NOT NULL,
|
||||
file_name TEXT NOT NULL,
|
||||
created_time DATETIME NOT NULL
|
||||
DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (
|
||||
owner_id
|
||||
)
|
||||
REFERENCES users (user_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
INSERT INTO images (
|
||||
file_id,
|
||||
owner_id,
|
||||
file_name,
|
||||
created_time
|
||||
)
|
||||
SELECT file_id,
|
||||
owner_id,
|
||||
file_name,
|
||||
created_time
|
||||
FROM images_rever_temp_table;
|
||||
|
||||
DROP TABLE images_rever_temp_table;
|
||||
|
||||
PRAGMA foreign_keys = 1;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -8,3 +8,6 @@ albums 2017-07-22T08:50:11Z Denis Fedoseev <denis.fedoseev@gmail.com> # Albums d
|
|||
user_images [users images] 2017-07-22T09:16:20Z Denis Fedoseev <denis.fedoseev@gmail.com> # +user_images table
|
||||
album_images [images albums] 2017-07-22T09:21:13Z Denis Fedoseev <denis.fedoseev@gmail.com> # +images to album mapping
|
||||
user_albums [users albums] 2017-07-22T09:47:48Z Denis Fedoseev <denis.fedoseev@gmail.com> # Albums to users mapping
|
||||
@v1.0.0 2017-08-02T03:46:51Z Denis Fedoseev <denis.fedoseev@gmail.com> # Tag v1.0.0.
|
||||
images [images@v1.0.0] 2017-08-02T03:55:08Z Denis Fedoseev <denis.fedoseev@gmail.com> # Adds images.original_filename.
|
||||
@v1.1.0 2017-08-02T04:46:42Z Denis Fedoseev <denis.fedoseev@gmail.com> # Tag v1.1.0.
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
BEGIN;
|
||||
|
||||
select file_id, owner_id, file_name, created_time from images where 0;
|
||||
select file_id, owner_id, file_name, original_filename, created_time from images where 0;
|
||||
|
||||
ROLLBACK;
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
<div id="images_list">
|
||||
<div class="foto-block row" v-for="image in imagesList">
|
||||
<div class="image col-md-3">
|
||||
<img v-bind:src="image.thumbnail_url">
|
||||
<img v-bind:src="image.thumbnail_url">
|
||||
<div class="image_title">{{ image.filename }}</div>
|
||||
</div>
|
||||
<div class="foto-notes col-md-3">
|
||||
<ul>
|
||||
|
|
Loading…
Reference in a new issue