File tree Expand file tree Collapse file tree 11 files changed +162
-0
lines changed Expand file tree Collapse file tree 11 files changed +162
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "directory": "bower_components"
3
+ }
Original file line number Diff line number Diff line change
1
+ ** /.DS_Store
2
+ nbproject
3
+ manifest.mf
4
+ build.xml
5
+
6
+ node_modules
7
+
8
+ .project
9
+ .settings
10
+ .idea /*
11
+
12
+ _public
13
+ npm-debug.log
14
+
15
+ # Bower stuff.
16
+ bower_components /
Original file line number Diff line number Diff line change
1
+ # dynamic-script
2
+ ### A demo project which loads dynamic initialization data via a script tag in
3
+ ### the static index.html file before any javascript has initialized.
4
+
5
+ /api/user.js returns a dummy script after a 1 second delay, mimicking
6
+ a slow call to an external api server.
7
+
8
+ To setup and start the server run:
9
+ npm install
10
+ bower install
11
+ npm start
Original file line number Diff line number Diff line change
1
+ ' use strict'
2
+
3
+ App = angular .module (' app' , [
4
+ ' app.controllers'
5
+ ])
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en " ng-app ="app ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title ng-bind-template ="{{pageTitle}} "> </ title >
6
+ < link rel ="stylesheet " href ="/css/app.css ">
7
+ < script src ="/js/vendor.js "> </ script >
8
+ < script src ="/js/app.js "> </ script >
9
+ < script src ="/api/user.js "> </ script >
10
+ </ head >
11
+ < body ng-controller ="AppCtrl ">
12
+ < div class ="container main-content ">
13
+ < div ng-hide ="user "> Loading user...</ div >
14
+ < div ng-show ="user "> Hello {{user.name}}</ div >
15
+ < div class ="experience " ng-class ="user.experience " ng-show ="user.experience == 'deadly' "> AARRRGGGHHH!!!</ div >
16
+ </ div >
17
+ </ body >
18
+ </ html >
Original file line number Diff line number Diff line change
1
+ ' use strict'
2
+
3
+ ### Controllers ###
4
+
5
+ app = angular .module (' app.controllers' , [])
6
+
7
+ app .controller ' AppCtrl' , ($scope , $window ) ->
8
+ $scope .user = $window .user
Original file line number Diff line number Diff line change
1
+ body {
2
+ font : 20px / 18px sans-serif ;
3
+ }
4
+
5
+ .container {
6
+ margin : 30px auto ;
7
+ width : 500px ;
8
+ text-align : center ;
9
+ }
10
+
11
+ .experience {
12
+ margin : 20px 0 ;
13
+ padding : 10px ;
14
+ border : 2px solid #333 ;
15
+
16
+ & .deadly {
17
+ color : #fff ;
18
+ background-color : #c42 ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " dynamic-script" ,
3
+ "repo" : " dynamic-script" ,
4
+ "version" : " 0.0.0" ,
5
+ "main" : " _public/js/app.js" ,
6
+ "ignore" : [
7
+ " **/.*" ,
8
+ " node_modules" ,
9
+ " components"
10
+ ],
11
+ "dependencies" : {
12
+ "angular" : " 1.2.5"
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ exports .config =
2
+ # See docs at http://brunch.readthedocs.org/en/latest/config.html.
3
+ conventions :
4
+ assets : / ^ app\/ assets\/ /
5
+ modules :
6
+ definition : false
7
+ wrapper : false
8
+ paths :
9
+ public : ' _public'
10
+ files :
11
+ javascripts :
12
+ joinTo :
13
+ ' js/app.js' : / ^ app\/ /
14
+
15
+ stylesheets :
16
+ joinTo :
17
+ ' css/app.css' : / ^ app\/ styles\/ /
18
+
19
+ server :
20
+ port : 3344
21
+ path : ' server.coffee'
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " dynamic-script" ,
3
+ "version" : " 0.0.0" ,
4
+ "description" : " Demo of dynamic content loaded from static html script tag (e.g. initial API call for user session/data)" ,
5
+ "scripts" : {
6
+ "start" : " ./node_modules/.bin/brunch watch --server"
7
+ },
8
+ "author" : " Jacob Frautschi" ,
9
+ "license" : " All rights reserved" ,
10
+ "private" : true ,
11
+ "dependencies" : {
12
+ "express" : " ~3" ,
13
+ "bower" : " ~1.0" ,
14
+ "coffee-script" : " ~1" ,
15
+ "brunch" : " ~1.7" ,
16
+ "css-brunch" : " ~1.7" ,
17
+ "less-brunch" : " ~1.7" ,
18
+ "stylus-brunch" : " ~1.8" ,
19
+ "javascript-brunch" : " ~1.7" ,
20
+ "coffee-script-brunch" : " ~1.8"
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ http = require ' http'
2
+ express = require ' express'
3
+
4
+ exports .startServer = (port , assetsPath , callback ) ->
5
+ app = express ()
6
+ server = http .createServer (app)
7
+
8
+ app .set ' port' , port
9
+ app .use express .static (assetsPath)
10
+ app .use app .router
11
+
12
+ # fake a slow api response
13
+ app .get ' /api/user.js' , (req , res ) ->
14
+ res .contentType ' text/javascript'
15
+ setTimeout (->
16
+ res .end """
17
+ window.user = {
18
+ name: 'Bones McGee',
19
+ experience: 'deadly'
20
+ };
21
+ """
22
+ ), 1000
23
+
24
+ server .listen port, callback
You can’t perform that action at this time.
0 commit comments