mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: web: show log files in project
This commit is contained in:
@@ -1,28 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
{% include 'header.html' %}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
{% include 'navigation.html' %}
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<ul class="nav nav-tabs flex-column" id="myTab" role="tablist">
|
<ul class="nav nav-tabs flex-column" id="myTab" role="tablist">
|
||||||
{% for log_file in log_files %}
|
{% for log_file in log_files %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button
|
<button
|
||||||
class="nav-link"
|
class="nav-link {% if loop.last %}active{% endif %}"
|
||||||
id="project-{{log_file['id']}}-tab"
|
id="project-{{log_file['id']}}-tab"
|
||||||
data-bs-toggle="tab"
|
data-bs-toggle="tab"
|
||||||
data-bs-target="#project-{{log_file['id']}}"
|
data-bs-target="#project-{{log_file['id']}}"
|
||||||
type="button"
|
type="button"
|
||||||
role="tab"
|
role="tab"
|
||||||
aria-controls="project-{{log_file['id']}}"
|
aria-controls="project-{{log_file['id']}}"
|
||||||
aria-selected="true"
|
aria-selected="{% if loop.last %}true{% else %}false{% endif %}"
|
||||||
>{{log_file['name']}}</button>
|
>{{log_file['name']}}</button>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -33,13 +24,13 @@
|
|||||||
<div class="tab-content" id="myTabContent">
|
<div class="tab-content" id="myTabContent">
|
||||||
{% for log_file in log_files %}
|
{% for log_file in log_files %}
|
||||||
<div
|
<div
|
||||||
class="tab-pane fade"
|
class="tab-pane fade {% if loop.last %}show active{% endif %}"
|
||||||
id="project-{{log_file['id']}}"
|
id="project-{{log_file['id']}}"
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
aria-labelledby="project-{{log_file['id']}}-tab"
|
aria-labelledby="project-{{log_file['id']}}-tab"
|
||||||
>
|
>
|
||||||
<div style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}
|
<div style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@@ -47,6 +38,3 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
+29
-26
@@ -7,20 +7,10 @@
|
|||||||
{% include 'navigation.html' %}
|
{% include 'navigation.html' %}
|
||||||
|
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
|
|
||||||
<h1> Project {{project_name}} </h1>
|
<h1> Project {{project_name}} </h1>
|
||||||
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- a bootstrap dropdown to select one of the log files -->
|
|
||||||
<div class="col-md-3">
|
|
||||||
|
|
||||||
<form method="POST" enctype="multipart/form-data" action="/add_project">
|
<form method="POST" enctype="multipart/form-data" action="/add_project">
|
||||||
|
<div class="row">
|
||||||
<div class="row row-cols-lg-auto g-3">
|
<div class="col-4">
|
||||||
|
|
||||||
<input type="text" name="project_name" class="hidden form-control" value="{{project_name}}"
|
<input type="text" name="project_name" class="hidden form-control" value="{{project_name}}"
|
||||||
placeholder="Projekt" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
|
placeholder="Projekt" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
|
||||||
|
|
||||||
@@ -42,6 +32,8 @@
|
|||||||
{{exe}}</option>
|
{{exe}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
|
||||||
<select class="form-select" name="source_style" aria-label="SOURCESTYLE">
|
<select class="form-select" name="source_style" aria-label="SOURCESTYLE">
|
||||||
{% for name, value in sourcestyles %}
|
{% for name, value in sourcestyles %}
|
||||||
@@ -51,6 +43,16 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="inject_style" aria-label="INJECTSTYLE">
|
||||||
|
{% for name, value in injectstyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if value in project.settings.inject_style.value %} selected {% endif %}
|
||||||
|
>{{value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
<select class="form-select" name="alloc_style" aria-label="ALLOCSTYLE">
|
<select class="form-select" name="alloc_style" aria-label="ALLOCSTYLE">
|
||||||
{% for name, value in allocstyles %}
|
{% for name, value in allocstyles %}
|
||||||
<option value="{{name}}"
|
<option value="{{name}}"
|
||||||
@@ -75,26 +77,27 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select class="form-select" name="inject_style" aria-label="INJECTSTYLE">
|
</div>
|
||||||
{% for name, value in injectstyles %}
|
|
||||||
<option value="{{name}}"
|
|
||||||
{% if value in project.settings.inject_style.value %} selected {% endif %}
|
|
||||||
>{{value}}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button class="btn btn-primary" type="submit" value="save">Save</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<button class="btn btn-primary" type="submit" value="save">Save</button>
|
||||||
|
|
||||||
<form method="POST" enctype="multipart/form-data" action="/start_project">
|
<form method="POST" enctype="multipart/form-data" action="/start_project">
|
||||||
<input type="hidden" name="project_name" value="{{project_name}}">
|
<input type="hidden" name="project_name" value="{{project_name}}">
|
||||||
<button class="btn btn-primary" type="submit" value="start">Start</button>
|
<button class="btn btn-primary" type="submit" value="start">Start</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
{% include 'files.html' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+20
-14
@@ -33,6 +33,7 @@ def index():
|
|||||||
@views.route("/project/<name>")
|
@views.route("/project/<name>")
|
||||||
def project(name):
|
def project(name):
|
||||||
project = storage.get_project(name)
|
project = storage.get_project(name)
|
||||||
|
log_files = get_logfiles()
|
||||||
|
|
||||||
exes = []
|
exes = []
|
||||||
for file in os.listdir("app/upload/exe"):
|
for file in os.listdir("app/upload/exe"):
|
||||||
@@ -59,6 +60,8 @@ def project(name):
|
|||||||
decoderstyles=decoderstyles,
|
decoderstyles=decoderstyles,
|
||||||
execstyles=execstyles,
|
execstyles=execstyles,
|
||||||
injectstyles=injectstyles,
|
injectstyles=injectstyles,
|
||||||
|
|
||||||
|
log_files=log_files,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -167,8 +170,14 @@ def build():
|
|||||||
|
|
||||||
@views.route("/files")
|
@views.route("/files")
|
||||||
def files():
|
def files():
|
||||||
log_files = []
|
log_files = get_logfiles()
|
||||||
|
return render_template('files.html',
|
||||||
|
log_files=log_files
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_logfiles():
|
||||||
|
log_files = []
|
||||||
id = 0
|
id = 0
|
||||||
asm_a = "" # for diff
|
asm_a = "" # for diff
|
||||||
asm_b = ""
|
asm_b = ""
|
||||||
@@ -181,7 +190,7 @@ def files():
|
|||||||
if file.endswith(".bin"):
|
if file.endswith(".bin"):
|
||||||
continue
|
continue
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
print("FILE: {}".format(file))
|
||||||
if 'main_c' in file:
|
if 'main_c' in file:
|
||||||
data = highlight(data, CLexer(), HtmlFormatter(full=False))
|
data = highlight(data, CLexer(), HtmlFormatter(full=False))
|
||||||
elif '_asm_' in file:
|
elif '_asm_' in file:
|
||||||
@@ -191,17 +200,18 @@ def files():
|
|||||||
if '_updated' in file:
|
if '_updated' in file:
|
||||||
asm_b = data
|
asm_b = data
|
||||||
data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
|
data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
|
||||||
elif '_shc' in file:
|
elif '.ascii' in file:
|
||||||
if '.txt' in file:
|
data = conv.convert(data, full=False)
|
||||||
|
elif '.txt' in file:
|
||||||
# skip it
|
# skip it
|
||||||
continue
|
continue
|
||||||
if '.ascii' in file:
|
elif '.hex' in file:
|
||||||
data = conv.convert(data, full=False)
|
print("-> hex")
|
||||||
if '.hex' in file:
|
continue
|
||||||
data = escape(data)
|
#data = escape(data)
|
||||||
#data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
|
#data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
|
||||||
elif '.log' in file:
|
elif '.log' in file:
|
||||||
data = escape(data)
|
data = conv.convert(data, full=False)
|
||||||
else:
|
else:
|
||||||
data = escape(data)
|
data = escape(data)
|
||||||
|
|
||||||
@@ -230,8 +240,4 @@ def files():
|
|||||||
id += 1
|
id += 1
|
||||||
#asm_a = ""
|
#asm_a = ""
|
||||||
asm_b = ""
|
asm_b = ""
|
||||||
|
return log_files
|
||||||
|
|
||||||
return render_template('project.html',
|
|
||||||
log_files=log_files
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user