mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 16:26:30 +01:00
Some webclient suggestions and practice committing to evennia.
text2html.py and webclient.css * Remove inline formatting and place in CSS file. This frees up the client to change the basic color scheme without modifying the server file. * Added a target="_blank" to links that are created to force a new tab (or window) to be opened in lieu of leaving the web client when a link is clicked. webclient.html * Added a void action to the form, just in case. evennia_webclient.js * Added code to move the caret to the end of the input box when the history is changed (up or down arrow listeners).
This commit is contained in:
parent
6d73b05d91
commit
e164b63d2b
4 changed files with 75 additions and 18 deletions
|
|
@ -41,24 +41,25 @@ class TextToHTMLparser(object):
|
|||
re.S|re.M|re.I)
|
||||
|
||||
def re_color(self, text):
|
||||
"Replace ansi colors with html color tags"
|
||||
"""Replace ansi colors with html color class names.
|
||||
Let the client choose how it will display colors, if it wishes to."""
|
||||
for colorname, code in self.colorcodes:
|
||||
regexp = "(?:%s)(.*?)(?:%s)" % (code, self.normalcode)
|
||||
regexp = regexp.replace('[', r'\[')
|
||||
text = re.sub(regexp, r'''<span style="color: %s">\1</span>''' % colorname, text)
|
||||
text = re.sub(regexp, r'''<span class="%s">\1</span>''' % colorname, text)
|
||||
return text
|
||||
|
||||
def re_bold(self, text):
|
||||
"Replace ansi hilight with bold text"
|
||||
"Replace ansi hilight with strong text element."
|
||||
regexp = "(?:%s)(.*?)(?:%s)" % ('\033[1m', self.normalcode)
|
||||
regexp = regexp.replace('[', r'\[')
|
||||
return re.sub(regexp, r'<span style="font-weight:bold">\1</span>', text)
|
||||
return re.sub(regexp, r'<strong>\1</strong>', text)
|
||||
|
||||
def re_underline(self, text):
|
||||
"Replace ansi underline with html equivalent"
|
||||
"Replace ansi underline with html underline class name."
|
||||
regexp = "(?:%s)(.*?)(?:%s)" % ('\033[4m', self.normalcode)
|
||||
regexp = regexp.replace('[', r'\[')
|
||||
return re.sub(regexp, r'<span style="text-decoration: underline">\1</span>', text)
|
||||
return re.sub(regexp, r'<span class="underline">\1</span>', text)
|
||||
|
||||
def remove_bells(self, text):
|
||||
"Remove ansi specials"
|
||||
|
|
@ -79,7 +80,9 @@ class TextToHTMLparser(object):
|
|||
def convert_urls(self, text):
|
||||
"Replace urls (http://...) by valid HTML"
|
||||
regexp = r"((ftp|www|http)(\W+\S+[^).,:;?\]\}(\<span\>) \r\n$]+))"
|
||||
return re.sub(regexp, r'<a href="\1">\1</a> ', text)
|
||||
# -> added target to output prevent the web browser from attempting to
|
||||
# change pages (and losing our webclient session).
|
||||
return re.sub(regexp, r'<a href="\1" target="_blank">\1</a>', text)
|
||||
|
||||
def do_sub(self, m):
|
||||
"Helper method to be passed to re.sub."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue