diff --git a/README.md b/README.md index 09059b1..dd74e14 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/paste/views.py b/paste/views.py index 28632a6..0ede515 100644 --- a/paste/views.py +++ b/paste/views.py @@ -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: diff --git a/using.fr.md b/using.fr.md index b16d19b..0fcbf42 100644 --- a/using.fr.md +++ b/using.fr.md @@ -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`.