diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/DoctrineMigrations/Version20170511211659.php | 100 | ||||
-rw-r--r-- | app/Resources/static/themes/_global/index.js | 16 |
2 files changed, 115 insertions, 1 deletions
diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php new file mode 100644 index 00000000..f2d5cf5e --- /dev/null +++ b/app/DoctrineMigrations/Version20170511211659.php | |||
@@ -0,0 +1,100 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Migrations\SkipMigrationException; | ||
7 | use Doctrine\DBAL\Schema\Schema; | ||
8 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
9 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
10 | |||
11 | /** | ||
12 | * Increase the length of the "quote" column of "annotation" table | ||
13 | */ | ||
14 | class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface | ||
15 | { | ||
16 | /** | ||
17 | * @var ContainerInterface | ||
18 | */ | ||
19 | private $container; | ||
20 | |||
21 | public function setContainer(ContainerInterface $container = null) | ||
22 | { | ||
23 | $this->container = $container; | ||
24 | } | ||
25 | |||
26 | private function getTable($tableName) | ||
27 | { | ||
28 | return $this->container->getParameter('database_table_prefix') . $tableName; | ||
29 | } | ||
30 | |||
31 | public function up(Schema $schema) | ||
32 | { | ||
33 | $tableName = $this->getTable('annotation'); | ||
34 | |||
35 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
36 | case 'sqlite': | ||
37 | $this->addSql(<<<EOD | ||
38 | CREATE TEMPORARY TABLE __temp__wallabag_annotation AS | ||
39 | SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges | ||
40 | FROM ${tableName} | ||
41 | EOD | ||
42 | ); | ||
43 | $this->addSql('DROP TABLE ' . $tableName); | ||
44 | $this->addSql(<<<EOD | ||
45 | CREATE TABLE ${tableName} | ||
46 | ( | ||
47 | id INTEGER PRIMARY KEY NOT NULL, | ||
48 | user_id INTEGER DEFAULT NULL, | ||
49 | entry_id INTEGER DEFAULT NULL, | ||
50 | text CLOB NOT NULL, | ||
51 | created_at DATETIME NOT NULL, | ||
52 | updated_at DATETIME NOT NULL, | ||
53 | quote CLOB NOT NULL, | ||
54 | ranges CLOB NOT NULL, | ||
55 | CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES wallabag_user (id), | ||
56 | CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES wallabag_entry (id) ON DELETE CASCADE | ||
57 | ); | ||
58 | CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); | ||
59 | CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); | ||
60 | EOD | ||
61 | ); | ||
62 | |||
63 | $this->addSql(<<<EOD | ||
64 | INSERT INTO ${tableName} (id, user_id, entry_id, text, created_at, updated_at, quote, ranges) | ||
65 | SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges | ||
66 | FROM __temp__wallabag_annotation; | ||
67 | EOD | ||
68 | ); | ||
69 | $this->addSql('DROP TABLE __temp__wallabag_annotation'); | ||
70 | break; | ||
71 | |||
72 | case 'mysql': | ||
73 | $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL'); | ||
74 | break; | ||
75 | |||
76 | case 'postgresql': | ||
77 | $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT'); | ||
78 | break; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public function down(Schema $schema) | ||
83 | { | ||
84 | $tableName = $this->getTable('annotation'); | ||
85 | |||
86 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
87 | case 'sqlite': | ||
88 | throw new SkipMigrationException('Too complex ...'); | ||
89 | break; | ||
90 | |||
91 | case 'mysql': | ||
92 | $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote VARCHAR(255) NOT NULL'); | ||
93 | break; | ||
94 | |||
95 | case 'postgresql': | ||
96 | $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255)'); | ||
97 | break; | ||
98 | } | ||
99 | } | ||
100 | } | ||
diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 3fdcaa3d..3ec26488 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js | |||
@@ -34,7 +34,21 @@ $(document).ready(() => { | |||
34 | app.registry.registerUtility(authorization, 'authorizationPolicy'); | 34 | app.registry.registerUtility(authorization, 'authorizationPolicy'); |
35 | 35 | ||
36 | const x = JSON.parse($('#annotationroutes').html()); | 36 | const x = JSON.parse($('#annotationroutes').html()); |
37 | app.include(annotator.storage.http, x); | 37 | app.include(annotator.storage.http, $.extend({}, x, { |
38 | onError(msg, xhr) { | ||
39 | if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) { | ||
40 | annotator.notification.banner('An error occurred', 'error'); | ||
41 | return; | ||
42 | } | ||
43 | $.each(xhr.responseJSON.children, (k, v) => { | ||
44 | if (v.errors) { | ||
45 | $.each(v.errors, (n, errorText) => { | ||
46 | annotator.notification.banner(errorText, 'error'); | ||
47 | }); | ||
48 | } | ||
49 | }); | ||
50 | }, | ||
51 | })); | ||
38 | 52 | ||
39 | app.start().then(() => { | 53 | app.start().then(() => { |
40 | app.annotations.load({ entry: x.entryId }); | 54 | app.annotations.load({ entry: x.entryId }); |