Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include asset map file contents into index.html (#6)
- Loading branch information
Ruslan Zavacky
committed
Apr 2, 2017
1 parent
7023766
commit 35f48c0
Showing
6 changed files
with
138 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
/* global window, __assetMapFilename__ */ | ||
/* global window, __assetMapPlaceholder__ */ | ||
import RSVP from 'rsvp'; | ||
import $ from 'jquery'; | ||
import AssetMap from '../services/asset-map'; | ||
|
||
export function initialize(app) { | ||
app.deferReadiness(); | ||
let config = app.__container__.lookupFactory('config:environment'); | ||
|
||
let assetMapFile = window && window.__assetMapFilename__; | ||
let assetMapFile = window && window.__assetMapPlaceholder__; | ||
|
||
if (!assetMapFile) { | ||
app.register('service:asset-map', AssetMap); | ||
app.advanceReadiness(); | ||
return; | ||
} | ||
|
||
const promise = new RSVP.Promise((resolve, reject) => { | ||
$.getJSON(assetMapFile, resolve).fail(reject); | ||
}); | ||
|
||
promise.then((map = {}) => { | ||
if (config.ifa.inline) { | ||
AssetMap.reopen({ | ||
map: map.assets, | ||
prepend: map.prepend, | ||
map: assetMapFile.assets, | ||
prepend: assetMapFile.prepend, | ||
enabled: true | ||
}); | ||
}).then(() => { | ||
app.register('service:asset-map', AssetMap); | ||
app.advanceReadiness(); | ||
}); | ||
} else { | ||
app.deferReadiness(); | ||
|
||
const promise = new RSVP.Promise((resolve, reject) => { | ||
$.getJSON(assetMapFile, resolve).fail(reject); | ||
}); | ||
|
||
promise.then((map = {}) => { | ||
AssetMap.reopen({ | ||
map: map.assets, | ||
prepend: map.prepend, | ||
enabled: true | ||
}); | ||
}).then(() => { | ||
app.register('service:asset-map', AssetMap); | ||
app.advanceReadiness(); | ||
}); | ||
} | ||
} | ||
|
||
export default { | ||
name: 'asset-map', | ||
initialize: initialize | ||
initialize | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Controller from 'ember-controller'; | ||
import service from 'ember-service/inject'; | ||
import computed from 'ember-computed'; | ||
|
||
export default Controller.extend({ | ||
assetMap: service(), | ||
|
||
image: 'assets/tomster-under-construction', | ||
|
||
imagePath: computed(function() { | ||
return this.get('assetMap').resolve(`${this.get('image')}.png`); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
<img src="assets/tomster-under-construction.png" /> | ||
<div style="display: flex; flex: 1 1 auto; align-items: center; justify-content: center;"> | ||
<div> | ||
<img style="max-height: 150px;" src="assets/tomster-under-construction.png" /> | ||
<div style="display: flex; justify-content: center;"> | ||
Template replace | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<img style="max-height: 150px;" src={{imagePath}} /> | ||
<div style="display: flex; justify-content: center;"> | ||
Asset Map Service | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<img style="max-height: 150px;" src={{asset-map (concat image '.png')}} /> | ||
<div style="display: flex; justify-content: center;"> | ||
Asset Map Helper | ||
</div> | ||
</div> | ||
</div> |