-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from leepeuker/add-biography-to-person
Add biography to person
- Loading branch information
Showing
10 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
db/migrations/mysql/20230704133329_AddBiographyToPersonTable.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class AddBiographyToPersonTable extends AbstractMigration | ||
{ | ||
public function down() : void | ||
{ | ||
$this->execute( | ||
<<<SQL | ||
ALTER TABLE person DROP COLUMN biography; | ||
SQL, | ||
); | ||
} | ||
|
||
public function up() : void | ||
{ | ||
$this->execute( | ||
<<<SQL | ||
ALTER TABLE person ADD COLUMN biography TEXT NULL AFTER birth_date; | ||
SQL, | ||
); | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
db/migrations/sqlite/20230704133329_AddBiographyToPersonTable.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class AddBiographyToPersonTable extends AbstractMigration | ||
{ | ||
public function down() | ||
{ | ||
$this->execute( | ||
<<<SQL | ||
CREATE TABLE `tmp_person` ( | ||
`id` INTEGER, | ||
`name` TEXT NOT NULL, | ||
`gender` TEXT NOT NULL, | ||
`known_for_department` TEXT DEFAULT NULL, | ||
`poster_path` TEXT DEFAULT NULL, | ||
`birth_date` TEXT DEFAULT NULL, | ||
`place_of_birth` TEXT DEFAULT NULL, | ||
`death_date` TEXT DEFAULT NULL, | ||
`tmdb_id` INTEGER NOT NULL, | ||
`tmdb_poster_path` TEXT DEFAULT NULL, | ||
`created_at` TEXT NOT NULL, | ||
`updated_at` TEXT DEFAULT NULL, | ||
`updated_at_tmdb` TEXT DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE (`tmdb_id`) | ||
) | ||
SQL, | ||
); | ||
$this->execute( | ||
'INSERT INTO `tmp_person` ( | ||
`id`, | ||
`name`, | ||
`gender`, | ||
`known_for_department`, | ||
`poster_path`, | ||
`birth_date`, | ||
`place_of_birth`, | ||
`death_date`, | ||
`tmdb_id`, | ||
`tmdb_poster_path`, | ||
`created_at`, | ||
`updated_at`, | ||
`updated_at_tmdb` | ||
) SELECT | ||
`id`, | ||
`name`, | ||
`gender`, | ||
`known_for_department`, | ||
`poster_path`, | ||
`birth_date`, | ||
`place_of_birth`, | ||
`death_date`, | ||
`tmdb_id`, | ||
`tmdb_poster_path`, | ||
`created_at`, | ||
`updated_at`, | ||
`updated_at_tmdb` | ||
FROM `person`', | ||
); | ||
$this->execute('DROP TABLE `person`'); | ||
$this->execute('ALTER TABLE `tmp_person` RENAME TO `person`'); | ||
} | ||
|
||
public function up() | ||
{ | ||
$this->execute( | ||
<<<SQL | ||
CREATE TABLE `tmp_person` ( | ||
`id` INTEGER, | ||
`name` TEXT NOT NULL, | ||
`gender` TEXT NOT NULL, | ||
`known_for_department` TEXT DEFAULT NULL, | ||
`poster_path` TEXT DEFAULT NULL, | ||
`biography` TEXT DEFAULT NULL, | ||
`birth_date` TEXT DEFAULT NULL, | ||
`place_of_birth` TEXT DEFAULT NULL, | ||
`death_date` TEXT DEFAULT NULL, | ||
`tmdb_id` INTEGER NOT NULL, | ||
`tmdb_poster_path` TEXT DEFAULT NULL, | ||
`created_at` TEXT NOT NULL, | ||
`updated_at` TEXT DEFAULT NULL, | ||
`updated_at_tmdb` TEXT DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE (`tmdb_id`) | ||
) | ||
SQL, | ||
); | ||
$this->execute( | ||
'INSERT INTO `tmp_person` ( | ||
`id`, | ||
`name`, | ||
`gender`, | ||
`known_for_department`, | ||
`poster_path`, | ||
`birth_date`, | ||
`place_of_birth`, | ||
`death_date`, | ||
`tmdb_id`, | ||
`tmdb_poster_path`, | ||
`created_at`, | ||
`updated_at`, | ||
`updated_at_tmdb` | ||
) SELECT | ||
`id`, | ||
`name`, | ||
`gender`, | ||
`known_for_department`, | ||
`poster_path`, | ||
`birth_date`, | ||
`place_of_birth`, | ||
`death_date`, | ||
`tmdb_id`, | ||
`tmdb_poster_path`, | ||
`created_at`, | ||
`updated_at`, | ||
`updated_at_tmdb` | ||
FROM `person`', | ||
); | ||
$this->execute('DROP TABLE `person`'); | ||
$this->execute('ALTER TABLE `tmp_person` RENAME TO `person`'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function toggleBiography() | ||
{ | ||
let expandContainer = document.getElementById('expandContainer'); | ||
if(document.getElementsByClassName('truncated').length > 0) { | ||
document.getElementById('biographyParagraph').classList.remove('truncated'); | ||
expandContainer.getElementsByTagName('i')[0].classList.remove('bi-chevron-down'); | ||
expandContainer.getElementsByTagName('i')[0].classList.add('bi-chevron-up'); | ||
expandContainer.children[1].innerHTML = 'Show less…'; | ||
} else { | ||
document.getElementById('biographyParagraph').classList.add('truncated'); | ||
expandContainer.getElementsByTagName('i')[0].classList.add('bi-chevron-down'); | ||
expandContainer.getElementsByTagName('i')[0].classList.remove('bi-chevron-up'); | ||
expandContainer.children[1].innerHTML = 'Show more…'; | ||
} | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
let biographyHeight = document.getElementById('biographyParagraph').offsetHeight; | ||
let windowHeight = window.outerHeight; | ||
if(((biographyHeight / windowHeight) * 100) > 20) { | ||
document.getElementById('biographyParagraph').classList.add('truncated'); | ||
document.getElementById('expandContainer').classList.remove('d-none'); | ||
} | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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