Skip to content

Commit

Permalink
generator
Browse files Browse the repository at this point in the history
  • Loading branch information
bryangerlach committed Sep 11, 2024
1 parent 4cebff7 commit 52dd85b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions api/templates/clients.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,20 @@
{% endfor %}
</tbody>
</table>
<table class="sortable">
<thead></thead>
<tbody>
<tr>
<th>File</th>
<th>Date</th>
</tr>
{% for filename, fileinfo in client_custom_files.items %}
<tr>
<td><a href='/api/download?filename={{filename}}&path={{fileinfo.path}}'>{{filename}}</a></td>
<td>{{fileinfo.modified}}</td>
</tr>
{% endfor %}
</tbody>
</table>

{% endblock %}
14 changes: 13 additions & 1 deletion api/views_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ def clients(request):
linuxx86_64 = os.path.join(basedir,'linux','x86_64')
mocos = os.path.join(basedir,'macOS')
sciter = os.path.join(basedir,'sciter')
custom = os.path.join(basedir,'custom')
client_files = {}
client_custom_files = {}
if os.path.exists(basedir):
for file in os.listdir(basedir):
if (file.endswith(".exe") or file.endswith(".msi")):
Expand Down Expand Up @@ -411,7 +413,17 @@ def clients(request):
'modified': modified,
'path': sciter
}
return render(request, 'clients.html', {'client_files': client_files, 'phone_or_desktop': is_mobile(request)})
if os.path.exists(custom):
for file in os.listdir(custom):
if file.endswith(".exe"):
filepath = os.path.join(custom,file)
modified = datetime.datetime.fromtimestamp(os.path.getmtime(filepath)).strftime('%Y-%m-%d %I:%M:%S %p')
client_custom_files[file] = {
'file': file,
'modified': modified,
'path': custom
}
return render(request, 'clients.html', {'client_files': client_files, 'client_custom_files': client_custom_files, 'phone_or_desktop': is_mobile(request)})

def download_file(request, filename, path):
file_path = os.path.join(str(BASE_DIR),path,filename)
Expand Down
3 changes: 2 additions & 1 deletion api/views_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def update_github_run(request):

def save_custom_client(request):
file = request.FILES['file']
file_save_path = "static/%s.exe" % file.name
file_save_path = "clients/custom/%s" % file.name
pathlib.Path(file_save_path).mkdir(parents=True, exist_ok=True)
with open(file_save_path, "wb+") as f:
for chunk in file.chunks():
f.write(chunk)
Expand Down

0 comments on commit 52dd85b

Please sign in to comment.