Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 6 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 24, 2013
Michael Hughes Added beginnings of selecting by tag 494d994
Michael Hughes Can now choose results by tag 333743a
Michael Hughes Make sure connections are closed 51987ff
Commits on Mar 25, 2013
Michael Hughes Responsive design start 8f4c646
Commits on Mar 26, 2013
Michael Hughes Updated responsive css f97b0b9
Michael Hughes Added bootstrap icons a3309f5
View
25 src/client/EntryListController.coffee
@@ -8,17 +8,28 @@ states = {
controller.EntryListCtrl = ($scope,$http)->
+ $scope.tags = [
+ {name:"All"},
+ {name:"Technology"},
+ {name:"News"},
+ {name:"Sport"}
+ ]
+ $scope.selectedTag = $scope.tags[0]
+
$scope.entries = []
- if $http
- $http.get("/latest/json")
- .success (data,status)->
- $scope.entries = data
- .error (data,status)->
#internal functions
+ $scope.refreshEntries = ()->
+ if $http
+ url = if $scope.selectedTag.name=="All" then "/latest/json" else "/latestByTag/json?tag=" + $scope.selectedTag.name
+ $http.get(url)
+ .success (data,status)->
+ $scope.entries = data
+ .error (data,status)->
+
$scope.changeState = (entry,state)->
ignoreOutput = (data,status)->
-
+
if $http
$http.get("/changeState?state=" + state + "&id=" + $scope.encode(entry.id))
.success(ignoreOutput)
@@ -49,4 +60,6 @@ controller.EntryListCtrl = ($scope,$http)->
$scope.status = (state)->
if state==states.STARRED then "" else "-empty"
+ $scope.refreshEntries()
+
scope:$scope
View
BIN src/resources/images/glyphicons-halflings-white.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/resources/images/glyphicons-halflings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
30 src/resources/sass/screen.scss
@@ -1,22 +1,19 @@
@import "compass/reset";
-@import "compass_twitter_bootstrap";
+@import "compass_twitter_bootstrap";
+@import "compass_twitter_bootstrap_responsive";
@import "compass/typography/links/link-colors";
$border-color:#DDD;
body {
font-size:12pt;
}
-h3 {
- font-size:120%;
-}
-
.entries {
- margin:1em;
- width:600px;
+ margin:0em;
border-top:1px solid $border-color;
border-left:1px solid $border-color;
border-right:1px solid $border-color;
+ width:600px;
}
.entry {
border-bottom: 1px solid $border-color;
@@ -26,11 +23,17 @@ h3 {
font-style:italic;
color : #CCC;
}
-.entry p.toggle-,p.toggle-false {
- margin:0px;
+.entry p {
+ margin:0px;
+}
+.entry p.toggle-false {
display:none;
}
.entry p.toggle-true {
+}
+.entry h3 {
+ font-size:120%;
+ text-decoration:none;
margin:0px;
}
.btns-right {
@@ -42,10 +45,11 @@ h3 {
.odd {
background-color : #FAFAFA;
}
-.entry h3 {
- text-decoration:none;
- margin:0px;
-}
a {
@include link-colors(#00c, #00c, #00c, #000)
}
+@media screen and (max-device-width: 800px), screen and (max-width: 800px) {
+ .entries {
+ width:100%;
+ }
+}
View
10 src/resources/views/index.jade
@@ -1,14 +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",type="submit",value="add")
-
-
.entries(ng-controller="EntryListCtrl")
+ .entry Showing stories from:
+ select(ng-model="selectedTag",ng-options="t.name for t in tags",ng-change="refreshEntries()")
.entry(ng-repeat="e in entries",ng-class-even="'even'",ng-class-odd="'odd'")
div(class="btn-group btns-right")
a(class="btn",ng-click="e.open = !e.open",ng-init="e.open=false")
View
2 src/resources/views/layout.jade
@@ -4,7 +4,7 @@ html(ng-app)
title Mike's Homepage
script(src='http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js')
script(src='scripts/all.js')
- link(href="styles/screen.css",rel="stylesheet")
+ link(href="styles/screen.css",rel="stylesheet",type="text/css")
#link(href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css",rel="stylesheet")
body
View
18 src/server/MongoStore.coffee
@@ -46,20 +46,26 @@ exports.createMongostore = (connectionString)->
collection.update {id:entry.id}, {$setOnInsert:{state:"new"},$set:entry}, {w:1,upsert:true}, @close(fun)
getEntries:(search,fun)->
- @connect (err,collection)->
+ @connect (err,collection)=>
if err then fun err,null
else
- collection.find(search).toArray fun
+ collection.find(search).toArray @close(fun)
getLatestNew:(amount,fun)->
- @connect (err,collection)->
+ @connect (err,collection)=>
+ if err then fun err,null
+ else
+ collection.find({$or: [{state:"new"},{state:"starred"}]}).sort({date:-1}).limit(amount).toArray @close(fun)
+
+ getLatestByTag:(tag,amount,fun)->
+ @connect (err,collection)=>
if err then fun err,null
else
- collection.find({$or: [{state:"new"},{state:"starred"}]}).sort({date:-1}).limit(amount).toArray fun
+ collection.find({$and: [{tags:tag},{$or: [{state:"new"},{state:"starred"}]}]}).sort({date:-1}).limit(amount).toArray @close(fun)
updateEntryState:(id,state,fun)->
- @connect (err,collection)->
+ @connect (err,collection)=>
if err then fun err,null
else
- collection.update {id:id},{$set:{state:state}},{w:1, upsert:true},fun
+ collection.update {id:id},{$set:{state:state}},{w:1, upsert:true},@close(fun)
View
8 src/server/Webserver.coffee
@@ -19,6 +19,14 @@ exports.createWebServer = (port,connectionString)->
else
res.json(result)
+ app.get '/latestByTag/json', (req,res)->
+ ms = store.createMongostore(connectionString)
+ ms.getLatestByTag req.query.tag,50, (err,result)->
+ ms.close()
+ if err then res.end(err)
+ else
+ res.json(result)
+
app.get '/redirect', (req,res)->
ms = store.createMongostore(connectionString)
ms.updateEntryState req.query.id,"read",(err,result)->
View
15 test/server/functional/WebServer_test.coffee
@@ -13,7 +13,7 @@ connectionString = "mongodb://localhost:27000/feeds"
database = mongostore.createMongostore(connectionString)
-twentyEntries = ({title:"title #{num}",id:"id#{num}",date:moment().subtract('minutes',20-num)} for num in [0...20])
+twentyEntries = ({title:"title #{num}",id:"id#{num}",date:moment().subtract('minutes',20-num),tags:[if num < 10 then "News" else "Technology"]} for num in [0...20])
webserver.createWebServer(port,connectionString)
@@ -28,7 +28,7 @@ requestingSomeJSONFrom=(URL,fun)->
.on 'error', (e)->
console.log("Got error: " + e.message)
fun(e.message,null)
-
+
describe 'Requesting the latest entries', () ->
before (done) ->
@@ -40,3 +40,14 @@ describe 'Requesting the latest entries', () ->
expect(data[0].title).to.equal "title 19"
expect(data.length).to.equal 20
done()
+
+describe 'Requesting the latest entries by tag', () ->
+ before (done) ->
+ after.insertingSome(twentyEntries).intoThe database,(err,result)->
+ done()
+
+ it 'should return JSON of them', (done) ->
+ requestingSomeJSONFrom url + "latestByTag/json?tag=News",(err,data)->
+ expect(data[0].title).to.equal "title 9"
+ expect(data.length).to.equal 10
+ done()
View
11 test/server/integration/MongoStore_test.coffee
@@ -7,8 +7,8 @@ after = andAlso = require '../shared/Feed_steps.coffee'
connectionString = "mongodb://localhost:27000/feeds"
feedData = [
- {"title":"A news story","link":"http://a.news.story/","tag","id":"1"}
- {"title":"Another news story","link":"http://another.news.story/","id":"2"}
+ {"title":"A news story","link":"http://a.news.story/","tags":["Technology"],"id":"1"}
+ {"title":"Another news story","link":"http://another.news.story/","tags":["News"],"id":"2"}
]
similarData = [
@@ -102,3 +102,10 @@ describe 'A mongodb store', ->
expect(result.length).to.equal 3
expect(result[0].title).to.equal "a newer entry"
done()
+
+ it 'should be able to limit results to certain tags',(done)->
+ after.insertingSome(feedData).intoThe @database,(result)=>
+ @database.getLatestByTag "News",10,(err,result)->
+ expect(result.length).to.equal 1
+ expect(result[0].title).to.equal "Another news story"
+ done()
View
2 test/server/unit/FeedCollector_test.coffee
@@ -88,7 +88,7 @@ describe 'A Feed collector', ->
link:"http://example.org/2003/12/13/atom03"
id:"def"
date: "2013-03-21T16:09:59.852Z"
- image:""
+# image:""
summary:""
tags:[]

No commit comments for this range

Something went wrong with that request. Please try again.