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'
|
||||
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 ->
|
||||
@route 'home',
|
||||
path: '/'
|
||||
@ -16,12 +25,10 @@ Router.map ->
|
||||
else @render()
|
||||
@route 'doc',
|
||||
path: '/d/:_id'
|
||||
layoutTemplate: 'docLayout'
|
||||
waitOn: -> @docHandle = Meteor.subscribe 'doc', @params._id
|
||||
data: -> docs.findOne @params._id
|
||||
action: ->
|
||||
if @ready() then @render()
|
||||
else @render 'loading'
|
||||
controller: docController
|
||||
@route 'src',
|
||||
path:'/src/:_id'
|
||||
controller: docController
|
||||
@route 'verify',
|
||||
path: '/verify/:token'
|
||||
template: 'loading'
|
||||
@ -64,7 +71,14 @@ Template.new.events
|
||||
errCallback err
|
||||
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.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
|
||||
'click #signup': (e,t) ->
|
||||
|
@ -30,6 +30,13 @@
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
// Viewer
|
||||
|
||||
#tools {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
// Sign up
|
||||
#signup-container, #signin-container {
|
||||
#mail { margin-top: 2em; }
|
||||
|
@ -43,7 +43,11 @@
|
||||
<template name="doc">
|
||||
{{#if showTitle}}<h1>{{title}}</h1><hr>{{/if}}
|
||||
{{#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}}
|
||||
<div class="text-center">
|
||||
<h1>Sorry</h1>
|
||||
@ -58,13 +62,18 @@
|
||||
<div class="btn-group" id="tools">
|
||||
{{#if currentUser}}
|
||||
<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}}
|
||||
<button id="clone-doc" class="btn btn-success">
|
||||
Clone</button>
|
||||
{{#if currentUser}}
|
||||
<button id="del-doc" class="btn btn-danger">
|
||||
Delete</button>
|
||||
<i class="fa fa-trash"></i> Delete</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
<br>Powered by <a href="/">MarkCloud</a>
|
||||
|
Loading…
Reference in New Issue
Block a user