A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

87 lines
2.2KB

  1. const package = require("./package.json");
  2. const exec = require('child_process').execSync;
  3. const fs = require("fs");
  4. const path = require("path");
  5. const express = require("express");
  6. const app = express();
  7. const http = require("http");
  8. const https = require("https");
  9. var production = process.env.PRODUCTION || false;
  10. var port = process.env.NESPORT || 80;
  11. var portSSL = process.env.NESPORTSSL || 443;
  12. var sslKeyPath = process.env.SSLKEYPATH || null;
  13. var sslCertPath = process.env.SSLCERTPATH || null;
  14. var sslCaPath = process.env.SSLCAPATH || null;
  15. function GenVersion(){
  16. var v = package.version;
  17. // Testing for a GIT repo... if not in a production environment.
  18. if (production === false){
  19. try{
  20. var res = exec("git rev-parse --abbrev-ref HEAD").toString();
  21. v += "-[" + res.trim();
  22. res = exec("git rev-parse HEAD").toString();
  23. v += ":" + res.substring(0, 5) + "]";
  24. } catch(e) {
  25. if (v !== package.version){
  26. v += "]"; // If v doesn't match package.version, then assume that the first git call worked.
  27. }
  28. }
  29. }
  30. return v;
  31. }
  32. var version = GenVersion();
  33. app.set('views', path.join(__dirname, "/views"));
  34. app.engine('html', require('ejs').renderFile);
  35. app.set('view engine', 'html');
  36. app.use("/app", express.static(path.join(__dirname, "/app")));
  37. app.get('/', function(req, res){
  38. res.render('index.html', {version:version, author:package.author});
  39. });
  40. console.log("NESPaint (v" + version + ") Server");
  41. if (sslKeyPath !== null && sslCertPath !== null){
  42. try {
  43. var options = {
  44. key: fs.readFileSync(sslKeyPath),
  45. cert: fs.readFileSync(sslCertPath)
  46. }
  47. if (sslCaPath !== null)
  48. options.ca = fs.readFileSync(sslCaPath);
  49. app.use(function(req, res, next){
  50. if (req.secure){
  51. next();
  52. } else {
  53. res.redirect('https://' + req.headers.host + req.url);
  54. }
  55. });
  56. https.createServer(options, app).listen(portSSL, () => {
  57. console.log("HTTPS Listening on port " + portSSL + "!");
  58. });
  59. } catch (e) {
  60. console.log("WARNING: Failed to initialize HTTPS server. \"" + e.toString() + "\"");
  61. }
  62. }
  63. http.createServer(app).listen(port, () => {
  64. console.log("HTTP Listening on port " + port + "!");
  65. });