Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalexling committed Jun 20, 2020
2 parents 650ba98 + a317086 commit 899b221
Show file tree
Hide file tree
Showing 50 changed files with 823 additions and 748 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

runs-on: ubuntu-latest
container:
image: crystallang/crystal:0.34.0-alpine
image: crystallang/crystal:0.35.1-alpine

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist
mango
.env
*.md
public/css/uikit.css
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crystallang/crystal:0.34.0-alpine AS builder
FROM crystallang/crystal:0.35.1-alpine AS builder

WORKDIR /Mango

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The official docker images are available on [Dockerhub](https://hub.docker.com/r
### CLI

```
Mango - Manga Server and Web Reader. Version 0.6.1
Mango - Manga Server and Web Reader. Version 0.7.0
Usage:
Expand Down
13 changes: 10 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const gulp = require('gulp');
const minify = require("gulp-babel-minify");
const minifyCss = require('gulp-minify-css');
const less = require('gulp-less');

gulp.task('minify-js', () => {
return gulp.src('public/js/*.js')
Expand All @@ -10,6 +11,12 @@ gulp.task('minify-js', () => {
.pipe(gulp.dest('dist/js'));
});

gulp.task('less', () => {
return gulp.src('src/assets/*.less')
.pipe(less())
.pipe(gulp.dest('public/css'));
});

gulp.task('minify-css', () => {
return gulp.src('public/css/*.css')
.pipe(minifyCss())
Expand All @@ -21,9 +28,9 @@ gulp.task('img', () => {
.pipe(gulp.dest('dist/img'));
});

gulp.task('favicon', () => {
return gulp.src('public/favicon.ico')
gulp.task('copy-files', () => {
return gulp.src('public/*.*')
.pipe(gulp.dest('dist'));
});

gulp.task('default', gulp.parallel('minify-js', 'minify-css', 'img', 'favicon'));
gulp.task('default', gulp.parallel('minify-js', gulp.series('less', 'minify-css'), 'img', 'copy-files'));
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
"devDependencies": {
"gulp": "^4.0.2",
"gulp-babel-minify": "^0.5.1",
"gulp-minify-css": "^1.2.4"
"gulp-less": "^4.0.1",
"gulp-minify-css": "^1.2.4",
"less": "^3.11.3"
},
"scripts": {
"uglify": "gulp"
},
"dependencies": {
"uikit": "^3.5.4"
}
}
162 changes: 84 additions & 78 deletions public/js/download-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,95 +24,101 @@ const loadConfig = () => {
const remove = (id) => {
var url = base_url + 'api/admin/mangadex/queue/delete';
if (id !== undefined)
url += '?' + $.param({id: id});
url += '?' + $.param({
id: id
});
console.log(url);
$.ajax({
type: 'POST',
url: url,
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to remove job from download queue. Error: ${data.error}`);
return;
}
load();
})
.fail((jqXHR, status) => {
alert('danger', `Failed to remove job from download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
type: 'POST',
url: url,
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to remove job from download queue. Error: ${data.error}`);
return;
}
load();
})
.fail((jqXHR, status) => {
alert('danger', `Failed to remove job from download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
};
const refresh = (id) => {
var url = base_url + 'api/admin/mangadex/queue/retry';
if (id !== undefined)
url += '?' + $.param({id: id});
url += '?' + $.param({
id: id
});
console.log(url);
$.ajax({
type: 'POST',
url: url,
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to restart download job. Error: ${data.error}`);
return;
}
load();
})
.fail((jqXHR, status) => {
alert('danger', `Failed to restart download job. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
type: 'POST',
url: url,
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to restart download job. Error: ${data.error}`);
return;
}
load();
})
.fail((jqXHR, status) => {
alert('danger', `Failed to restart download job. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
};
const toggle = () => {
$('#pause-resume-btn').attr('disabled', '');
const paused = $('#pause-resume-btn').text() === 'Resume download';
const action = paused ? 'resume' : 'pause';
const url = `${base_url}api/admin/mangadex/queue/${action}`;
$.ajax({
type: 'POST',
url: url,
dataType: 'json'
})
.fail((jqXHR, status) => {
alert('danger', `Failed to ${action} download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
})
.always(() => {
load();
$('#pause-resume-btn').removeAttr('disabled');
});
type: 'POST',
url: url,
dataType: 'json'
})
.fail((jqXHR, status) => {
alert('danger', `Failed to ${action} download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
})
.always(() => {
load();
$('#pause-resume-btn').removeAttr('disabled');
});
};
const load = () => {
if (loading) return;
loading = true;
console.log('fetching');
$.ajax({
type: 'GET',
url: base_url + 'api/admin/mangadex/queue',
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to fetch download queue. Error: ${data.error}`);
return;
}
console.log(data);
const btnText = data.paused ? "Resume download" : "Pause download";
$('#pause-resume-btn').text(btnText);
$('#pause-resume-btn').removeAttr('hidden');
const rows = data.jobs.map(obj => {
var cls = 'uk-label ';
if (obj.status === 'Completed')
cls += 'uk-label-success';
if (obj.status === 'Error')
cls += 'uk-label-danger';
if (obj.status === 'MissingPages')
cls += 'uk-label-warning';
type: 'GET',
url: base_url + 'api/admin/mangadex/queue',
dataType: 'json'
})
.done(data => {
if (!data.success && data.error) {
alert('danger', `Failed to fetch download queue. Error: ${data.error}`);
return;
}
console.log(data);
const btnText = data.paused ? "Resume download" : "Pause download";
$('#pause-resume-btn').text(btnText);
$('#pause-resume-btn').removeAttr('hidden');
const rows = data.jobs.map(obj => {
var cls = 'label ';
if (obj.status === 'Pending')
cls += 'label-pending';
if (obj.status === 'Completed')
cls += 'label-success';
if (obj.status === 'Error')
cls += 'label-danger';
if (obj.status === 'MissingPages')
cls += 'label-warning';

const info = obj.status_message.length > 0 ? '<span uk-icon="info"></span>' : '';
const statusSpan = `<span class="${cls}">${obj.status} ${info}</span>`;
const dropdown = obj.status_message.length > 0 ? `<div uk-dropdown>${obj.status_message}</div>` : '';
const retryBtn = obj.status_message.length > 0 ? `<a onclick="refresh('${obj.id}')" uk-icon="refresh"></a>` : '';
return `<tr id="chapter-${obj.id}">
const info = obj.status_message.length > 0 ? '<span uk-icon="info"></span>' : '';
const statusSpan = `<span class="${cls}">${obj.status} ${info}</span>`;
const dropdown = obj.status_message.length > 0 ? `<div uk-dropdown>${obj.status_message}</div>` : '';
const retryBtn = obj.status_message.length > 0 ? `<a onclick="refresh('${obj.id}')" uk-icon="refresh"></a>` : '';
return `<tr id="chapter-${obj.id}">
<td><a href="${baseURL}/chapter/${obj.id}">${obj.title}</a></td>
<td><a href="${baseURL}/manga/${obj.manga_id}">${obj.manga_title}</a></td>
<td>${obj.success_count}/${obj.pages}</td>
Expand All @@ -123,16 +129,16 @@ const load = () => {
${retryBtn}
</td>
</tr>`;
});
});

const tbody = `<tbody>${rows.join('')}</tbody>`;
$('tbody').remove();
$('table').append(tbody);
})
.fail((jqXHR, status) => {
alert('danger', `Failed to fetch download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
})
.always(() => {
loading = false;
});
const tbody = `<tbody>${rows.join('')}</tbody>`;
$('tbody').remove();
$('table').append(tbody);
})
.fail((jqXHR, status) => {
alert('danger', `Failed to fetch download queue. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
})
.always(() => {
loading = false;
});
};
11 changes: 8 additions & 3 deletions public/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const setTheme = themeStr => {
$('.uk-card').addClass('uk-card-secondary');
$('.uk-card').removeClass('uk-card-default');
$('.ui-widget-content').addClass('dark');
}
else {
} else {
$('html').css('background', '');
$('body').removeClass('uk-light');
$('.uk-card').removeClass('uk-card-secondary');
Expand All @@ -39,5 +38,11 @@ const styleModal = () => {
$('.uk-modal-footer').css('background', color);
};

// do it before document is ready to prevent the initial flash of white
// do it before document is ready to prevent the initial flash of white on
// most pages
setTheme(getTheme());

$(() => {
// hack for the reader page
setTheme(getTheme());
});
10 changes: 6 additions & 4 deletions public/js/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
if (percentage === 0) {
$('#continue-btn').attr('hidden', '');
$('#unread-btn').attr('hidden', '');
} else if (percentage === 100) {
$('#read-btn').attr('hidden', '');
$('#continue-btn').attr('hidden', '');
} else {
$('#continue-btn').text('Continue from ' + percentage + '%');
}
if (percentage === 100) {
$('#read-btn').attr('hidden', '');
}

$('#modal-title-link').text(title);
$('#modal-title-link').attr('href', `${base_url}book/${titleID}`);
Expand All @@ -35,7 +35,9 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
updateProgress(titleID, entryID, 0);
});

$('.uk-modal-title.break-word > a').attr('onclick', `edit("${entryID}")`);
$('#modal-edit-btn').attr('onclick', `edit("${entryID}")`);

$('#modal-download-btn').attr('href', `/opds/download/${titleID}/${entryID}`);

UIkit.modal($('#modal')).show();
styleModal();
Expand Down
2 changes: 2 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
26 changes: 13 additions & 13 deletions shard.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
version: 1.0
version: 2.0
shards:
ameba:
github: crystal-ameba/ameba
git: https://github.com/crystal-ameba/ameba.git
version: 0.12.1

archive:
github: hkalexling/archive.cr
git: https://github.com/hkalexling/archive.cr.git
version: 0.2.0

baked_file_system:
github: schovi/baked_file_system
git: https://github.com/schovi/baked_file_system.git
version: 0.9.8

clim:
github: at-grandpa/clim
git: https://github.com/at-grandpa/clim.git
version: 0.12.0

db:
github: crystal-lang/crystal-db
git: https://github.com/crystal-lang/crystal-db.git
version: 0.9.0

exception_page:
github: crystal-loot/exception_page
git: https://github.com/crystal-loot/exception_page.git
version: 0.1.4

kemal:
github: kemalcr/kemal
version: 0.26.1
git: https://github.com/kemalcr/kemal.git
version: 0.26.1+git.commit.a8c0f09b858162bd13c96663febef5527b322a32

kemal-session:
github: kemalcr/kemal-session
git: https://github.com/kemalcr/kemal-session.git
version: 0.12.1

kilt:
github: jeromegn/kilt
git: https://github.com/jeromegn/kilt.git
version: 0.4.0

radix:
github: luislavena/radix
git: https://github.com/luislavena/radix.git
version: 0.3.9

sqlite3:
github: crystal-lang/crystal-sqlite3
git: https://github.com/crystal-lang/crystal-sqlite3.git
version: 0.16.0

Loading

0 comments on commit 899b221

Please sign in to comment.