mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
Because of the deprecation of responseBody Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import Mark from 'markup.min.njs';
|
|
|
|
function fancyIndexRender(r, templateUrl){
|
|
r.subrequest(templateUrl, {
|
|
args: '',
|
|
body: '',
|
|
method: 'GET'
|
|
}, function(rTmpl){
|
|
if(rTmpl.status != 200){
|
|
return r.return(rTmpl.status);
|
|
}
|
|
var tmpl = rTmpl.responseText;
|
|
var result = Mark.up(tmpl, {
|
|
url: r.variables.request_uri.replace(/\/+/g, '/').replace(/\?.*$/, ''),
|
|
open: '{{',
|
|
close: '}}',
|
|
});
|
|
r.status = 200;
|
|
r.headersOut['Content-Type'] = 'text/html';
|
|
r.sendHeader();
|
|
r.send(result);
|
|
r.finish();
|
|
});
|
|
}
|
|
|
|
function fancyIndexBeforeRender(r){
|
|
if(r.variables.isbrowser && r.variables.isbrowser != '0'){
|
|
return fancyIndexRender(r, '/fancy-index/before.html');
|
|
}else{
|
|
return fancyIndexRender(r, '/fancy-index/before-legacy.html');
|
|
}
|
|
}
|
|
|
|
function fancyIndexAfterRender(r){
|
|
if(r.variables.isbrowser && r.variables.isbrowser != '0'){
|
|
return fancyIndexRender(r, '/fancy-index/after.html');
|
|
}else{
|
|
return fancyIndexRender(r, '/fancy-index/after-legacy.html');
|
|
}
|
|
}
|
|
|
|
export default {fancyIndexBeforeRender, fancyIndexAfterRender};
|