Skip to content

Commit

Permalink
Added tags tables
Browse files Browse the repository at this point in the history
Avoid long files name breaking the table
  • Loading branch information
sergix44 committed Mar 13, 2020
1 parent d8a5e28 commit 6d57345
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public function delete(Request $request, Response $response, int $id): Response
return redirect($response, route('user.index'));
}


/**
* @param Request $request
* @param Response $response
Expand Down
4 changes: 2 additions & 2 deletions bin/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ if (isset($argv[1]) && $argv[1] === '--install') {
$db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('[email protected]', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), humanRandomString(5)]);
}

if (file_exists(__DIR__.'/../install')) {
removeDirectory(__DIR__.'/../install');
if (file_exists(__DIR__.'/../install') && (!isset($config['debug']) || !$config['debug'])) {
//removeDirectory(__DIR__.'/../install');
}

echo 'If you are upgrading from a previous version, please run a "php bin\clean".'.PHP_EOL;
Expand Down
4 changes: 3 additions & 1 deletion install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@
cleanDirectory(__DIR__.'/../resources/cache');
cleanDirectory(__DIR__.'/../resources/sessions');

removeDirectory(__DIR__.'/../install');
if (!isset($config['debug']) || !$config['debug']) {
removeDirectory(__DIR__.'/../install');
}

// Installed successfully, destroy the installer session
$session->destroy();
Expand Down
18 changes: 18 additions & 0 deletions resources/schemas/mysql/mysql.6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS `tags` (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(32) NOT NULL,
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX (`name`)
);

CREATE TABLE IF NOT EXISTS `uploads_tags` (
`upload_id` INTEGER,
`tag_id` INTEGER,
PRIMARY KEY (`upload_id`, `tag_id`),
FOREIGN KEY (`upload_id`) REFERENCES `uploads` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE,
FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE
);
20 changes: 20 additions & 0 deletions resources/schemas/sqlite/sqlite.6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE IF NOT EXISTS `tags` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` VARCHAR(32) NOT NULL,
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE UNIQUE INDEX IF NOT EXISTS `tag_name`
ON `tags` (`name`);

CREATE TABLE IF NOT EXISTS `uploads_tags` (
`upload_id` INTEGER,
`tag_id` INTEGER,
PRIMARY KEY (`upload_id`, `tag_id`),
FOREIGN KEY (`upload_id`) REFERENCES `uploads` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE,
FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`)
ON UPDATE CASCADE
ON DELETE CASCADE
);
2 changes: 1 addition & 1 deletion resources/templates/dashboard/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<i class="far {{ mime2font(media.mimetype) }} fa-2x"></i>
{% endif %}
</td>
<td>{{ media.filename }}</td>
<td><span class="text-maxlen">{{ media.filename }}</span></td>
<td>{{ media.size }}</td>
<td id="published_{{ media.id }}">
{% if media.published %}
Expand Down
13 changes: 13 additions & 0 deletions src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,16 @@ body {
.grecaptcha-badge {
top: 5px !important;
}

.text-maxlen {
display: inline-block;
max-width: 330px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.text-maxlen:hover {
overflow: auto;
text-overflow: unset;
}

0 comments on commit 6d57345

Please sign in to comment.