diff --git a/source/documents/_scripts.html.jade b/source/documents/_scripts.html.jade
index 9d25b4a..a40f171 100644
--- a/source/documents/_scripts.html.jade
+++ b/source/documents/_scripts.html.jade
@@ -4,6 +4,7 @@ script(src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.js")
// TODO use cdnjs.com once they serve marked
script(src="//raw.github.com/chjj/marked/master/lib/marked.js")
script(src="scripts/app.js")
+script(src="scripts/services/fetch.js")
script(src="scripts/services/reader/_factory.js")
script(src="scripts/services/reader/markdown.js")
script(src="scripts/services/reader/json.js")
diff --git a/source/documents/index.html.jade b/source/documents/index.html.jade
index fa4de5c..082941b 100644
--- a/source/documents/index.html.jade
+++ b/source/documents/index.html.jade
@@ -16,7 +16,7 @@ html(ng-app="sideBySide")
.version-outer
.version-inner
.section {{ version.section }}
- .text {{ version.text }}
+ .text(ng-bind-html-unsafe="version.text")
//// debugging cascade
//hr
diff --git a/source/documents/scripts/controllers.js.coffee b/source/documents/scripts/controllers.js.coffee
index 580eb19..a60c2ae 100644
--- a/source/documents/scripts/controllers.js.coffee
+++ b/source/documents/scripts/controllers.js.coffee
@@ -1,41 +1,23 @@
angular.module("sideBySide.controllers", [])
-.controller "comparisonController", ['$scope', ($scope) ->
- $scope.columns = 2
- $scope.verses = [
- [
- {
- section: 'first'
- text: 'a'
- }, {
- section: 'I'
- text: '1'
- }
- ], [
- {
- section: 'second'
- text: 'b'
- }, {
- section: 'II'
- text: '2'
- }
- ], [
- {
- section: 'third'
- text: 'c'
- }, {
- section: 'III'
- text: '3'
- }
- ], [
- {
- section: 'fourth'
- text: 'd'
- }, {
- section: 'IV'
- text: '4'
- }
- ]
- ]
+.controller "comparisonController", [
+ '$location', '$q', '$scope', 'fetch', 'transformer'
+ ($location, $q, $scope, fetch, transformer) ->
+ $scope.columns = 1
+ $scope.verses = [[{
+ section: 'Loading...'
+ text: 'Please be patient!'
+ }]]
+
+ update = (config) ->
+ fetch(config).then((promises) ->
+ $q.all(promises).then((results) ->
+ $scope.columns = results.length
+ transformed = transformer(results)
+ $scope.verses = transformed.verses
+ )
+ )
+
+ update($location.path() + "/config.json")
]
#.controller "notificationController", ['$scope', '$timeout', ($scope, $timeout) ->
diff --git a/source/documents/scripts/services/fetch.js.coffee b/source/documents/scripts/services/fetch.js.coffee
new file mode 100644
index 0000000..e78ccec
--- /dev/null
+++ b/source/documents/scripts/services/fetch.js.coffee
@@ -0,0 +1,16 @@
+angular.module("sideBySide").factory "fetch", ['$http', 'readerFactory', ($http, readerFactory) ->
+ # Fetch
+ #
+ # @param file [String] Path to config file
+ # @return TODO
+ return (file = "config.json") ->
+ $http.get(file).then((response) ->
+ promises = []
+ for poem in response.data.files
+ promises.push($http.get(poem).then((response) ->
+ reader = readerFactory(poem)
+ return reader(response.data)
+ ))
+ return promises
+ )
+]