Skip to content

Commit

Permalink
Index entries: link in current popup is deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Jan 27, 2020
1 parent ecdd3c6 commit 443971b
Showing 1 changed file with 32 additions and 64 deletions.
96 changes: 32 additions & 64 deletions eoapublications/management/commands/publicationimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,23 @@ def process_as_string(self,xmlElement):
for xmlChild in xmlElement.iterchildren():
strResult = strResult + etree.tostring(xmlChild).decode()
return strResult
def process_index_entries(self,xmlIndex,xmlElement,Newelement,Newpublication):
for xmlEntry in xmlElement.findall('EOAindex'):
if xmlEntry.get("secondary") is not None:
continue
Newindexelement = Indexelement(Element=Newelement)
strMainEntry = xmlEntry.get("main")
strHtml = strMainEntry + ": "
# Find corresponding Entry in EOAprintindex
for xmlIndexEntry in xmlIndex.findall(".//EOAindexentry"):
if xmlIndexEntry.get("main") == strMainEntry:
intLinkNumber = 1
for xmlIndexLink in xmlIndexEntry.findall("./EOAindexlink"):
strHtml = strHtml + "<a href='/" + Newpublication.Serie.lower() + "/" + \
Newpublication.Number + "/" + xmlIndexLink.get("chapterorder") + "/index.html#"\
+ xmlIndexLink.get('elementorder') + "'>"
strHtml = strHtml + str(intLinkNumber)
strHtml = strHtml + "</a> "
intLinkNumber += 1
strHtml = strHtml + "<br/>"
Newindexelement.Html = strHtml
Newindexelement.save()
def process_personindex_entries(self,xmlPersonindex,xmlElement,Newelement,Newpublication):
for xmlEntry in xmlElement.findall('EOAindexperson'):
if xmlEntry.get("secondary") is not None:
continue
Newindexelement = Indexelement(Element=Newelement)
strMainEntry = xmlEntry.get("main")
if xmlEntry.get("display") is not None:
strHtml = xmlEntry.get("display") + ": "
else:
strHtml = xmlEntry.get("main") + ": "
# Find corresponding Entry in EOAprintindex
for xmlIndexEntry in xmlPersonindex.findall(".//EOAindexentry"):
if xmlIndexEntry.get("main") == strMainEntry:
intLinkNumber = 1
for xmlIndexLink in xmlIndexEntry.findall("./EOAindexlink"):
strHtml = strHtml + "<a href='/" + Newpublication.Serie.lower() + "/" + \
Newpublication.Number + "/" + xmlIndexLink.get("chapterorder") + "/index.html#"\
+ xmlIndexLink.get('elementorder') + "'>"
strHtml = strHtml + str(intLinkNumber)
strHtml = strHtml + "</a> "
intLinkNumber += 1
strHtml = strHtml + "<br/>"
Newindexelement.Html = strHtml
Newindexelement.save()
def process_locationindex_entries(self,xmlLocationindex,xmlElement,Newelement,Newpublication):
for xmlEntry in xmlElement.findall('EOAindexlocation'):
# def process_as_string ends here

def process_index_entries(self, xmlIndex, xmlElement, xmlChapter, Newelement, Newpublication, index_type):
"""Construct the popups for index entries next to paragraphs."""

if index_type == "keyword":
xml_entries = xmlElement.findall('.//EOAindex')
elif index_type == "person":
xml_entries = xmlElement.findall('.//EOAindexperson')
elif index_type == "location":
xml_entries = xmlElement.findall('.//EOAindexlocation')
else:
print("No suitable index found.")

for xmlEntry in xml_entries:
current_chapter_order = xmlChapter.get('order')
current_element_order = xmlElement.get('order')
if xmlEntry.get("secondary") is not None:
continue
Newindexelement = Indexelement(Element=Newelement)
Expand All @@ -79,27 +49,25 @@ def process_locationindex_entries(self,xmlLocationindex,xmlElement,Newelement,Ne
else:
strHtml = xmlEntry.get("main") + ": "
# Find corresponding Entry in EOAprintindex
for xmlIndexEntry in xmlLocationindex.findall(".//EOAindexentry"):
for xmlIndexEntry in xmlIndex.findall(".//EOAindexentry"):
if xmlIndexEntry.get("main") == strMainEntry:
intLinkNumber = 1
for xmlIndexLink in xmlIndexEntry.findall("./EOAindexlink"):
strHtml = strHtml + "<a href='/" + Newpublication.Serie.lower() + "/" + \
if xmlIndexLink.get("chapterorder") == current_chapter_order and xmlIndexLink.get('elementorder') == current_element_order:
strHtml = strHtml + "<span>" + str(intLinkNumber) + "</span> "
else:
strHtml = strHtml + "<a href='/" + Newpublication.Serie.lower() + "/" + \
Newpublication.Number + "/" + xmlIndexLink.get("chapterorder") + "/index.html#"\
+ xmlIndexLink.get('elementorder') + "'>"
strHtml = strHtml + str(intLinkNumber)
strHtml = strHtml + "</a> "
strHtml = strHtml + str(intLinkNumber)
strHtml = strHtml + "</a> "
intLinkNumber += 1
strHtml = strHtml + "<br/>"
Newindexelement.Html = strHtml
print ("Index Entry for Location Processed:")
print(strHtml)
Newindexelement.save()
# def process_index_entries ends here



print (xmlEntry.get("main"))
return

def process_indexsection(self, xmlIndexsection, intObjectOrder, intIndexEntry, publication_number, index_type, Newpublication, olddesign=False):
"""Create HTML code for indexsections"""

Expand Down Expand Up @@ -545,15 +513,15 @@ def handle(self, **options):
if xmlChild.findall("EOAindex") is not None:
xmlEOAindex = xmlTree.find(".//EOAprintindex")
if xmlEOAindex is not None:
self.process_index_entries(xmlEOAindex,xmlChild,Newelement,Newpublication)
self.process_index_entries(xmlEOAindex,xmlChild,xmlChapter,Newelement,Newpublication, "keyword")
if xmlChild.findall("EOAindexperson") is not None:
xmlEOApersonindex = xmlTree.find(".//EOAprintpersonindex")
if xmlEOApersonindex is not None:
self.process_personindex_entries(xmlEOApersonindex,xmlChild,Newelement,Newpublication)
xmlEOAindex = xmlTree.find(".//EOAprintpersonindex")
if xmlEOAindex is not None:
self.process_index_entries(xmlEOAindex,xmlChild,xmlChapter,Newelement,Newpublication, "person")
if xmlChild.findall("EOAindexlocation") is not None:
xmlEOAlocationindex = xmlTree.find(".//EOAprintlocationindex")
if xmlEOAlocationindex is not None:
self.process_locationindex_entries(xmlEOAlocationindex,xmlChild,Newelement,Newpublication)
xmlEOAindex = xmlTree.find(".//EOAprintlocationindex")
if xmlEOAindex is not None:
self.process_index_entries(xmlEOAindex,xmlChild,xmlChapter,Newelement,Newpublication, "location")
xmlFacsimileparts = xmlTree.findall("EOAfacsimilepart")
for xmlFacsimilepart in xmlFacsimileparts:
print("Process Facsimileparts")
Expand Down

0 comments on commit 443971b

Please sign in to comment.