mirror of
https://github.com/flarum/core.git
synced 2025-08-07 00:47:00 +02:00
Upgrade ember-cli to 0.1.4 and fix related breakage. closes #18
This commit is contained in:
@@ -1,26 +1,37 @@
|
||||
import Ember from 'ember';
|
||||
import DS from 'ember-data';
|
||||
|
||||
export default DS.JsonApiAdapter.extend({
|
||||
import JsonApiAdapter from 'ember-json-api/json-api-adapter';
|
||||
export default JsonApiAdapter.extend({
|
||||
host: '/api',
|
||||
|
||||
xhr: [],
|
||||
|
||||
ajax: function(url, type, hash) {
|
||||
var adapter = this;
|
||||
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
hash = adapter.ajaxOptions(url, type, hash);
|
||||
|
||||
hash.success = function(json) {
|
||||
Ember.run(null, resolve, json);
|
||||
};
|
||||
|
||||
hash.error = function(jqXHR, textStatus, errorThrown) {
|
||||
Ember.run(null, reject, adapter.ajaxError(jqXHR));
|
||||
};
|
||||
|
||||
adapter.xhr.push(Ember.$.ajax(hash));
|
||||
}, "DS: RestAdapter#ajax " + type + " to " + url);
|
||||
},
|
||||
findQuery: function(store, type, query) {
|
||||
var ids = null;
|
||||
if (query.ids) {
|
||||
ids = query.ids.join(',');
|
||||
delete query.ids;
|
||||
}
|
||||
return this.ajax(this.buildURL(type.typeKey, ids), 'GET', {data: query});
|
||||
},
|
||||
});
|
||||
|
||||
// export default DS.JsonApiAdapter.extend({
|
||||
// host: '/api',
|
||||
|
||||
// // xhr: [],
|
||||
|
||||
// // ajax: function(url, type, hash) {
|
||||
// // var adapter = this;
|
||||
|
||||
// // return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
// // hash = adapter.ajaxOptions(url, type, hash);
|
||||
|
||||
// // hash.success = function(json) {
|
||||
// // Ember.run(null, resolve, json);
|
||||
// // };
|
||||
|
||||
// // hash.error = function(jqXHR, textStatus, errorThrown) {
|
||||
// // Ember.run(null, reject, adapter.ajaxError(jqXHR));
|
||||
// // };
|
||||
|
||||
// // adapter.xhr.push(Ember.$.ajax(hash));
|
||||
// // }, "DS: RestAdapter#ajax " + type + " to " + url);
|
||||
// // },
|
||||
// });
|
||||
|
@@ -1,21 +1,17 @@
|
||||
import Ember from 'ember';
|
||||
import Resolver from 'ember/resolver';
|
||||
import loadInitializers from 'ember/load-initializers';
|
||||
import config from './config/environment';
|
||||
|
||||
Ember.MODEL_FACTORY_INJECTIONS = true;
|
||||
|
||||
var App = Ember.Application.extend({
|
||||
modulePrefix: 'flarum', // TODO: loaded via config
|
||||
Resolver: Resolver,
|
||||
|
||||
registerPlugin: function(plugin) {
|
||||
console.log('Plugin loaded: '+plugin.name);
|
||||
plugin.boot();
|
||||
}
|
||||
modulePrefix: config.modulePrefix,
|
||||
podModulePrefix: config.podModulePrefix,
|
||||
Resolver: Resolver
|
||||
});
|
||||
|
||||
loadInitializers(App, 'flarum');
|
||||
|
||||
loadInitializers(App, config.modulePrefix);
|
||||
|
||||
//-----------------------------------------
|
||||
// TODO: Move all this to an initializer
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Handlebars.makeBoundHelper(function(number, options) {
|
||||
return new Handlebars.SafeString(number);
|
||||
return new Ember.Handlebars.SafeString(''+number);
|
||||
});
|
||||
|
||||
|
@@ -1,14 +0,0 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
// This helper takes a post as its argument and renders a certain component
|
||||
// corresponding to the post's type. The naming convention is 'post-type-[type]'
|
||||
// (for example, post-type-comment for a comment.) Other arguments added to the
|
||||
// helper are passed through to the component.
|
||||
|
||||
export default Ember.Handlebars.makeBoundHelper(function(post, options) {
|
||||
options.hash.post = post;
|
||||
var component = 'post-type-'+post.get('type');
|
||||
var helper = Ember.Handlebars.resolveHelper(options.data.view.container, component);
|
||||
|
||||
helper.call(this, options);
|
||||
});
|
@@ -7,20 +7,19 @@
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{{BASE_TAG}}
|
||||
{{content-for 'head'}}
|
||||
|
||||
<link rel="stylesheet" href="assets/vendor.css">
|
||||
<link rel="stylesheet" href="assets/flarum.css">
|
||||
|
||||
{{content-for 'head-footer'}}
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.FlarumENV = {{ENV}};
|
||||
window.EmberENV = window.FlarumENV.EmberENV;
|
||||
</script>
|
||||
{{content-for 'body'}}
|
||||
|
||||
<script src="assets/vendor.js"></script>
|
||||
<script src="assets/flarum.js"></script>
|
||||
<script>
|
||||
window.Flarum = require('flarum/app')['default'].create(FlarumENV.APP);
|
||||
</script>
|
||||
|
||||
{{content-for 'body-footer'}}
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import Ember from 'ember';
|
||||
import config from './config/environment';
|
||||
|
||||
console.log(config.locationType);
|
||||
var Router = Ember.Router.extend({
|
||||
location: FlarumENV.locationType
|
||||
location: config.locationType
|
||||
});
|
||||
|
||||
Router.map(function() {
|
||||
|
||||
this.resource('categories', { path: '/categories' });
|
||||
this.resource('categories', { path: '/categories' });
|
||||
|
||||
this.resource('discussions', { path: '/' }, function() {
|
||||
this.resource('discussion', { path: '/:id/:slug' });
|
||||
@@ -18,7 +19,6 @@ Router.map(function() {
|
||||
this.route('discussions');
|
||||
this.route('preferences');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
@@ -1,14 +1,12 @@
|
||||
import Ember from 'ember';
|
||||
import DS from 'ember-data';
|
||||
import JsonApiSerializer from 'ember-json-api/json-api-serializer';
|
||||
export default JsonApiSerializer.extend({
|
||||
normalize: function(type, hash, property) {
|
||||
var json = {};
|
||||
|
||||
export default DS.JsonApiSerializer.extend({
|
||||
normalize: function(type, hash, property) {
|
||||
var json = {};
|
||||
for (var prop in hash) {
|
||||
json[prop.camelize()] = hash[prop];
|
||||
}
|
||||
|
||||
for (var prop in hash) {
|
||||
json[prop.camelize()] = hash[prop];
|
||||
}
|
||||
|
||||
return this._super(type, json, property);
|
||||
}
|
||||
});
|
||||
return this._super(type, json, property);
|
||||
}
|
||||
});
|
@@ -10,4 +10,4 @@
|
||||
{{!-- #{{view.post.number}} (ID: {{view.post.id}}) --}}
|
||||
{{/link-to}}
|
||||
|
||||
{{post-content view.post}}
|
||||
{{dynamic-component type=view.contentComponent post=view.post}}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<div class="controls btn-group">
|
||||
{{!-- <div class="controls btn-group">
|
||||
<button data-toggle="dropdown" class="dropdown-toggle btn btn-default btn-xs btn-icon">{{fa-icon "caret-down"}}</button>
|
||||
{{menu-list items=view.controls class="dropdown-menu pull-right"}}
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class="discussion">
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
{{#link-to "user" discussion.lastUser}}{{user-avatar discussion.lastUser class="avatar-thumb"}}{{/link-to}}
|
||||
{{#link-to "discussion" discussion.content (query-params start="last")}}{{abbreviate-time discussion.lastTime}}{{/link-to}}
|
||||
{{/if}}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="replies">{{abbreviate-number discussion.repliesCount}}</span>
|
||||
|
||||
|
@@ -9,6 +9,10 @@ export default Ember.View.extend({
|
||||
|
||||
controls: null,
|
||||
|
||||
contentComponent: function() {
|
||||
return 'post-type-'+this.get('post.type');
|
||||
}.property('post.type'),
|
||||
|
||||
classNames: ['post'],
|
||||
classNameBindings: ['post.deleted', 'post.edited'],
|
||||
|
||||
|
Reference in New Issue
Block a user