.txt files should not be interpreted as Markdown.
This commit is contained in:
parent
1f6a43803e
commit
ccfec0affc
|
@ -30,6 +30,15 @@ other. So to create one for your instance, just paste something to it, like:
|
|||
The `Authorization` allows you to update the paste by uploading it again.
|
||||
|
||||
|
||||
### I want a robots.txt
|
||||
|
||||
Just past it:
|
||||
|
||||
$ printf "User-agent: *\nDisallow: /\n" | curl localhost:8000/robots.txt -XPUT -H "Authorization: Secret supersecret" --data-binary @-
|
||||
|
||||
It'll work as `.txt` files are not pretty printed.
|
||||
|
||||
|
||||
### Where's the admin?
|
||||
|
||||
The admin is hosted as `/::/admin/`. As almost any URL can be used by pastes, we "burry" the admin here.
|
||||
|
|
|
@ -53,7 +53,9 @@ class PasteView(View):
|
|||
paste = get_object_or_404(Paste, slug=path)
|
||||
paste.incr_viewcount()
|
||||
|
||||
if "html" in request.headers.get("accept", "html"):
|
||||
if "html" in request.headers.get(
|
||||
"accept", "html"
|
||||
) and not paste.filename.endswith(".txt"):
|
||||
return HttpResponse(paste_to_html(paste.filename, paste.content))
|
||||
else:
|
||||
return HttpResponse(paste.content, content_type="text/plain")
|
||||
|
@ -138,7 +140,7 @@ class ListView(View):
|
|||
def paste_to_html(filename, filecontents):
|
||||
data = {}
|
||||
data["filename"] = filename
|
||||
if filename.endswith(".md") or filename.endswith(".txt") or "." not in filename:
|
||||
if filename.endswith(".md") or "." not in filename:
|
||||
data["highlighted"] = markdown_to_html(filecontents)
|
||||
return loader.render_to_string("paste/show-markdown.html", data)
|
||||
else:
|
||||
|
|
|
@ -69,8 +69,10 @@ $ curl https://p.afpy.org/ -Fmanage.py=@manage.py -Frequirements.txt=@requiremen
|
|||
C’est l’extension dans le nom du fichier qui permet de choisir la
|
||||
coloration syntaxique pour chaque fichier.
|
||||
|
||||
Les fichiers texte sont interprétés en Markdown lors de l’affichage
|
||||
dans un navigateur.
|
||||
Les fichiers texte sont rendus en `plain/text`, donc sans coloration syntaxique.
|
||||
|
||||
Les fichiers `.md` et les fichiers sans extension sont interprétés en
|
||||
Markdown lors de l’affichage dans un navigateur.
|
||||
|
||||
Les fichiers sont toujours rendus tels quels lorsqu’ils sont récupérés
|
||||
hors d’un navigateur, typiquement via `wget` ou `curl`.
|
||||
|
|
Loading…
Reference in New Issue