mirror of
https://github.com/wassname/side-by-side.git
synced 2026-08-22 12:30:36 +08:00
19 lines
541 B
CoffeeScript
19 lines
541 B
CoffeeScript
angular.module("sideBySide").factory "fetch", ['$http', '$q', 'readerFactory', ($http, $q, readerFactory) ->
|
|
# Fetch
|
|
#
|
|
# @param base [String] Path to config file directory
|
|
# @return [Object] Promises and heading
|
|
(base) ->
|
|
file = base + '/config.json'
|
|
$http.get(file).then (config) ->
|
|
promises = config.data.files.map (poem) ->
|
|
$http.get(base + '/' + poem).then (response) ->
|
|
readerFactory(poem) response.data
|
|
|
|
{
|
|
fetchPoems: $q.all promises
|
|
heading: config.data.heading
|
|
display: config.data.display
|
|
}
|
|
]
|