views/subcontent.pug (192 lines of code) (raw):
include util
mixin files
.rnd.hig.gap.wlp.ins
.pad
b.vgi-clip Attachments
#fileList
+fileList
form.pad
input.fbn(id="file1",name="file1", type='file',multiple=true,onchange='preview(this,event)')
input.txt(size="40em",name="comment", placeholder="Description of the attachment(s)")
button.btn.vgi-indent.save#upb(onclick="attach(this, event)") Attach
progress.hid(name="prg")
div.indent.indent(class="filePreview")
mixin fileList
if(files && files.length>0)
- fields = {name: {href:'/'+schemaName+'/' + doc_id + '/file/', class: 'icn ', target:'_blank', xref: {class: 'type'}}, user: {class: 'ico'}, delete: {class: 'ico delete',onclick:'fileDelete(this)'}};
+table(files, ['name','comment','size','updatedAt','user','delete'])
mixin commentBox
#commentTemplate.hid
form.wht.bor.shd.rnd.gap.pad(onsubmit="sendComment(this);return false;")
input(type="hidden",name="id",value=id)
.toolbar
div
span.btg.indent
a.sbn.vgi-bold(data-wysihtml5-command='bold', title='Bold CTRL+B')
a.sbn.vgi-italic(data-wysihtml5-command='italic', title='Italic CTRL+I')
a.sbn.vgi-underline(data-wysihtml5-command='underline', title='Underline CTRL+U')
a.sbn.vgi-highlight(data-wysihtml5-command='bgColorStyle', title='highlight', color="#666699", data-wysihtml5-command-value='#effa66')
// <a class="fbn icn strikethrough" data-wysihtml5-command="strike" title="Strike"></a>
span.btg.indent
a.sbn.vgi-p(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='p',title='paragraph style')
a.sbn.vgi-h1(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='h1',title='Heading 1')
a.sbn.vgi-h2(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='h2',title='Heading 2')
a.sbn.vgi-h3(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='h3',title='Heading 3')
a.wysihtml5-command-active.sbn.vgi-noformat(data-wysihtml5-command='formatBlock', data-wysihtml5-command-blank-value='true',unselectable='on',title='Clear styles')
span.btg.indent
a.sbn.vgi-link(data-wysihtml5-command='createLink',title='Hyperlink')
a.sbn.vgi-unlink(data-wysihtml5-command='removeLink',title='Unlink')
a.sbn.vgi-pic(data-wysihtml5-command='insertImage',title='Insert image')
a.sbn.vgi-console(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='tt',title='Code text')
a.sbn.vgi-quote(data-wysihtml5-command='formatBlock', data-wysihtml5-command-value='blockquote',title='Block quote')
a.sbn.vgi-table(data-wysihtml5-command='createTable',title='Insert Table')
span.btg.indent
a.sbn.vgi-bullet(data-wysihtml5-command='insertUnorderedList',title='Bulletted list')
a.sbn.vgi-numbered(data-wysihtml5-command='insertOrderedList',title='Numbered list')
span.btg.indent
a.sbn.vgi-undo(data-wysihtml5-command='undo',title='Undo')
a.sbn.vgi-redo(data-wysihtml5-command='redo',title='Redo')
a.sbn.vgi-markup(data-wysihtml5-action='change_view',title='HTML source view')
span.btg.indent(data-wysihtml5-hiddentools='table', style='display: none;')
a.sbn.vgi-add-row-top(data-wysihtml5-command='addTableCells', data-wysihtml5-command-value='above',title='Insert row above')
a.sbn.vgi-add-row-down(data-wysihtml5-command='addTableCells', data-wysihtml5-command-value='below',title='Insert row below')
a.sbn.vgi-add-col-left(data-wysihtml5-command='addTableCells', data-wysihtml5-command-value='before',title='Insert column before')
a.sbn.vgi-add-col-right(data-wysihtml5-command='addTableCells', data-wysihtml5-command-value='after',title='Insert column after')
a.sbn.vgi-row-red(data-wysihtml5-command='deleteTableCells', data-wysihtml5-command-value='row',title='Delete row')
a.sbn.vgi-col-red(data-wysihtml5-command='deleteTableCells', data-wysihtml5-command-value='column',title='Delete column')
div(data-wysihtml5-dialog='createLink', style='display: none;')
label.lbl.sml.vgi-link Link:
input.vgi-text(size='90', data-wysihtml5-dialog-field='href', value='https://',title='URL')
a.btn.vgi-ext(onclick='window.open(this.previousElementSibling.value)') Open
a.btn.indent.vgi-ok(data-wysihtml5-dialog-action='save') OK
a.btn.vgi-cancel(data-wysihtml5-dialog-action='cancel') Cancel
div(data-wysihtml5-dialog='insertImage', style='display: none;')
label.lbl.vgi-link URL
input.vgi-txt(data-wysihtml5-dialog-field='src',size=50,value='https://')
label.lbl or
label.btn.vgi-folder(title='Browse for local images to insert') Insert Image ..
input.hid(type='file',onchange='loadimg.call(this, event)',accept="image/*")
a.btn.indent.vgi-ok(data-wysihtml5-dialog-action='save') OK
a.btn.vgi-cancel(data-wysihtml5-dialog-action='cancel') Cancel
div(data-wysihtml5-dialog='createTable', style='display: none;')
label.vgi-table.lbl Rows:
input.txt(type='text', data-wysihtml5-dialog-field='rows')
label.lbl Cols:
input.txt(type='text', data-wysihtml5-dialog-field='cols')
a.btn.vgi-ok.indent(data-wysihtml5-dialog-action='save') OK
a.btn.vgi-cancel(data-wysihtml5-dialog-action='cancel') Cancel
.wysihtml5-editor.fil.txt(style="min-height:10em")
//, onkeyup="this.form.button.disabled=this.value ? false : true",onblur="this.form.button.disabled=this.value ? false : true")
//#addCommentText.wysDiv(onkeyup="setCommentButton(this, this.form.button)",onblur="setCommentButton(this, this.form.button)")
button.btn.gap.sml(type="submit",name="button",disabled=true) Add comment (optional and internal only, sends email)
mixin comments
if docs
each c, i in docs
.shd.rnd.bor.pad.gap(class=c._id? 'lyel': 'wht')
dt
- var cd = new Date(c.createdAt);
- var ud = new Date(c.updatedAt);
span.pad3.lbl(class=c.subject ? 'Email' : '')
b.vguser(title=c.author)=c.author
| on
= cd.toLocaleDateString("en-US",{year: 'numeric', month: 'short', day: 'numeric'})
|
if(c.updatedAt && (cd.getTime() !== ud.getTime()))
| (updated
= ud.toLocaleDateString("en-US",{year: 'numeric', month: 'short', day: 'numeric'})
| )
|
if(c.author == username)
button.btn.sml(onclick="editPost(this.parentNode)") update
| -
b.lbl=c.title
if c._id
a.lbl.vgi-ext(href='/mail/'+c._id)
=c.subject
else
b.lbl=c.subject
.wysihtml5-editor.fil
if c.hypertext
+asis(c.hypertext)
else if c.body
div.wrp=c.body
else
i.tgrey No content
input(type="hidden",name="slug",value=c.slug)
input(type="hidden",name="date",value=c.createdAt)
mixin changeIcon(op)
if op == 'remove'
span.lbl →
else if op == 'add'
span.lbl +
else
span.lbl →
mixin changes
- var past = {add: 'added', remove: 'removed', replace: 'changed', move: 'moved', copy: 'copied'}
table.diff
if docs
each v, i in docs
tbody
each op, i in v.body.patch
tr.hig
td.pad(colspan=3)
span.vguser(title=v.author)
b= v.author
| on
+hyperdate(v,'updatedAt')
|
= past[op.op] ? past[op.op] : op.op
|
b= op.path
tr.change(class=op.op)
if op.op == 'remove'
- op.old = op.value
- delete op.value
if op.op == 'replace' && typeof op.old === 'string' && typeof op.value === 'string'
if textUtil
- var diffs = textUtil.diffline(op.old, op.value);
td
pre.pre
for s in diffs.lhs
case s.t
when 0
= s.str
when 1
span.red=s.str
td
+changeIcon(op.op)
td
pre.pre
for s in diffs.rhs
case s.t
when 0
= s.str
when 1
span.grn=s.str
else
td
pre.pre=op.old
td
+changeIcon(op.op)
td
pre.pre=op.value
else
td
if op.old instanceof Object
pre= JSON.stringify(op.old, null, 1)
else
= op.old
td
+changeIcon(op.op)
td
if op.value == null
i.vgi-del deleted
if op.value instanceof Object
pre= JSON.stringify(op.value, null, 1)
else
= op.value
mixin filePreview
+table(docs,columns)
block red
if ctemplate != undefined
+#{ctemplate}