Skip to content

Commit

Permalink
build: Now possible to pick out login screen by config
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Nov 21, 2016
1 parent 7e5ad83 commit 1974359
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 128 deletions.
8 changes: 8 additions & 0 deletions src/build/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,17 @@
scripts.push(' <script type="text/javascript" charset="utf-8" src="' + i + '"></script>');
}, test);

var loginHTML = '';
var loginName = opts.build.dist.login || 'default';
var loginFile = _path.join(ROOT, 'src', 'templates', 'dist', 'login', loginName + '.html');
if ( _fs.existsSync(loginFile) ) {
loginHTML = _fs.readFileSync(loginFile).toString();
}

var tpl = _fs.readFileSync(_path.join(tpldir, fileName)).toString();
tpl = _utils.replaceAll(tpl, '%STYLES%', styles.join('\n'));
tpl = _utils.replaceAll(tpl, '%SCRIPTS%', scripts.join('\n'));
tpl = _utils.replaceAll(tpl, '%LOGIN%', loginHTML);

_fs.writeFileSync(_path.join(outdir, fileName), tpl);
}
Expand Down
59 changes: 2 additions & 57 deletions src/client/stylesheets/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,73 +33,18 @@ html, body {
height : 100%;
overflow : hidden;
}

body {
margin : 0;
padding : 0;
background-color : #572a79;
}

body, input, button, textarea, label, select {
font-size : 12px;
font-family : Sans-serif, Arial;
}

/**
* ===========================================================================
* LOGIN SCREEN
* ===========================================================================
*/

#Login {
background : #fff;
width : 400px;
height : 230px;
padding : 20px;
position : absolute;
left : 50%;
top : 50%;
z-index : 9999;
margin-left : -200px;
margin-top : -155px; /* -40 because of loading bar*/
border : 4px solid rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
-moz-box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
box-sizing : border-box;

display : none;
}
#LoginForm > div {
margin-bottom : 20px;
}
#Login label {
display : block;
font-weight : bold;
height : 30px;
line-height : 30px;
}
#Login input[type=text],
#Login input[type=password] {
display : block;
width : 100%;
height : 24px;
padding : 4px;
line-height : 12px;
box-sizing : border-box;
}
#Login input[type=submit] {
height : 40px;
padding : 10px;
padding-left : 20px;
padding-right : 20px;
box-sizing : border-box;
background : rgba(0, 0, 0, .1);
border : 0 none;
cursor : pointer;
}
#Login .Submit {
text-align : right;
}

/**
* ===========================================================================
* LOADING SCREEN
Expand Down
3 changes: 2 additions & 1 deletion src/conf/500-build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"build": {
"dist": {
"template": "default"
"template": "default",
"login": "default"
},
"statics": {
"src/client/dialogs.html": "dist/dialogs.html",
Expand Down
16 changes: 1 addition & 15 deletions src/templates/dist/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,7 @@
<img alt="" src="splash.png" />
</div>

<div id="Login">
<form method="post" id="LoginForm">
<div>
<label for="LoginUsername">Username</label>
<input type="text" name="LoginUsername" id="LoginUsername" value="" placeholder="Username" />
</div>
<div>
<label for="LoginPassword">Password</label>
<input type="password" name="LoginPassword" id="LoginPassword" value="" placeholder="Password" />
</div>
<div class="Submit">
<input type="submit" name="LoginSubmit" id="LoginSubmit" value="Login" />
</div>
</form>
</div>
%LOGIN%

</body>
</html>
57 changes: 3 additions & 54 deletions src/templates/dist/default/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,24 @@
<head>
<meta charset="utf-8" />
<meta name="google" content="notranslate" />

<!--
OS.js - JavaScript Cloud/Web Desktop Platform
Copyright (c) 2011-2016, Anders Evenrud <andersevenrud@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@author Anders Evenrud <andersevenrud@gmail.com>
@licence Simplified BSD License
-->
<meta name="description" content="OS.js - JavaScript Cloud/Web Desktop Platform" />
<meta name="keywords" content="OS.js,Web Desktop,Cloud Desktop,JavaScript OS" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Mocha - OS.js</title>

<title>OS.js</title>
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="apple-touch-icon-precomposed" href="favicon.png" />

<!-- Styles -->
<link type="text/css" rel="stylesheet" href="/vendor/mocha.css" />
<link type="text/css" rel="stylesheet" href="themes/fonts.css" />
%STYLES%

<!-- Scripts -->
<script type="text/javascript" charset="utf-8" src="settings.js"></script>
%SCRIPTS%

</head>
<body data-mocha="true">

<div id="LoadingScreen">
<img alt="" src="splash.png" />
</div>

<div id="Login">
<form method="post" id="LoginForm">
<div>
<label for="LoginUsername">Username</label>
<input type="text" name="LoginUsername" id="LoginUsername" value="" placeholder="Username" />
</div>
<div>
<label for="LoginPassword">Password</label>
<input type="password" name="LoginPassword" id="LoginPassword" value="" placeholder="Password" />
</div>
<div class="Submit">
<input type="submit" name="LoginSubmit" id="LoginSubmit" value="Login" />
</div>
</form>
</div>
%LOGIN%

<script type="text/javascript" charset="utf-8" src="/vendor/mocha.js"></script>
<script type="text/javascript" charset="utf-8" src="/vendor/chai.js"></script>
Expand Down
72 changes: 72 additions & 0 deletions src/templates/dist/login/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

<div id="Login">
<form method="post" id="LoginForm">
<div>
<label for="LoginUsername">Username</label>
<input type="text" name="LoginUsername" id="LoginUsername" value="" placeholder="Username" />
</div>
<div>
<label for="LoginPassword">Password</label>
<input type="password" name="LoginPassword" id="LoginPassword" value="" placeholder="Password" />
</div>
<div class="Submit">
<input type="submit" name="LoginSubmit" id="LoginSubmit" value="Login" />
</div>
</form>
</div>

<style type="text/css">

#Login {
background : #fff;
width : 400px;
height : 230px;
padding : 20px;
position : absolute;
left : 50%;
top : 50%;
z-index : 9999;
margin-left : -200px;
margin-top : -155px;
border : 4px solid rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
-moz-box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
box-shadow: 0 0 5px 4px rgba(0,0,0,0.15);
box-sizing : border-box;

display : none;
}
#LoginForm > div {
margin-bottom : 20px;
}
#Login label {
display : block;
font-weight : bold;
height : 30px;
line-height : 30px;
}
#Login input[type=text],
#Login input[type=password] {
display : block;
width : 100%;
height : 24px;
padding : 4px;
line-height : 12px;
box-sizing : border-box;
}
#Login input[type=submit] {
height : 40px;
padding : 10px;
padding-left : 20px;
padding-right : 20px;
box-sizing : border-box;
background : rgba(0, 0, 0, .1);
border : 0 none;
cursor : pointer;
}
#Login .Submit {
text-align : right;
}

</style>

6 changes: 5 additions & 1 deletion src/templates/nw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"min_height": 480
},
"dependencies": {
"node-fs-extra": ">=0.8.1"
"node-fs-extra": ">=0.8.1",
"diskspace": ">=1.0.3",
"findit": ">=2.0.0",
"formidable": ">=1.0.17",
"fstream": "^1.0.10"
}
}

0 comments on commit 1974359

Please sign in to comment.