Skip to content

Commit

Permalink
Add initial scaffolding for agora
Browse files Browse the repository at this point in the history
 - Create basic routes structure
 - Expose configuration object
 - Expose db connection
 - Modularize views
 - Create initial layout for homepage
 - Create initial structure for api
  • Loading branch information
Kaustav Das Modak committed Jun 19, 2014
1 parent 303e186 commit ea33ce8
Show file tree
Hide file tree
Showing 18 changed files with 531 additions and 177 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

node_modules
npm-debug.log

.DS_Store
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
The OpenShift `nodejs` cartridge documentation can be found at:
# Agora

http://openshift.github.io/documentation/oo_cartridge_guide.html#nodejs
This is the application powering the Applait Marketplace, aka, Agora. It is a NodeJS application using Express as its
framework and MongoDB as the storage backend.
36 changes: 36 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node

var express = require("express"),
path = require("path"),
bodyParser = require("body-parser"),
session = require("express-session"),
cookieParser = require("cookie-parser"),
config = require("./config"),
nunjucks = require("nunjucks");

var app = express();


// Configure template engine
nunjucks.configure('views', {
autoescape: true,
express: app
});

// Configure application
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser("banana"));
app.use("/assets", express.static(path.join(__dirname, 'assets')));
app.use(session({ secret: "potato" }));


// --- Begin routes ---- //

app.use("/", require("./routes/home"));
app.use("/api", require("./routes/api"));

// Start the server
var server = app.listen(config.APP_PORT, function () {
console.log("Listening on port %d", server.address().port);
});
240 changes: 240 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
@charset "utf-8";

/**
* Stylesheet Index:
* =================
*
* 0. Elements
* 1. ID & Class
* 2. Pseudoclass
* 3. Media Queries
*/

/* 0. Elements */
html, body {
width: 100%;
height: 100%;
font-family: "Merriweather", sans-serif;
color: #fff;
background-color: #5F5F5F;
-webkit-tap-highlight-color: rgba(255,255,255,.2);
}

h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0 0 35px;
text-transform: uppercase;
font-family: "Montserrat", sans-serif;
font-weight: 700;
letter-spacing: 1px;
}

p {
margin: 0 0 25px;
font-size: 18px;
line-height: 1.5;
}

a {
color: #FF9500;
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}

input {
width: 100%;
padding: 8px;
font-size: 20px;
outline: none;
border: solid #804000;
border-width: 1px 1px 4px;
}

input[type="text"] { color: #666; }

/* 1. ID & Class */
.navbar {
border: none;
margin-bottom: 0;
background-color: #333333;
padding-top: 0;
padding-bottom: 0;
}

.navbar a { color: #fff; }

#request-app-link {
outline: 0;
float: right;
padding: 15px;
display: block;
background-color: #CD6723;
}

.navbar-brand,
#brand-wordmark {
font-size: 1.5em;
font-weight: 400;
text-transform: lowercase;
font-family: "Alegreya", sans-serif;
}

#brand-wordmark { font-size: 4em; }

.intro {
display: table;
width: 100%;
height: 100%;
padding: 100px 0;
text-align: center;
background-color: #333333;
}

.intro-body {
display: table-cell;
vertical-align: middle;
}

.btn-circle {
width: 70px;
height: 70px;
margin-top: 30px;
padding: 5px 16px;
border: 2px solid #fff;
border-radius: 50%;
font-size: 3em;
}

.btn-circle:hover i.animated {
-webkit-animation-name: pulse;
-webkit-animation-duration: 0.5s;
-webkit-animation-direction: alternate;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-transition-duration: 1s;
-webkit-transition-property: -webkit-transform;
animation-name: pulse;
animation-duration: 0.5s;
animation-direction: alternate;
animation-timing-function: linear;
animation-iteration-count: infinite;
transition-duration: 1s;
transition-property: -moz-transform;
}

.content-section {
padding: 50px 0;
}

#offer { background-color: #5A5C63; }
#about { background-color: #4D4E53; }
#contact { background-color: #3D3E42; }
#request { background: #CD6723; }

.show { opacity: 1; }
.crossfade {
-webkit-transition: all .3s ease-out;
transition: all .3s ease-out;
}

.not-form-group { width: 100%; }

