Skip to content

Instantly share code, notes, and snippets.

View Blackmist's full-sized avatar

Larry Franks Blackmist

  • Microsoft
  • Belmont, NC
View GitHub Profile
@Blackmist
Blackmist / gist:5586544
Created May 15, 2013 19:17
ftpdeploy section of gruntfile
'ftp-deploy': {
build: {
auth: {
host: "waws-prod-blah-001.ftp.azurewebsites.windows.net",
port: 21,
authKey: 'key1'
},
src: 'dist',
dest: '/site/wwwroot'
}
@Blackmist
Blackmist / gist:5586475
Created May 15, 2013 19:08
server side script for insert operation. Looks up authenticated user names.
function insert(item, user, request) {
item.author = "Unknown";
var identities = user.getIdentities();
var url;
if (identities.google) {
var googleAccessToken = identities.google.accessToken;
url = 'https://www.googleapis.com/oauth2/v1/userinfo?access_token=' + googleAccessToken;
} else if (identities.facebook) {
@Blackmist
Blackmist / newpost.hbs
Created May 15, 2013 19:05
newpost.hbs with auth
{{#if isAuthenticated}}
<div class="span6">
{{view Ember.TextField valueBinding="title" class="span6" placeholder="Title"}}
</div>
<div class="span8">
{{view Ember.TextArea valueBinding="body" class="span8" rows="6" placeholder="Your blog goes here"}}
</div>
<div class="span12">
<button {{action save}} class="btn">Save</button>
@Blackmist
Blackmist / application.hbs
Created May 15, 2013 19:04
application.hbs template
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
{{#linkTo index class="brand"}}My Great Blog{{/linkTo}}
<div class="nav-collapse collapse">
@Blackmist
Blackmist / applicationcontroller.js
Created May 15, 2013 19:03
controllers that talk to loginstate
//Application controller, since we want login to be an application wide thing
//login/logout events are bubbled up to here regardless of the page you are on
App.ApplicationController = Em.Controller.extend({
authStateBinding: Ember.Binding.oneWay('App.LoginStateManager.currentState.name'),
authState: null,
isAuthenticated: function () {
return (this.get('authState') == 'isAuthenticated');
}.property('authState'),
@Blackmist
Blackmist / gist:5586402
Created May 15, 2013 19:00
login tracking using ember.statemanager
//login statemachine
App.LoginStateManager = Ember.StateManager.create({
initialState: "isNotAuthenticated",
isAuthenticated: Ember.State.create({
enter: function () {
console.log("enter " + this.name);
},
logout: function (manager, context) {
manager.transitionTo('isNotAuthenticated');
}
// Newpost controller
App.NewpostController = Ember.ObjectController.extend({
title: '',
author: '',
body: '',
save: function() {
//create the post
var now = new Date();
var post=App.Post.create({
@Blackmist
Blackmist / gist:5569268
Created May 13, 2013 15:41
Post model, create an instance of the adapter
var attr = Ember.attr;
//define model
App.Post = Ember.Model.extend({
id: attr('number'),
title: attr('string'),
author: attr('string'),
body: attr('string'),
posted: attr('date')
});
@Blackmist
Blackmist / ember-model-wam.js
Created May 13, 2013 15:40
Ember-model-based adapter that uses the Windows Azure Mobile Services client.
// ember-model-based adapter
Ember.WAMAdapter = Ember.Object.extend({
table: null,
init: function() {
this.table = this.get('table');
},
find: function(record, id) {
var query = this.table.where({ id: id });
return query.read().then(function(data) {
@Blackmist
Blackmist / gist:5548924
Last active December 17, 2015 04:18
newpost action controller
App.NewpostController = Ember.ObjectController.extend({
title: '',
author: '',
body: '',
save: function() {
//create the post
console.log('title: '+this.get('title'));
//set fields back to empty so the form is cleared
//on next visit