diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4425e5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +node_modules/ +xdk/ +*.xdk +*.xdke +*.xdk_bak +*.xdke_bak diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ee52e9e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Nils Solanki + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index f883849..35df96f 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ -# secret-server +# Secret Server +From the outside, this is just a regular webserver. But as long as the digital button is pressed, a secret page appears to the visitors. + +## Installation +1. Clone/download this repository +2. Attach a digital button to pin 2 +3. Upload the files to the intel edison +4. Start the script +5. Navigate to the your edison on port `3000`, eg. `http://192.169.0.101:3000` diff --git a/client/index.css b/client/index.css new file mode 100644 index 0000000..55f8fc2 --- /dev/null +++ b/client/index.css @@ -0,0 +1,32 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box +} + +body { + background-color: #f4f4f4; + font-family: Helvetica, Arial, sans-serif; + font-size: 18px; + color: #aaa; + + width: 100vw; + height: 100vh; +} + +.main { + display: -webkit-flex; + display: -moz-flex; + display: -ms-flex; + display: -o-flex; + display: flex; + align-items: center; + justify-content: center; + + width: 100%; + height: 100%; +} + +.secret { + color: #333338; +} diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..7c829a1 --- /dev/null +++ b/client/index.html @@ -0,0 +1,14 @@ + + + + + + ... + + + +
+

Hier gibt es nichts zu sehen...

+
+ + diff --git a/client/secret.html b/client/secret.html new file mode 100644 index 0000000..5b74c66 --- /dev/null +++ b/client/secret.html @@ -0,0 +1,14 @@ + + + + + + Geheime Seite + + + +
+

Das Geheimnis ist: Geduld

+
+ + diff --git a/main.js b/main.js new file mode 100644 index 0000000..8f64ec3 --- /dev/null +++ b/main.js @@ -0,0 +1,33 @@ +var mraa = require('mraa'); +var express = require('express'); +var app = express(); +var path = require('path'); + +// The button on pin 2 +var digitalButtonPin = new mraa.Gpio(2); +digitalButtonPin.dir(mraa.DIR_IN); + +var buttonIsPressed = 0; + +// When website is accessed, show either normal or secret page +app.get('/', function(req, res) { + if(buttonIsPressed) { + res.sendFile(path.join(__dirname, '/client/secret.html')); // Send the secret page + } else { + res.sendFile(path.join(__dirname, '/client/index.html')); // Send the normal page + } +}); + +// Serve static files like the index.css file +app.use(express.static(__dirname + '/client')); + +// Start web server +var server = app.listen(3000, function(){ + console.log('Web server listening on port 3000'); + readPin(); +}); + +function readPin() { + buttonIsPressed = digitalButtonPin.read(); + setTimeout(readPin, 100); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3974262 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "websockets", + "description": "", + "version": "0.0.0", + "main": "main.js", + "engines": { + "node": ">=0.10.0" + }, + "dependencies": { + "express": "latest", + "socket.io":"latest" + } +} \ No newline at end of file