This file contains hidden or 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
Blog.controller('FeedController', function ($scope, GlobalService, PostService, posts) { | |
$scope.posts = posts; | |
$scope.globals = GlobalService; | |
//options for modals | |
$scope.opts = { | |
backdropFade: true, | |
dialogFade: true | |
}; | |
//open modals | |
$scope.open = function (action) { |
This file contains hidden or 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
<body data-spy="scroll" id="index" style="zoom: 1;" ng-controller="AppController" ng-init="initialize('{{ user.is_authenticated }}')"> |
This file contains hidden or 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
var appController = Blog.controller('AppController', function ($scope, $rootScope, $location, GlobalService) { | |
var failureCb = function (status) { | |
console.log(status); | |
}; | |
$scope.globals = GlobalService; | |
$scope.initialize = function (is_authenticated) { | |
$scope.globals.is_authenticated = is_authenticated; | |
}; | |
}) |
This file contains hidden or 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
Blog.factory('PostService', function ($http, $q) { | |
var api_url = "/posts/"; | |
return { | |
get: function (post_id) { | |
var url = api_url + post_id + "/"; | |
var defer = $q.defer(); | |
$http({method: 'GET', url: url}). | |
success(function (data, status, headers, config) { | |
defer.resolve(data); | |
}) |
This file contains hidden or 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
Blog.factory('GlobalService', function () { | |
var vars = { | |
is_authenticated: false | |
} | |
return vars; | |
}); |
This file contains hidden or 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
Blog.directive('timeAgo', function ($timeout) { | |
return { | |
restrict: 'A', | |
scope: { | |
title: '@' | |
}, | |
link: function (scope, elem, attrs) { | |
var updateTime = function () { | |
if (attrs.title) { | |
elem.text(moment(attrs.title).fromNow()); |
This file contains hidden or 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
'use strict'; | |
//(1) | |
var Blog = angular.module("Blog", ["ui.bootstrap", "ngCookies"], function ($interpolateProvider) { | |
$interpolateProvider.startSymbol("{[{"); | |
$interpolateProvider.endSymbol("}]}"); | |
} | |
); | |
//(2) |
This file contains hidden or 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
{% extends "base.html" %} | |
{% load i18n %} | |
{% block extra_head %} | |
<meta name="keywords" content=""/> | |
<meta name="description" content=""/> | |
<script src="{{ STATIC_URL }}js/app/controllers/app-controller.js"></script> | |
<script src="{{ STATIC_URL }}js/app/controllers/feed-controller.js"></script> | |
<script src="{{ STATIC_URL }}js/app/controllers/posts-controller.js"></script> | |
<script src="{{ STATIC_URL }}js/app/services/app-service.js"></script> | |
<script src="{{ STATIC_URL }}js/app/services/posts-service.js"></script> |
This file contains hidden or 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
from django.conf.urls import patterns, include, url | |
from rest_framework.urlpatterns import format_suffix_patterns | |
from posts import views | |
urlpatterns = patterns('', | |
url(r'^$', views.PostList.as_view(), name='post-list'), | |
url(r'^(?P<pk>[0-9]+)/$', views.PostDetail.as_view(), name='post-detail'), | |
) | |
This file contains hidden or 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
from rest_framework import generics | |
from posts.models import Post | |
from posts.serializers import PostSerializer | |
class PostList(generics.ListCreateAPIView): | |
""" | |
List all boards, or create a new board. | |
""" | |
model = Post |