Skip to content

Commit f034892

Browse files
author
Simon Mackie
committed
Initial commit
0 parents  commit f034892

File tree

6,553 files changed

+1441698
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,553 files changed

+1441698
-0
lines changed

Ch 02/sp-blogger/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License
2+
3+
Copyright (c) 2010-2012 Google, Inc. http://angularjs.org
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+

Ch 02/sp-blogger/README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# angular-seed — the seed for AngularJS apps
2+
3+
This project is an application skeleton for a typical [AngularJS](http://angularjs.org/) web app.
4+
You can use it to quickly bootstrap your angular webapp projects and dev environment for these
5+
projects.
6+
7+
The seed contains AngularJS libraries, test libraries and a bunch of scripts all preconfigured for
8+
instant web development gratification. Just clone the repo (or download the zip/tarball), start up
9+
our (or your) webserver and you are ready to develop and test your application.
10+
11+
The seed app doesn't do much, just shows how to wire two controllers and views together. You can
12+
check it out by opening app/index.html in your browser (might not work file `file://` scheme in
13+
certain browsers, see note below).
14+
15+
_Note: While angular is client-side-only technology and it's possible to create angular webapps that
16+
don't require a backend server at all, we recommend hosting the project files using a local
17+
webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
18+
sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
19+
etc to function properly when an html page is opened via `file://` scheme instead of `http://`._
20+
21+
22+
## How to use angular-seed
23+
24+
Clone the angular-seed repository and start hacking...
25+
26+
27+
### Running the app during development
28+
29+
You can pick one of these options:
30+
31+
* serve this repository with your webserver
32+
* install node.js and run `scripts/web-server.js`
33+
34+
Then navigate your browser to `http://localhost:<port>/app/index.html` to see the app running in
35+
your browser.
36+
37+
38+
### Running the app in production
39+
40+
This really depends on how complex is your app and the overall infrastructure of your system, but
41+
the general rule is that all you need in production are all the files under the `app/` directory.
42+
Everything else should be omitted.
43+
44+
Angular apps are really just a bunch of static html, css and js files that just need to be hosted
45+
somewhere, where they can be accessed by browsers.
46+
47+
If your Angular app is talking to the backend server via xhr or other means, you need to figure
48+
out what is the best way to host the static files to comply with the same origin policy if
49+
applicable. Usually this is done by hosting the files by the backend server or through
50+
reverse-proxying the backend server(s) and a webserver(s).
51+
52+
53+
### Running unit tests
54+
55+
We recommend using [jasmine](http://pivotal.github.com/jasmine/) and
56+
[Karma](http://karma-runner.github.io) for your unit tests/specs, but you are free
57+
to use whatever works for you.
58+
59+
Requires [node.js](http://nodejs.org/), Karma (`sudo npm install -g karma`) and a local
60+
or remote browser.
61+
62+
* start `scripts/test.sh` (on windows: `scripts\test.bat`)
63+
* a browser will start and connect to the Karma server (Chrome is default browser, others can be captured by loading the same url as the one in Chrome or by changing the `config/karma.conf.js` file)
64+
* to run or re-run tests just change any of your source or test javascript files
65+
66+
67+
### End to end testing
68+
69+
We recommend using [protractor](https://github.com/angular/protractor) for end-to-end tests. It
70+
uses native events and has special features for Angular applications.
71+
72+
Requires a webserver, node.js + `./scripts/web-server.js` or your backend server that hosts the angular static files.
73+
74+
* create your end-to-end tests in `test/e2e/scenarios.js`
75+
* serve your project directory with your http/backend server or node.js + `scripts/web-server.js`
76+
* to run:
77+
* run the tests from console with [Protractor](https://github.com/angular/protractor) via
78+
`scripts/e2e-test.sh` (on windows: `scripts\e2e-test.bat`)
79+
80+
### Continuous Integration
81+
82+
CloudBees have provided a CI/deployment setup:
83+
84+
<a href="https://grandcentral.cloudbees.com/?CB_clickstart=https://raw.github.com/CloudBees-community/angular-js-clickstart/master/clickstart.json"><img src="https://d3ko533tu1ozfq.cloudfront.net/clickstart/deployInstantly.png"/></a>
85+
86+
If you run this, you will get a cloned version of this repo to start working on in a private git repo,
87+
along with a CI service (in Jenkins) hosted that will run unit and end to end tests in both Firefox and Chrome.
88+
89+
### Receiving updates from upstream
90+
91+
When we upgrade angular-seed's repo with newer angular or testing library code, you can just
92+
fetch the changes and merge them into your project with git.
93+
94+
95+
## Directory Layout
96+
97+
app/ --> all of the files to be used in production
98+
css/ --> css files
99+
app.css --> default stylesheet
100+
img/ --> image files
101+
index.html --> app layout file (the main html template file of the app)
102+
index-async.html --> just like index.html, but loads js files asynchronously
103+
js/ --> javascript files
104+
app.js --> application
105+
controllers.js --> application controllers
106+
directives.js --> application directives
107+
filters.js --> custom angular filters
108+
services.js --> custom angular services
109+
lib/ --> angular and 3rd party javascript libraries
110+
angular/
111+
angular.js --> the latest angular js
112+
angular.min.js --> the latest minified angular js
113+
angular-*.js --> angular add-on modules
114+
version.txt --> version number
115+
partials/ --> angular view partials (partial html templates)
116+
partial1.html
117+
partial2.html
118+
119+
config/karma.conf.js --> config file for running unit tests with Karma
120+
config/protractor-conf.js --> config file for running e2e tests with Protractor
121+
122+
scripts/ --> handy shell/js/ruby scripts
123+
e2e-test.sh --> runs end-to-end tests with Karma (*nix)
124+
e2e-test.bat --> runs end-to-end tests with Karma (windows)
125+
test.bat --> autotests unit tests with Karma (windows)
126+
test.sh --> autotests unit tests with Karma (*nix)
127+
web-server.js --> simple development webserver based on node.js
128+
129+
test/ --> test source files and libraries
130+
e2e/ -->
131+
scenarios.js --> end-to-end specs
132+
lib/
133+
angular/ --> angular testing libraries
134+
angular-mocks.js --> mocks that replace certain angular services in tests
135+
version.txt --> version file
136+
unit/ --> unit level specs/tests
137+
controllersSpec.js --> specs for controllers
138+
directivessSpec.js --> specs for directives
139+
filtersSpec.js --> specs for filters
140+
servicesSpec.js --> specs for services
141+
142+
## Contact
143+
144+
For more information on AngularJS please check out http://angularjs.org/

Ch 02/sp-blogger/app/css/.gitkeep

Whitespace-only changes.

Ch 02/sp-blogger/app/css/app.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* app css stylesheet */
2+
3+
.menu {
4+
list-style: none;
5+
border-bottom: 0.1em solid black;
6+
margin-bottom: 2em;
7+
padding: 0 0 0.5em;
8+
}
9+
10+
.menu:before {
11+
content: "[";
12+
}
13+
14+
.menu:after {
15+
content: "]";
16+
}
17+
18+
.menu > li {
19+
display: inline;
20+
}
21+
22+
.menu > li:before {
23+
content: "|";
24+
padding-right: 0.3em;
25+
}
26+
27+
.menu > li:nth-child(1):before {
28+
content: "";
29+
padding: 0;
30+
}

Ch 02/sp-blogger/app/img/.gitkeep

Whitespace-only changes.

Ch 02/sp-blogger/app/index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>The Single Page Blogger</title>
6+
<script type="text/javascript" src="lib/angular/angular-loader.js"></script>
7+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/script.js/2.4.0/script.min.js"></script>
8+
<script type="text/javascript">
9+
$script([
10+
'lib/angular/angular.js',
11+
'js/controllers.js',
12+
'js/directives.js',
13+
'js/services.js',
14+
'js/filters.js',
15+
'js/app.js',
16+
'modules/posts/postModule.js',
17+
'modules/posts/js/services.js',
18+
'modules/posts/js/controllers.js',
19+
'modules/posts/js/filters.js',
20+
'modules/posts/js/directives.js'
21+
], function() {
22+
angular.bootstrap(document, ['spBlogger']);
23+
});
24+
</script>
25+
</head>
26+
<body>
27+
<!-- The Content Goes here. We will develop this-->
28+
<i>The Single Page Blogger <app-version/></i>
29+
</body>
30+
</html>

Ch 02/sp-blogger/app/js/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict'
2+
3+
angular.module('spBlogger',['spBlogger.posts','spBlogger.controllers','spBlogger.directives','spBlogger.filters','spBlogger.services']);
4+
5+
angular.module('spBlogger').value('version','V1.0');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
3+
angular.module('spBlogger.controllers',[]);

Ch 02/sp-blogger/app/js/directives.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
3+
angular.module('spBlogger.directives',[]);
4+
5+
angular.module('spBlogger.directives').directive('appVersion',function(version){
6+
return {
7+
restrict: 'AE',
8+
link: function(scope,elem,attrs){
9+
elem.html(version);
10+
}
11+
}
12+
});

Ch 02/sp-blogger/app/js/filters.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
3+
angular.module('spBlogger.filters',[]);

Ch 02/sp-blogger/app/js/routes.js

Whitespace-only changes.

Ch 02/sp-blogger/app/js/services.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
3+
angular.module('spBlogger.services',[]);

0 commit comments

Comments
 (0)