Skip to content

Commit 6d9cecc

Browse files
committed
Improved support for CLI Tool, adding first version of CLI tool
1 parent 5131340 commit 6d9cecc

File tree

5 files changed

+39
-16
lines changed

5 files changed

+39
-16
lines changed

imports/api/notes/notes.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ Notes.schema = new SimpleSchema
174174
done:
175175
type: Boolean
176176
optional: yes
177+
inbox:
178+
type: Boolean
179+
optional: yes
177180

178181
Notes.attachSchema Notes.schema
179182

imports/api/notes/server/methods.coffee

+24-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'
66
Dropbox = require('dropbox')
77

88
import childCountDenormalizer from '/imports/api/notes/childCountDenormalizer.coffee'
9+
import rankDenormalizer from '/imports/api/notes/rankDenormalizer.coffee'
910

1011
import { Notes } from '/imports/api/notes/notes.coffee'
1112

@@ -74,20 +75,35 @@ export inbox = new ValidatedMethod
7475
validate: new SimpleSchema
7576
title: Notes.simpleSchema().schema('title')
7677
body: Notes.simpleSchema().schema('body')
77-
inboxCode: Notes.simpleSchema().schema('_id')
78+
userId: Notes.simpleSchema().schema('_id')
7879
.validator
7980
clean: yes
8081
filter: no
81-
run: ({ title, body, inboxCode }) ->
82-
inbox = Notes.findOne(inboxCode)
83-
if inbox
84-
console.log inboxCode, inbox
85-
Notes.insert
82+
run: ({ title, body, userId }) ->
83+
inbox = Notes.findOne
84+
owner: userId
85+
inbox: true
86+
deleted: {$exists:false}
87+
console.log "Got inbox: ",inbox,userId
88+
if !inbox
89+
inboxId = Notes.insert
90+
title: "<b>Inbox</b>"
91+
createdAt: new Date()
92+
owner: userId
93+
inbox: true
94+
showChildren: true
95+
else
96+
inboxId = inbox._id
97+
if inboxId
98+
noteId = Notes.insert
8699
title: title
87100
body: body
88-
parent: inbox._id
89-
owner: inbox.owner
101+
parent: inboxId
102+
owner: userId
90103
createdAt: new Date()
104+
rank: 0
105+
rankDenormalizer.updateSiblings inboxId
106+
return noteId
91107

92108
export summary = new ValidatedMethod
93109
name: 'notes.summary'

imports/api/notes/server/routes.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Picker.middleware( bodyParser.json() )
44
Picker.middleware( bodyParser.urlencoded( { extended: false } ) )
55

66
Picker.route '/notes/inbox', ( params, request, response, next ) ->
7-
Meteor.call 'notes.inbox',
8-
inboxCode: request.body.inboxCode
7+
noteId = Meteor.call 'notes.inbox',
8+
userId: request.body.userId
99
title: request.body.title
1010
body: request.body.body
1111
response.setHeader( 'Content-Type', 'application/json' );
1212
response.statusCode = 200;
13-
response.end( "OK" );
13+
response.end( noteId );

imports/ui/components/note/note.jade

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ template(name='note')
2121
a.calendar(href='/calendar/{{_id}}')
2222
i.glyphicon.glyphicon-calendar
2323
| Calendar
24+
li
25+
a.delete(href='#')
26+
i.glyphicon.glyphicon-trash
27+
| Delete
2428
if this.inbox
29+
li.divider(role="separator")
2530
li
2631
a(href="javascript:function bninbox(){var d=document,z=d.createElement('scr'+'ipt'),b=d.body;try{if(!b)throw(0);d.title='(Saving...) '+d.title;z.setAttribute('src','http://localhost:3000/notes/inbox/'+encodeURIComponent(d.location.href)+'&t='+(new Date().getTime()));b.appendChild(z);}catch(e){alert('Please wait until the page has loaded.');}}bninbox();void(0)")
2732
i.glyphicon.glyphicon-envelope
2833
| Drag this link to your bookmarks to save pages to this list.
29-
else
30-
li
31-
a.delete(href='#')
32-
i.glyphicon.glyphicon-trash
33-
| Delete
3434
.pull-right(class='{{favoriteClass}}')
3535
if currentUser
3636
i.glyphicon.glyphicon-heart.favorite

note.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
NOTEID=$(curl -X POST -H "Content-Type:application/json" https://bulletnotes.io/notes/inbox --digest -s -d "{\"title\":\"$1\",\"body\":\"$2\",\"userId\":\"WuQ2ha7E4BRbERWyh\"}")
3+
echo "Note saved! Title: $1 Body: $2";
4+
echo "View note: https://bulletnotes.io/note/$NOTEID"

0 commit comments

Comments
 (0)