1
0
mirror of https://github.com/fazo96/markcloud.git synced 2025-01-10 11:04:21 +01:00

added anonymous and public links and fixed profile links

This commit is contained in:
Enrico Fasoli 2014-10-09 15:07:00 +02:00
parent be8309d014
commit 1879b974c1
2 changed files with 26 additions and 17 deletions

View File

@ -43,7 +43,7 @@ Router.map ->
path: '/d/:_id' path: '/d/:_id'
controller: docController controller: docController
@route 'userDoc', @route 'userDoc',
path: '/@:owner/:_id' path: '/@:user/:_id'
controller: docController controller: docController
@route 'src', @route 'src',
path:'/src/:_id' path:'/src/:_id'
@ -62,20 +62,18 @@ Router.map ->
waitOn: -> Meteor.subscribe 'doc', @params._id waitOn: -> Meteor.subscribe 'doc', @params._id
data: -> docs.findOne @params._id data: -> docs.findOne @params._id
@route 'profile', @route 'profile',
path: '/@:user?' path: '/@:user'
waitOn: -> waitOn: ->
[Meteor.subscribe('docs', @params.user), [Meteor.subscribe('docs', @params.user),
Meteor.subscribe('user', @params.user)] Meteor.subscribe('user', @params.user)]
data: -> Meteor.users.findOne() data: -> Meteor.users.findOne username: @params.user
onBeforeAction: ->
if Meteor.user() and !@params.user
@params.user = Meteor.user().username
action: -> action: ->
if !@ready() or Meteor.loggingIn() then @render 'loading' if Meteor.loggingIn() then @render 'loading'
else if !@data() then @render '404' else @render() else if @ready()
if !@data() then @render '404' else @render()
else @render 'loading'
@route 'new', template: 'editor' @route 'new', template: 'editor'
@route 'signup', @route 'signup', controller: loggedOutController
controller: loggedOutController
@route 'signin', @route 'signin',
path: 'login' path: 'login'
controller: loggedOutController controller: loggedOutController
@ -160,7 +158,12 @@ Template.profile.events
Template.doc.valid = -> @text? Template.doc.valid = -> @text?
Template.doc.source = -> Router.current().route.name is 'src' Template.doc.source = -> Router.current().route.name is 'src'
Template.doc.rows = -> ""+@text.split('\n').length Template.doc.rows = -> ""+@text.split('\n').length
Template.doc.owned = -> Meteor.user()._id is @owner Template.doc.owned = -> Meteor.user() and Meteor.user()._id is @owner
Template.doc.privateUrl = ->
Template.doc.ownerName = ->
if Router.current().route.name is 'userDoc'
console.log Router.current()
return Router.current().params.owner
Template.doc.expirationDays = -> Template.doc.expirationDays = ->
if @owner then return 'never' if @owner then return 'never'
else return moment.unix(@dateCreated).add(7,'days').fromNow() else return moment.unix(@dateCreated).add(7,'days').fromNow()

View File

@ -11,11 +11,11 @@
<h1>MarkCloud <h1>MarkCloud
{{#if currentUser}} {{#if currentUser}}
{{#if amIValid}} {{#if amIValid}}
<a class="pull-right" href="{{pathFor 'profile'}}"> <a id="icon" class="pull-right" href="{{pathFor 'profile' user=currentUser.username}}">
<small><i class="fa fa-chevron-right"></i></small> <small><i class="fa fa-chevron-right"></i></small>
</a> </a>
{{else}} {{else}}
<a class="pull-right ttip" href="{{pathFor 'profile'}}" data-toggle="tooltip" data-placement="left" title="Need email verification"> <a class="pull-right" id="icon" href="{{pathFor 'profile' user=currentUser.username}}" data-toggle="tooltip" data-placement="left" title="Need email verification">
<small><i class="fa fa-envelope"></i></small> <small><i class="fa fa-envelope"></i></small>
</a> </a>
{{/if}} {{/if}}
@ -114,11 +114,17 @@ You will be able to delete your account and all your data whenever you want.
{{/unless}} {{/unless}}
{{#if valid}} {{#if valid}}
{{#if owned}} {{#if owned}}
<p>This document is <a href="{{pathFor 'profile'}}">yours</a>.</p> <p>This document is <a id="owner-link" href="{{pathFor 'profile' user=currentUser.username}}">yours</a>.</p>
<p>You can link this document using a <a href="{{pathFor 'userDoc' user=currentUser.username _id=this._id}}">public</a> or <a href="{{pathFor 'doc'}}">anonymous link</a>.</p>
<p>Anonymous links don't reveal your profile.</p>
{{else}} {{else}}
{{#unless owner}} {{#if ownerName}}
<p>This anonymous document will <b>expire {{expirationDays}}</b></p> <p>Document owned by <a href="{{pathFor 'profile' user=currentUser.username}}">{{ownerName}}</a></p>
{{/unless}} {{else}}
{{#unless owner}}
<p>This anonymous document will <b>expire {{expirationDays}}</b></p>
{{/unless}}
{{/if}}
{{/if}} {{/if}}
<div class="btn-group" id="tools"> <div class="btn-group" id="tools">
{{#if currentUser}}{{#if owned}} {{#if currentUser}}{{#if owned}}