Skip to content

Commit

Permalink
fsg initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Gergen authored and Bryan Gergen committed May 4, 2016
1 parent 335f67e commit 7252de2
Show file tree
Hide file tree
Showing 65 changed files with 2,556 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# editorconfig.org
root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
219 changes: 219 additions & 0 deletions .eslintrc

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
node_modules
npm-debug.log
public
.DS_Store
coverage
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node server/start.js
11 changes: 11 additions & 0 deletions browser/js/about/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<section id="about">
<p>
This website--the very one at which you currently gaze--was created by a basic scaffolding
concocted at Fullstack Academy. Here are some of the people who make it all very real:
</p>
<carousel interval="2000">
<slide ng-repeat="image in images">
<img height="300" ng-src="{{ image }}" />
</slide>
</carousel>
</section>
17 changes: 17 additions & 0 deletions browser/js/about/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
app.config(function ($stateProvider) {

// Register our *about* state.
$stateProvider.state('about', {
url: '/about',
controller: 'AboutController',
templateUrl: 'js/about/about.html'
});

});

app.controller('AboutController', function ($scope, FullstackPics) {

// Images of beautiful Fullstack people.
$scope.images = _.shuffle(FullstackPics);

});
55 changes: 55 additions & 0 deletions browser/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';
window.app = angular.module('FullstackGeneratedApp', ['fsaPreBuilt', 'ui.router', 'ui.bootstrap', 'ngAnimate']);

app.config(function ($urlRouterProvider, $locationProvider) {
// This turns off hashbang urls (/#about) and changes it to something normal (/about)
$locationProvider.html5Mode(true);
// If we go to a URL that ui-router doesn't have registered, go to the "/" url.
$urlRouterProvider.otherwise('/');
// Trigger page refresh when accessing an OAuth route
$urlRouterProvider.when('/auth/:provider', function () {
window.location.reload();
});
});

