Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Solanki committed Oct 20, 2015
1 parent 723ce45 commit 9a38b31
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
xdk/
*.xdk
*.xdke
*.xdk_bak
*.xdke_bak
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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`
32 changes: 32 additions & 0 deletions client/index.css
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>...</title>
<link rel="stylesheet" href="index.css"/>
</head>
<body>
<main class="main">
<h1 class="h1">Hier gibt es nichts zu sehen...</h1>
</main>
</body>
</html>
14 changes: 14 additions & 0 deletions client/secret.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Geheime Seite</title>
<link rel="stylesheet" href="index.css"/>
</head>
<body>
<main class="main secret">
<h1 class="h1">Das Geheimnis ist: Geduld</h1>
</main>
</body>
</html>
33 changes: 33 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 9a38b31

Please sign in to comment.