Page MenuHomeDevCentral

No OneTemporary

diff --git a/build.js b/build.js
new file mode 100755
index 0000000..5603b8e
--- /dev/null
+++ b/build.js
@@ -0,0 +1,80 @@
+#!/usr/bin/env node
+
+/* -------------------------------------------------------------
+ Servers homepages
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ Project: Nasqueron
+ Licence: BSD-2-Clause
+ Description: Generate index.html homepage for Nasqueron
+ servers from a generic template and specific
+ servers data.
+ ------------------------------------------------------------- */
+
+const fs = require('fs');
+const path = require('path');
+const AutoLinker = require('autolinker');
+
+/* -------------------------------------------------------------
+ Handle arguments
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+if (process.argv.length < 3) {
+ var scriptName = path.basename(process.argv[1]);
+ console.error(`Usage: ${scriptName} <server name>`);
+ process.exit(1);
+}
+
+var serverFile = __dirname + '/servers/' + process.argv[2] + ".json";
+
+if (!fs.existsSync(serverFile)) {
+ console.error(`Can't found ${serverFile}`);
+ process.exit(2);
+}
+
+var serverData = require(serverFile);
+
+/* -------------------------------------------------------------
+ Helper functions
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+var autolinker = new AutoLinker({
+ newWindow: false,
+});
+
+serverData.getLineTitle = function (entry) {
+ return entry[0];
+}
+
+serverData.getLineEntries = function (entry) {
+ var entries;
+ if (typeof entry[1] === 'string') {
+ entries = [entry[1]];
+ } else {
+ entries = entry[1];
+ }
+
+ return entries.map(text => function (text) {
+ return autolinker.link(text);
+ });
+}
+
+/* -------------------------------------------------------------
+ Render template
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+require('ect')({
+ root: __dirname + '/templates',
+ ext: '.ect',
+}).render(
+ 'index',
+ serverData,
+ function (error, html) {
+ if (error) {
+ console.error(error);
+ }
+
+ if (html) {
+ console.log(html);
+ }
+ }
+);
diff --git a/package.json b/package.json
index 8dd6471..67f70f6 100644
--- a/package.json
+++ b/package.json
@@ -1,31 +1,32 @@
{
"name": "nasqueron-servers-homepages",
"version": "0.1.0",
"description": "Static homepages for Nasqueron servers",
"author": {
"name": "Sébastien Santoro aka Dereckson",
"email": "dereckson@espace-win.org",
"url": "http://www.dereckson.be/"
},
"homepage": "http://agora.nasqueron.org/Servers_administration",
"repository": {
"type": "git",
"url": "https://github.com/nasqueron/servers-homepages"
},
"bugs": {
"url": "http://devcentral.nasqueron.org/tag/servers"
},
"keywords": [
"Nasqueron",
"infrastructure",
"sysadmin"
],
"engines": {
"node": ">= 0.4.0"
},
"dependencies": {
- "ect": "^0.5.9"
+ "autolinker": "^1.6.0",
+ "ect": "^0.5.9",
},
"private": true,
"license": "BSD"
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 07:10 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259670
Default Alt Text
(3 KB)

Event Timeline