Permalink
Browse files

Added Angularjs and initial webserver, views etc

  • Loading branch information...
1 parent d456f7d commit b57dd9b97b034e4593fe1cc0571f2b4c8a163095 Michael Hughes committed Mar 20, 2013
@@ -0,0 +1,15 @@
+controller = exports ? this
+
+controller.FeedListCtrl = ($scope)->
+ $scope.feedURL = ''
+
+ $scope.listData = [
+ {url: "http://feeds.bbci.co.uk/news/rss.xml"},
+ {url: "http://www.theverge.com/rss/index.xml"}
+ ]
+
+ $scope.addFeed = ()->
+ $scope.listData.push({url:$scope.feedURL});
+ $scope.feedURL = ''
+
+ scope:$scope
@@ -0,0 +1,27 @@
+// Generated by CoffeeScript 1.6.1
+(function() {
+ var controller;
+
+ controller = typeof exports !== "undefined" && exports !== null ? exports : this;
+
+ controller.FeedListCtrl = function($scope) {
+ $scope.feedURL = '';
+ $scope.listData = [
+ {
+ url: "http://feeds.bbci.co.uk/news/rss.xml"
+ }, {
+ url: "http://www.theverge.com/rss/index.xml"
+ }
+ ];
+ $scope.addFeed = function() {
+ $scope.listData.push({
+ url: $scope.feedURL
+ });
+ return $scope.feedURL = '';
+ };
+ return {
+ scope: $scope
+ };
+ };
+
+}).call(this);
@@ -0,0 +1,8 @@
+extend layout
+block content
+ div(ng-controller="FeedListCtrl")
+ li(ng-repeat="l in listData")
+ span{{l.url}}
+ form(ng-submit="addFeed()")
+ input(type="text",ng-model="feedURL",size="30",placeholder="add new URL here")
+ input(class="btn-primary",type="submit",value="add")
@@ -0,0 +1,15 @@
+!!!5
+html(ng-app)
+ head
+ title Mike's Homepage
+ script(src='http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js')
+ script(src='scripts/all.js')
+ body
+ .container
+ header
+ h1 Mike's Homepage
+ .main-content
+ block content
+ footer
+ p
+ a(href="https://github.com/mikeyhu/RSS-Homepage") RSS-Homepage
@@ -0,0 +1,15 @@
+express = require 'express'
+
+app = express()
+
+app.use express.static(process.cwd() + '/src/resources/')
+app.set('views', __dirname + '/../resources/views')
+app.set('view engine', 'jade')
+
+port = process.env.PORT or 5555
+
+app.get '/', (req, res)->
+ res.render('index',{})
+
+# Start Server
+app.listen port, -> console.log "Server is listening on #{port}\nPress CTRL-C to stop server."
@@ -0,0 +1,22 @@
+controller = require '../../../src/client/FeedListController.coffee'
+expect = (require 'chai').expect
+
+describe 'A FeedListCtrl controller', ->
+ it 'should be able to list people', ()->
+ c = new controller.FeedListCtrl({})
+ expect(c.scope.listData).to.eql [
+ {url: "http://feeds.bbci.co.uk/news/rss.xml"},
+ {url: "http://www.theverge.com/rss/index.xml"}
+ ]
+
+ it 'should be able to add a person', ()->
+ c = new controller.FeedListCtrl({})
+ c.scope.feedURL = "http://someother.feed"
+ c.scope.addFeed()
+ expect(c.scope.listData).to.eql [
+ {url: "http://feeds.bbci.co.uk/news/rss.xml"},
+ {url: "http://www.theverge.com/rss/index.xml"},
+ {url: "http://someother.feed"}
+ ]
+ expect(c.scope.feedURL).to.equal ""
+

0 comments on commit b57dd9b

Please sign in to comment.