mirror of
https://github.com/fazo96/markcloud.git
synced 2025-01-10 11:04:21 +01:00
can now make private documents
This commit is contained in:
parent
66e3ea81a9
commit
0c37404201
@ -23,11 +23,9 @@ loggedInController = RouteController.extend
|
||||
Router.map ->
|
||||
@route 'home',
|
||||
path: '/'
|
||||
waitOn: -> Meteor.subscribe 'docs'
|
||||
action: ->
|
||||
if !@ready()
|
||||
@render(); @render 'spinner', to: 'outside'
|
||||
else @render()
|
||||
if !@ready() then @render 'spinner', to: 'outside'
|
||||
@render()
|
||||
@route 'doc',
|
||||
path: '/d/:_id'
|
||||
controller: docController
|
||||
@ -41,7 +39,7 @@ Router.map ->
|
||||
if err then errCallback err else Router.go 'home'
|
||||
@route 'edit',
|
||||
path: '/edit/:_id'
|
||||
template: 'new'
|
||||
template: 'editor'
|
||||
controller: loggedInController
|
||||
waitOn: -> Meteor.subscribe 'doc', @params._id
|
||||
data: -> docs.findOne @params._id
|
||||
@ -50,16 +48,17 @@ Router.map ->
|
||||
waitOn: ->
|
||||
[Meteor.subscribe('docs', @params.user),
|
||||
Meteor.subscribe('user',@params.user)]
|
||||
data: -> userId: @params.user
|
||||
data: -> Meteor.users.findOne @params.user
|
||||
onBeforeAction: ->
|
||||
if Meteor.user() and !@params.user
|
||||
Router.go 'profile', user: Meteor.user()._id
|
||||
action: ->
|
||||
if !@params.user then @render '404'
|
||||
else @render()
|
||||
if !@data() then @render '404'
|
||||
else if @ready() then @render()
|
||||
else @render 'loading'
|
||||
@route 'delete',
|
||||
controller: loggedInController
|
||||
@route 'new'
|
||||
@route 'new', template: 'editor'
|
||||
@route 'signup',
|
||||
controller: loggedOutController
|
||||
@route 'signin',
|
||||
@ -84,8 +83,8 @@ Template.layout.notHome = -> Router.current().route.name isnt 'home'
|
||||
Template.layout.showSpinner = ->
|
||||
Meteor.status().connected is no or Router.current().ready() is no
|
||||
Template.home.ndocs = -> docs.find().count()
|
||||
Template.new.showTitleChecked = -> return "checked" unless @showTitle is no
|
||||
Template.new.events
|
||||
Template.editor.showTitleChecked = -> return "checked" unless @showTitle is no
|
||||
Template.editor.events
|
||||
'click #upload': (e,t) ->
|
||||
if t.find('#title').value is ''
|
||||
return notify msg: 'please insert a title'
|
||||
@ -95,6 +94,7 @@ Template.new.events
|
||||
title: t.find('#title').value
|
||||
text: t.find('#editor').value
|
||||
showTitle: $('#show-title').is(':checked')
|
||||
public: $('#make-public').is(':checked')
|
||||
}, (err) =>
|
||||
if err then errCallback err
|
||||
else
|
||||
@ -104,17 +104,17 @@ Template.new.events
|
||||
title: t.find('#title').value
|
||||
text: t.find('#editor').value
|
||||
showTitle: $('#show-title').is(':checked')
|
||||
public: $('#make-public').is(':checked')
|
||||
}, (err,id) ->
|
||||
if err then errCallback err
|
||||
else notify type:'success', msg:'Document created successfully'
|
||||
if id then Router.go 'doc', _id: id
|
||||
|
||||
Template.profile.name = -> Meteor.user().username
|
||||
Template.profile.isMe = ->
|
||||
Meteor.user() and Meteor.user()._id is @userId
|
||||
Template.profile.noDocs = -> docs.find(owner: @userId).count() is 0
|
||||
Meteor.user() and Meteor.user()._id is @_id
|
||||
Template.profile.noDocs = -> docs.find(owner: @_id).count() is 0
|
||||
Template.profile.documents = ->
|
||||
docs.find {owner: @userId}, sort: dateCreated: -1
|
||||
docs.find {owner: @_id}, sort: dateCreated: -1
|
||||
Template.profile.events
|
||||
'click #logout': -> Meteor.logout(); Router.go 'home'
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Body
|
||||
.container {
|
||||
max-width: 40em;
|
||||
max-width: 35em;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.close {
|
||||
@ -74,3 +75,7 @@
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.label {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
@ -27,6 +27,11 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template name="docLayout">
|
||||
{{> yield region="outside"}}
|
||||
<div class="container">{{> yield}}</div>
|
||||
</template>
|
||||
|
||||
<template name="home">
|
||||
{{#markdown}}
|
||||
### Share your markdown easily
|
||||
@ -65,21 +70,18 @@ You will be able to delete your account and all your data whenever you want.
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template name="new">
|
||||
<template name="editor">
|
||||
<p>Write your document in <a href="https://help.github.com/articles/github-flavored-markdown/">GitHub Flavored Markdown</a> then submit it with the button. You will be redirected to its permanent link</p>
|
||||
<input type="text" id="title" class="form-control" placeholder="Title" value="{{title}}">
|
||||
<input type="checkbox" id="show-title" {{showTitleChecked}}>
|
||||
Show title in document
|
||||
<input type="checkbox" id="make-public" {{public}}>
|
||||
Make document visible on your profile
|
||||
<textarea id="editor" class="form-control" rows="10" placeholder="Write your markdown :)" autofocus>{{text}}</textarea>
|
||||
<button id="upload" class="btn btn-primary">
|
||||
<i class="fa fa-upload"></i> {{#if _id}}Update{{else}}Create{{/if}}</button>
|
||||
</template>
|
||||
|
||||
<template name="docLayout">
|
||||
{{> yield region="outside"}}
|
||||
<div class="container">{{> yield}}</div>
|
||||
</template>
|
||||
|
||||
<template name="doc">
|
||||
{{#if valid}}
|
||||
{{#if showTitle}}<h1>{{title}}</h1><hr>{{/if}}
|
||||
@ -192,20 +194,12 @@ You will be able to delete your account and all your data whenever you want.
|
||||
|
||||
<template name="profile">
|
||||
{{#if isMe}}
|
||||
<div class="text-center">
|
||||
<p>Hello {{name}} ({{mail}}). This is your profile.</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if noDocs}}
|
||||
<div class="text-center">
|
||||
{{#if isMe}}
|
||||
<p>You don't have any documents yet.</p>
|
||||
{{else}}
|
||||
<p>This user does not have any documents.</p>
|
||||
{{/if}}
|
||||
<p>Hello <b>{{username}}</b> ({{mail}}). This is your profile.</p>
|
||||
{{#if noDocs}}
|
||||
<p>You don't have any documents yet.</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if isMe}}
|
||||
<div class="text-center" id="profile-tools">
|
||||
<a class="btn btn-primary" id="logout">
|
||||
<i class="fa fa-sign-out"></i> Logout</a>
|
||||
@ -214,11 +208,24 @@ You will be able to delete your account and all your data whenever you want.
|
||||
<a class="btn btn-danger" href="/delete">
|
||||
<i class="fa fa-exclamation-circle"></i> Delete Account</a>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="text-center">
|
||||
{{#if noDocs}}
|
||||
<p>{{username}} doesn't have any public documents.</p>
|
||||
{{else}}
|
||||
<p>These are {{username}}'s public documents.</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#unless noDocs}}
|
||||
<ul class="list-group">
|
||||
{{#each documents}}
|
||||
<a class="list-group-item" href="/d/{{_id}}">{{title}}</a>
|
||||
<a class="list-group-item" href="/d/{{_id}}">
|
||||
{{title}}
|
||||
{{#if public}}
|
||||
<span class="label label-primary pull-right">Public</span>
|
||||
{{/if}}
|
||||
</a>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/unless}}
|
||||
|
@ -20,10 +20,13 @@ validatedUser = (uid) ->
|
||||
|
||||
Meteor.publish 'doc', (id) -> docs.find {_id: id}, limit: 1
|
||||
Meteor.publish 'docs', (userId) ->
|
||||
if userId? then docs.find {owner: userId}, fields: text: 0
|
||||
if userId?
|
||||
if userId is @userId
|
||||
docs.find {owner: userId}, fields: text: 0
|
||||
else docs.find {owner: userId, public: yes}, fields: text: 0
|
||||
else docs.find {}, fields: text: 0
|
||||
Meteor.publish 'user', (id) ->
|
||||
Meteor.users.find {_id: id}, fields: {username: 1}
|
||||
Meteor.users.find id, fields: {username: 1}
|
||||
|
||||
docs.allow
|
||||
insert: (uid,doc) ->
|
||||
|
Loading…
Reference in New Issue
Block a user