new file: s/contact.tpl.html
new file: s/favicon.gif new file: s/how.tpl.html modified: s/index.tpl.html modified: s/item.tpl.html modified: s/style.css modified: src/main.js deleted: s/irccat.gif
This commit is contained in:
34
src/main.js
34
src/main.js
@ -47,7 +47,7 @@ bot.on('motd', (e) => {
|
||||
|
||||
bot.on('message', (e) => {
|
||||
var orig = e.message;
|
||||
if(orig.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi) && e.channel.getName() == "#f0ck") { // shitpostcatcher
|
||||
if(orig.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi)/* && e.channel.getName() == "#f0ck"*/) { // shitpostcatcher
|
||||
if(!orig.match(/\!ignore$/)) {
|
||||
var tmp = orig.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
|
||||
tmp.forEach((entry,i,a) => {
|
||||
@ -95,6 +95,10 @@ bot.on('message', (e) => {
|
||||
var tmp = getUser(e.user.getNick(), e.network);
|
||||
setTimeout(()=>{ e.reply(tmp); }, 1500);
|
||||
}
|
||||
else if(orig.match(/^\!reload tpl$/)) {
|
||||
getTpls();
|
||||
e.reply("templates reloaded");
|
||||
}
|
||||
});
|
||||
|
||||
var getUser = (u, n) => {
|
||||
@ -172,7 +176,6 @@ http.createServer((req, res) => {
|
||||
var url = req.url.split("/")[1];
|
||||
if(filePath == './')
|
||||
filePath = './index.html';
|
||||
|
||||
var extname = String(path.extname(filePath)).toLowerCase();
|
||||
var contentType = 'text/html';
|
||||
var mimeTypes = {
|
||||
@ -240,8 +243,18 @@ http.createServer((req, res) => {
|
||||
res.end(tpl(data), 'utf-8');
|
||||
});
|
||||
}
|
||||
else if(filePath == "./how") {
|
||||
var tpl = swig.compile(templates.how);
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(tpl(), 'utf-8');
|
||||
}
|
||||
else if(filePath == "./contact") {
|
||||
var tpl = swig.compile(templates.contact);
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(tpl(), 'utf-8');
|
||||
}
|
||||
else if(filePath.match(/^\.\/(b|s|t)\/.*/)) { // file
|
||||
contentType = mimeTypes[extname] || 'application/octect-stream';
|
||||
contentType = mimeTypes[extname];
|
||||
switch(contentType) {
|
||||
case "video/webm":
|
||||
case "video/mp4":
|
||||
@ -280,7 +293,7 @@ http.createServer((req, res) => {
|
||||
}
|
||||
}
|
||||
else {
|
||||
res.writeHead(200, { 'Content-Type': contentType, 'Content-Length': content.length });
|
||||
res.writeHead(200, { 'Content-Type': contentType, 'Content-Length': content.length, 'Cache-Control': 'max-age=2592000, public' });
|
||||
res.end(content, 'utf-8');
|
||||
}
|
||||
});
|
||||
@ -290,7 +303,7 @@ http.createServer((req, res) => {
|
||||
if(error) {
|
||||
if(error.code == 'ENOENT') {
|
||||
res.writeHead(200, { 'Content-Type': contentType });
|
||||
res.end('404 - file not found', 'utf-8');
|
||||
res.end('404 - f0ck you', 'utf-8');
|
||||
}
|
||||
else {
|
||||
res.writeHead(500);
|
||||
@ -305,14 +318,16 @@ http.createServer((req, res) => {
|
||||
}
|
||||
else { // errorpage
|
||||
res.writeHead(404);
|
||||
res.end('404 - not found', 'utf-8');
|
||||
res.end('404 - f0ck you', 'utf-8');
|
||||
}
|
||||
}).listen(cfg.webserver.port);
|
||||
|
||||
var getTpls = () => {
|
||||
templates = {
|
||||
"index": fs.readFileSync("./s/index.tpl.html", "utf-8"),
|
||||
"item": fs.readFileSync("./s/item.tpl.html", "utf-8")
|
||||
"item": fs.readFileSync("./s/item.tpl.html", "utf-8"),
|
||||
"how": fs.readFileSync("./s/how.tpl.html", "utf-8"),
|
||||
"contact": fs.readFileSync("./s/contact.tpl.html", "utf-8")
|
||||
};
|
||||
};
|
||||
getTpls();
|
||||
@ -330,9 +345,8 @@ var generateThumbs = () => {
|
||||
exec('ffmpegthumbnailer -i'+e.dest+' -o'+outdir+e.id+'.png -a', (error) => {
|
||||
if(error) {
|
||||
bot.send("#f0ck", "failed thumbnail for "+e.id+" ("+e.mime+")", 'n0xy');
|
||||
fs.unlink(outdir+e.id+'.png');
|
||||
fs.copySync('./s/mp3.png', outdir+e.id+'.png');
|
||||
// Standardthumb reinkopieren
|
||||
fs.unlink(outdir+e.id+'.png'); //
|
||||
fs.copySync('./s/mp3.png', outdir+e.id+'.png'); // copy standardthumbnail
|
||||
}
|
||||
else {
|
||||
bot.send("#f0ck", "generated thumbnail for "+e.id+" ("+e.mime+")", 'n0xy');
|
||||
|
Reference in New Issue
Block a user