Skip to content

Commit

Permalink
Merge pull request #895 from philborman/master
Browse files Browse the repository at this point in the history
Display tidying, unicode book titles, strip underscores for fuzzy matching
  • Loading branch information
philborman authored Jul 4, 2017
2 parents abf2bd8 + 7e47c17 commit 89a9e68
Show file tree
Hide file tree
Showing 15 changed files with 219 additions and 81 deletions.
3 changes: 2 additions & 1 deletion LazyLibrarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
def main():
# rename this thread
threading.currentThread().name = "MAIN"

# Set paths
if hasattr(sys, 'frozen'):
lazylibrarian.FULL_PATH = os.path.abspath(sys.executable)
Expand Down Expand Up @@ -96,7 +97,7 @@ def main():
# lazylibrarian.LOGLEVEL = 0
lazylibrarian.daemonize()
else:
print "Daemonize not supported under Windows, starting normally"
print("Daemonize not supported under Windows, starting normally")

if options.nolaunch:
lazylibrarian.CONFIG['LAUNCH_BROWSER'] = False
Expand Down
26 changes: 12 additions & 14 deletions data/interfaces/bookstrap/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@
%if showseries >= 1:
<a href="series?AuthorID=${author['AuthorID']}" class="btn btn-sm btn-primary"><i class="fa fa-book"></i> Series</a>
%endif
<div class="form-group pull-right">
%if len(types) > 1:
<div class="form-group pull-right">
<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>
</div>
<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
%if len(languages) > 1:
<div class="form-group pull-right">
<label for="chooselanguage"><small>Language</small></label>
<select class="form-control input-sm" name="chooselanguage" id="chooselanguage">
<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>
<option value="${language['BookLang']}">${language['BookLang']}</option>
%endfor
</select>
</div>
</select>
%endif
</div>
</form>
</div>
<script type="text/javascript">
Expand Down
16 changes: 3 additions & 13 deletions data/interfaces/bookstrap/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<script src="js/lazylibrarian-bs.js"></script>
${next.headIncludes()}
<script type="text/javascript">
// Allow the user to reset the search box
// Allow the user to reset the filter box
$(document).ready(function () {
$.fn.dataTableExt.oApi.clearSearch = function ( oSettings ) {
var table = this;
var clearSearch = $('<i class="fa fa-remove" style="cursor:pointer;width:16px;text-align:left;" title="Reset Search"></i>');
var clearSearch = $('<i class="fa fa-remove" style="cursor:pointer;width:16px;text-align:left;" title="Reset Filter"></i>');

$(clearSearch).click( function ()
{
Expand Down Expand Up @@ -74,7 +74,7 @@
</div>
<div class="collapse navbar-collapse" id="MainNav">
<ul class="nav navbar-nav">
<li><a href="home" class="navbarele">Authors</a></li>
<!--li><a href="home" class="navbarele">Authors</a></li-->
<li><a id="books" href="books" class="navbarele">eBooks</a></li>
<li><a id="series" href="series" class="navbarele">Series</a></li>
<li><a id="audio" href="audio" class="navbarele">AudioBooks</a></li>
Expand All @@ -84,16 +84,6 @@
<li><a href="logs" class="navbarele">Logs</a></li>
<li><a href="config" class="navbarcfg"><i class="fa fa-cog"></i> Config</a></li>
</ul>
<form class="navbar-form navbar-right" action="search" method="get">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control deletable input-sm" value="" onfocus="if(this.value==this.defaultValue) this.value='';" name="name" placeholder="Title / Author / ISBN" id="searchbox">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</form>
</div>
</div>
<div id="subnav" class="navbar-inverse">
Expand Down
25 changes: 23 additions & 2 deletions data/interfaces/bookstrap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,38 @@
import lazylibrarian
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<div id="subhead_menu">
<div id="subhead_container" class="row">
<form action="search" method="get">
<div id="subhead_menu" class="col-xs-12 col-md-8">
<a href="forceUpdate" class="btn btn-sm btn-primary" id="refresh"><i class="fa fa-refresh"></i> Refresh Active Authors</a>
%if lazylibrarian.IGNORED_AUTHORS == True:
<a href="toggleAuth" class="button btn btn-sm btn-primary">Show Active Authors</a>
%else:
<a href="toggleAuth" class="button btn btn-sm btn-primary">Show Ignored Authors</a>
%endif
</div>
<div class="clearfix visible-xs"><hr/></div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="sr-only">Search</label>
<div class="input-group">
<input type="text" id="name" name="name" placeholder="Title / Author / ISBN" name="title" class="form-control input-sm col-xs-12">
<!--input type="text" class="form-control input-sm col-xs-12" value="" onfocus="if(this.value==this.defaultValue) this.value='';" name="name" placeholder="Title / Author / ISBN" id="searchbox" name="searchbox"-->
<span class="input-group-btn">
<button type="submit" value="Book" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Search for book"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</div>
</form>
</div>
</%def>

<%def name="body()">
<h1>${title}</h1>
%if lazylibrarian.AUTHORS_UPDATE == True:
<p class="alert alert-info"><i class="fa fa-circle-o-notch fa-spin"></i> Author Refresh in progress ...</p>
%endif
<div class="table-responsive">
%if lazylibrarian.CONFIG['TOGGLES'] == True:
Toggle: <a class="toggle-vis" data-column="0">Image</a> - <a class="toggle-vis" data-column="1">Author</a> - <a class="toggle-vis" data-column="2">Latest</a> - <a class="toggle-vis" data-column="3">Released</a> - <a class="toggle-vis" data-column="4">Downloaded</a> - <a class="toggle-vis" data-column="5">Status</a>
Expand Down Expand Up @@ -89,6 +107,9 @@ <h1>${title}</h1>
</div>
</%def>
<%def name="headIncludes()">
%if lazylibrarian.AUTHORS_UPDATE == True:
<meta http-equiv="refresh" content="20">
%endif
</%def>
<%def name="javascriptIncludes()">
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/magazines.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="input-group">
<input type="text" placeholder="Magazine Title" name="title" class="form-control input-sm col-xs-12">
<span class="input-group-btn">
<button type="submit" value="Magazine" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Add and Search for Magazine"><i class="fa fa-search-plus"></i><span> Magazine</span></button>
<button type="submit" value="Magazine" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Search and add Magazine"><i class="fa fa-search-plus"></i><span> Magazine</span></button>
</span>
</div>
</div>
Expand Down
60 changes: 54 additions & 6 deletions data/interfaces/bookstrap/managebooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@
<%!
import lazylibrarian
%>

<%def name="headerIncludes()">
<div id="subhead_container">
<div id="subhead_menu">
<a href="importAlternate" class="button btn btn-sm btn-primary"><i class="fa fa-book"></i> Import Book</a>
<a href="importCSV" class="button btn btn-sm btn-primary"><i class="fa fa-upload"></i> Import CSV Wishlist</a>
<a href="exportCSV" class="button btn btn-sm btn-primary"><i class="fa fa-download"></i> Export CSV Wishlist</a>
<div id="subhead_container" class="row">
<form action="search" method="get">
<div id="subhead_menu" class="col-xs-12 col-md-8">
<a href="importAlternate" class="button btn btn-sm btn-primary"><i class="fa fa-book"></i> Import Book</a>
<button class="button btn btn-sm btn-primary" type="button" value="importcsv" id="importcsv"><i class="fa fa-download"></i> Import CSV Wishlist</button>
<button class="button btn btn-sm btn-primary" type="button" value="exportcsv" id="exportcsv"><i class="fa fa-upload"></i> Export CSV Wishlist</button>
</div>
<div class="clearfix visible-xs"><hr/></div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="sr-only">Search</label>
<div class="input-group">
<input type="text" class="form-control deletable input-sm col-xs-12" value="" onfocus="if(this.value==this.defaultValue) this.value='';" name="name" placeholder="Title / Author / ISBN" id="searchbox" name="searchbox">
<span class="input-group-btn">
<button type="submit" value="Book" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Search for book"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</%def>
<%def name="body()">
<h1>${title}</h1>
Expand Down Expand Up @@ -71,6 +86,39 @@ <h1>${title}</h1>
if ( show != '1' ) { showimg = false }
else { showimg = true }

$('#exportcsv').on('click', function(e) {
$.get('exportCSV', function(data) {
bootbox.dialog({
title: 'CSV Export Result',
message: '<pre>'+data+'</pre>',
buttons: {
primary: {
label: "Close",
className: 'btn-primary'
},
}
});
});
});

$('#importcsv').on('click', function(e) {
$.get('importCSV', function(data) {
var myModal = bootbox.dialog({
title: 'CSV Import Info',
message: '<pre>'+data+'</pre>',
buttons: {
primary: {
label: "Close",
className: 'btn-primary'
},
}
});
setTimeout(function(){
myModal.modal('hide');
}, 5000);
});
});

var table = $('#book_table').DataTable(
{
"bAutoWidth": false,
Expand Down
20 changes: 20 additions & 0 deletions data/interfaces/bookstrap/searchresults.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
<%!
import lazylibrarian
%>
<%def name="headerIncludes()">
<div id="subhead_container" class="row">
<form action="search" method="get">
<div id="subhead_menu" class="col-xs-12 col-md-8">
</div>
<div class="clearfix visible-xs"><hr/></div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="sr-only">Search</label>
<div class="input-group">
<input type="text" class="form-control deletable input-sm col-xs-12" value="" onfocus="if(this.value==this.defaultValue) this.value='';" name="name" placeholder="Title / Author / ISBN" id="searchbox" name="searchbox">
<span class="input-group-btn">
<button type="submit" value="Book" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Search for book"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</div>
</form>
</div>
</%def>
<%def name="body()">

<h1>${title}</h1>
Expand Down
28 changes: 24 additions & 4 deletions data/interfaces/bookstrap/series.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
import lazylibrarian
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<a href="authorPage?AuthorID=${authorid}" class="btn btn-sm btn-primary"><i class="fa fa-chevron-left"></i> Return to Author</a>
<a href="refreshAuthor?AuthorID=${authorid}" class="btn btn-sm btn-primary"><i class="fa fa-refresh"></i> Refresh Author</a>
</div>
<div id="subhead_container" class="row">
<form action="search" method="get">
<div id="subhead_menu" class="col-xs-12 col-md-8">
%if authorid != None:
<a href="authorPage?AuthorID=${authorid}" class="btn btn-sm btn-primary"><i class="fa fa-chevron-left"></i> Return to Author</a>
%else:
<label for="dummy" class="control-label"> </label>
%endif
</div>
<div class="clearfix visible-xs"><hr/></div>
<div class="col-xs-12 col-md-4">
<div class="form-group">
<label class="sr-only">Search</label>
<div class="input-group">
<input type="text" class="form-control deletable input-sm col-xs-12" value="" onfocus="if(this.value==this.defaultValue) this.value='';" name="name" placeholder="Title / Author / ISBN" id="searchbox" name="searchbox">
<span class="input-group-btn">
<button type="submit" value="Book" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="bottom" title="Search for book"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</div>
</form>
</div>
</%def>

<%def name="body()">
<h1>${title}</h1>
<form action="series" method="get" class="form-inline">
Expand Down
1 change: 1 addition & 0 deletions lazylibrarian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
MAG_UPDATE = 0
EBOOK_UPDATE = 0
AUDIO_UPDATE = 0
AUTHORS_UPDATE = 0

# Shared dictionaries
isbn_979_dict = {
Expand Down
3 changes: 3 additions & 0 deletions lazylibrarian/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,17 @@ def dbUpdate(refresh=False):
myDB = database.DBConnection()
cmd = 'SELECT AuthorID from authors WHERE Status="Active" or Status="Loading" order by DateAdded ASC'
activeauthors = myDB.select(cmd)
lazylibrarian.AUTHORS_UPDATE = True
logger.info('Starting update for %i active author%s' % (len(activeauthors), plural(len(activeauthors))))
for author in activeauthors:
authorid = author['AuthorID']
# noinspection PyUnresolvedReferences
lazylibrarian.importer.addAuthorToDB(refresh=refresh, authorid=authorid)
logger.info('Active author update complete')
lazylibrarian.AUTHORS_UPDATE = False
return 'Updated %i active author%s' % (len(activeauthors), plural(len(activeauthors)))
except Exception:
lazylibrarian.AUTHORS_UPDATE = False
msg = 'Unhandled exception in dbUpdate: %s' % traceback.format_exc()
logger.error(msg)
return msg
Expand Down
Loading

0 comments on commit 89a9e68

Please sign in to comment.