mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
rotatable images & text
This commit is contained in:
parent
017f916ef9
commit
9c05cb6af0
@ -406,6 +406,16 @@ def expofilerename(request, filepath):
|
|||||||
Currently this just does files within wallets i.e. in /surveyscans/
|
Currently this just does files within wallets i.e. in /surveyscans/
|
||||||
and it returns control to the original wallet edit page
|
and it returns control to the original wallet edit page
|
||||||
"""
|
"""
|
||||||
|
def is_rotatable(path):
|
||||||
|
"""If file is a JPG but has no filename extension, then it must be renamed
|
||||||
|
before it can be rotated.
|
||||||
|
"""
|
||||||
|
print(f"{path}: '{Path(path).suffix.lower()}'")
|
||||||
|
if Path(path).suffix.lower() in [".png", ".jpg", ".jpeg"]:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def rotate_image():
|
def rotate_image():
|
||||||
wallet = str(Path(filepath).parent).lstrip("surveyscans/")
|
wallet = str(Path(filepath).parent).lstrip("surveyscans/")
|
||||||
cwd = settings.SCANS_ROOT / wallet
|
cwd = settings.SCANS_ROOT / wallet
|
||||||
@ -455,7 +465,9 @@ def expofilerename(request, filepath):
|
|||||||
"filesize": filesize,
|
"filesize": filesize,
|
||||||
"files": files,
|
"files": files,
|
||||||
"walletpath": walletpath,
|
"walletpath": walletpath,
|
||||||
|
"wallet": wallet,
|
||||||
"notpics": notpics,
|
"notpics": notpics,
|
||||||
|
"rotatable": rotatable,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -474,8 +486,11 @@ def expofilerename(request, filepath):
|
|||||||
else:
|
else:
|
||||||
filename = Path(filepath).name
|
filename = Path(filepath).name
|
||||||
walletpath = Path(filepath).parent
|
walletpath = Path(filepath).parent
|
||||||
|
wallet = Path(walletpath).name
|
||||||
folder = actualpath.parent
|
folder = actualpath.parent
|
||||||
filesize = f"{actualpath.stat().st_size:,}"
|
filesize = f"{actualpath.stat().st_size:,}"
|
||||||
|
rotatable= is_rotatable(filename)
|
||||||
|
|
||||||
|
|
||||||
if not actualpath.is_relative_to(Path(settings.SCANS_ROOT)):
|
if not actualpath.is_relative_to(Path(settings.SCANS_ROOT)):
|
||||||
message = f'\n Can only do rename within wallets (expofiles/surveyscans/) currently, sorry. "{actualpath}" '
|
message = f'\n Can only do rename within wallets (expofiles/surveyscans/) currently, sorry. "{actualpath}" '
|
||||||
@ -494,10 +509,10 @@ def expofilerename(request, filepath):
|
|||||||
for d in f.iterdir():
|
for d in f.iterdir():
|
||||||
dirs.append(f"{f.name}/{d.name}")
|
dirs.append(f"{f.name}/{d.name}")
|
||||||
if f.is_file():
|
if f.is_file():
|
||||||
if Path(f.name).suffix.lower() in [".jpg", ".jpeg", ".png"]:
|
if is_rotatable(f.name): # should allow all images here which can be thumsized, not just rotatables. e.g. PDF
|
||||||
files.append(f.name)
|
files.append(f.name)
|
||||||
else:
|
else:
|
||||||
notpics.append(f.name)
|
notpics.append(f.name)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
files.append(
|
files.append(
|
||||||
"(Error. There should be at least one filename visible here. Try refresh.)"
|
"(Error. There should be at least one filename visible here. Try refresh.)"
|
||||||
@ -537,6 +552,7 @@ def expofilerename(request, filepath):
|
|||||||
"filesize": filesize,
|
"filesize": filesize,
|
||||||
"files": files,
|
"files": files,
|
||||||
"walletpath": walletpath,
|
"walletpath": walletpath,
|
||||||
|
"wallet": wallet,
|
||||||
"notpics": notpics,
|
"notpics": notpics,
|
||||||
"rename_bad": rename_bad,
|
"rename_bad": rename_bad,
|
||||||
},
|
},
|
||||||
|
@ -37,15 +37,20 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
{% if rotatable %}
|
||||||
<form method ='post' >
|
<form method ='post' >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" name="rotate" type = "submit" title="Rotates 90 degrees clockwise. JPG and PNG files only." value = "Rotate" >
|
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" name="rotate" type = "submit" title="Rotates 90 degrees clockwise. JPG and PNG files only." value = "Rotate" >
|
||||||
Rotate it
|
Rotate it
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<p style="padding: 0.5em 25px; margin-left: 110px">Not a rotatable image.
|
||||||
|
{% endif %}
|
||||||
<br /><br /><br />
|
<br /><br /><br />
|
||||||
Full urlencoded path for this file in expofiles is <a href="/expofiles/{{filepath|urlencode}}"><em>{{filepath|urlencode}}</em></a>
|
Full urlencoded path for this file in expofiles is <a href="/expofiles/{{filepath|urlencode}}"><em>{{filepath|urlencode}}</em></a>
|
||||||
|
<br /><br />
|
||||||
|
Return to wallet <a href="/walletedit/{{wallet|urlencode}}">{{wallet}}</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<h2>Wallet {{wallet}}</h2>
|
<h2>Wallet {{wallet}}</h2>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<style>
|
||||||
|
var {font-family: monospace;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<form method ='post' style="text-align: center">
|
<form method ='post' style="text-align: center">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
@ -29,13 +33,13 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
<p style="font-family: monospace; font-weight: bold; font-size: 130%; text-align: center">
|
<p style="font-family: monospace; font-weight: bold; font-size: 130%; text-align: center">
|
||||||
<a style="font-weight: normal;" href="/walletedit/{{prevy}}:01">{{prevy}}</a>
|
<a style="font-weight: normal;" href="/walletedit/{{prevy|urlencode}}:01">{{prevy}}</a>
|
||||||
...
|
...
|
||||||
<a href="/walletedit/{{recent_year}}:{{recent_number}}">{{recent_year}}:{{recent_number}}</a>
|
<a href="/walletedit/{{recent_year}}:{{recent_number}}">{{recent_year}}:{{recent_number}}</a>
|
||||||
← {{wallet}} →
|
← {{wallet}} →
|
||||||
<a href="/walletedit/{{year}}:{{next}}">{{year}}:{{next}}</a>
|
<a href="/walletedit/{{year}}:{{next}}">{{year}}:{{next}}</a>
|
||||||
...
|
...
|
||||||
<a style="font-weight: normal;" href="/walletedit/{{nexty}}:01">{{nexty}}</a>
|
<a style="font-weight: normal;" href="/walletedit/{{nexty|urlencode}}:01">{{nexty}}</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
@ -58,10 +62,10 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
<details><summary>Do NOT invent your own filenaming scheme. <br />Click for more details.</summary>
|
<details style="text-align: left"><summary>Troggle needs standardised filenames. Use <br />"<var>notes1-myhole.jpg</var>", "<var>notes2-myhole.jpg</var>" etc. for in-cave notes,<br />"<var>plan1-myhole.jpg</var>" for the first page of the <em>drawn up</em> plan, <br />"<var>elev3-myhole.jpg</var>" for p3 of the <em>drawn up</em> elevation. <p><u>Click</u> for more details.</summary>
|
||||||
<div align="left">We have a 20-year old scheme for naming scanned files, <br><br>
|
<div align="left"><p>Please do NOT invent your own filenaming scheme. We have a 20-year old scheme for naming scanned files, <br><br>
|
||||||
Name the scanned pages <em>"notes-cavepassagename.jpg"</em> etc., (or <em>notes-1.jpg</em> if you must, but self-describing filenames are much better). This is important as a script detects whether these files exist (with names beginning <em>"notes..", "plan.." and "elev.."</em>) and if you name them something else it will hassle you unnecessarily. (Or you can use this format <em>cavepassagename5-notes.jpg</em> if you like.)
|
Name the scanned pages <var>"notes-cavepassagename.jpg"</var> etc., or <var>notes-1.jpg</var> if you like, but self-describing filenames are better. This is important as a script detects whether these files exist (with names beginning <var>"notes..", "plan.." and "elev.."</var>) and if you name them something else it will hassle you unnecessarily. (Or you can use this format <var>cavepassagename5-notes.jpg</var> if you like.) See how this works in the Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a>
|
||||||
Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a> </div></details>
|
<p>The '<var>plan..</var>' and '<var>elev..</var>' scans are <em>for fully drawn-up Tunnel or Therion plans or elevations</em>. If you have hand-sketches, then these are '<var>notes..</var>' as are the raw survex survey data numbers.</div></details>
|
||||||
</div>
|
</div>
|
||||||
<div style = "max-width:29%; margin-left:20%; text-align: left" >
|
<div style = "max-width:29%; margin-left:20%; text-align: left" >
|
||||||
{% if filesaved %}
|
{% if filesaved %}
|
||||||
@ -76,14 +80,14 @@ Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a> </di
|
|||||||
{% if not create %}
|
{% if not create %}
|
||||||
<p>
|
<p>
|
||||||
{% for f in files %}
|
{% for f in files %}
|
||||||
<a href="/expofilerename/surveyscans/{{year}}/{{wallet|urlencode}}/{{f}}">»</a> <a href="/expofiles/surveyscans/{{year}}/{{wallet|urlencode}}/{{f}}">{{ f}}</a><br />
|
<a href="/expofilerename/surveyscans/{{year}}/{{wallet|urlencode}}/{{f|urlencode}}">»</a> <a href="/expofiles/surveyscans/{{year}}/{{wallet|urlencode}}/{{f|urlencode}}">{{ f}}</a> - <a href="/expofilerename/surveyscans/{{year}}/{{wallet|urlencode}}/{{f|urlencode}}"><em>Rename or Rotate</em></a><br />
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p><No files in this wallet. >
|
<p><No files in this wallet. >
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for d in dirs %}
|
{% for d in dirs %}
|
||||||
<a href="/expofiles/surveyscans/{{year}}/{{wallet|urlencode}}/{{d}}"><em>{{d}}</em></a><br />
|
<a href="/expofiles/surveyscans/{{year}}/{{wallet|urlencode}}/{{d|urlencode}}"><em>{{d}}</em></a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -135,7 +139,7 @@ Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a> </di
|
|||||||
<br>
|
<br>
|
||||||
<span style="font-family: monospace; font-size: 150%; ">
|
<span style="font-family: monospace; font-size: 150%; ">
|
||||||
{% if cave %}<u>Cave ID</u>:
|
{% if cave %}<u>Cave ID</u>:
|
||||||
{% if caveobject %}<b>{{cave}}</b></a> which implies "<a href="/{{caveobject.url}}">{{caveobject}}</a>"<br>
|
{% if caveobject %}<b>{{cave}}</b></a> which implies "<a href="/{{caveobject.url|urlencode}}">{{caveobject}}</a>"<br>
|
||||||
{% else %}
|
{% else %}
|
||||||
<b>{{cave}}</b><br>
|
<b>{{cave}}</b><br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -143,7 +147,7 @@ Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a> </di
|
|||||||
{% if psg %}<u>Survey area</u>: <b>{{psg}}</b><br>{% endif %}
|
{% if psg %}<u>Survey area</u>: <b>{{psg}}</b><br>{% endif %}
|
||||||
{% if svxfiles %}<u>Survex files</u>:
|
{% if svxfiles %}<u>Survex files</u>:
|
||||||
{% for svx in svxfiles %}
|
{% for svx in svxfiles %}
|
||||||
<a href="/survexfile/{{svx}}">{{svx}}</a>
|
<a href="/survexfile/{{svx|urlencode}}">{{svx}}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<br>
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -238,7 +242,7 @@ Handbook: <a href="/handbook/survey/newwallet.html">Creating a Wallet</a> </di
|
|||||||
{% if metadataurl %}<span style="font-size: 70%; "><details><summary>
|
{% if metadataurl %}<span style="font-size: 70%; "><details><summary>
|
||||||
JSON <br>
|
JSON <br>
|
||||||
</summary>
|
</summary>
|
||||||
<a href="{{metadataurl}}">{{metadataurl}}</a><br>
|
<a href="{{metadataurl|urlencode}}">{{metadataurl}}</a><br>
|
||||||
<pre>
|
<pre>
|
||||||
{{metadata}}
|
{{metadata}}
|
||||||
</pre>
|
</pre>
|
||||||
|
Loading…
Reference in New Issue
Block a user