Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Carnegie Apps 2016
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ThierrySans
January 19, 2016
0
82
Carnegie Apps 2016
Building and deploying a web application using AngularJS, Firebase and Gitbub
ThierrySans
January 19, 2016
Tweet
Share
More Decks by ThierrySans
See All by ThierrySans
CSCD27 Social Engineering
thierrysans
0
250
CSCD27 Web Security
thierrysans
0
440
CSCD27 Malicious Software
thierrysans
0
390
CSCD27 Protection
thierrysans
0
500
CSCD27 System Insecurity
thierrysans
0
430
CSCD27 Human Authentication
thierrysans
0
350
CSCD27 Network security
thierrysans
0
560
CSCD27 Network (in)security
thierrysans
0
560
CSCD27 Cryptography Protocols
thierrysans
0
710
Featured
See All Featured
The Curse of the Amulet
leimatthew05
1
8.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Documentation Writing (for coders)
carmenintech
77
5.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
A Modern Web Designer's Workflow
chriscoyier
698
190k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
80
How to make the Groovebox
asonas
2
1.9k
Transcript
Building and deploying a web app using Thierry Sans Carnegie
App’s 2016
Credits Firebase - AngularFire Quickstart from https://www.firebase.com/tutorial/#tutorial/angular/0
Firechat
Perfect technology for hackathons frontend backend hosting
Get the starter code from Github $ git clone https://github.com/ThierrySans/firechat.git
Start a development server $ cd firechat $ python -m
SimpleHTTPServer
Frontend Development
Install AngularJS <!doctype html> <html ng-app> <head> <link rel="stylesheet" href=“style/example.css”/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js"></script> </head> <body> ... /index.html
AngularJS directives ... <body> <div class="c l-demo-container"> <header>Firebase Chat Demo</header>
<div class="c-toolbar"> <label for="nameInput">Username:</label> <input type="text" id="nameInput" placeholder="enter a username…" ng-model="username"/> </div> <ul class="c-messages"> <li><strong class="c-username">John Doe</strong>Who am I?</li> <li><strong class="c-username">Homer Simpson</strong>Doh!</li> <li><strong class=“c-username”>{{username}}</strong>{{content}}</li> </ul> <footer> <input type="text" id="messageInput" placeholder="Type a message…" ng-model="content"/> </footer> </div> </body> ... ng-model="username" $scope {{username}} /index.html form context view
AngularJS controller <!doctype html> <html ng-app="firechat"> <head> <link rel="stylesheet" href="style/example.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js" ></script> <script src="app/firechat.js"></script> </head> <body ng-controller="myController"> ... /index.html /app/firechat.js var firechat = angular.module("firechat", []); firechat.controller("myController", ["$scope",function($scope){ console.log("Hello myController"); }]);
Separating data firechat.controller("myController", ["$scope",function($scope){ $scope.messages = [{'username': 'John Doe', 'content':'Who
am I?'}, {'username': 'Homer Simpson’, 'content':'Doh!'}]; }]); /app/firechat.js /index.html <ul class="c-messages"> <li ng-repeat="msg in messages"> <strong class="c-username">{{ msg.username }}</strong> {{ msg.content }} </li> </ul>
Add an event handler firechat.controller("myController", ["$scope",function($scope){ $scope.messages = ... $scope.addMessage
= function(e){ console.log($scope.username); console.log($scope.content); console.log(e.keyCode); }; }]); /app/firechat.js /index.html <footer> <input type="text" id="messageInput" placeholder="..." ng-model="content" ng-keydown="addMessage($event)"/> </footer>
Putting it all together firechat.controller("myController", ["$scope",function($scope){ $scope.messages = ...] $scope.addMessage
= function(e){ if (e.keyCode === 13 && $scope.content) { // set anonymous var username = $scope.username || "anonymous"; // add message to messages $scope.messages.push({ username: username, content: $scope.content }); // reset the content $scope.content = ""; } }; }]); /app/firechat.js
Backed Development
Creating a firebase account
Creating a firebase database get the database URL
Install Firebase /index.html <!doctype html> <html ng-app="firechat"> <head> <link rel="stylesheet"
href="style/example.css"/> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js"></script> <script src="https://cdn.firebase.com/js/client/2.2.1/firebase.js"></script> <script src="https://cdn.firebase.com/libs/angularfire/1.0.0/angularfire.min.js"></script> <script src="app/firechat.js"></script> </head> /app/firebase.js var firebase = angular.module("firechat", ["firebase"]); firebase.controller("myController", ["$scope","$firebaseArray",function($scope,$firebaseArray){ var db = new Firebase(“https://brilliant-heat-5654.firebaseio.com/"); ...
Pushing and pulling data with Firebase firechat.controller("myController", ["$scope",function($scope){ var db
= new Firebase(“https://brilliant-heat-5654.firebaseio.com/"); $scope.messages = $firebaseArray(db); $scope.addMessage = function(e){ if (e.keyCode === 13 && $scope.content) { // set anonymous var username = $scope.username || "anonymous"; // add message to messages $scope.messages.$add({ username: username, content: $scope.content }); // reset the content $scope.content = ""; } }; }]); /app/firechat.js
Firebase admin
Deployment
Create a repository
Initialize the repository $ rm -Rf .git
Push the code $ git add -A $ git
commit -m “first version” $ git push
Synchronize the gh-pages branch $ git checkout gh-pages $ git
merge master $ git push origin gh-pages $ git branch gh-pages Create the gh-pages branch (first time only) Synchronize gh-pages with master
Ta-Dah! https://thierrysans.github.io/firetest/