-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTMLBars goodness! Since there was some breakage and a lot of fiddling around to get some things working, I took this opportunity to do a big cleanup of the whole Ember app. I accidentally worked on some new features too :3 Note that the app is still broken right now, pending on emberjs/ember.js#10401 Cleanup: - Restructuring of components - Consolidation of some stuff into mixins, cleanup of some APIs that will be public - Change all instances of .property() / .observes() / .on() to Ember.computed() / Ember.observer() / Ember.on() respectively (I think it is more readable) - More comments - Start conforming to a code style (2 spaces for indentation) New features: - Post hiding/restoring - Mark individual discussions as read by clicking - Clicking on a read discussion jumps to the end - Mark all discussions as read - Progressively mark the discussion as read as the page is scrolled - Unordered list post formatting - Post permalink popup Demo once that Ember regression is fixed!
- Loading branch information
1 parent
cf88fda
commit c283079
Showing
164 changed files
with
4,708 additions
and
4,672 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Flarum | ||
|
||
This README outlines the details of collaborating on this Ember application. | ||
A short introduction of this app could easily go here. | ||
|
||
## Prerequisites | ||
|
||
You will need the following things properly installed on your computer. | ||
|
||
* [Git](http://git-scm.com/) | ||
* [Node.js](http://nodejs.org/) (with NPM) | ||
* [Bower](http://bower.io/) | ||
* [Ember CLI](http://www.ember-cli.com/) | ||
* [PhantomJS](http://phantomjs.org/) | ||
|
||
## Installation | ||
|
||
* `git clone <repository-url>` this repository | ||
* change into the new directory | ||
* `npm install` | ||
* `bower install` | ||
|
||
## Running / Development | ||
|
||
* `ember server` | ||
* Visit your app at [http://localhost:4200](http://localhost:4200). | ||
|
||
### Code Generators | ||
|
||
Make use of the many generators for code, try `ember help generate` for more details | ||
|
||
### Running Tests | ||
|
||
* `ember test` | ||
* `ember test --server` | ||
|
||
### Building | ||
|
||
* `ember build` (development) | ||
* `ember build --environment production` (production) | ||
|
||
### Deploying | ||
|
||
Specify what it takes to deploy your app. | ||
|
||
## Further Reading / Useful Links | ||
|
||
* [ember.js](http://emberjs.com/) | ||
* [ember-cli](http://www.ember-cli.com/) | ||
* Development Browser Extensions | ||
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) | ||
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) | ||
|
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,24 +1,38 @@ | ||
import DS from 'ember-data'; | ||
import JsonApiAdapter from 'ember-json-api/json-api-adapter'; | ||
import config from '../config/environment'; | ||
|
||
import config from 'flarum/config/environment'; | ||
import AlertMessage from 'flarum/components/ui/alert-message'; | ||
|
||
export default JsonApiAdapter.extend({ | ||
host: config.apiURL, | ||
|
||
ajaxError: function(jqXHR) { | ||
var errors = this._super(jqXHR); | ||
|
||
// Reparse the errors in accordance with the JSON-API spec to fit with | ||
// Ember Data style. Hopefully something like this will eventually be a | ||
// part of the JsonApiAdapter. | ||
if (errors instanceof DS.InvalidError) { | ||
var newErrors = {}; | ||
for (var i in errors.errors) { | ||
var error = errors.errors[i]; | ||
newErrors[error.path] = error.detail; | ||
} | ||
errors = new DS.InvalidError(newErrors); | ||
} else if (errors instanceof JsonApiAdapter.ServerError) { | ||
// @todo show an alert message | ||
console.log(errors); | ||
return new DS.InvalidError(newErrors); | ||
} | ||
|
||
// If it's a server error, show an alert message. The alerts controller | ||
// has been injected into this adapter. | ||
if (errors instanceof JsonApiAdapter.ServerError) { | ||
var message = AlertMessage.create({ | ||
type: 'warning', | ||
message: errors.message | ||
}); | ||
this.get('alerts').send('alert', message); | ||
return; | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
}); |
Empty file.
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import Ember from 'ember'; | ||
|
||
/** | ||
The back/pin button group in the top-left corner of Flarum's interface. | ||
*/ | ||
export default Ember.Component.extend({ | ||
classNames: ['back-button'], | ||
classNameBindings: ['active'], | ||
|
||
active: Ember.computed.or('target.paneIsShowing', 'target.paneIsPinned'), | ||
|
||
mouseEnter: function() { | ||
this.get('target').send('showPane'); | ||
}, | ||
|
||
mouseLeave: function() { | ||
this.get('target').send('hidePane'); | ||
}, | ||
|
||
actions: { | ||
back: function() { | ||
this.get('target').send('transitionFromBackButton'); | ||
this.set('target', null); | ||
}, | ||
|
||
togglePinned: function() { | ||
this.get('target').send('togglePinned'); | ||
} | ||
} | ||
}); |
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,7 @@ | ||
import Ember from 'ember'; | ||
|
||
var precompileTemplate = Ember.Handlebars.compile; | ||
|
||
export default Ember.Component.extend({ | ||
layout: precompileTemplate('{{number}} {{label}}') | ||
}); |
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,12 @@ | ||
import Ember from 'ember'; | ||
|
||
import ActionButton from 'flarum/components/ui/action-button'; | ||
|
||
export default ActionButton.extend({ | ||
title: 'Go to Top', | ||
icon: 'arrow-up', | ||
className: 'control-top', | ||
action: function() { | ||
$('html, body').stop(true).animate({scrollTop: 0}); | ||
} | ||
}) |
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,7 @@ | ||
import Ember from 'ember'; | ||
|
||
var precompileTemplate = Ember.Handlebars.compile; | ||
|
||
export default Ember.Component.extend({ | ||
layout: precompileTemplate('<a href="http://flarum.org" target="_blank">Powered by Flarum</a>') | ||
}); |
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,27 @@ | ||
import Ember from 'ember'; | ||
|
||
import HasItemLists from 'flarum/mixins/has-item-lists'; | ||
import DropdownButton from 'flarum/components/ui/dropdown-button'; | ||
import SeparatorItem from 'flarum/components/ui/separator-item'; | ||
|
||
export default DropdownButton.extend(HasItemLists, { | ||
layoutName: 'components/application/user-dropdown', | ||
itemLists: ['items'], | ||
|
||
buttonClass: 'btn btn-default btn-naked btn-rounded btn-user', | ||
menuClass: 'pull-right', | ||
label: Ember.computed.alias('user.username'), | ||
|
||
populateItems: function(items) { | ||
this.addActionItem(items, 'profile', 'Profile', 'user'); | ||
this.addActionItem(items, 'settings', 'Settings', 'cog'); | ||
items.pushObject(SeparatorItem.create()); | ||
this.addActionItem(items, 'logout', 'Log Out', 'sign-out', null, null, this); | ||
}, | ||
|
||
actions: { | ||
logout: function() { | ||
this.logout(); | ||
} | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
import Ember from 'ember'; | ||
|
||
import HasItemLists from 'flarum/mixins/has-item-lists'; | ||
|
||
/** | ||
This component is a base class for a composer body. It provides a template | ||
with a list of controls, a text editor, and some default behaviour. | ||
*/ | ||
export default Ember.Component.extend(HasItemLists, { | ||
layoutName: 'components/composer/composer-body', | ||
|
||
itemLists: ['controls'], | ||
|
||
submitLabel: '', | ||
placeholder: '', | ||
content: '', | ||
originalContent: '', | ||
user: null, | ||
submit: null, | ||
loading: false, | ||
confirmExit: '', | ||
|
||
disabled: Ember.computed.alias('composer.minimized'), | ||
|
||
actions: { | ||
submit: function(content) { | ||
this.get('submit')({ | ||
content: content | ||
}); | ||
}, | ||
|
||
willExit: function(abort) { | ||
// If the user has typed something, prompt them before exiting | ||
// this composer state. | ||
if (this.get('content') !== this.get('originalContent') && !confirm(this.get('confirmExit'))) { | ||
abort(); | ||
} | ||
} | ||
} | ||
}); |
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,41 @@ | ||
import Ember from 'ember'; | ||
|
||
import ComposerBody from 'flarum/components/composer/composer-body'; | ||
|
||
var precompileTemplate = Ember.Handlebars.compile; | ||
|
||
/** | ||
The composer body for starting a new discussion. Adds a text field as a | ||
control so the user can enter the title of their discussion. Also overrides | ||
the `submit` and `willExit` actions to account for the title. | ||
*/ | ||
export default ComposerBody.extend({ | ||
submitLabel: 'Post Discussion', | ||
confirmExit: 'You have not posted your discussion. Do you wish to discard it?', | ||
titlePlaceholder: 'Discussion Title', | ||
title: '', | ||
|
||
populateControls: function(items) { | ||
var title = Ember.Component.create({ | ||
tagName: 'h3', | ||
layout: precompileTemplate('{{ui/text-input value=component.title class="form-control" placeholder=component.titlePlaceholder disabled=component.disabled autoGrow=true}}'), | ||
component: this | ||
}); | ||
items.pushObjectWithTag(title, 'title'); | ||
}, | ||
|
||
actions: { | ||
submit: function(content) { | ||
this.get('submit')({ | ||
title: this.get('title'), | ||
content: content | ||
}); | ||
}, | ||
|
||
willExit: function(abort) { | ||
if ((this.get('title') || this.get('content')) && !confirm(this.get('confirmExit'))) { | ||
abort(); | ||
} | ||
} | ||
} | ||
}); |
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,26 @@ | ||
import Ember from 'ember'; | ||
|
||
import ComposerBody from 'flarum/components/composer/composer-body'; | ||
|
||
var precompileTemplate = Ember.Handlebars.compile; | ||
|
||
/** | ||
The composer body for editing a post. Sets the initial content to the | ||
content of the post that is being edited, and adds a title control to | ||
indicate which post is being edited. | ||
*/ | ||
export default ComposerBody.extend({ | ||
submitLabel: 'Save Changes', | ||
content: Ember.computed.oneWay('post.content'), | ||
originalContent: Ember.computed.oneWay('post.content'), | ||
|
||
populateControls: function(controls) { | ||
var title = Ember.Component.create({ | ||
tagName: 'h3', | ||
layout: precompileTemplate('Editing Post #{{component.post.number}} in <em>{{discussion.title}}</em>'), | ||
discussion: this.get('post.discussion'), | ||
component: this | ||
}); | ||
controls.pushObjectWithTag(title, 'title'); | ||
} | ||
}); |
Oops, something went wrong.