-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from integer32llc/categorization
Add Categorization!
- Loading branch information
Showing
50 changed files
with
1,393 additions
and
215 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,11 @@ | ||
import ApplicationAdapter from './application'; | ||
import Ember from 'ember'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
pathForType(modelName) { | ||
var decamelized = Ember.String.underscore( | ||
Ember.String.decamelize(modelName) | ||
); | ||
return Ember.String.pluralize(decamelized); | ||
} | ||
}); |
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,17 @@ | ||
import Ember from 'ember'; | ||
import PaginationMixin from '../mixins/pagination'; | ||
|
||
const { computed } = Ember; | ||
|
||
export default Ember.Controller.extend(PaginationMixin, { | ||
queryParams: ['page', 'per_page', 'sort'], | ||
page: '1', | ||
per_page: 10, | ||
sort: 'alpha', | ||
|
||
totalItems: computed.readOnly('model.meta.total'), | ||
|
||
currentSortBy: computed('sort', function() { | ||
return (this.get('sort') === 'crates') ? '# Crates' : 'Alphabetical'; | ||
}), | ||
}); |
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,17 @@ | ||
import Ember from 'ember'; | ||
import PaginationMixin from '../../mixins/pagination'; | ||
|
||
const { computed } = Ember; | ||
|
||
export default Ember.Controller.extend(PaginationMixin, { | ||
queryParams: ['page', 'per_page', 'sort'], | ||
page: '1', | ||
per_page: 10, | ||
sort: 'downloads', | ||
|
||
totalItems: computed.readOnly('model.meta.total'), | ||
|
||
currentSortBy: computed('sort', function() { | ||
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical'; | ||
}), | ||
}); |
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,5 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
slug: DS.attr('string'), | ||
}); |
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 DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
category: DS.attr('string'), | ||
slug: DS.attr('string'), | ||
description: DS.attr('string'), | ||
created_at: DS.attr('date'), | ||
crates_cnt: DS.attr('number'), | ||
|
||
subcategories: DS.attr(), | ||
|
||
crates: DS.hasMany('crate', { async: true }) | ||
}); |
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,12 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
queryParams: { | ||
page: { refreshModel: true }, | ||
sort: { refreshModel: true }, | ||
}, | ||
|
||
model(params) { | ||
return this.store.query('category', params); | ||
}, | ||
}); |
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'; | ||
|
||
export default Ember.Route.extend({ | ||
queryParams: { | ||
page: { refreshModel: true }, | ||
sort: { refreshModel: true }, | ||
}, | ||
|
||
model(params) { | ||
return this.store.query('category-slug', params); | ||
}, | ||
}); |
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,11 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model(params) { | ||
return this.store.find('category', params.category_id).catch(e => { | ||
if (e.errors.any(e => e.detail === 'Not Found')) { | ||
this.controllerFor('application').set('flashError', `Category '${params.category_id}' does not exist`); | ||
} | ||
}); | ||
} | ||
}); |
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,18 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
queryParams: { | ||
page: { refreshModel: true }, | ||
sort: { refreshModel: true }, | ||
}, | ||
|
||
model(params) { | ||
params.category = this.modelFor('category').id; | ||
return this.store.query('crate', params); | ||
}, | ||
|
||
setupController(controller, model) { | ||
controller.set('category', this.modelFor('category')); | ||
this._super(controller, model); | ||
}, | ||
}); |
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,73 @@ | ||
{{ title 'Categories' }} | ||
|
||
<div id='crates-heading'> | ||
<img class='logo crate' src="/assets/crate.png"/> | ||
<h1>All Categories</h1> | ||
</div> | ||
|
||
<div id='results'> | ||
<div class='nav'> | ||
<span class='amt small'> | ||
Displaying | ||
<span class='cur'>{{ currentPageStart }}-{{ currentPageEnd }}</span> | ||
of <span class='total'>{{ totalItems }}</span> total results | ||
</span> | ||
</div> | ||
|
||
<div class='sort'> | ||
<span class='small'>Sort by</span> | ||
{{#rl-dropdown-container class="dropdown-container"}} | ||
{{#rl-dropdown-toggle tagName="a" class="dropdown"}} | ||
<img class="sort" src="/assets/sort.png"/> | ||
{{ currentSortBy }} | ||
<span class='arrow'></span> | ||
{{/rl-dropdown-toggle}} | ||
|
||
{{#rl-dropdown tagName="ul" class="dropdown" closeOnChildClick="a:link"}} | ||
<li> | ||
{{#link-to (query-params sort="alpha")}} | ||
Alphabetical | ||
{{/link-to}} | ||
</li> | ||
<li> | ||
{{#link-to (query-params sort="crates")}} | ||
# Crates | ||
{{/link-to}} | ||
</li> | ||
{{/rl-dropdown}} | ||
{{/rl-dropdown-container}} | ||
</div> | ||
</div> | ||
|
||
<div class='white-rows'> | ||
{{#each model as |category|}} | ||
<div class='row'> | ||
<div class='desc'> | ||
<div class='info'> | ||
{{link-to category.category "category" category.slug}} | ||
<span class='small'> | ||
{{ format-num category.crates_cnt }} | ||
crates | ||
</span> | ||
</div> | ||
<div class='summary'> | ||
<span class='small'> | ||
{{ truncate-text category.description }} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
{{/each}} | ||
</div> | ||
|
||
<div class='pagination'> | ||
{{#link-to (query-params page=prevPage) class="prev" rel="prev" title="previous page"}} | ||
<img class="left-pag" src="/assets/left-pag.png"/> | ||
{{/link-to}} | ||
{{#each pages as |page|}} | ||
{{#link-to (query-params page=page)}}{{ page }}{{/link-to}} | ||
{{/each}} | ||
{{#link-to (query-params page=nextPage) class="next" rel="next" title="next page"}} | ||
<img class="right-pag" src="/assets/right-pag.png"/> | ||
{{/link-to}} | ||
</div> |
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 @@ | ||
{{ title 'Category Not Found' }} |
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,85 @@ | ||
{{ title category.category ' - Categories' }} | ||
|
||
<div id='crates-heading'> | ||
<img class='logo crate' src="/assets/crate.png"/> | ||
<h1>{{ category.category }}</h1> | ||
</div> | ||
|
||
{{#if category.subcategories }} | ||
<div id='subcategories'> | ||
<h2>Subcategories</h2> | ||
<div class='white-rows'> | ||
{{#each category.subcategories as |subcategory| }} | ||
<div class='row'> | ||
<div class='desc'> | ||
<div class='info'> | ||
{{link-to subcategory.category "category" subcategory.slug}} | ||
<span class='small'> | ||
{{ format-num subcategory.crates_cnt }} | ||
crates | ||
</span> | ||
</div> | ||
<div class='summary'> | ||
<span class='small'> | ||
{{ truncate-text subcategory.description }} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
{{/each}} | ||
</div> | ||
</div> | ||
{{/if}} | ||
|
||
<h2>Crates</h2> | ||
<div id='results'> | ||
<div class='nav'> | ||
<span class='amt small'> | ||
Displaying | ||
<span class='cur'>{{ currentPageStart }}-{{ currentPageEnd }}</span> | ||
of <span class='total'>{{ totalItems }}</span> total results | ||
</span> | ||
</div> | ||
|
||
<div class='sort'> | ||
<span class='small'>Sort by</span> | ||
{{#rl-dropdown-container class="dropdown-container"}} | ||
{{#rl-dropdown-toggle tagName="a" class="dropdown"}} | ||
<img class="sort" src="/assets/sort.png"/> | ||
{{ currentSortBy }} | ||
<span class='arrow'></span> | ||
{{/rl-dropdown-toggle}} | ||
|
||
{{#rl-dropdown tagName="ul" class="dropdown" closeOnChildClick="a:link"}} | ||
<li> | ||
{{#link-to (query-params sort="alpha")}} | ||
Alphabetical | ||
{{/link-to}} | ||
</li> | ||
<li> | ||
{{#link-to (query-params sort="downloads")}} | ||
Downloads | ||
{{/link-to}} | ||
</li> | ||
{{/rl-dropdown}} | ||
{{/rl-dropdown-container}} | ||
</div> | ||
</div> | ||
|
||
<div id='crates' class='white-rows'> | ||
{{#each model as |crate|}} | ||
{{crate-row crate=crate}} | ||
{{/each}} | ||
</div> | ||
|
||
<div class='pagination'> | ||
{{#link-to (query-params page=prevPage) class="prev" rel="prev" title="previous page"}} | ||
<img class="left-pag" src="/assets/left-pag.png"/> | ||
{{/link-to}} | ||
{{#each pages as |page|}} | ||
{{#link-to (query-params page=page)}}{{ page }}{{/link-to}} | ||
{{/each}} | ||
{{#link-to (query-params page=nextPage) class="next" rel="next" title="next page"}} | ||
<img class="right-pag" src="/assets/right-pag.png"/> | ||
{{/link-to}} | ||
</div> |
Oops, something went wrong.