mirror of https://github.com/status-im/codimd.git
Update to support showing owner on the infobar
This commit is contained in:
parent
7a85d62b77
commit
3175616573
|
@ -205,6 +205,9 @@ function showPublishNote(req, res, next) {
|
||||||
url: origin,
|
url: origin,
|
||||||
body: text,
|
body: text,
|
||||||
useCDN: config.usecdn,
|
useCDN: config.usecdn,
|
||||||
|
owner: note.owner ? note.owner.id : null,
|
||||||
|
ownerprofile: note.owner ? models.User.parseProfile(note.owner.profile) : null,
|
||||||
|
lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null,
|
||||||
lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null,
|
lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null,
|
||||||
robots: meta.robots || false, //default allow robots
|
robots: meta.robots || false, //default allow robots
|
||||||
GA: meta.GA,
|
GA: meta.GA,
|
||||||
|
@ -576,6 +579,9 @@ function showPublishSlide(req, res, next) {
|
||||||
slides: slides,
|
slides: slides,
|
||||||
meta: JSON.stringify(obj.meta || {}),
|
meta: JSON.stringify(obj.meta || {}),
|
||||||
useCDN: config.usecdn,
|
useCDN: config.usecdn,
|
||||||
|
owner: note.owner ? note.owner.id : null,
|
||||||
|
ownerprofile: note.owner ? models.User.parseProfile(note.owner.profile) : null,
|
||||||
|
lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null,
|
||||||
lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null,
|
lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null,
|
||||||
robots: meta.robots || false, //default allow robots
|
robots: meta.robots || false, //default allow robots
|
||||||
GA: meta.GA,
|
GA: meta.GA,
|
||||||
|
|
|
@ -7,6 +7,7 @@ var lastchangeui = {
|
||||||
user: $(".ui-lastchangeuser"),
|
user: $(".ui-lastchangeuser"),
|
||||||
nouser: $(".ui-no-lastchangeuser")
|
nouser: $(".ui-no-lastchangeuser")
|
||||||
}
|
}
|
||||||
|
var ownerui = $(".ui-owner");
|
||||||
|
|
||||||
function updateLastChange() {
|
function updateLastChange() {
|
||||||
if (!lastchangeui) return;
|
if (!lastchangeui) return;
|
||||||
|
@ -41,6 +42,23 @@ function updateLastChangeUser() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var owner = null;
|
||||||
|
var ownerprofile = null;
|
||||||
|
function updateOwner() {
|
||||||
|
if (ownerui) {
|
||||||
|
if (owner && ownerprofile && owner !== lastchangeuser) {
|
||||||
|
var icon = ownerui.children('i');
|
||||||
|
icon.attr('title', ownerprofile.name).tooltip('fixTitle');
|
||||||
|
var styleString = 'background-image:url(' + ownerprofile.photo + ')';
|
||||||
|
if (ownerprofile.photo && icon.attr('style') !== styleString)
|
||||||
|
icon.attr('style', styleString);
|
||||||
|
ownerui.show();
|
||||||
|
} else {
|
||||||
|
ownerui.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//get title
|
//get title
|
||||||
function getTitle(view) {
|
function getTitle(view) {
|
||||||
var title = "";
|
var title = "";
|
||||||
|
|
|
@ -2255,7 +2255,7 @@ var authorship = [];
|
||||||
var authorshipMarks = {};
|
var authorshipMarks = {};
|
||||||
var authorMarks = {}; // temp variable
|
var authorMarks = {}; // temp variable
|
||||||
var addTextMarkers = []; // temp variable
|
var addTextMarkers = []; // temp variable
|
||||||
function updateLastInfo(data) {
|
function updateInfo(data) {
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
if (data.hasOwnProperty('createtime') && createtime !== data.createtime) {
|
if (data.hasOwnProperty('createtime') && createtime !== data.createtime) {
|
||||||
createtime = data.createtime;
|
createtime = data.createtime;
|
||||||
|
@ -2265,10 +2265,16 @@ function updateLastInfo(data) {
|
||||||
lastchangetime = data.updatetime;
|
lastchangetime = data.updatetime;
|
||||||
updateLastChange();
|
updateLastChange();
|
||||||
}
|
}
|
||||||
|
if (data.hasOwnProperty('owner') && owner !== data.owner) {
|
||||||
|
owner = data.owner;
|
||||||
|
ownerprofile = data.ownerprofile;
|
||||||
|
updateOwner();
|
||||||
|
}
|
||||||
if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) {
|
if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) {
|
||||||
lastchangeuser = data.lastchangeuser;
|
lastchangeuser = data.lastchangeuser;
|
||||||
lastchangeuserprofile = data.lastchangeuserprofile;
|
lastchangeuserprofile = data.lastchangeuserprofile;
|
||||||
updateLastChangeUser();
|
updateLastChangeUser();
|
||||||
|
updateOwner();
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty('authors') && authors !== data.authors) {
|
if (data.hasOwnProperty('authors') && authors !== data.authors) {
|
||||||
authors = data.authors;
|
authors = data.authors;
|
||||||
|
@ -2483,13 +2489,12 @@ socket.on('check', function (data) {
|
||||||
data = LZString.decompressFromUTF16(data);
|
data = LZString.decompressFromUTF16(data);
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
updateLastInfo(data);
|
updateInfo(data);
|
||||||
});
|
});
|
||||||
socket.on('permission', function (data) {
|
socket.on('permission', function (data) {
|
||||||
updatePermission(data.permission);
|
updatePermission(data.permission);
|
||||||
});
|
});
|
||||||
var docmaxlength = null;
|
var docmaxlength = null;
|
||||||
var owner = null;
|
|
||||||
var permission = null;
|
var permission = null;
|
||||||
socket.on('refresh', function (data) {
|
socket.on('refresh', function (data) {
|
||||||
data = LZString.decompressFromUTF16(data);
|
data = LZString.decompressFromUTF16(data);
|
||||||
|
@ -2497,9 +2502,8 @@ socket.on('refresh', function (data) {
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
docmaxlength = data.docmaxlength;
|
docmaxlength = data.docmaxlength;
|
||||||
editor.setOption("maxLength", docmaxlength);
|
editor.setOption("maxLength", docmaxlength);
|
||||||
owner = data.owner;
|
updateInfo(data);
|
||||||
updatePermission(data.permission);
|
updatePermission(data.permission);
|
||||||
updateLastInfo(data);
|
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
// auto change mode if no content detected
|
// auto change mode if no content detected
|
||||||
var nocontent = editor.getValue().length <= 0;
|
var nocontent = editor.getValue().length <= 0;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<small>
|
<small>
|
||||||
<span>
|
<span>
|
||||||
<span class="ui-lastchangeuser" style="display: none;"> <i class="ui-user-icon small" data-toggle="tooltip" data-placement="right"></i></span>
|
<span class="ui-lastchangeuser" style="display: none;"> <i class="ui-user-icon small" data-toggle="tooltip" data-placement="right"></i></span>
|
||||||
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o"></i></span>
|
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o fa-fw" style="width: 18px;"></i></span>
|
||||||
<span class="text-uppercase ui-status-lastchange"></span>
|
<span class="text-uppercase ui-status-lastchange"></span>
|
||||||
<span class="ui-lastchange text-uppercase"></span>
|
<span class="ui-lastchange text-uppercase"></span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -21,6 +21,11 @@
|
||||||
<li class="ui-permission-private"><a><i class="fa fa-hand-stop-o fa-fw"></i> Private - Only owner can view & edit</a></li>
|
<li class="ui-permission-private"><a><i class="fa fa-hand-stop-o fa-fw"></i> Private - Only owner can view & edit</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
|
<br>
|
||||||
|
<span class="ui-owner" style="display: none;">
|
||||||
|
 <i class="ui-user-icon small" data-toggle="tooltip" data-placement="right"></i>
|
||||||
|
<span class="text-uppercase">owned this note</span>
|
||||||
|
</span>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div id="doc" class="markdown-body container-fluid"></div>
|
<div id="doc" class="markdown-body container-fluid"></div>
|
||||||
|
|
|
@ -54,12 +54,19 @@
|
||||||
<% if(lastchangeuserprofile) { %>
|
<% if(lastchangeuserprofile) { %>
|
||||||
<span class="ui-lastchangeuser"> <i class="ui-user-icon small" style="background-image: url(<%- lastchangeuserprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- lastchangeuserprofile.name %>"></i></span>
|
<span class="ui-lastchangeuser"> <i class="ui-user-icon small" style="background-image: url(<%- lastchangeuserprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- lastchangeuserprofile.name %>"></i></span>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o"></i></span>
|
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o fa-fw" style="width: 18px;"></i></span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<span class="text-uppercase ui-status-lastchange"></span>
|
<span class="text-uppercase ui-status-lastchange"></span>
|
||||||
<span class="ui-lastchange text-uppercase" data-createtime="<%- createtime %>" data-updatetime="<%- updatetime %>"></span>
|
<span class="ui-lastchange text-uppercase" data-createtime="<%- createtime %>" data-updatetime="<%- updatetime %>"></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="pull-right"><%- viewcount %> views <a href="#" class="ui-edit" title="Edit this note"><i class="fa fa-fw fa-pencil"></i></a></span>
|
<span class="pull-right"><%- viewcount %> views <a href="#" class="ui-edit" title="Edit this note"><i class="fa fa-fw fa-pencil"></i></a></span>
|
||||||
|
<br>
|
||||||
|
<% if(ownerprofile && owner !== lastchangeuser) { %>
|
||||||
|
<span class="ui-owner">
|
||||||
|
 <i class="ui-user-icon small" style="background-image: url(<%- ownerprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- ownerprofile.name %>"></i>
|
||||||
|
<span class="text-uppercase">owned this note</span>
|
||||||
|
</span>
|
||||||
|
<% } %>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div id="doc" class="container markdown-body"><%- body %></div>
|
<div id="doc" class="container markdown-body"><%- body %></div>
|
||||||
|
|
|
@ -60,12 +60,19 @@
|
||||||
<% if(lastchangeuserprofile) { %>
|
<% if(lastchangeuserprofile) { %>
|
||||||
<span class="ui-lastchangeuser"> <i class="ui-user-icon small" style="background-image: url(<%- lastchangeuserprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- lastchangeuserprofile.name %>"></i></span>
|
<span class="ui-lastchangeuser"> <i class="ui-user-icon small" style="background-image: url(<%- lastchangeuserprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- lastchangeuserprofile.name %>"></i></span>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o"></i></span>
|
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o fa-fw" style="width: 18px;"></i></span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<span class="text-uppercase ui-status-lastchange"></span>
|
<span class="text-uppercase ui-status-lastchange"></span>
|
||||||
<span class="ui-lastchange text-uppercase" data-createtime="<%- createtime %>" data-updatetime="<%- updatetime %>"></span>
|
<span class="ui-lastchange text-uppercase" data-createtime="<%- createtime %>" data-updatetime="<%- updatetime %>"></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="pull-right"><%- viewcount %> views <a href="#" class="ui-edit" title="Edit this note"><i class="fa fa-fw fa-pencil"></i></a></span>
|
<span class="pull-right"><%- viewcount %> views <a href="#" class="ui-edit" title="Edit this note"><i class="fa fa-fw fa-pencil"></i></a></span>
|
||||||
|
<br>
|
||||||
|
<% if(ownerprofile && owner !== lastchangeuser) { %>
|
||||||
|
<span class="ui-owner">
|
||||||
|
 <i class="ui-user-icon small" style="background-image: url(<%- ownerprofile.photo %>);" data-toggle="tooltip" data-placement="right" title="<%- ownerprofile.name %>"></i>
|
||||||
|
<span class="text-uppercase">owned this note</span>
|
||||||
|
</span>
|
||||||
|
<% } %>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<% if(typeof disqus !== 'undefined' && disqus) { %>
|
<% if(typeof disqus !== 'undefined' && disqus) { %>
|
||||||
|
|
Loading…
Reference in New Issue