This commit is contained in:
grant-kun 2022-11-09 08:20:42 -06:00
parent 235242d211
commit d7be47140f
1 changed files with 26 additions and 3 deletions

View File

@ -5,6 +5,7 @@ const {gitToJs} = require("git-parse")
const options = {
cert: readFileSync("cert.pem"),
key: readFileSync("key.pem"),
titanEnabled: true,
};
try{
mkdirSync("tmp")
@ -136,16 +137,36 @@ app.use(async(_req: Request, res: Response) => {
}
let aa = aaa.split('/')
aa.splice(3,0,z.join(""))
let bbb = '';
for(let l of def){
bbb+=l+"/"
}
let bb = bbb.split('/')
for(let n of bb){
if(n==''){
bb.splice(bb.indexOf(n),1)
}
}
console.log(bb)
if(!(bb.length==2)){
bb.splice(bb.length-1,1)
if(!bb.includes("source")){
bb.splice(2,0,"source")
}
}
//bb.splice(bb.length,1)
if(z.join("").includes('source')){
try{
let gitDir = readdirSync("."+x.join("/"))
//let t = `=> gemini://${_req.url.host+x.join('/')} ${x.join('/')}\n\n`
let t = ''
console.log(`gemini://${_req.url.host}/${bb.join("/") }`)
let t = `=> gemini://${_req.url.host}${_req.url.pathname} [d] .\n=> gemini://${_req.url.host}/${bb.join("/") } [d] ..\n`
for(let i of gitDir){
try{
readFileSync("."+x.join("/")+'/'+i)
t += `=> gemini://${_req.url.host+aa.join("/")+'/'+i} ${i}\n`
t += `=> gemini://${_req.url.host+aa.join("/")+'/'+i} ${i}\n`
} catch(e) {//is directory
t += `=> gemini://${_req.url.host+aa.join("/")+'/'+i} [d] ${i}\n`
}
@ -174,7 +195,9 @@ app.use(async(_req: Request, res: Response) => {
}
}
} else {
} else if(_req.url.pathname.includes('/forum')) {
}else {
let a:any = Math.random()
let t = readFileSync("./pages/404.gemini").toString().replace(/{domain}/g,_req.url.host)
writeFileSync("tmp/"+a+".gemini",t)