mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
fix for issue #2.
This commit is contained in:
@@ -203,6 +203,8 @@ class ComicBook(models.Model):
|
|||||||
book = ComicBook.process_comic_book(next_comic, self.directory)
|
book = ComicBook.process_comic_book(next_comic, self.directory)
|
||||||
else:
|
else:
|
||||||
book = ComicBook.process_comic_book(next_comic)
|
book = ComicBook.process_comic_book(next_comic)
|
||||||
|
if type(book) is str:
|
||||||
|
raise IndexError
|
||||||
comic_path = urlsafe_base64_encode(book.selector.bytes)
|
comic_path = urlsafe_base64_encode(book.selector.bytes)
|
||||||
cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user)
|
cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user)
|
||||||
index = cs.last_read_page
|
index = cs.last_read_page
|
||||||
@@ -258,12 +260,16 @@ class ComicBook(models.Model):
|
|||||||
comic_full_path = path.join(base_dir, directory.get_path(), comic_file_name)
|
comic_full_path = path.join(base_dir, directory.get_path(), comic_file_name)
|
||||||
else:
|
else:
|
||||||
comic_full_path = path.join(base_dir, comic_file_name)
|
comic_full_path = path.join(base_dir, comic_file_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cbx = rarfile.RarFile(comic_full_path)
|
cbx = rarfile.RarFile(comic_full_path)
|
||||||
except rarfile.NotRarFile:
|
except rarfile.NotRarFile:
|
||||||
cbx = zipfile.ZipFile(comic_full_path)
|
cbx = None
|
||||||
except zipfile.BadZipfile:
|
if not cbx:
|
||||||
return False
|
try:
|
||||||
|
cbx = zipfile.ZipFile(comic_full_path)
|
||||||
|
except zipfile.BadZipFile:
|
||||||
|
return comic_file_name
|
||||||
with atomic():
|
with atomic():
|
||||||
if directory:
|
if directory:
|
||||||
book = ComicBook(file_name=comic_file_name,
|
book = ComicBook(file_name=comic_file_name,
|
||||||
|
|||||||
@@ -46,18 +46,23 @@ $(document).ready(function() {
|
|||||||
"url": "{{ json_url }}",
|
"url": "{{ json_url }}",
|
||||||
"data": function ( d ) {
|
"data": function ( d ) {
|
||||||
d.csrfmiddlewaretoken = Cookies.get('csrftoken');
|
d.csrfmiddlewaretoken = Cookies.get('csrftoken');
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
"rowCallback": function( row, data, index ) {
|
"rowCallback": function( row, data, index ) {
|
||||||
var r = $(row);
|
var r = $(row);
|
||||||
var cols = $('td:nth-child(n+2)', row);
|
var cols = $('td:nth-child(n+2)', row);
|
||||||
cols.attr('data-href', data['url']);
|
|
||||||
cols.attr('style', 'cursor: pointer;')
|
if (data['selector'] === '0') {
|
||||||
cols.click(function() {
|
|
||||||
window.document.location = $(this).data("href");
|
} else {
|
||||||
});
|
cols.attr('data-href', data['url']);
|
||||||
|
cols.attr('style', 'cursor: pointer;');
|
||||||
|
cols.click(function () {
|
||||||
|
window.document.location = $(this).data("href");
|
||||||
|
});
|
||||||
|
}
|
||||||
var tds = $('td:eq(0)', row);
|
var tds = $('td:eq(0)', row);
|
||||||
if (data['type'] == 'directory'){
|
if (data['type'] === 'directory') {
|
||||||
tds.html('');
|
tds.html('');
|
||||||
} else {
|
} else {
|
||||||
tds.html('<input type="checkbox" name="selected" value="'+data['selector']+'" data-type="'+data['type']+'"/>');
|
tds.html('<input type="checkbox" name="selected" value="'+data['selector']+'" data-type="'+data['type']+'"/>');
|
||||||
@@ -65,25 +70,25 @@ $(document).ready(function() {
|
|||||||
cb.change(function() {
|
cb.change(function() {
|
||||||
$(this).closest('tr').toggleClass('info')
|
$(this).closest('tr').toggleClass('info')
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
"drawCallback": function( settings ) {
|
"drawCallback": function( settings ) {
|
||||||
var tds = $('table tr td:first-child');
|
var tds = $('table tr td:first-child');
|
||||||
tds.click(function(event){
|
tds.click(function(event){
|
||||||
if (!$(event.target).is('input')) {
|
if (!$(event.target).is('input')) {
|
||||||
var $cb = $('input', this)
|
var $cb = $('input', this);
|
||||||
$cb.click();
|
$cb.click();
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "data" : "blank", "orderable": false },
|
{ "data" : "blank", "orderable": false },
|
||||||
{ "data" : "icon", "orderable": false },
|
{ "data" : "icon", "orderable": false },
|
||||||
{ "data" : "name" },
|
{ "data" : "name" },
|
||||||
{ "data" : "label" },
|
{"data": "label"}
|
||||||
],
|
],
|
||||||
|
|
||||||
"order": [[ 2, 'asc' ]],
|
"order": [[2, 'asc']]
|
||||||
});
|
});
|
||||||
$(".clickable-row").click(function() {
|
$(".clickable-row").click(function() {
|
||||||
window.document.location = $(this).data("href");
|
window.document.location = $(this).data("href");
|
||||||
@@ -100,12 +105,12 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
$('#select-all').click(function(event){
|
$('#select-all').click(function(event){
|
||||||
var cb = $('input', this)
|
var cb = $('input', this);
|
||||||
if (!$(event.target).is('input')) {
|
if (!$(event.target).is('input')) {
|
||||||
cb.click();
|
cb.click();
|
||||||
};
|
}
|
||||||
$('table tr td:first-child input').each(function(chkbx) {
|
$('table tr td:first-child input').each(function(chkbx) {
|
||||||
row = $(this)
|
row = $(this);
|
||||||
if (row.prop('checked') != cb.prop('checked')){
|
if (row.prop('checked') != cb.prop('checked')){
|
||||||
row.click();
|
row.click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,16 +98,24 @@ class DirFile:
|
|||||||
self.type = 'directory'
|
self.type = 'directory'
|
||||||
|
|
||||||
def populate_comic(self, comic, user):
|
def populate_comic(self, comic, user):
|
||||||
self.icon = 'glyphicon-book'
|
if type(comic) == str:
|
||||||
self.name = comic.file_name
|
self.icon = 'glyphicon-remove'
|
||||||
status, created = ComicStatus.objects.get_or_create(comic=comic, user=user)
|
self.name = comic
|
||||||
if created:
|
self.selector = '0'
|
||||||
status.save()
|
self.location = '/'
|
||||||
self.selector = urlsafe_base64_encode(comic.selector.bytes).decode()
|
self.label = '<center><span class="label label-danger">Error</span></center>'
|
||||||
self.location = '/comic/read/{0}/{1}/'.format(self.selector,
|
self.type = 'book'
|
||||||
status.last_read_page)
|
else:
|
||||||
self.label = generate_label(comic, status)
|
self.icon = 'glyphicon-book'
|
||||||
self.type = 'book'
|
self.name = comic.file_name
|
||||||
|
status, created = ComicStatus.objects.get_or_create(comic=comic, user=user)
|
||||||
|
if created:
|
||||||
|
status.save()
|
||||||
|
self.selector = urlsafe_base64_encode(comic.selector.bytes).decode()
|
||||||
|
self.location = '/comic/read/{0}/{1}/'.format(self.selector,
|
||||||
|
status.last_read_page)
|
||||||
|
self.label = generate_label(comic, status)
|
||||||
|
self.type = 'book'
|
||||||
|
|
||||||
|
|
||||||
def generate_directory(user, directory=False):
|
def generate_directory(user, directory=False):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
from captcha.fields import CaptchaField
|
||||||
from django import forms
|
from django import forms
|
||||||
from captcha.fields import ReCaptchaField
|
|
||||||
from comic.models import Setting
|
from comic.models import Setting
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ class LoginForm(forms.Form):
|
|||||||
public_key = Setting.objects.get(name='RECAPTCHA_PUBLIC_KEY').value
|
public_key = Setting.objects.get(name='RECAPTCHA_PUBLIC_KEY').value
|
||||||
private_key = Setting.objects.get(name='RECAPTCHA_PRIVATE_KEY').value
|
private_key = Setting.objects.get(name='RECAPTCHA_PRIVATE_KEY').value
|
||||||
|
|
||||||
captcha = ReCaptchaField(
|
captcha = CaptchaField(
|
||||||
label='',
|
label='',
|
||||||
public_key=public_key,
|
public_key=public_key,
|
||||||
private_key=private_key,
|
private_key=private_key,
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
ujson
|
ujson
|
||||||
django
|
django
|
||||||
|
django-simple-captcha
|
||||||
Reference in New Issue
Block a user