mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-19 05:57:20 +00:00
bugfix in .url file
This commit is contained in:
@@ -300,8 +300,9 @@ def new_image_form(request, path):
|
||||
editor = form.cleaned_data["who_are_you"]
|
||||
editor = git_string(editor)
|
||||
title = form.cleaned_data["header"]
|
||||
referer = request.headers["Referer"].replace("_edit","") # original page being edited
|
||||
host = request.headers["Host"]
|
||||
referer = request.headers["Referer"] # original
|
||||
host = request.headers["Host"]
|
||||
print(f"{host=}")
|
||||
f = request.FILES["file_"]
|
||||
if not title:
|
||||
title = f.name
|
||||
@@ -455,7 +456,7 @@ def save_original_in_expofiles(f, year, photographer, host, handbook_directory,
|
||||
f.open() # rewind to beginning
|
||||
content = f.read()
|
||||
write_binary_file(filepath, content)
|
||||
write_url_file(filepath, f.name, handbook_directory, page)
|
||||
write_url_file(filepath, host, handbook_directory, page)
|
||||
elif isinstance(f, TemporaryUploadedFile):
|
||||
if filepath.is_file:
|
||||
print(f"+++++ Out of cheese error\n Destination EXISTS {filepath}")
|
||||
@@ -479,11 +480,18 @@ def save_original_in_expofiles(f, year, photographer, host, handbook_directory,
|
||||
raise TypeError(msg)
|
||||
return
|
||||
|
||||
def write_url_file(targetpath, host, handbook_rel_path, page):
|
||||
def write_url_file(targetpath, host, handbook_rel_path, page):
|
||||
"""
|
||||
page is the referrer page, which is sort-of what we want,
|
||||
but troggle URLs are such that this is not the same page we want to be visiting, e.g.
|
||||
if he referrer is a "_edit" page, then we want to go to the view page, not the edit page.
|
||||
ALSO ths will be different if the page is a Cave Description Page, and Entrance page pr a Handbook page.
|
||||
"""
|
||||
# the ".url" is there, just never visible in Windows Explorer.
|
||||
|
||||
# FIND AND FIX the correct host for this !
|
||||
content = f"[InternetShortcut]\nURL={page}\n\n[TroggleImage]\nURL=http://{host}/{handbook_rel_path}"
|
||||
content = content.replace("localhost:8000", "expo.survex.com")
|
||||
print(content)
|
||||
filepath = targetpath.with_suffix(".url")
|
||||
write_files([(filepath, content, "utf8")])
|
||||
|
||||
Reference in New Issue
Block a user