#request-submit {
color: #804000;
padding: 8px 16px;
background-color: #FF9500;
}

#failure-toast,
#submission-toast {
color: #6a4d2b;
display: none;
font-size: 1.5rem;
}

.request-again {
cursor: pointer;
text-decoration: underline;
}

/* 2. Pseudoclass */
::-moz-selection {
text-shadow: none;
background: #fcfcfc;
background: rgba(255,255,255,.2);
}

::selection {
text-shadow: none;
background: #fcfcfc;
background: rgba(255,255,255,.2);
}

input::-moz-selection {
color: #eee;
background: #444;
}

input::selection {
color: #eee;
background: #444;
}

a:hover,
a:focus {
text-decoration: none;
color: #FFA640;
}

.navbar-brand:focus { outline: 0; }

#request-app-link:hover,
#request-app-link:focus,
#request-app-link:active {
background-color: rgba(255,255,255,.2);
}

.btn-circle:hover,
.btn-circle:focus {
outline: 0;
color: #fff;
background: rgba(255,255,255,.1);
}

#request-submit:hover,
#request-submit:focus,
#request-submit:active {
color: #eee;
background-color: #E66000;
}

@-webkit-keyframes pulse {
from { -webkit-transform: scale(1); }
to { -webkit-transform: scale(1.2); }
}
@keyframes pulse {
from { transform: scale(1); }
to { transform: scale(1.2); }
}

/* 3. Media Queries */
@media(min-width:767px) {
p {
margin: 0 0 35px;
font-size: 20px;
line-height: 1.6;
}
.intro { padding: 0; }
#brand-wordmark { font-size: 6em; }
.intro-text { font-size: 1.75em; }
.content-section { padding: 100px 0; }
#request-form .form-group {
margin: auto 2px;
width: 35%;
}
#request-form .not-form-group { width: 25%; }
}
Binary file added assets/img/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/social.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Configuration parapmeters
var endPoint = "/api/apps/create";

//jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
$('.page-scroll a').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});

// Handle app-request with AJAX
var youGoBoy = function (appname, appdescription, url) {
$.ajax({
type: "POST",
url: endPoint,
data: {
name: appname,
description: appdescription,
url: url
}
}).done(function (data) {
$("#submission-toast").fadeIn();
$("#request-form").hide();
}).fail(function (error) {
console.log(JSON.stringify(error, null, " "));
});
};

var ohNoes = function () {
$("#failure-toast").fadeIn();
$("#request-form").hide();
}

$("#request-submit").click( function (event) {
event.preventDefault();
var appname = $("#item-app-name").val();
var appdescription = $("#item-app-description").val();
var url = $("#item-url").val();
(appname && appdescription && url) ? youGoBoy(appname, appdescription, url) : ohNoes();
return false;
});

// Reenable form, for resubmission
$(".request-again").click( function (event) {
$(this).parent().hide();
$("#request-form").fadeIn();
$("#item-app-name").select();
});
25 changes: 25 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var config = {
REPO_USERNAME : "applait",
REPO_SLUG : "agora",
APP_IP: process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1",
APP_PORT: process.env.OPENSHIFT_NODEJS_PORT || "1337",
DB_HOST: process.env.OPENSHIFT_MONGODB_DB_HOST || "localhost",
DB_PORT: process.env.OPENSHIFT_MONGODB_DB_PORT || "27017",
DB_USER: process.env.OPENSHIFT_MONGODB_DB_USER || "",
DB_PASS: process.env.OPENSHIFT_MONGODB_DB_PASS || "",
DB_NAME: process.env.OPENSHIFT_MONGODB_DB_NAME || "agora",

endpoint : function (str) {
return config.APIBASE + str.replace(/\{user\}/, config.REPO_USERNAME).replace(/\{repo\}/, config.REPO_SLUG);
},

loggedin : function (req, res, next) {
if (req.user) {
next();
} else {
res.redirect("/login");
}
}
};

module.exports = config;
8 changes: 8 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var config = require("./config"),
monk = require("monk"),
dbpath;

dbpath = (config.DB_USER ? config.DB_USER + ":" + config.DB_PASS + "@" : "") + config.DB_HOST +
":" + config.DB_PORT + "/" + config.DB_NAME;

module.exports = monk(dbpath);
Loading

0 comments on commit ea33ce8

Please sign in to comment.