Files
LazyLibrarian/data/interfaces/bookstrap/author.html
2018-11-09 15:58:30 +01:00

400 lines
19 KiB
HTML

<%inherit file="base.html"/>
<%!
import lazylibrarian
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<form id="subhead_menu" class="form-inline">
%if perm&lazylibrarian.perm_force:
%if author['Status'] == 'Paused':
<a href="resumeAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-pause"></i> Paused</a>
%else:
%if author['Status'] == 'Active':
<a href="wantAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-play"></i> Active</a>
%else:
%if author['Status'] == 'Wanted':
<a href="ignoreAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i> Wanted</a>
%else:
<a href="pauseAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-ban"></i> Ignored</a>
%endif
%endif
%endif
<a href="refreshAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-sync"></i> Refresh Author</a>
<a href="libraryScanAuthor?AuthorID=${author['AuthorID']}&library=eBook" class="btn btn-sm btn-primary"><i class="fa fa-sync"></i> eBook Scan</a>
% if lazylibrarian.SHOW_AUDIO > 0:
%if perm&lazylibrarian.perm_force:
<a href="libraryScanAuthor?AuthorID=${author['AuthorID']}&library=AudioBook" class="btn btn-sm btn-primary"><i class="fa fa-sync"></i> AudioBook Scan</a>
%endif
% endif
<button class="button btn btn-sm btn-primary" type="button" value="removeme" id="removeme"><i class="fa fa-times"></i> Remove Author</button>
%if ignored == 'True':
<a href="authorPage?AuthorID=${author['AuthorID']}&amp;Ignored=False" class="btn btn-sm btn-primary"><i class="fa fa-book"></i> Show Active</a>
%else:
<a href="authorPage?AuthorID=${author['AuthorID']}&amp;Ignored=True" class="btn btn-sm btn-primary"><i class="fa fa-ban"></i> Show Ignored</a>
%endif
%endif
%if showseries >= 1:
%if perm&lazylibrarian.perm_series:
<a href="series?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-book"></i> Series</a>
%endif
%endif
%if lazylibrarian.CONFIG['GR_FOLLOW'] == True:
%if author['GRfollow']:
%if author['GRfollow'] != '0':
<a href="unfollowAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> Following</a>
%else:
<a href="followAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-times"></i> Not Following</a>
%endif
%else:
<a href="followAuthor?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-times"></i> Not Following</a>
%endif
%endif
<div class="form-group pull-right">
%if len(types) > 1:
%if perm&lazylibrarian.perm_audio:
<label for="chooselib"><small>&nbsp;Library</small></label>
<select class="form-control input-sm" name="chooselib" id="chooselib">
%for library in types:
<option value="${library}">${library}</option>
%endfor
</select>
%endif
%endif
%if len(languages) > 1:
<label for="chooselanguage"><small>Language</small></label>
<select class="form-control input-sm" name="chooselanguage" id="chooselanguage">
<option value="">All</option>
%for language in languages:
<option value="${language['BookLang']}">${language['BookLang']}</option>
%endfor
</select>
%endif
</div>
</form>
</div>
<script type="text/javascript">
</script>
</%def>
<%def name="body()">
<div class="row">
%if lazylibrarian.CONFIG['AUTHOR_IMG']:
<div id="authorart_container" class="col-md-3">
<div id="authorart_menu">
<img src="${author['AuthorImg']}" class="box-shadow img-responsive" alt="${author['AuthorName']}" title="${author['AuthorName']}">
</div>
</div>
%endif
<div id="authorhead_container" class="col-md-9">
<div id="authorhead_menu">
<h1><a href="${author['AuthorLink']}" target="_blank" rel="noreferrer">${author['AuthorName']}</a>
%if perm&lazylibrarian.perm_edit:
<a href="editAuthor?authorid=${author['AuthorID']}"&amp; target="_new"><small><i>Edit</i></small></a>
%endif
</h1>
%if author['AuthorDeath']:
<p><b>Born:</b> ${author['AuthorBorn']}, <b>Died:</b> ${author['AuthorDeath']}</p>
%else:
%if author['AuthorBorn']:
<p><b>Born:</b> ${author['AuthorBorn']}</p>
%endif
%endif
%if author['Status'] == 'Loading':
<p>
<button onclick="" id="myAlert" title=""><i class="fa fa-circle-notch fa-spin"></i> Fetching information for this author ...</button>
</p>
%endif
<p><b>Totalbooks:</b> ${author['TotalBooks']}</p>
<%
totalbooks = author['UnignoredBooks']
havebooks = author['HaveBooks']
if not havebooks:
havebooks = 0
try:
percent = (havebooks*100.0)/totalbooks
if percent > 100:
percent = 100
if percent <= 100:
css = "bg-success"
if percent <= 75:
css = "bg-info"
if percent <= 50:
css = "bg-warning"
if percent <= 25:
css = "bg-danger"
except (ZeroDivisionError, TypeError):
percent = 0
totalbooks = '0'
css = "bg-danger"
%>
<div class="row" title="${percent}">
<div class="col-xs-4"><strong>Progress:</strong></div>
<div class="col-xs-4">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="${percent}" aria-valuemin="0" aria-valuemax="100" style="width: ${percent}%;">
<span class="sr-only">${percent}% Complete</span>
</div>
</div>
</div>
<div class="col-xs-4">
<span class="progressbar-front-text">${havebooks} / ${totalbooks}</span>
</div>
</div>
</div>
</div>
</div>
<form action="markBooks" method="get" class="form-inline">
<div class="indented">
<input type="hidden" name="AuthorID" value="${author['AuthorID']}">
<input type="hidden" name="redirect" value="author">
<input type="hidden" name="booklang" value=${booklang}>
<input type="hidden" name="library" value=${library}>
<input type="hidden" name="ignored" value=${ignored}>
%if perm&lazylibrarian.perm_status or lazylibrarian.CONFIG['USER_ACCOUNTS']:
<div class="form-group">
<label for="action" class="">Mark selected as</label>
<select class="markBooks form-control input-sm" id="action" name="action">
%if perm&lazylibrarian.perm_status:
<option value="Wanted">Wanted</option>
<option value="Have">Have</option>
<option value="Ignored">Ignored</option>
<option value="Skipped">Skipped</option>
<option value="Remove">Remove</option>
<option value="Delete">Delete</option>
<option value="Leave" hidden>Leave</option>
% endif
%if lazylibrarian.CONFIG['USER_ACCOUNTS']:
<option value="Unread">Unread</option>
<option value="Read">Read</option>
<option value="ToRead">To Read</option>
%endif
</select>
</div>
<input type="submit" class="markBooks btn btn-sm btn-primary" value="Go">
%endif
%if lazylibrarian.CONFIG['TOGGLES'] == True:
&nbsp;&nbsp;Toggle: <a class="toggle-vis" data-column="1">Cover - </a>
<a class="toggle-vis" data-column="3">Title - </a>
<a class="toggle-vis" data-column="4">Series - </a>
<a class="toggle-vis hidden-sm hidden-xs" data-column="5">Rating - </a>
<a class="toggle-vis" data-column="6">Released - </a>
<a class="toggle-vis" data-column="7">Added - </a>
<a class="toggle-vis" data-column="8">Status</a>
<p>&nbsp;</p>
%endif
</div>
<div class="table-responsive">
<table class="display table table-striped table-hover table-bordered" id="book_table">
<thead>
<tr>
<th class="select text-center no-sort"><input type="checkbox" onClick="toggleAll(this)" /></th>
<th class="bookart text-center no-sort">Cover</th>
<th class="authorname hidden">Author</th>
<th class="bookname">Title</th>
<th class="series">Series</th>
<th class="stars text-center hidden-sm hidden-xs">Rating</th>
<th class="date text-center">Date</th>
<th class="date text-center">Added</th>
<th class="status text-center">Status</th>
</tr>
</thead>
</table>
</div>
</form>
<p>&nbsp;</p>
</%def>
<%def name="headIncludes()">
%if author['Status'] == 'Loading':
<meta http-equiv="refresh" content="12">
%endif
</%def>
<%def name="javascriptIncludes()">
<script type="text/javascript">
$(document).ready(function()
{
$('#removeme').click(function () {
bootbox.confirm({
message: "Are you sure you want to permanently delete the author?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (result) {
if (result) { $.get("removeAuthor", {'AuthorID': ${author['AuthorID']} },
function (data) { window.location = 'home' }); }
}
});
});
$('#chooselanguage').change(function(){
new_settings = 'authorPage?AuthorID=${author['AuthorID']}&BookLang=' + $(this).val()
if (typeof $("#chooselib").val() != 'undefined') {
new_settings += '&library=' + $("#chooselib").val() }
window.location = new_settings
})
$('#chooselib').change(function(){
new_settings = 'authorPage?AuthorID=${author['AuthorID']}&library=' + $(this).val()
if (typeof $("#chooselanguage").val() != 'undefined') {
new_settings += '&BookLang=' + $("#chooselanguage").val() }
window.location = new_settings
})
$('#chooselanguage').val(getUrlVars()['BookLang']);
$('#chooselib').val(getUrlVars()['library']);
if ($("#chooselib").val() != 'AudioBook') {
$('#chooselib').val('eBook')
}
var show = ""+${lazylibrarian.CONFIG['BOOK_IMG']};
if ( show != '1' ) { showimg = false }
else { showimg = true }
var oTable = $('#book_table').DataTable(
{
"order": [[ 6, 'desc' ]],
"bAutoWidth": false,
"stateSave": true,
"columnDefs":[
{ targets: 'no-sort', orderable: false },
{ targets: [0],
'class': 'text-center',
'render': function(data, type, row) {
return '<input type="checkbox" name="' + data + '" class="checkbox" />';} },
{ targets: [1],
'class': 'text-center',
'visible': showimg,
'render': function(data, type, row) {
return '<a href="' + data + '" target="_blank" rel="noreferrer"><img src="' + data + '" alt="Cover" class="bookcover-sm img-responsive"></a>';} },
{ targets: [2], 'class': "hidden" },
{ targets: [3], 'render': function(data, type, row) {
var pre = data.split('<');
var limit = window.innerWidth / 30;
var title = truncateOnWord(pre[0], limit);
var tail = data.slice(pre[0].length);
btn = '<button onclick="bookinfo(\'' + row[9] + '\')" class="button btn-link text-left" type="button" '
return btn + ' title="' + pre[0] + '">' + title + '</button>' + tail ;
}
},
{ targets: [4], 'render': function(data, type, row){
if (row[12] === null ) { return data; }
if (row[12] === '' ) { return row[4]; }
var series = row[12].split('^');
var output = [];
for (var index=0; index < series.length; ++index) {
var link_data = series[index].split("~");
output.push('<a href=seriesMembers?seriesid=' + link_data[0] + '>' + link_data[1] + '</a>')
}
return output.join('<br>');
}},
{ targets: [5],
'class': 'text-center',
'render': function(data, type, row) {
return '<img src="images/' + data + '-stars.png" alt="Rating">';} },
{ targets: [6], 'class': "text-center" },
{ targets: [7],
'class': 'text-center',
'render': function(data, type, row) {
var dtime = row[10];
var str = String(dtime).substr(0, 10);
if (str === "null"){ str = ""}
return str ;} },
{ targets: [8],
'class': 'text-center',
'render': function(data, type, row) {
var btn = row[11]
var flag = row[13]
btn = btn + flag
if ( btn.indexOf('Open') >= 0 ) {
btn = '<a class="button green btn btn-xs btn-warning" href="openBook?bookid=' + row[9] +
'&library=${library}" target="_self"><i class="fa fa-book"></i> ' + btn + '</a>'
}
else if ( btn.indexOf('Wanted') >= 0 ) {
btn = '<p><a class="a btn btn-xs btn-danger">' + btn + '</a></p><p><a class="b btn btn-xs btn-success" href="searchForBook?bookid=' + row[9] + '&library=${library}" target="_self"><i class="fa fa-search"></i> Search</a></p>'}
else if ( btn.indexOf('Snatched') >= 0 ) {
btn = '<a class="button btn btn-xs btn-info">' + btn + '</a>'}
else if ( btn.indexOf('Ignored') >= 0 ) {
btn = '<button onclick="dlinfo(\'' + btn + '^' + row[9] +
'\')" class="button btn btn-xs btn-primary" type="button">' + btn + '</button>'}
else if ( btn.indexOf('Have') >= 0 ) {
%if perm&lazylibrarian.perm_status:
btn = '<a class="button btn btn-xs btn-info">' + btn + '</a>'
%else:
btn = '<p><a class="button btn btn-xs btn-default grey" href="requestBook?bookid=' + row[9] + '&library=${library}" target="_self">Request</a></p>'
%endif
}
else {
%if perm&lazylibrarian.perm_status:
btn = '<a class="button btn btn-xs btn-default grey">' + btn + '</a>'
%else:
btn = '<p><a class="button btn btn-xs btn-default grey" href="requestBook?bookid=' + row[9] + '&library=${library}" target="_self">Request</a></p>'
%endif
}
return btn;} }
],
"oLanguage": {
"sSearch": "Filter: ",
"sLengthMenu":"_MENU_ rows per page",
"sEmptyTable": "No books found",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ rows",
"sInfoEmpty":"Showing 0 to 0 of 0 rows",
"sInfoFiltered":"(filtered from _MAX_ total rows)"},
"sPaginationType": "full_numbers",
"aaSorting": [[6, 'desc']],
"bServerSide": true,
"sAjaxSource": 'getBooks?source=Author&AuthorID=${author['AuthorID']}&booklang=${booklang}&library=${library}&ignored=${ignored}',
"bFilter": true,
"aLengthMenu": [[5, 10, 15, 25, 50, 100, -1], [5, 10, 15, 25, 50, 100, "All"]],
"iDisplayLength": ${lazylibrarian.CONFIG['DISPLAYLENGTH']},
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// hide cover,stars,date on small devices
//$('td', nRow).eq(1).addClass('hidden-xs');
$('td', nRow).eq(5).addClass('hidden-sm hidden-xs');
//$('td', nRow).eq(6).addClass('hidden-xs');
//$('td', nRow).eq(7).addClass('hidden-xs');
return nRow;
},
});
var page = oTable.page();
if ( page != '0' ) {
if (${firstpage}) { oTable.page( 'first' ).draw( 'page' ); }
}
$('.dataTables_filter input').attr("placeholder", "Results Filter");
//$(window).resize(function() {oTable.draw(false)});
$('a.toggle-vis').click(function (e) {
e.preventDefault();
var column = oTable.column( $(this).attr('data-column') );
column.visible( ! column.visible() );
} );
});
function dlinfo(target) {
var res = target.split('^');
var status = res[0]
var rowid = res[1]
$.get('dlinfo', {'target': target},
function(data) {
bootbox.dialog({
title: 'Title '+ status,
message: '<pre>'+data+'</pre>',
buttons: {
primary: {
label: "Close",
className: 'btn-primary'
}
}
});
});
};
</script>
</%def>