// This app.run is for controlling access to specific states.
app.run(function ($rootScope, AuthService, $state) {

// The given state requires an authenticated user.
var destinationStateRequiresAuth = function (state) {
return state.data && state.data.authenticate;
};

// $stateChangeStart is an event fired
// whenever the process of changing a state begins.
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {

if (!destinationStateRequiresAuth(toState)) {
// The destination state does not require authentication
// Short circuit with return.
return;
}

if (AuthService.isAuthenticated()) {
// The user is authenticated.
// Short circuit with return.
return;
}

// Cancel navigating to new state.
event.preventDefault();

AuthService.getLoggedInUser().then(function (user) {
// If a user is retrieved, then renavigate to the destination
// (the second time, AuthService.isAuthenticated() will work)
// otherwise, if no user is logged in, go to "login" state.
if (user) {
$state.go(toState.name, toParams);
} else {
$state.go('login');
}
});

});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://jlau-bucket-1.s3.amazonaws.com/uploads/topic/image/42/fullstack.png" />
6 changes: 6 additions & 0 deletions browser/js/common/directives/fullstack-logo/fullstack-logo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.directive('fullstackLogo', function () {
return {
restrict: 'E',
templateUrl: 'js/common/directives/fullstack-logo/fullstack-logo.html'
};
});
17 changes: 17 additions & 0 deletions browser/js/common/directives/navbar/navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<nav class="navbar navbar-static-top">
<div class="container">
<div class="navbar-header">
<fullstack-logo></fullstack-logo>
</div>
<ul class="nav navbar-nav">
<li ng-repeat="item in items" ng-show="!item.auth || isLoggedIn()">
<a ui-sref-active="active" ui-sref="{{ item.state }}">{{ item.label }}</a>
</li>
</ul>
<button ng-show="!user" ui-sref="login" class="btn login-button">Login</button>
<div ng-show="user" class="welcome">
<span>Welcome, {{ user.email }}!</span>
<a ng-click="logout()">Logout</a>
</div>
</div>
</nav>
48 changes: 48 additions & 0 deletions browser/js/common/directives/navbar/navbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
app.directive('navbar', function ($rootScope, AuthService, AUTH_EVENTS, $state) {

return {
restrict: 'E',
scope: {},
templateUrl: 'js/common/directives/navbar/navbar.html',
link: function (scope) {

scope.items = [
{ label: 'Home', state: 'home' },
{ label: 'About', state: 'about' },
{ label: 'Documentation', state: 'docs' },
{ label: 'Members Only', state: 'membersOnly', auth: true }
];

scope.user = null;

scope.isLoggedIn = function () {
return AuthService.isAuthenticated();
};

scope.logout = function () {
AuthService.logout().then(function () {
$state.go('home');
});
};

var setUser = function () {
AuthService.getLoggedInUser().then(function (user) {
scope.user = user;
});
};

var removeUser = function () {
scope.user = null;
};

setUser();

$rootScope.$on(AUTH_EVENTS.loginSuccess, setUser);
$rootScope.$on(AUTH_EVENTS.logoutSuccess, removeUser);
$rootScope.$on(AUTH_EVENTS.sessionTimeout, removeUser);

}

};

});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>{{ greeting }}</h1>
11 changes: 11 additions & 0 deletions browser/js/common/directives/rando-greeting/rando-greeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app.directive('randoGreeting', function (RandomGreetings) {

return {
restrict: 'E',
templateUrl: 'js/common/directives/rando-greeting/rando-greeting.html',
link: function (scope) {
scope.greeting = RandomGreetings.getRandomGreeting();
}
};

});
30 changes: 30 additions & 0 deletions browser/js/common/factories/FullstackPics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
app.factory('FullstackPics', function () {
return [
'https://pbs.twimg.com/media/B7gBXulCAAAXQcE.jpg:large',
'https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xap1/t31.0-8/10862451_10205622990359241_8027168843312841137_o.jpg',
'https://pbs.twimg.com/media/B-LKUshIgAEy9SK.jpg',
'https://pbs.twimg.com/media/B79-X7oCMAAkw7y.jpg',
'https://pbs.twimg.com/media/B-Uj9COIIAIFAh0.jpg:large',
'https://pbs.twimg.com/media/B6yIyFiCEAAql12.jpg:large',
'https://pbs.twimg.com/media/CE-T75lWAAAmqqJ.jpg:large',
'https://pbs.twimg.com/media/CEvZAg-VAAAk932.jpg:large',
'https://pbs.twimg.com/media/CEgNMeOXIAIfDhK.jpg:large',
'https://pbs.twimg.com/media/CEQyIDNWgAAu60B.jpg:large',
'https://pbs.twimg.com/media/CCF3T5QW8AE2lGJ.jpg:large',
'https://pbs.twimg.com/media/CAeVw5SWoAAALsj.jpg:large',
'https://pbs.twimg.com/media/CAaJIP7UkAAlIGs.jpg:large',
'https://pbs.twimg.com/media/CAQOw9lWEAAY9Fl.jpg:large',
'https://pbs.twimg.com/media/B-OQbVrCMAANwIM.jpg:large',
'https://pbs.twimg.com/media/B9b_erwCYAAwRcJ.png:large',
'https://pbs.twimg.com/media/B5PTdvnCcAEAl4x.jpg:large',
'https://pbs.twimg.com/media/B4qwC0iCYAAlPGh.jpg:large',
'https://pbs.twimg.com/media/B2b33vRIUAA9o1D.jpg:large',
'https://pbs.twimg.com/media/BwpIwr1IUAAvO2_.jpg:large',
'https://pbs.twimg.com/media/BsSseANCYAEOhLw.jpg:large',
'https://pbs.twimg.com/media/CJ4vLfuUwAAda4L.jpg:large',
'https://pbs.twimg.com/media/CI7wzjEVEAAOPpS.jpg:large',
'https://pbs.twimg.com/media/CIdHvT2UsAAnnHV.jpg:large',
'https://pbs.twimg.com/media/CGCiP_YWYAAo75V.jpg:large',
'https://pbs.twimg.com/media/CIS4JPIWIAI37qu.jpg:large'
];
});
29 changes: 29 additions & 0 deletions browser/js/common/factories/RandomGreetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
app.factory('RandomGreetings', function () {

var getRandomFromArray = function (arr) {
return arr[Math.floor(Math.random() * arr.length)];
};

var greetings = [
'Hello, world!',
'At long last, I live!',
'Hello, simple human.',
'What a beautiful day!',
'I\'m like any other project, except that I am yours. :)',
'This empty string is for Lindsay Levine.',
'こんにちは、ユーザー様。',
'Welcome. To. WEBSITE.',
':D',
'Yes, I think we\'ve met before.',
'Gimme 3 mins... I just grabbed this really dope frittata',
'If Cooper could offer only one piece of advice, it would be to nevSQUIRREL!',
];

return {
greetings: greetings,
getRandomGreeting: function () {
return getRandomFromArray(greetings);
}
};

});
4 changes: 4 additions & 0 deletions browser/js/docs/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h3>
Documentation can be found in
<a target="_blank" href="https://github.com/FullstackAcademy/fsg/wiki/Getting-Started">the project's Github wiki</a>.
</h3>
6 changes: 6 additions & 0 deletions browser/js/docs/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app.config(function ($stateProvider) {
$stateProvider.state('docs', {
url: '/docs',
templateUrl: 'js/docs/docs.html'
});
});
Loading

0 comments on commit 7252de2

Please sign in to comment.