Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit 3abd292

Browse files
authored
Merge pull request #156 from hkalexling/dev
v0.20.0
2 parents b712db9 + 21233df commit 3abd292

28 files changed

+746
-78
lines changed

.ameba.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ Lint/UnusedArgument:
77
- src/routes/*
88
Metrics/CyclomaticComplexity:
99
Enabled: false
10+
Layout/LineLength:
11+
Enabled: true
12+
MaxLength: 80
13+
Excluded:
14+
- src/routes/api.cr

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ test:
2929
check:
3030
crystal tool format --check
3131
./bin/ameba
32-
./dev/linewidth.sh
3332

3433
arm32v7:
3534
crystal build src/mango.cr --release --progress --error-trace --cross-compile --target='arm-linux-gnueabihf' -o mango-arm32v7

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The official docker images are available on [Dockerhub](https://hub.docker.com/r
5252
### CLI
5353

5454
```
55-
Mango - Manga Server and Web Reader. Version 0.19.1
55+
Mango - Manga Server and Web Reader. Version 0.20.0
5656
5757
Usage:
5858
@@ -82,7 +82,6 @@ library_path: ~/mango/library
8282
db_path: ~/mango/mango.db
8383
scan_interval_minutes: 5
8484
thumbnail_generation_interval_hours: 24
85-
db_optimization_interval_hours: 24
8685
log_level: info
8786
upload_path: ~/mango/uploads
8887
plugin_path: ~/mango/plugins

dev/linewidth.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

migration/ids_signature.7.cr

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class IDSignature < MG::Base
2+
def up : String
3+
<<-SQL
4+
ALTER TABLE ids ADD COLUMN signature TEXT;
5+
SQL
6+
end
7+
8+
def down : String
9+
<<-SQL
10+
-- remove signature column from ids
11+
ALTER TABLE ids RENAME TO tmp;
12+
13+
CREATE TABLE ids (
14+
path TEXT NOT NULL,
15+
id TEXT NOT NULL
16+
);
17+
18+
INSERT INTO ids
19+
SELECT path, id
20+
FROM tmp;
21+
22+
DROP TABLE tmp;
23+
24+
-- recreate the indices
25+
CREATE UNIQUE INDEX path_idx ON ids (path);
26+
CREATE UNIQUE INDEX id_idx ON ids (id);
27+
28+
-- recreate the foreign key constraint on thumbnails
29+
ALTER TABLE thumbnails RENAME TO tmp;
30+
31+
CREATE TABLE thumbnails (
32+
id TEXT NOT NULL,
33+
data BLOB NOT NULL,
34+
filename TEXT NOT NULL,
35+
mime TEXT NOT NULL,
36+
size INTEGER NOT NULL,
37+
FOREIGN KEY (id) REFERENCES ids (id)
38+
ON UPDATE CASCADE
39+
ON DELETE CASCADE
40+
);
41+
42+
INSERT INTO thumbnails
43+
SELECT * FROM tmp;
44+
45+
DROP TABLE tmp;
46+
47+
CREATE UNIQUE INDEX tn_index ON thumbnails (id);
48+
SQL
49+
end
50+
end

migration/relative_path.8.cr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class RelativePath < MG::Base
2+
def up : String
3+
base = Config.current.library_path
4+
# Escape single quotes in case the path contains them, and remove the
5+
# trailing slash (this is a mistake, fixed in DB version 10)
6+
base = base.gsub("'", "''").rstrip "/"
7+
8+
<<-SQL
9+
-- update the path column in ids to relative paths
10+
UPDATE ids
11+
SET path = REPLACE(path, '#{base}', '');
12+
13+
-- update the path column in titles to relative paths
14+
UPDATE titles
15+
SET path = REPLACE(path, '#{base}', '');
16+
SQL
17+
end
18+
19+
def down : String
20+
base = Config.current.library_path
21+
base = base.gsub("'", "''").rstrip "/"
22+
23+
<<-SQL
24+
-- update the path column in ids to absolute paths
25+
UPDATE ids
26+
SET path = '#{base}' || path;
27+
28+
-- update the path column in titles to absolute paths
29+
UPDATE titles
30+
SET path = '#{base}' || path;
31+
SQL
32+
end
33+
end

migration/relative_path_fix.10.cr

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# In DB version 8, we replaced the absolute paths in DB with relative paths,
2+
# but we mistakenly left the starting slashes. This migration removes them.
3+
class RelativePathFix < MG::Base
4+
def up : String
5+
<<-SQL
6+
-- remove leading slashes from the paths in ids
7+
UPDATE ids
8+
SET path = SUBSTR(path, 2, LENGTH(path) - 1)
9+
WHERE path LIKE '/%';
10+
11+
-- remove leading slashes from the paths in titles
12+
UPDATE titles
13+
SET path = SUBSTR(path, 2, LENGTH(path) - 1)
14+
WHERE path LIKE '/%';
15+
SQL
16+
end
17+
18+
def down : String
19+
<<-SQL
20+
-- add leading slashes to paths in ids
21+
UPDATE ids
22+
SET path = '/' || path
23+
WHERE path NOT LIKE '/%';
24+
25+
-- add leading slashes to paths in titles
26+
UPDATE titles
27+
SET path = '/' || path
28+
WHERE path NOT LIKE '/%';
29+
SQL
30+
end
31+
end

migration/unavailable.9.cr

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
class UnavailableIDs < MG::Base
2+
def up : String
3+
<<-SQL
4+
-- add unavailable column to ids
5+
ALTER TABLE ids ADD COLUMN unavailable INTEGER NOT NULL DEFAULT 0;
6+
7+
-- add unavailable column to titles
8+
ALTER TABLE titles ADD COLUMN unavailable INTEGER NOT NULL DEFAULT 0;
9+
SQL
10+
end
11+
12+
def down : String
13+
<<-SQL
14+
-- remove unavailable column from ids
15+
ALTER TABLE ids RENAME TO tmp;
16+
17+
CREATE TABLE ids (
18+
path TEXT NOT NULL,
19+
id TEXT NOT NULL,
20+
signature TEXT
21+
);
22+
23+
INSERT INTO ids
24+
SELECT path, id, signature
25+
FROM tmp;
26+
27+
DROP TABLE tmp;
28+
29+
-- recreate the indices
30+
CREATE UNIQUE INDEX path_idx ON ids (path);
31+
CREATE UNIQUE INDEX id_idx ON ids (id);
32+
33+
-- recreate the foreign key constraint on thumbnails
34+
ALTER TABLE thumbnails RENAME TO tmp;
35+
36+
CREATE TABLE thumbnails (
37+
id TEXT NOT NULL,
38+
data BLOB NOT NULL,
39+
filename TEXT NOT NULL,
40+
mime TEXT NOT NULL,
41+
size INTEGER NOT NULL,
42+
FOREIGN KEY (id) REFERENCES ids (id)
43+
ON UPDATE CASCADE
44+
ON DELETE CASCADE
45+
);
46+
47+
INSERT INTO thumbnails
48+
SELECT * FROM tmp;
49+
50+
DROP TABLE tmp;
51+
52+
CREATE UNIQUE INDEX tn_index ON thumbnails (id);
53+
54+
-- remove unavailable column from titles
55+
ALTER TABLE titles RENAME TO tmp;
56+
57+
CREATE TABLE titles (
58+
id TEXT NOT NULL,
59+
path TEXT NOT NULL,
60+
signature TEXT
61+
);
62+
63+
INSERT INTO titles
64+
SELECT path, id, signature
65+
FROM tmp;
66+
67+
DROP TABLE tmp;
68+
69+
-- recreate the indices
70+
CREATE UNIQUE INDEX titles_id_idx on titles (id);
71+
CREATE UNIQUE INDEX titles_path_idx on titles (path);
72+
73+
-- recreate the foreign key constraint on tags
74+
ALTER TABLE tags RENAME TO tmp;
75+
76+
CREATE TABLE tags (
77+
id TEXT NOT NULL,
78+
tag TEXT NOT NULL,
79+
UNIQUE (id, tag),
80+
FOREIGN KEY (id) REFERENCES titles (id)
81+
ON UPDATE CASCADE
82+
ON DELETE CASCADE
83+
);
84+
85+
INSERT INTO tags
86+
SELECT * FROM tmp;
87+
88+
DROP TABLE tmp;
89+
90+
CREATE INDEX tags_id_idx ON tags (id);
91+
CREATE INDEX tags_tag_idx ON tags (tag);
92+
SQL
93+
end
94+
end

public/css/mango.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
// Dark theme
6868
.uk-light {
69-
.uk-navbar-dropdown,
7069
.uk-modal-header,
7170
.uk-modal-body,
7271
.uk-modal-footer {
@@ -75,6 +74,7 @@
7574
.uk-navbar-dropdown,
7675
.uk-dropdown {
7776
color: #ccc;
77+
background: #333;
7878
}
7979
.uk-nav-header,
8080
.uk-description-list > dt {

public/js/download.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ const search = () => {
156156
langs.unshift('All');
157157
group_names.unshift('All');
158158

159-
$('select#lang-select').append(langs.map(e => `<option>${e}</option>`).join(''));
160-
$('select#group-select').append(group_names.map(e => `<option>${e}</option>`).join(''));
159+
$('select#lang-select').html(langs.map(e => `<option>${e}</option>`).join(''));
160+
$('select#group-select').html(group_names.map(e => `<option>${e}</option>`).join(''));
161161

162162
$('#filter-form').removeAttr('hidden');
163163

@@ -241,7 +241,7 @@ const buildTable = () => {
241241
if (v === 'All') return;
242242
if (k === 'group') {
243243
chapters = chapters.filter(c => {
244-
unescaped_groups = Object.entries(c.groups).map(([g, id]) => unescapeHTML(g));
244+
const unescaped_groups = Object.entries(c.groups).map(([g, id]) => unescapeHTML(g));
245245
return unescaped_groups.indexOf(v) >= 0;
246246
});
247247
return;

0 commit comments

Comments
 (0)