Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

template

  • Loading branch information...
commit f2de4d4d469982bf6ca4d02cd8fecc8efdeb42c7 1 parent dbc4dd1
@rowoot rowoot authored
View
1  .gitignore
@@ -1 +1,2 @@
.nodester.appconfig
+node_modules
View
4 auth.js
@@ -11,9 +11,9 @@ function check_auth(options) {
// method, api path, data, credentials, callback
console.log("nodester ==> ", nodester);
// authorize: user
- nodester.authorize(req.user, function(bool) {
+ nodester.authorize(req.user.creds, function(bool) {
if(bool) {
- executionScope.success( {name: req.user.user}, callback )
+ executionScope.success( {}, callback )
} else {
executionScope.fail( callback )
}
View
3  encoding.js
@@ -108,4 +108,5 @@ function decodeBase64(str){
return result;
}
-exports.base64 = encodeBase64;
+exports.base64 = encodeBase64;
+exports.dbase64 = decodeBase64;
View
8 package.json
@@ -1,6 +1,6 @@
{
"author": "rowoot",
- "name": "admin",
+ "name": "nodester_admin",
"version": "0.0.1",
"repository": {
"type": "git",
@@ -14,5 +14,9 @@
"node": "0.4.7"
},
"dependencies": {},
- "devDependencies": {}
+ "devDependencies": {},
+ "scripts": {
+ "start": "node server.js"
+ },
+ "description": "admin interface for nodester"
}
View
28 public/javascripts/n.js
@@ -1,18 +1,36 @@
(function($) {
$(document).ready(function() {
- var apps_template = "{{#items}}<li>name : {{name}}</li>{{/items}}";
-
$("a[rel='ajax']").click(function(e) {
e.preventDefault();
var href = $(this).attr("href");
$.ajax({
url:href,
success:function(r) {
- var view = {items:r};
- $(".c").html("<ul>" + Mustache.to_html(apps_template, view) + "</ul>");
+ var keys = getKeys(r[0]),
+ len = keys.length,
+ template = "",
+ view = {items:r},
+ apps_template = "{{#items}}<tr>--sub--</tr>{{/items}}",
+ header_template = "";
+ // run across array
+ for(var i=0;i<len;i++) {
+ template += ["<td>{{",keys[i],"}}</td>"].join("");
+ header_template += ["<th>",keys[i],"</th>"].join("");
+ }
+ // replace sub with new
+ apps_template = apps_template.replace(/--sub--/i, template);
+ $(".tree").html(["<thead><tr>",header_template,"</tr></thead>","<tbody>", Mustache.to_html(apps_template, view),"</tbody>"].join(""));
}
});
});
-
});
+
+ // get keys of object
+ function getKeys(obj) {
+ var keys = [];
+ for(var key in obj) {
+ keys.push(key);
+ }
+ return keys;
+ }
})(jQuery);
View
132 public/stylesheets/style.css
@@ -1,13 +1,46 @@
+/* Resets
+------ */
+
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6,
+p, blockquote, pre, a, abbr, address, cite, code, del, dfn, em,
+img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, hr,
+dl, dt, dd, ol, ul, li, fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, figure, figcaption, hgroup,
+menu, footer, header, nav, section, summary, time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+}
+
+article, aside, canvas, figure, figure img, figcaption, hgroup,
+footer, header, nav, section, audio, video {
+ display: block;
+}
+
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
- color:#3b3b3b;
+ color:#4b4b4b;
+}
+
+h1,h2,h3 {
+ line-height:1.2em;
+}
+
+ul,ol {
+ padding-left:2em;
+}
+
+p {
+ line-height:1.2em;
+ padding:0.5em 0;
}
*:focus {outline: none;}
a {
- color: #00B7FF;
+ color: #1d64a0;
}
.fr {
@@ -27,15 +60,41 @@ a {
}
#content_wrapper {
- width:600px;
+ padding-top:1.4em;
}
.sidebar {
width:200px;
}
+ul.lnav {
+ padding:0;
+ list-style:none;
+ width:150px;
+ font-size:12px;
+}
+
+ul.lnav li.first {
+ margin:0;
+}
+
+ul.lnav li {
+ margin-top:2px;
+}
+
+ul.lnav li a {
+ display:block;
+ background:#ddd;
+ padding:0.5em 1em;
+ color:#555;
+ text-decoration:none;
+}
+
+ul.lnav li a:hover {
+ background:#ccc;
+}
+
.content {
- width:390px;
}
@@ -45,7 +104,7 @@ span.label {
fieldset {
border:1px solid #ddd;
- padding:5px 0 5px 20px;
+ padding:5px 20px;
}
.input {
@@ -56,9 +115,6 @@ fieldset {
-webkit-box-shadow: 2px 2px 4px rgba(0,0,0,0.1) inset inset;
-o-box-shadow: 2px 2px 4px rgba(0,0,0,0.1) inset inset;
box-shadow: -2px 2px 4px rgba(0,0,0,0.1) inset;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
}
input.error {
@@ -69,11 +125,69 @@ input.error {
font-size:12px;
font-weight:700;
padding:5px 10px;
- background:firebrick;
color:#fff;
border:0;
text-shadow:0 -1px 1px rgba(0,0,0,0.3);
+}
+
+.submit:active {
+ background-color: #1d64a0;
+}
+
+.bluegrad {
+ background-color: #3289d3;
+ background-image: -moz-linear-gradient(top, #3289d3, #1a6db4); /* FF3.6 */
+ background-image: -ms-linear-gradient(top, #3289d3, #1a6db4); /* IE10 */
+ background-image: -o-linear-gradient(top, #3289d3, #1a6db4); /* Opera 11.10+ */
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#3289d3), to(#1a6db4)); /* Saf4+, Chrome */
+ background-image: -webkit-linear-gradient(top, #3289d3, #1a6db4); /* Chrome 10+, Saf5.1+ */
+ background-image: linear-gradient(top, #3289d3, #1a6db4);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#3289d3', EndColorStr='#1a6db4'); /* IE6–IE9 */
+}
+
+p.log_info {
+ font-size:12px;
+}
+
+p.msg {
+ font-size:11px;
+ font-weight:700;
+ padding:10px;
+ text-shadow:0 -1px 1px rgba(0,0,0,0.3);
+}
+
+p#failed,
+p#incomplete {
+ background:firebrick;
+ color:#fff;
+}
+
+.r5 {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
+ /* useful if you don't want a bg color from leaking outside the border: */
+ -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
+}
+
+.c {
+ max-width:650px;
+}
+
+.tree {
+ border-top: 1px solid #D8D8D8;
+ border-left: 1px solid #D8D8D8;
+ border-right: 1px solid #D8D8D8;
+ font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
+ font-size:12px;
+ margin: 0;
+ margin-bottom: 1em;
+ width:100%;
+}
+
+.tree td {
+ padding: .5em .7em;
+ color: #484848;
+ border-bottom: 1px solid #E1E1E1;
+ text-align:center;
}
View
10 server.js
@@ -86,7 +86,10 @@ app.post('/login',checkAuth, function(req,res, next) {
}
// encode username and password in base64
- req.user = encode.base64(req.body.user.user + ":" + req.body.user.pass);
+ req.user = {
+ creds:encode.base64(req.body.user.user + ":" + req.body.user.pass),
+ user:req.body.user.user
+ }
// authenticate user
req.authenticate('awesomeauth', function(err, authenticated) {
@@ -114,7 +117,8 @@ app.get('/', checkAuth, function(req, res){
else
res.render('index', {
title: 'Home | Nodester Admin Panel',
- is_logged: req.is_logged
+ is_logged: req.is_logged,
+ user: req.user.user
});
});
@@ -131,7 +135,7 @@ app.all("/api/*", checkAuth, function(req, res, next){
}
// method, api path, data, credentials, callback
- nodester.request("GET", req.params[0], params, req.user,function(data) {
+ nodester.request("GET", req.params[0], params, req.user.creds,function(data) {
res.header('Content-Type', 'application/json');
console.log(typeof(data),data);
res.end(data);
View
3  views/index.jade
@@ -1 +1,2 @@
-.c
+.c
+ table.tree(cellspacing:0,cellpadding:0)
View
3  views/layout.jade
@@ -6,7 +6,8 @@ html
body
h1 Nodester Admin Panel
- if(is_logged)
- p
+ p.log_info
+ | Howdy <strong>#{user}</strong> !
a(href="/logout") Logout
#content_wrapper
View
10 views/login.jade
@@ -4,10 +4,14 @@ form(method="post",action="/login")
p
label(for="user[user]")
span.label Username:
- input(type:"text", name:"user[user]", class:"input " + (action == "incomplete" ? "error" : ""))
+ input(type:"text", name:"user[user]", class:"input r5 " + ((action) ? "error" : ""))
p
label(for="user[pass]")
span.label Password:
- input(type:"password", name:"user[pass]", class:"input " + (action == "incomplete" ? "error" : ""))
+ input(type:"password", name:"user[pass]", class:"input r5 " + ((action) ? "error" : ""))
p.buttons
- input.submit(type="submit", value="Login")
+ input.submit.r5.bluegrad(type="submit", value="Login")
+ -if(action == "failed")
+ p#failed.msg.r5 Authorization Failed ! Do you have an account ?
+ -else if(action == "incomplete")
+ p#incomplete.msg.r5 Either username or password was blank.
View
6 views/sidebar.jade
@@ -1,4 +1,6 @@
.sidebar
- ul
+ ul.lnav
+ li.first
+ a(href="/api/apps",rel="ajax") My Apps
li
- a(href="/api/apps",rel="ajax") My Apps
+ a(href="/api/appdomains",rel="ajax") My Domains
Please sign in to comment.
Something went wrong with that request. Please try again.