Przeglądaj źródła

better caching, minimized jquery

master
mort 8 lat temu
rodzic
commit
4691f01e2b
5 zmienionych plików z 10 dodań i 3 usunięć
  1. 2
    1
      conf.json.example
  2. 2
    1
      server.js
  3. 1
    1
      templates/head.html
  4. 5
    0
      web/i/index.node.js
  5. 0
    0
      web/view/script.js

+ 2
- 1
conf.json.example Wyświetl plik

}, },
"debug": false, "debug": false,
"max_runs": 9999, "max_runs": 9999,
"cache_max_age": 604800,
"cache_max_age": 2628000,
"cache_max_age_images": 2628000,
"purge_collections_timeout": "2 days", "purge_collections_timeout": "2 days",
"purge_collections_interval": 1800000 "purge_collections_interval": 1800000
} }

+ 2
- 1
server.js Wyświetl plik

//Viewer //Viewer
"/view": "view/index.node.js", "/view": "view/index.node.js",
"/view/style.css": "view/style.css", "/view/style.css": "view/style.css",
"/view/script.js": "view/script.js",


//Plain images //Plain images
"/i": "i/index.node.js", "/i": "i/index.node.js",
var ep = loaded.endpoints[req.url.split("?")[0]]; var ep = loaded.endpoints[req.url.split("?")[0]];


//If the file doesn't exist, we 404. //If the file doesn't exist, we 404.
if (!ep) {
if (ep === undefined) {
ep = loaded.endpoints["/404"]; ep = loaded.endpoints["/404"];
ctx.setStatus(404); ctx.setStatus(404);
} }

+ 1
- 1
templates/head.html Wyświetl plik

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="/{{env#view}}/style.css?{{conf#currentRun}}"> <link rel="stylesheet" href="/{{env#view}}/style.css?{{conf#currentRun}}">


<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/global.js?{{conf#currentRun}}"></script> <script src="/global.js?{{conf#currentRun}}"></script>
<script src="/{{env#view}}/script.js?{{conf#currentRun}}"></script> <script src="/{{env#view}}/script.js?{{conf#currentRun}}"></script>

+ 5
- 0
web/i/index.node.js Wyświetl plik

if (!id) if (!id)
return ctx.end(ctx.view("404")); return ctx.end(ctx.view("404"));


ctx.res.setHeader(
"Cache-Control",
"public, max-age="+ctx.conf.cache_max_age_images
);

var readStream = fs.createReadStream(ctx.conf.dir.imgs+"/"+id); var readStream = fs.createReadStream(ctx.conf.dir.imgs+"/"+id);
readStream.pipe(ctx.res); readStream.pipe(ctx.res);



+ 0
- 0
web/view/script.js Wyświetl plik


Ładowanie…
Anuluj
Zapisz