Skip to content

Commit e5b915f

Browse files
addisonedwardleepetebacondarwin
authored andcommitted
refact(*): update overall application architecture to match best practices
1 parent 9d0b43b commit e5b915f

File tree

13 files changed

+152
-21
lines changed

13 files changed

+152
-21
lines changed

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,38 @@ Now browse to the app at `http://localhost:8000/app/index.html`.
7070

7171
## Directory Layout
7272

73-
app/ --> all of the files to be used in production
74-
css/ --> css files
75-
app.css --> default stylesheet
76-
img/ --> image files
77-
index.html --> app layout file (the main html template file of the app)
78-
index-async.html --> just like index.html, but loads js files asynchronously
79-
js/ --> javascript files
80-
app.js --> application
81-
controllers.js --> application controllers
82-
directives.js --> application directives
83-
filters.js --> custom angular filters
84-
services.js --> custom angular services
85-
partials/ --> angular view partials (partial html templates)
86-
partial1.html
87-
partial2.html
88-
89-
test/ --> test config and source files
73+
app/ --> all of the files to be used in production
74+
assets/ --> all static asset files
75+
css/ --> css files
76+
app.css --> default stylesheet
77+
img/ --> image files
78+
components/ --> all app specific modules
79+
directives/ --> application level directives
80+
appVersion.js --> custom directive that returns the current app version
81+
filters/ --> application level filters
82+
interpolate.js --> custom interpolation filter
83+
services/ --> application level services
84+
appVersionService.js --> custom service that returns the current app version
85+
view1/ --> a custom module for this application
86+
view1.html --> the template rendered for this module
87+
view1.js --> the application logic for this module
88+
view2/ --> a custom module for this application
89+
view2.html --> the template rendered for this module
90+
view2.js --> the application logic for this module
91+
app.js --> application
92+
index.html --> app layout file (the main html template file of the app)
93+
index-async.html --> just like index.html, but loads js files asynchronously
94+
test/ --> test config and source files
9095
protractor-conf.js --> config file for running e2e tests with Protractor
9196
e2e/ --> end-to-end specs
9297
scenarios.js
9398
karma.conf.js --> config file for running unit tests with Karma
9499
unit/ --> unit level specs/tests
95-
controllersSpec.js --> specs for controllers
96-
directivessSpec.js --> specs for directives
97-
filtersSpec.js --> specs for filters
98-
servicesSpec.js --> specs for services
100+
directivessSpec.js --> specs for application level directives
101+
filtersSpec.js --> specs for application level filters
102+
servicesSpec.js --> specs for application level services
103+
view1Spec.js --> specs for the view1 module
104+
view2Spec.js --> specs for the view2 module
99105

100106

101107
## Testing

app/assets/css/.gitkeep

Whitespace-only changes.

app/assets/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+
}

app/assets/img/.gitkeep

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
angular.module('appVersion', [])
4+
.directive('appVersion', ['version', function(version) {
5+
return function(scope, element, attributes, controller) {
6+
element.text(version);
7+
};
8+
}]);

app/components/filters/interpolate.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
/* Filters */
4+
5+
angular.module('interpolate', []).
6+
filter('interpolate', ['version', function(version) {
7+
return function(text) {
8+
return String(text).replace(/\%VERSION\%/mg, version);
9+
};
10+
}]);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
/* Services */
4+
5+
// Demonstrate how to register services
6+
// In this case it is a simple value service.
7+
angular.module('appVersionService', [])
8+
.value('version', '0.1');

app/components/view1/view1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>This is the partial for view 1.</p>

app/components/view1/view1.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
angular.module('view1', [])
4+
.config(['$routeProvider', function($routeProvider) {
5+
$routeProvider.when('/view1', {
6+
templateUrl: 'components/view1/view1.html',
7+
controller: 'MyCtrl1'
8+
});
9+
}])
10+
11+
.controller('MyCtrl1', ['$scope', function($scope) {
12+
13+
}]);

app/components/view2/view2.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>This is the partial for view 2.</p>
2+
<p>
3+
Showing of 'interpolate' filter:
4+
{{ 'Current version is v%VERSION%.' | interpolate }}
5+
</p>

0 commit comments

Comments
 (0)