diff --git a/pkg/interface/publish/src/js/components/lib/comment-item.js b/pkg/interface/publish/src/js/components/lib/comment-item.js index 8fd2340326..1619c62177 100644 --- a/pkg/interface/publish/src/js/components/lib/comment-item.js +++ b/pkg/interface/publish/src/js/components/lib/comment-item.js @@ -1,7 +1,8 @@ import React, { Component } from 'react'; import moment from 'moment'; +import { Sigil } from './icons/sigil'; +import { uxToHex } from '../../lib/util'; -//TODO take props and render div export class CommentItem extends Component { constructor(props){ super(props); @@ -36,12 +37,31 @@ export class CommentItem extends Component { }); let date = moment(commentData["date-created"]).fromNow(); + let contact = !!(commentData.author.substr(1) in this.props.contacts) + ? this.props.contacts[commentData.author.substr(1)] : false; + + let name = commentData.author; + let color = "#000000"; + if (contact) { + name = (contact.nickname.length > 0) + ? contact.nickname : commentData.author; + color = `#${uxToHex(contact.color)}`; + } + return (
-
{commentData.author}
-
{date}
+ +
+ {name} +
+
{date}
{content} diff --git a/pkg/interface/publish/src/js/components/lib/comments.js b/pkg/interface/publish/src/js/components/lib/comments.js index b7a19fc7c9..721e033228 100644 --- a/pkg/interface/publish/src/js/components/lib/comments.js +++ b/pkg/interface/publish/src/js/components/lib/comments.js @@ -34,7 +34,11 @@ export class Comments extends Component { render() { let commentArray = this.props.comments.map((com, i) => { return ( - + ); }) diff --git a/pkg/interface/publish/src/js/components/lib/icons/sigil.js b/pkg/interface/publish/src/js/components/lib/icons/sigil.js index 7d21261bb9..68fa449d96 100644 --- a/pkg/interface/publish/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/publish/src/js/components/lib/icons/sigil.js @@ -1,18 +1,21 @@ import React, { Component } from 'react'; import { sigil, reactRenderer } from 'urbit-sigil-js'; + export class Sigil extends Component { render() { const { props } = this; + let classes = props.classes || ""; + if (props.ship.length > 14) { return ( -
+
); } else { return ( -
+
{sigil({ patp: props.ship, renderer: reactRenderer, @@ -24,3 +27,4 @@ export class Sigil extends Component { } } } + diff --git a/pkg/interface/publish/src/js/components/lib/note.js b/pkg/interface/publish/src/js/components/lib/note.js index 59e19b6233..35743df73c 100644 --- a/pkg/interface/publish/src/js/components/lib/note.js +++ b/pkg/interface/publish/src/js/components/lib/note.js @@ -89,20 +89,30 @@ export class Note extends Component { } render() { - let notebook = this.props.notebooks[this.props.ship][this.props.book]; - let comments = notebook.notes[this.props.note].comments; - let title = notebook.notes[this.props.note].title; - let author = notebook.notes[this.props.note].author; - let file = notebook.notes[this.props.note].file; - let date = moment(notebook.notes[this.props.note]["date-created"]).fromNow(); + const { props } = this; + let notebook = props.notebooks[props.ship][props.book]; + let comments = notebook.notes[props.note].comments; + let title = notebook.notes[props.note].title; + let author = notebook.notes[props.note].author; + let file = notebook.notes[props.note].file; + let date = moment(notebook.notes[props.note]["date-created"]).fromNow(); + + let contact = !!(author.substr(1) in props.contacts) + ? props.contacts[author.substr(1)] : false; + + let name = author; + if (contact) { + name = (contact.nickname.length > 0) + ? contact.nickname : author; + } if (!file) { return null; } let newfile = file.slice(file.indexOf(';>')+2); - let prevId = notebook.notes[this.props.note]["prev-note"]; - let nextId = notebook.notes[this.props.note]["next-note"]; + let prevId = notebook.notes[props.note]["prev-note"]; + let nextId = notebook.notes[props.note]["next-note"]; let prev = (prevId === null) ? null @@ -129,7 +139,10 @@ export class Note extends Component {
{title}
-
{author}
+
+ {name} +
{date}
@@ -139,12 +152,14 @@ export class Note extends Component { - + ship={props.ship} + book={props.book}/> +
diff --git a/pkg/interface/publish/src/js/components/lib/notebook-item.js b/pkg/interface/publish/src/js/components/lib/notebook-item.js index dc7af2190c..d98b0d7650 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook-item.js +++ b/pkg/interface/publish/src/js/components/lib/notebook-item.js @@ -13,12 +13,27 @@ export class NotebookItem extends Component { let unread = (props.unreadCount > 0) ? `${props.unreadCount} unread` : ""; + let notebookContacts = (props.contactsPath in props.contacts) + ? props.contacts[props.contactsPath] : {}; + let contact = !!(props.author.substr(1) in notebookContacts) + ? notebookContacts[props.author.substr(1)] : false; + + let name = props.author; + if (contact) { + name = (contact.nickname.length > 0) + ? contact.nickname : props.author; + } + return (

{props.title}

-

by {props.author}

+

by + + {name} + +

{postCount} diff --git a/pkg/interface/publish/src/js/components/lib/notebook-posts.js b/pkg/interface/publish/src/js/components/lib/notebook-posts.js index f9cedb175d..5a78599283 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook-posts.js +++ b/pkg/interface/publish/src/js/components/lib/notebook-posts.js @@ -30,14 +30,24 @@ export class NotebookPosts extends Component { } render() { + const { props } = this; let notes = []; - for (var i=0; i 0) + ? contact.nickname : note.author; + } let comment = "No Comments"; if (note["num-comments"] == 1) { comment = "1 Comment"; @@ -45,7 +55,7 @@ export class NotebookPosts extends Component { comment = `${note["num-comments"]} Comments`; } let date = moment(note["date-created"]).fromNow(); - let url = `/~publish/note/${this.props.host}/${this.props.notebookName}/${noteId}` + let url = `/~publish/note/${props.host}/${props.notebookName}/${noteId}` notes.push( @@ -53,7 +63,8 @@ export class NotebookPosts extends Component {

{note.title}

{note.snippet}

-
{note.author}
+
{name}
{date}
{comment}
diff --git a/pkg/interface/publish/src/js/components/lib/notebook.js b/pkg/interface/publish/src/js/components/lib/notebook.js index 6246fd0507..d0dd65d64a 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook.js +++ b/pkg/interface/publish/src/js/components/lib/notebook.js @@ -69,7 +69,9 @@ export class Notebook extends Component { } render() { - let notebook = this.props.notebooks[this.props.ship][this.props.book]; + const { props } = this; + + let notebook = props.notebooks[props.ship][props.book]; let tabStyles = { posts: "bb b--gray4 gray2 pv4 ph2", @@ -77,17 +79,19 @@ export class Notebook extends Component { // subscribers: "bb b--gray4 gray2 pv4 ph2", // settings: "bb b--gray4 pr2 gray2 pv4 ph2", }; - tabStyles[this.props.view] = "bb b--black black pv4 ph2"; + tabStyles[props.view] = "bb b--black black pv4 ph2"; let inner = null; - switch (this.props.view) { + switch (props.view) { case "posts": let notesList = notebook["notes-by-date"] || []; let notes = notebook.notes || null; inner = + host={props.ship} + notebookName={props.book} + contacts={props.contacts} + /> break; case "about": inner =

{notebook.about}

@@ -102,16 +106,24 @@ export class Notebook extends Component { break; } - let base = `/~publish/notebook/${this.props.ship}/${this.props.book}`; + let contact = !!(props.ship.substr(1) in props.contacts) + ? props.contacts[props.ship.substr(1)] : false; + let name = props.ship; + if (contact) { + name = (contact.nickname.length > 0) + ? contact.nickname : props.ship; + } + + let base = `/~publish/notebook/${props.ship}/${props.book}`; let about = base + '/about'; let subs = base + '/subscribers'; let settings = base + '/settings'; let newUrl = base + '/new'; let newPost = null; - if (notebook["writers-group-path"] in this.props.groups){ + if (notebook["writers-group-path"] in props.groups){ let writers = notebook["writers-group-path"]; - if (this.props.groups[writers].has(window.ship)) { + if (props.groups[writers].has(window.ship)) { newPost = New Post @@ -119,7 +131,7 @@ export class Notebook extends Component { } } - let unsub = (window.ship === this.props.ship.slice(1)) + let unsub = (window.ship === props.ship.slice(1)) ? null :
diff --git a/pkg/interface/publish/src/js/components/lib/sidebar.js b/pkg/interface/publish/src/js/components/lib/sidebar.js index 62a94dde88..e7faa14158 100644 --- a/pkg/interface/publish/src/js/components/lib/sidebar.js +++ b/pkg/interface/publish/src/js/components/lib/sidebar.js @@ -126,6 +126,8 @@ export class Sidebar extends Component { key={book.title} title={book.title} author={author} + contacts={props.contacts} + contactsPath={book["subscribers-group-path"]} path={path} total={book["num-notes"]} unreadCount={book["num-unread"]} diff --git a/pkg/interface/publish/src/js/components/root.js b/pkg/interface/publish/src/js/components/root.js index 388d307d03..aeea94cf35 100644 --- a/pkg/interface/publish/src/js/components/root.js +++ b/pkg/interface/publish/src/js/components/root.js @@ -21,6 +21,8 @@ export class Root extends Component { render() { const { props, state } = this; + let contacts = !!state.contacts ? state.contacts : {}; + return ( + notebooks={state.notebooks} + contacts={contacts}>
@@ -54,7 +57,8 @@ export class Root extends Component { rightPanelHide={false} sidebarShown={true} invites={state.invites} - notebooks={state.notebooks}> + notebooks={state.notebooks} + contacts={contacts}> + notebooks={state.notebooks} + contacts={contacts}> ) @@ -89,6 +94,11 @@ export class Root extends Component { let path = `${ship}/${notebook}`; + let bookGroupPath = + state.notebooks[ship][notebook]["subscribers-group-path"]; + let notebookContacts = (bookGroupPath in contacts) + ? contacts[bookGroupPath] : {}; + if (view === "new") { return ( @@ -137,6 +150,11 @@ export class Root extends Component { let path = `${ship}/${notebook}` let note = props.match.params.note || ""; + let bookGroupPath = + state.notebooks[ship][notebook]["subscribers-group-path"]; + let notebookContacts = (bookGroupPath in state.contacts) + ? contacts[bookGroupPath] : {}; + return ( diff --git a/pkg/interface/publish/src/js/components/skeleton.js b/pkg/interface/publish/src/js/components/skeleton.js index 9365f4e049..7197a25183 100644 --- a/pkg/interface/publish/src/js/components/skeleton.js +++ b/pkg/interface/publish/src/js/components/skeleton.js @@ -29,6 +29,7 @@ export class Skeleton extends Component { sidebarShown={props.sidebarShown} active={props.active} notebooks={props.notebooks} + contacts={props.contacts} path={props.path} invites={props.invites} /> diff --git a/pkg/interface/publish/src/js/lib/util.js b/pkg/interface/publish/src/js/lib/util.js index 6d61a41492..8d1fa35701 100644 --- a/pkg/interface/publish/src/js/lib/util.js +++ b/pkg/interface/publish/src/js/lib/util.js @@ -36,3 +36,13 @@ export function dateToDa(d, mil) { `${mil ? "..0000" : ""}`   ); } + +export function uxToHex(ux) { + if (ux.length > 2 && ux.substr(0, 2) === '0x') { + let value = ux.substr(2).replace('.', '').padStart(6, '0'); + return value; + } + + let value = ux.replace('.', '').padStart(6, '0'); + return value; +}