reply raw markdown unless ?v

This commit is contained in:
ed 2022-10-24 02:10:07 +02:00
parent 835f8a20e6
commit 2701238cea
7 changed files with 12 additions and 10 deletions

View file

@ -1270,7 +1270,7 @@ authenticate using header `Cookie: cppwd=foo` or url param `&pw=foo`
| GET | `?ups` | show recent uploads from your IP |
| GET | `?ups&filter=f` | ...where URL contains `f` |
| GET | `?mime=foo` | specify return mimetype `foo` |
| GET | `?raw` | get markdown file at URL as plaintext |
| GET | `?v` | render markdown file at URL |
| GET | `?txt` | get file at URL as plaintext |
| GET | `?txt=iso-8859-1` | ...with specific charset |
| GET | `?th` | get image/video at URL as thumbnail |

View file

@ -374,7 +374,6 @@ class HttpCli(object):
self.out_headerlist.append(("Set-Cookie", self.get_pwd_cookie(self.pw)[0]))
if self.is_rclone:
uparam["raw"] = ""
uparam["dots"] = ""
uparam["b"] = ""
cookies["b"] = ""
@ -2968,7 +2967,7 @@ class HttpCli(object):
self.log("wrong filekey, want {}, got {}".format(correct, got))
return self.tx_404()
if abspath.endswith(".md") and "raw" not in self.uparam:
if abspath.endswith(".md") and "v" in self.uparam:
return self.tx_md(abspath)
return self.tx_file(abspath)

View file

@ -3446,7 +3446,7 @@ var showfile = (function () {
xhr.fname = uricom_dec(url.split('/').pop());
xhr.no_push = no_push;
xhr.ts = Date.now();
xhr.open('GET', url.split('?')[0] + '?raw', true);
xhr.open('GET', url.split('?')[0], true);
xhr.onprogress = loading;
xhr.onload = xhr.onerror = load_cb;
xhr.send();
@ -5181,8 +5181,11 @@ var treectl = (function () {
id += 'a';
seen[id] = 1;
if (lang)
if (lang) {
showfile.files.push({ 'id': id, 'name': fname });
if (lang == 'md')
tn.href += tn.href.indexOf('?') < 0 ? '?v' : '&v';
}
if (tn.lead == '-')
tn.lead = '<a href="?doc=' + tn.href + '" class="doc' + (lang ? ' bri' : '') +

View file

@ -31,7 +31,7 @@
{%- else %}
<a href="{{ arg_base }}edit" tt="good: higher performance$Ngood: same document width as viewer$Nbad: assumes you know markdown">edit (basic)</a>
<a href="{{ arg_base }}edit2" tt="not in-house so probably less buggy">edit (fancy)</a>
<a href="{{ arg_base }}raw">view raw</a>
<a href="{{ arg_base }}">view raw</a>
{%- endif %}
</div>
<div id="toc"></div>

View file

@ -253,7 +253,7 @@ function Modpoll() {
}
console.log('modpoll...');
var url = (document.location + '').split('?')[0] + '?raw&_=' + Date.now();
var url = (document.location + '').split('?')[0] + '?_=' + Date.now();
var xhr = new XHR();
xhr.open('GET', url, true);
xhr.responseType = 'text';
@ -389,7 +389,7 @@ function save_cb() {
function run_savechk(lastmod, txt, btn, ntry) {
// download the saved doc from the server and compare
var url = (document.location + '').split('?')[0] + '?raw&_=' + Date.now();
var url = (document.location + '').split('?')[0] + '?_=' + Date.now();
var xhr = new XHR();
xhr.open('GET', url, true);
xhr.responseType = 'text';

View file

@ -166,7 +166,7 @@ function save_cb() {
//alert('save OK -- wrote ' + r.size + ' bytes.\n\nsha512: ' + r.sha512);
// download the saved doc from the server and compare
var url = (document.location + '').split('?')[0] + '?raw';
var url = (document.location + '').split('?')[0] + '?_=' + Date.now();
var xhr = new XHR();
xhr.open('GET', url, true);
xhr.responseType = 'text';

View file

@ -2092,7 +2092,7 @@ function up2k_init(subtle) {
try { orz(e); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
};
xhr.open('HEAD', t.purl + uricom_enc(t.name) + '?raw', true);
xhr.open('HEAD', t.purl + uricom_enc(t.name), true);
xhr.send();
}