mirror of
https://github.com/fazo96/markcloud.git
synced 2025-01-10 11:04:21 +01:00
added ability to view the source
This commit is contained in:
parent
7636cee3ec
commit
67d87ecf04
@ -6,6 +6,15 @@ Router.configure
|
|||||||
layoutTemplate: 'layout'
|
layoutTemplate: 'layout'
|
||||||
loadingTemplate: 'loading'
|
loadingTemplate: 'loading'
|
||||||
|
|
||||||
|
docController = RouteController.extend
|
||||||
|
template: 'doc'
|
||||||
|
layoutTemplate: 'docLayout'
|
||||||
|
waitOn: -> Meteor.subscribe 'doc', @params._id
|
||||||
|
data: -> docs.findOne @params._id
|
||||||
|
action: ->
|
||||||
|
if @ready() then @render()
|
||||||
|
else @render 'loading'
|
||||||
|
|
||||||
Router.map ->
|
Router.map ->
|
||||||
@route 'home',
|
@route 'home',
|
||||||
path: '/'
|
path: '/'
|
||||||
@ -16,12 +25,10 @@ Router.map ->
|
|||||||
else @render()
|
else @render()
|
||||||
@route 'doc',
|
@route 'doc',
|
||||||
path: '/d/:_id'
|
path: '/d/:_id'
|
||||||
layoutTemplate: 'docLayout'
|
controller: docController
|
||||||
waitOn: -> @docHandle = Meteor.subscribe 'doc', @params._id
|
@route 'src',
|
||||||
data: -> docs.findOne @params._id
|
path:'/src/:_id'
|
||||||
action: ->
|
controller: docController
|
||||||
if @ready() then @render()
|
|
||||||
else @render 'loading'
|
|
||||||
@route 'verify',
|
@route 'verify',
|
||||||
path: '/verify/:token'
|
path: '/verify/:token'
|
||||||
template: 'loading'
|
template: 'loading'
|
||||||
@ -64,7 +71,14 @@ Template.new.events
|
|||||||
errCallback err
|
errCallback err
|
||||||
if id then Router.go 'doc', _id: id
|
if id then Router.go 'doc', _id: id
|
||||||
|
|
||||||
|
Template.doc.source = -> Router.current().route.name is 'src'
|
||||||
|
Template.doc.rows = -> ""+@text.split('\n').length
|
||||||
Template.doc.canEdit = -> "disabled" unless Meteor.user()._id is @owner
|
Template.doc.canEdit = -> "disabled" unless Meteor.user()._id is @owner
|
||||||
|
Template.doc.events
|
||||||
|
'click #src-doc': ->
|
||||||
|
if Router.current().route.name is 'src'
|
||||||
|
Router.go 'doc', _id: @_id
|
||||||
|
else Router.go 'src', _id: @_id
|
||||||
|
|
||||||
Template.signup.events
|
Template.signup.events
|
||||||
'click #signup': (e,t) ->
|
'click #signup': (e,t) ->
|
||||||
|
@ -30,6 +30,13 @@
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Viewer
|
||||||
|
|
||||||
|
#tools {
|
||||||
|
margin-top: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
// Sign up
|
// Sign up
|
||||||
#signup-container, #signin-container {
|
#signup-container, #signin-container {
|
||||||
#mail { margin-top: 2em; }
|
#mail { margin-top: 2em; }
|
||||||
|
@ -43,7 +43,11 @@
|
|||||||
<template name="doc">
|
<template name="doc">
|
||||||
{{#if showTitle}}<h1>{{title}}</h1><hr>{{/if}}
|
{{#if showTitle}}<h1>{{title}}</h1><hr>{{/if}}
|
||||||
{{#if text}}
|
{{#if text}}
|
||||||
{{#markdown}}{{text}}{{/markdown}}
|
{{#if source}}
|
||||||
|
<textarea id="src" class="form-control" rows="{{rows}}" readonly>{{text}}</textarea>
|
||||||
|
{{else}}
|
||||||
|
<div id="doc">{{#markdown}}{{text}}{{/markdown}}</div>
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1>Sorry</h1>
|
<h1>Sorry</h1>
|
||||||
@ -58,13 +62,18 @@
|
|||||||
<div class="btn-group" id="tools">
|
<div class="btn-group" id="tools">
|
||||||
{{#if currentUser}}
|
{{#if currentUser}}
|
||||||
<button id="edit-doc" class="btn btn-primary" {{canEdit}}>
|
<button id="edit-doc" class="btn btn-primary" {{canEdit}}>
|
||||||
Edit</button>
|
<i class="fa fa-edit"></i> Edit</button>
|
||||||
|
{{/if}}
|
||||||
|
{{#if source}}
|
||||||
|
<button id="src-doc" class="btn btn-success">
|
||||||
|
<i class="fa fa-book"></i> View Document</button>
|
||||||
|
{{else}}
|
||||||
|
<button id="src-doc" class="btn btn-success">
|
||||||
|
<i class="fa fa-code"></i> View Source</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<button id="clone-doc" class="btn btn-success">
|
|
||||||
Clone</button>
|
|
||||||
{{#if currentUser}}
|
{{#if currentUser}}
|
||||||
<button id="del-doc" class="btn btn-danger">
|
<button id="del-doc" class="btn btn-danger">
|
||||||
Delete</button>
|
<i class="fa fa-trash"></i> Delete</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<br>Powered by <a href="/">MarkCloud</a>
|
<br>Powered by <a href="/">MarkCloud</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user