diff --git a/lib/response.js b/lib/response.js index 796f951..15b8117 100755 --- a/lib/response.js +++ b/lib/response.js @@ -205,6 +205,9 @@ function showPublishNote(req, res, next) { url: origin, body: text, 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, robots: meta.robots || false, //default allow robots GA: meta.GA, @@ -576,6 +579,9 @@ function showPublishSlide(req, res, next) { slides: slides, meta: JSON.stringify(obj.meta || {}), 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, robots: meta.robots || false, //default allow robots GA: meta.GA, diff --git a/public/js/extra.js b/public/js/extra.js index 77f298f..6c2e2d4 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -7,6 +7,7 @@ var lastchangeui = { user: $(".ui-lastchangeuser"), nouser: $(".ui-no-lastchangeuser") } +var ownerui = $(".ui-owner"); function updateLastChange() { 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 function getTitle(view) { var title = ""; diff --git a/public/js/index.js b/public/js/index.js index 4b8ae71..5681dcf 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2255,7 +2255,7 @@ var authorship = []; var authorshipMarks = {}; var authorMarks = {}; // temp variable var addTextMarkers = []; // temp variable -function updateLastInfo(data) { +function updateInfo(data) { //console.log(data); if (data.hasOwnProperty('createtime') && createtime !== data.createtime) { createtime = data.createtime; @@ -2265,10 +2265,16 @@ function updateLastInfo(data) { lastchangetime = data.updatetime; updateLastChange(); } + if (data.hasOwnProperty('owner') && owner !== data.owner) { + owner = data.owner; + ownerprofile = data.ownerprofile; + updateOwner(); + } if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) { lastchangeuser = data.lastchangeuser; lastchangeuserprofile = data.lastchangeuserprofile; updateLastChangeUser(); + updateOwner(); } if (data.hasOwnProperty('authors') && authors !== data.authors) { authors = data.authors; @@ -2483,13 +2489,12 @@ socket.on('check', function (data) { data = LZString.decompressFromUTF16(data); data = JSON.parse(data); //console.log(data); - updateLastInfo(data); + updateInfo(data); }); socket.on('permission', function (data) { updatePermission(data.permission); }); var docmaxlength = null; -var owner = null; var permission = null; socket.on('refresh', function (data) { data = LZString.decompressFromUTF16(data); @@ -2497,9 +2502,8 @@ socket.on('refresh', function (data) { //console.log(data); docmaxlength = data.docmaxlength; editor.setOption("maxLength", docmaxlength); - owner = data.owner; + updateInfo(data); updatePermission(data.permission); - updateLastInfo(data); if (!loaded) { // auto change mode if no content detected var nocontent = editor.getValue().length <= 0; diff --git a/public/views/body.ejs b/public/views/body.ejs index 28680e4..0b56edb 100644 --- a/public/views/body.ejs +++ b/public/views/body.ejs @@ -7,7 +7,7 @@ - +   @@ -21,6 +21,11 @@
  • Private - Only owner can view & edit
  • +
    +
    diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 7af474a..cc6fb33 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -54,12 +54,19 @@ <% if(lastchangeuserprofile) { %> <% } else { %> - + <% } %>   <%- viewcount %> views +
    + <% if(ownerprofile && owner !== lastchangeuser) { %> + +   +  owned this note + + <% } %>
    <%- body %>
    diff --git a/public/views/slide.ejs b/public/views/slide.ejs index a001637..fb3734b 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -60,12 +60,19 @@ <% if(lastchangeuserprofile) { %> <% } else { %> - + <% } %>   <%- viewcount %> views +
    + <% if(ownerprofile && owner !== lastchangeuser) { %> + +   +  owned this note + + <% } %> <% if(typeof disqus !== 'undefined' && disqus) { %>