Fix donationmessage plugin

This commit is contained in:
HelloZeroNet 2016-03-16 23:25:27 +01:00
parent 77ac1ae796
commit f241a9aef3
1 changed files with 12 additions and 14 deletions

View File

@ -6,19 +6,17 @@ from Plugin import PluginManager
@PluginManager.registerTo("UiRequest")
class UiRequestPlugin(object):
# Inject a donation message to every page top right corner
def actionWrapper(self, path):
back = super(UiRequestPlugin, self).actionWrapper(path)
if not back or not hasattr(back, "endswith"): return back # Wrapper error or not string returned, injection not possible
# Inject a donation message to every page top right corner
def renderWrapper(self, *args, **kwargs):
body = super(UiRequestPlugin, self).renderWrapper(*args, **kwargs) # Get the wrapper frame output
back = re.sub("</body>\s*</html>\s*$",
"""
<style>
#donation_message { position: absolute; bottom: 0px; right: 20px; padding: 7px; font-family: Arial; font-size: 11px }
</style>
<a id='donation_message' href='https://blockchain.info/address/1QDhxQ6PraUZa21ET5fYUCPgdrwBomnFgX' target='_blank'>Please donate to help to keep this ZeroProxy alive</a>
</body>
</html>
""", back)
inject_html = """
<style>
#donation_message { position: absolute; bottom: 0px; right: 20px; padding: 7px; font-family: Arial; font-size: 11px }
</style>
<a id='donation_message' href='https://blockchain.info/address/1QDhxQ6PraUZa21ET5fYUCPgdrwBomnFgX' target='_blank'>Please donate to help to keep this ZeroProxy alive</a>
</body>
</html>
"""
return back
return re.sub("</body>\s*</html>\s*$", inject_html, body)