mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
ui: better website
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<ul class="nav nav-tabs flex-column" id="myTab" role="tablist">
|
||||
{% for log_file in log_files %}
|
||||
<li class="nav-item" role="presentation">
|
||||
@@ -29,7 +29,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-md-10">
|
||||
<div class="col-md-9">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
{% for log_file in log_files %}
|
||||
<div
|
||||
@@ -38,7 +38,7 @@
|
||||
role="tabpanel"
|
||||
aria-labelledby="project-{{log_file['id']}}-tab"
|
||||
>
|
||||
{{log_file['content']|safe}}
|
||||
<div style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
+49
-34
@@ -6,12 +6,16 @@ import io
|
||||
from typing import List, Tuple
|
||||
from datetime import date
|
||||
from pygments import highlight
|
||||
from pygments.lexers import CLexer, NasmLexer, DiffLexer
|
||||
from pygments.lexers import CLexer, NasmLexer, DiffLexer, HexdumpLexer
|
||||
from pygments.formatters import HtmlFormatter
|
||||
import difflib
|
||||
from ansi2html import Ansi2HTMLConverter
|
||||
|
||||
|
||||
views = Blueprint('views', __name__)
|
||||
|
||||
conv = Ansi2HTMLConverter()
|
||||
|
||||
|
||||
@views.route("/")
|
||||
def index():
|
||||
@@ -27,49 +31,60 @@ def project():
|
||||
asm_a = "" # for diff
|
||||
asm_b = ""
|
||||
for file in os.listdir("logs"):
|
||||
if file.endswith(".txt"):
|
||||
print("Handle: ", file)
|
||||
print("Handle: ", file)
|
||||
|
||||
with open(os.path.join("logs", file), "r") as f:
|
||||
data = f.read()
|
||||
with open(os.path.join("logs", file), "r") as f:
|
||||
data = f.read()
|
||||
|
||||
if 'main_c' in file:
|
||||
data = highlight(data, CLexer(), HtmlFormatter(full=False))
|
||||
elif '_asm' in file:
|
||||
# handle special cases
|
||||
if '_orig' in file:
|
||||
asm_a = data
|
||||
if '_cleanup' in file:
|
||||
asm_b = data
|
||||
if 'main_c' in file:
|
||||
data = highlight(data, CLexer(), HtmlFormatter(full=False))
|
||||
elif 'payload_asm' in file:
|
||||
# handle special cases
|
||||
if '_orig' in file:
|
||||
asm_a = data
|
||||
if '_cleanup' in file:
|
||||
asm_b = data
|
||||
|
||||
data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
|
||||
elif 'shc_from_asm' in file:
|
||||
if '.txt' in file:
|
||||
# skip it
|
||||
continue
|
||||
if '.ascii' in file:
|
||||
#data = data.replace(" ", " ")
|
||||
data = conv.convert(data, full=False)
|
||||
#data = data.replace("\n", "<br>")
|
||||
if '.hex' in file:
|
||||
#data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
|
||||
#data = data.replace("\n", "<br>")
|
||||
#data = data.replace(" ", " ")
|
||||
data = data
|
||||
|
||||
data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
|
||||
entry = {
|
||||
"name": file,
|
||||
"id": str(id),
|
||||
"content": data,
|
||||
}
|
||||
log_files.append(entry)
|
||||
id += 1
|
||||
|
||||
# more
|
||||
if asm_a != "" and asm_b != "":
|
||||
# do the diff from the content of the two files
|
||||
a = asm_a.splitlines()
|
||||
b = asm_b.splitlines()
|
||||
diff_generator = difflib.unified_diff(a, b, lineterm='')
|
||||
diff_string = '\n'.join(diff_generator)
|
||||
diff_l = highlight(diff_string, DiffLexer(), HtmlFormatter(full=False))
|
||||
entry = {
|
||||
"name": file,
|
||||
"name": "_asm_diff".format(),
|
||||
"id": str(id),
|
||||
"content": data,
|
||||
"content": diff_l,
|
||||
}
|
||||
log_files.append(entry)
|
||||
id += 1
|
||||
|
||||
# more
|
||||
if asm_a != "" and asm_b != "":
|
||||
# do the diff from the content of the two files
|
||||
a = asm_a.splitlines()
|
||||
b = asm_b.splitlines()
|
||||
diff_generator = difflib.unified_diff(a, b, lineterm='')
|
||||
diff_string = '\n'.join(diff_generator)
|
||||
diff_l = highlight(diff_string, DiffLexer(), HtmlFormatter(full=False))
|
||||
entry = {
|
||||
"name": "_asm_diff".format(),
|
||||
"id": str(id),
|
||||
"content": diff_l,
|
||||
}
|
||||
log_files.append(entry)
|
||||
id += 1
|
||||
asm_a = ""
|
||||
asm_b = ""
|
||||
asm_a = ""
|
||||
asm_b = ""
|
||||
|
||||
|
||||
return render_template('project.html',
|
||||
|
||||
Reference in New Issue
Block a user