mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
Add fetcher
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
@@ -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
|
||||
)
|
||||
]
|
||||
Reference in New Issue
Block a user