Skip to content

Instantly share code, notes, and snippets.

View darthdeus's full-sized avatar

Jakub Arnold darthdeus

View GitHub Profile
var get = Ember.get;
/**
@extends Ember.Mixin
Implements common pagination management properties for controllers.
*/
Ember.PaginationSupport = Ember.Mixin.create({
/**
*/
window.App = Em.Application.create({
LOG_TRANSITIONS: true
});
App.deferReadiness();
App.Router.map(function() {
this.route("login", { path: "/login" });
this.route("explore", { path: "/explore" });
this.route("events", { path: "/events" });
App.Router = Ember.Router.extend({
enableLogging: true,
root: Ember.Route.extend({
// Transitions
showModuleDocuments: Ember.Route.transitionTo('moduleDocuments'),
showModuleTask: Ember.Route.transitionTo('moduleTask'),
showSettings: Ember.Route.transitionTo('settings'),
showManagement: Ember.Route.transitionTo('management'),
showAdministration: Ember.Route.transitionTo('administration'),
@darthdeus
darthdeus / gist:4706568
Last active December 12, 2015 03:28 — forked from jackkitley/gist:4706392
{{#linkTo catalogue.item item}
App.Router.map(function() {
this.resource('catalogue', function() {
// this.route('index'); - this is automatic
this.route('search', { path: ':searchvalue' });
this.route('item', {path: '/view/:itemguid'});
});
});
@darthdeus
darthdeus / init.coffee
Last active December 13, 2015 18:59 — forked from ohcibi/init.coffee
Ember.Handlebars.registerBoundHelper 'forMoreThanOneIn', (collection) ->
alert collection.toArray()
return elseFn() if collection.length == 1
return "Compound"
window.App = Ember.Application.create
rootElement: "#QiviconBasicClient"
App.Router.map -> @resource 'rooms'
App.IndexRoute = Ember.Route.extend redirect: -> @transitionTo 'rooms'

I've been trying to do routing in Ember using something other than id. This is how I implemted a dasherized version of a post's title. I get the feeling that instead of the deserialize function I should be overwrite the model function as the guides suggest, but then I lose the symmetry I have with the serialize function.

If there's a better/more ember way, I'd love to know.

Thanks @darthdeus for teaching me about DS.LoadPromise

var alertAdminController;
module("EurekaJ.AdministrationAlertsController", {
setup: function() {
this.xhr = sinon.useFakeXMLHttpRequest();
this.server = sinon.fakeServer.create();
var requests = this.requests = [];
@darthdeus
darthdeus / gist:5303646
Last active December 15, 2015 18:28 — forked from joachimhs/gist:5303131
var alertAdminController;
module("EurekaJ.AdministrationAlertsController", {
setup: function() {
this.server = sinon.fakeServer.create();
Ember.run(function() {
alertAdminController = EurekaJ.__container__.lookup("controller:administrationAlerts");
});
@darthdeus
darthdeus / rails_resources.md
Created May 8, 2014 17:25 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h