mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 12:17:09 +00:00
git integration with Save this page
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from urllib.parse import urljoin, unquote as urlunquote
|
||||
from urllib.request import urlopen
|
||||
@@ -276,7 +277,6 @@ def editexpopage(request, path):
|
||||
# if re.search(r"iso-8859-1", html):
|
||||
# body = str(body, "iso-8859-1")
|
||||
else:
|
||||
#return HttpResponse("Page could not be split into header and body")
|
||||
return HttpResponse(default_head + html + '<h3>HTML Parsing failure:<br>Page could not be parsed into header and body:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to be in the expected full HTML format .</body' )
|
||||
except IOError:
|
||||
print("### File not found ### ", filepath)
|
||||
@@ -304,9 +304,16 @@ def editexpopage(request, path):
|
||||
body = pageform.cleaned_data["html"]
|
||||
body = body.replace("\r", "")
|
||||
result = "%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody)
|
||||
f = open(filepath, "w")
|
||||
f.write(result)
|
||||
f.close()
|
||||
|
||||
cwd = filepath.parent
|
||||
filename = filepath.name
|
||||
git = settings.GIT
|
||||
with open(filepath, "w") as f:
|
||||
f.write(result)
|
||||
print(f'WROTE {cwd}---{filename} ')
|
||||
subprocess.call([git, "add", filename], cwd=cwd)
|
||||
subprocess.call([git, "commit", "-m", 'Edit this page'], cwd=cwd)
|
||||
|
||||
return HttpResponseRedirect(reverse('expopage', args=[path])) # Redirect after POST
|
||||
else:
|
||||
if filefound:
|
||||
|
||||
Reference in New Issue
Block a user