From fed25c77f4ae953cee4a2a587a7176f7f9d2593c Mon Sep 17 00:00:00 2001 From: reimannsum Date: Sun, 12 Jun 2016 22:19:03 -0400 Subject: [PATCH] Improvements to HTML spoiler Changed how Creativity card examples are handled as to not flood magiccards.info and cause it to blacklist computer. Also added forum spoiler to each card. changed the link for similar cards to the magiccards.info page. --- decode.py | 10 +- lib/cardlib.py | 25 +- lib/html_extra_data.py | 820 +++++++++++++++++++++++------------------ 3 files changed, 478 insertions(+), 377 deletions(-) diff --git a/decode.py b/decode.py index 4f0bd19..f4373ac 100755 --- a/decode.py +++ b/decode.py @@ -69,9 +69,9 @@ def main(fname, oname = None, verbose = True, encoding = 'std', namestr = '' if for_html: if code: - namestr = ('
' + truename - + 'image' + ': ' + str(dist) + '
') + namestr = ('
' + ': ' + str(dist) + '
') else: namestr = '
' + truename + ': ' + str(dist) + '
' elif for_forum: @@ -111,10 +111,14 @@ def main(fname, oname = None, verbose = True, encoding = 'std', if creativity: cstring = '~~ closest cards ~~\n' + if for_html: + cstring += "
\n" nearest = card.nearest_cards for dist, cardname in nearest: cstring += hoverimg(cardname, dist, namediff) cstring += '~~ closest names ~~\n' + if for_html: + cstring += "
\n" nearest = card.nearest_names for dist, cardname in nearest: cstring += hoverimg(cardname, dist, namediff) diff --git a/lib/cardlib.py b/lib/cardlib.py index c655c17..5dc5a0c 100644 --- a/lib/cardlib.py +++ b/lib/cardlib.py @@ -651,6 +651,12 @@ class Card: rarity = self.__dict__[field_rarity] outstr += ' (' + rarity + ')' + if for_html and for_forum: + #force for_html to false to create tootip with forum spoiler + outstr += ('
[F]

' + + self.format(gatherer=gatherer, for_forum=for_forum, for_html=False, vdump=vdump).replace('\n', '
') + + '

') + if vdump: if not self.parsed: outstr += ' _UNPARSED_' @@ -736,6 +742,12 @@ class Card: outstr += ' _UNPARSED_' if not self.valid: outstr += ' _INVALID_' + + if for_html and for_forum: + #force for_html to false to create tootip with forum spoiler + outstr += ('
[F]

' + + self.format(gatherer=gatherer, for_forum=for_forum, for_html=False, vdump=vdump).replace('\n', '
') + + '

') outstr += linebreak @@ -810,13 +822,14 @@ class Card: outstr += linebreak outstr += self.bside.format(gatherer=gatherer, for_forum=for_forum, for_html=for_html, vdump=vdump) + # if for_html: + # if for_forum: + # outstr += linebreak + # # force for_html to false to create a copyable forum spoiler div + # outstr += ('
' + # + self.format(gatherer=gatherer, for_forum=for_forum, for_html=False, vdump=vdump).replace('\n', '
') + # + '
') if for_html: - if for_forum: - outstr += linebreak - # force for_html to false to create a copyable forum spoiler div - outstr += ('
' - + self.format(gatherer=gatherer, for_forum=for_forum, for_html=False, vdump=vdump).replace('\n', '
') - + '
') outstr += "" return outstr diff --git a/lib/html_extra_data.py b/lib/html_extra_data.py index db62a9d..60a3673 100644 --- a/lib/html_extra_data.py +++ b/lib/html_extra_data.py @@ -1,371 +1,455 @@ box_width = 350 html_prepend = """ - -""" + + + +"""