forked from expo/troggle
fix final \n on edited files
This commit is contained in:
parent
406b4590a9
commit
02e475642a
@ -300,7 +300,7 @@ def editexpopage(request, path):
|
|||||||
headerargs = ""
|
headerargs = ""
|
||||||
postheader = ""
|
postheader = ""
|
||||||
bodyargs = ""
|
bodyargs = ""
|
||||||
postbody = "</html>"
|
postbody = "</html>\n"
|
||||||
body = pageform.cleaned_data["html"]
|
body = pageform.cleaned_data["html"]
|
||||||
body = body.replace("\r", "")
|
body = body.replace("\r", "")
|
||||||
result = "%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody)
|
result = "%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody)
|
||||||
@ -308,11 +308,18 @@ def editexpopage(request, path):
|
|||||||
cwd = filepath.parent
|
cwd = filepath.parent
|
||||||
filename = filepath.name
|
filename = filepath.name
|
||||||
git = settings.GIT
|
git = settings.GIT
|
||||||
|
try:
|
||||||
with open(filepath, "w") as f:
|
with open(filepath, "w") as f:
|
||||||
f.write(result)
|
f.write(result)
|
||||||
#print(f'WROTE {cwd}---{filename} ')
|
#print(f'WROTE {cwd}---{filename} ')
|
||||||
subprocess.call([git, "add", filename], cwd=cwd)
|
subprocess.call([git, "add", filename], cwd=cwd)
|
||||||
subprocess.call([git, "commit", "-m", 'Edit this page'], cwd=cwd)
|
subprocess.call([git, "commit", "-m", 'Edit this page'], cwd=cwd)
|
||||||
|
except PermissionError:
|
||||||
|
message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {filename}. Ask a nerd to fix this.'
|
||||||
|
return render(request,'errors/generic.html', {'message': message})
|
||||||
|
except:
|
||||||
|
message = f'CANNOT git on server for this file {filename}. Edits not saved.\nAsk a nerd to fix this.'
|
||||||
|
return render(request,'errors/generic.html', {'message': message})
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('expopage', args=[path])) # Redirect after POST
|
return HttpResponseRedirect(reverse('expopage', args=[path])) # Redirect after POST
|
||||||
else:
|
else:
|
||||||
|
@ -152,6 +152,7 @@ class SvxForm(forms.Form):
|
|||||||
|
|
||||||
# javascript seems to insert CRLF on WSL1 whatever you say. So fix that:
|
# javascript seems to insert CRLF on WSL1 whatever you say. So fix that:
|
||||||
res = fout.write(rcode.replace("\r",""))
|
res = fout.write(rcode.replace("\r",""))
|
||||||
|
res = fout.write("\n")
|
||||||
fout.close()
|
fout.close()
|
||||||
return "SAVED ."
|
return "SAVED ."
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user