Skip to content

Instantly share code, notes, and snippets.

David Ratajczak mockra

Block or report user

Report or block mockra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mockra
mockra / nginx
Last active Jul 25, 2019
nginx config for static site
View nginx
server {
listen 80;
root /var/www/yourdomain.com/public;
index index.html index.htm;
server_name yourdomain.com;
location / {
default_type "text/html";
View login.hbs
<form {{action login on='submit'}}>
<label for="identification">Login</label>
{{view Ember.TextField id='identification' valueBinding='identification' placeholder='Enter Login'}}
<label for="password">Password</label>
{{view Ember.TextField id='password' type='password' valueBinding='password' placeholder='Enter Password'}}
<button type="submit">Login</button>
</form>
View login_controller.js
App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin);
View sessions_controller.rb
class SessionsController < ApplicationController
def create
user = User.find_by_email params[:username]
if user && user.authenticate(params[:password])
render json: { access_token: user.access_token }
else
render json: {}, status: 401
end
end
end
View router.js
App.Router.map(function() {
this.route('login');
});
View ember-init.js
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.setup(container, application);
}
});
View router.js
App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);
App.Router.map(function() {
this.resource('todos', { path: '/' }, function() {
this.route('active');
this.route('completed');
});
});
View ember-data-url.js
DS.RESTAdapter.reopen({
host: 'https://api.example.com'
// OR
url: 'https://api.example.com'
});
View todos.js
App.TodosRoute = Ember.Route.extend({
model: function () {
return this.store.find('todo');
}
});
App.TodosIndexRoute = Ember.Route.extend({
model: function () {
return this.modelFor('todos');
}
View todos.js
var Todo = require('../models/todo');
exports.index = function(req, res) {
Todo.find(function(err, todos) {
res.send({
todos: todos
});
});
};
You can’t perform that action at this time.