Skip to content

Commit

Permalink
Fixes #919 : Deploy Backend API to heroku and frontend fix for prod (#…
Browse files Browse the repository at this point in the history
…920)

<!-- Add the issue number that is fixed by this PR (In the form Fixes #123) -->
Fixes #919

#### Checklist

- [x] I have read the [Contribution & Best practices Guide](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia) and my PR follows them.
- [x] My branch is up-to-date with the Upstream `development` branch.
- [ ] I have added necessary documentation (if appropriate)

### Preview Link 

- **Replace XXX with your PR no**
- Link to live demo: http://pr-920-fossasia-badgeyay.surge.sh  

#### Changes proposed in this pull request:

- Deployed new backend to heroku
- Fixes asset path for production
  • Loading branch information
yashLadha authored and djmgit committed Jun 3, 2018
1 parent 3e3652d commit 0d74239
Show file tree
Hide file tree
Showing 17 changed files with 4,623 additions and 4,527 deletions.
2 changes: 1 addition & 1 deletion api/controllers/assetHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def getDefaultBackgrounds():
obj['id'] = idx
obj['type'] = 'def-image'
obj['attributes'] = {
'name': file_,
'name': file_.split('.')[0],
}
resp.append(obj)
resp_ = {'data': resp}
Expand Down
5 changes: 4 additions & 1 deletion api/controllers/generateBadges.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def generateBadges():
text_color = data.get('font_color', '#ffffff')
badge_size = data.get('badge_size', 'A3')
svg2png = SVG2PNG()
svg2png.do_text_fill('static/badges/8BadgesOnA3.svg', text_color)
if config.ENV == 'PROD':
svg2png.do_text_fill(os.getcwd()+ '/api/static/badges/8BadgesOnA3.svg', text_color)
else:
svg2png.do_text_fill('static/badges/8BadgesOnA3.svg', text_color)
merge_badges = MergeBadges(image_name, csv_name, badge_size)
merge_badges.merge_pdfs()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Component from '@ember/component';
export default Component.extend({
init() {
// To be inflated from the backend data
this.host = 'http://localhost:5000/';
this.fingerPrint = window.ASSET_FINGERPRINT_HASH;
return this._super(...arguments);
},
click() {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/badgeyay.js"></script>
<script src="{{rootURL}}assets/assets-fingerprint.js"></script>

{{content-for "body-footer"}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="menu">
{{#each defImages as |image|}}
<div data-value="{{image.id}}" class="item">
<img class="ui mini image" src="/images/badge_backgrounds/{{image.name}}">
<img class="ui mini image" src="/assets/images/badge_backgrounds/{{image.name}}{{fingerPrint}}.png">
{{image.name}}
</div>
{{/each}}
Expand Down
11 changes: 10 additions & 1 deletion frontend/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const writeFile = require('broccoli-file-creator');
const md5 = require('md5');

module.exports = function(defaults) {
const fingerprintHash = md5(Date.now());

let app = new EmberApp(defaults, {
// Add options here
'ember-cli-babel': {
includePolyfill: true
},
fingerprint: {
extensions : ['js', 'css', 'png'], // list of extensions to fingerprint
customHash : fingerprintHash // use a single fingeprint/hash for all assets
}
});

Expand All @@ -23,5 +31,6 @@ module.exports = function(defaults) {
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

return app.toTree();
var assetFingerprintTree = writeFile('./assets/assets-fingerprint.js', `(function(_window){ _window.ASSET_FINGERPRINT_HASH = "${(app.env === 'production' ? `-${fingerprintHash}` : '')}"; })(window);`);
return app.toTree(assetFingerprintTree);
};
Loading

0 comments on commit 0d74239

Please sign in to comment.