Added images of covers
This commit is contained in:
parent
a72e51c7da
commit
b6e818d66d
|
@ -1,3 +1,4 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
test/
|
test/
|
||||||
input/
|
input/
|
||||||
|
images/
|
||||||
|
|
2
TODO
2
TODO
|
@ -0,0 +1,2 @@
|
||||||
|
- Improve file unzip and images storage with some caching method
|
||||||
|
Don't use the copy from the temporary directory
|
3
main.py
3
main.py
|
@ -54,6 +54,9 @@ tmpOutDir = tempfile.mkdtemp()
|
||||||
zipHandler = zipfile.ZipFile(settings.path, 'r')
|
zipHandler = zipfile.ZipFile(settings.path, 'r')
|
||||||
zipHandler.extractall(tmpOutDir)
|
zipHandler.extractall(tmpOutDir)
|
||||||
zipHandler.close()
|
zipHandler.close()
|
||||||
|
# Move images to webserver folder
|
||||||
|
sh.rmtree('./images')
|
||||||
|
sh.move(tmpOutDir + '/images', '.')
|
||||||
|
|
||||||
# Get a Python-friendly library struct from XML file
|
# Get a Python-friendly library struct from XML file
|
||||||
library = tcparser.getLibrary(tmpOutDir + "/tellico.xml")
|
library = tcparser.getLibrary(tmpOutDir + "/tellico.xml")
|
||||||
|
|
|
@ -26,9 +26,16 @@ table {
|
||||||
|
|
||||||
thead {
|
thead {
|
||||||
background-color: #CECECE;
|
background-color: #CECECE;
|
||||||
|
position: sticky;
|
||||||
|
top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
td, th {
|
td, th {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 200px;
|
||||||
|
}
|
||||||
|
|
11
tcparser.py
11
tcparser.py
|
@ -37,6 +37,8 @@ def getLibrary(path):
|
||||||
newbook['isbn'] = j.text.replace('-', '')
|
newbook['isbn'] = j.text.replace('-', '')
|
||||||
for j in i.iter('pages'):
|
for j in i.iter('pages'):
|
||||||
newbook['pages'] = int(j.text)
|
newbook['pages'] = int(j.text)
|
||||||
|
for j in i.iter('cover'):
|
||||||
|
newbook['cover'] = j.text
|
||||||
newbook['authors'] = list()
|
newbook['authors'] = list()
|
||||||
for j in i.iter('authors'):
|
for j in i.iter('authors'):
|
||||||
for k in j.findall('author'):
|
for k in j.findall('author'):
|
||||||
|
@ -91,7 +93,7 @@ def getHTML(library):
|
||||||
table.append(thead)
|
table.append(thead)
|
||||||
thead.append(tr)
|
thead.append(tr)
|
||||||
|
|
||||||
for i in ('ID', 'Title', 'Publisher', 'Year', 'ISBN', 'Pages', 'Author'):
|
for i in ('ID', 'Cover', 'Title', 'Publisher', 'Year', 'ISBN', 'Pages', 'Author'):
|
||||||
th = ET.Element('th')
|
th = ET.Element('th')
|
||||||
th.text = i
|
th.text = i
|
||||||
tr.append(th)
|
tr.append(th)
|
||||||
|
@ -104,6 +106,13 @@ def getHTML(library):
|
||||||
id.text = str(i.get('id'))
|
id.text = str(i.get('id'))
|
||||||
tr.append(id)
|
tr.append(id)
|
||||||
|
|
||||||
|
cover = ET.Element('td')
|
||||||
|
if i.get('cover'):
|
||||||
|
img = ET.Element('img', attrib={'alt': 'Book "' + i.get('title') + '" cover', 'src': 'images/' + i.get('cover')})
|
||||||
|
cover.append(img)
|
||||||
|
|
||||||
|
tr.append(cover)
|
||||||
|
|
||||||
title = ET.Element('td')
|
title = ET.Element('td')
|
||||||
title.text = i.get('title')
|
title.text = i.get('title')
|
||||||
tr.append(title)
|
tr.append(title)
|
||||||
|
|
Loading…
Reference in New Issue