diff --git a/pkg/interface/chat/src/js/components/lib/header-bar.js b/pkg/interface/chat/src/js/components/lib/header-bar.js index 3798ded8d1..7a990aad4d 100644 --- a/pkg/interface/chat/src/js/components/lib/header-bar.js +++ b/pkg/interface/chat/src/js/components/lib/header-bar.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import classnames from "classnames"; +import { cite } from '../../lib/util'; import { IconHome } from "/components/lib/icons/icon-home"; import { Sigil } from "/components/lib/icons/sigil"; @@ -50,7 +50,7 @@ export class HeaderBar extends Component { size={16} color={"#000000"} /> - {"~" + window.ship} + {cite(window.ship)} ); diff --git a/pkg/interface/chat/src/js/components/lib/icons/sigil.js b/pkg/interface/chat/src/js/components/lib/icons/sigil.js index c160e62f8a..853332901f 100644 --- a/pkg/interface/chat/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/chat/src/js/components/lib/icons/sigil.js @@ -10,7 +10,9 @@ export class Sigil extends Component { if (props.ship.length > 14) { return ( -
+
); } else { diff --git a/pkg/interface/chat/src/js/components/lib/member-element.js b/pkg/interface/chat/src/js/components/lib/member-element.js index b0151f223a..2e25b63078 100644 --- a/pkg/interface/chat/src/js/components/lib/member-element.js +++ b/pkg/interface/chat/src/js/components/lib/member-element.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import classnames from 'classnames'; import { Sigil } from '/components/lib/icons/sigil'; -import { uxToHex } from '/lib/util'; +import { uxToHex, cite } from '/lib/util'; export class MemberElement extends Component { @@ -35,7 +35,7 @@ export class MemberElement extends Component { } let name = !!props.contact - ? `${props.contact.nickname} (~${props.ship})` : `~${props.ship}`; + ? `${props.contact.nickname} (${cite(props.ship)})` : `${cite(props.ship)}`; let color = !!props.contact ? uxToHex(props.contact.color) : '000000'; return ( diff --git a/pkg/interface/chat/src/js/components/lib/message.js b/pkg/interface/chat/src/js/components/lib/message.js index 304fef97ef..36fd7eb363 100644 --- a/pkg/interface/chat/src/js/components/lib/message.js +++ b/pkg/interface/chat/src/js/components/lib/message.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { Sigil } from '/components/lib/icons/sigil'; import classnames from 'classnames'; import { Route, Link } from 'react-router-dom' -import { uxToHex } from '/lib/util'; +import { uxToHex, cite } from '/lib/util'; import urbitOb from 'urbit-ob'; import moment from 'moment'; import _ from 'lodash'; @@ -154,6 +154,11 @@ export class Message extends Component { color = `#${uxToHex(contact.color)}`; sigilClass = ""; } + + if (`~${props.msg.author}` === name) { + name = cite(props.msg.author); + } + return (
-

- {name} +

+ + {name} +

{timestamp}

{datestamp}

diff --git a/pkg/interface/chat/src/js/components/lib/sidebar-item.js b/pkg/interface/chat/src/js/components/lib/sidebar-item.js index 618f8866a3..3d0ecb2c42 100644 --- a/pkg/interface/chat/src/js/components/lib/sidebar-item.js +++ b/pkg/interface/chat/src/js/components/lib/sidebar-item.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import { cite } from '../../lib/util'; import classnames from 'classnames'; import moment from 'moment'; @@ -62,13 +63,15 @@ export class SidebarItem extends Component { let latest = this.getLetter(props.latest); - let selectedCss = !!props.selected ? 'bg-gray5 bg-gray1-d gray3-d' : 'bg-white bg-gray0-d gray3-d pointer'; + let selectedCss = !!props.selected + ? 'bg-gray5 bg-gray1-d gray3-d c-default' + : 'bg-white bg-gray0-d gray3-d pointer'; let authorCss = (props.nickname === props.ship) ? "mono" : ""; let author = (props.nickname === props.ship) - ? `~${props.ship}` : props.nickname; + ? cite(props.ship) : props.nickname; return (

+ unreadElem + " dib f9 mr3 mw4 truncate v-mid " + authorCss} + title={props.ship || ""}> {(author === "~") ? "" : author}

{state.timeSinceNewestMessage}

diff --git a/pkg/interface/chat/src/js/lib/util.js b/pkg/interface/chat/src/js/lib/util.js index feab48fbb2..f166c5d5c0 100644 --- a/pkg/interface/chat/src/js/lib/util.js +++ b/pkg/interface/chat/src/js/lib/util.js @@ -95,4 +95,23 @@ export function writeText(str) { }).catch(function (error) { console.error(error); });; -}; \ No newline at end of file +}; + +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file diff --git a/pkg/interface/groups/src/js/components/lib/contact-item.js b/pkg/interface/groups/src/js/components/lib/contact-item.js index b9b3e80d83..2a53c5808e 100644 --- a/pkg/interface/groups/src/js/components/lib/contact-item.js +++ b/pkg/interface/groups/src/js/components/lib/contact-item.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import { Route, Link } from 'react-router-dom'; import { Sigil } from '../lib/icons/sigil'; -import { uxToHex } from '../../lib/util'; +import { uxToHex, cite } from '../../lib/util'; export class ContactItem extends Component { @@ -10,7 +10,7 @@ export class ContactItem extends Component { let selectedClass = (props.selected) ? "bg-gray4 bg-gray1-d" : ""; let hexColor = uxToHex(props.color); - let name = (props.nickname) ? props.nickname : "~" + props.ship; + let name = (props.nickname) ? props.nickname : cite(props.ship); let prefix = props.share ? 'share' : 'view'; let suffix = !props.share ? `/${props.ship}` : ''; @@ -28,7 +28,8 @@ export class ContactItem extends Component { className={ "f9 w-70 dib v-mid ml2 nowrap " + ((props.nickname) ? "" : "mono")} - style={{ paddingTop: 6 }}> + style={{ paddingTop: 6 }} + title={props.ship}> {name}

diff --git a/pkg/interface/groups/src/js/components/lib/contact-sidebar.js b/pkg/interface/groups/src/js/components/lib/contact-sidebar.js index 0f296d854d..84188bfa6a 100644 --- a/pkg/interface/groups/src/js/components/lib/contact-sidebar.js +++ b/pkg/interface/groups/src/js/components/lib/contact-sidebar.js @@ -3,6 +3,7 @@ import { Route, Link } from 'react-router-dom'; import { ContactItem } from '/components/lib/contact-item'; import { ShareSheet } from '/components/lib/share-sheet'; import { Sigil } from '../lib/icons/sigil'; +import { cite } from '../../lib/util'; export class ContactSidebar extends Component { render() { @@ -60,8 +61,9 @@ export class ContactSidebar extends Component { classes="mix-blend-diff" />

- ~{member} + style={{ paddingTop: 6, color: '#aaaaaa' }} + title={member}> + {cite(member)}

); diff --git a/pkg/interface/groups/src/js/components/lib/group-sidebar.js b/pkg/interface/groups/src/js/components/lib/group-sidebar.js index 9d606f1d3e..c41b57aa23 100644 --- a/pkg/interface/groups/src/js/components/lib/group-sidebar.js +++ b/pkg/interface/groups/src/js/components/lib/group-sidebar.js @@ -4,7 +4,7 @@ import { Route, Link } from 'react-router-dom'; import { GroupItem } from '/components/lib/group-item'; import { Sigil } from '/components/lib/icons/sigil'; import { SidebarInvite } from '/components/lib/sidebar-invite'; -import { uxToHex } from '/lib/util'; +import { cite } from '/lib/util'; export class GroupSidebar extends Component { // drawer to the left @@ -29,7 +29,7 @@ export class GroupSidebar extends Component {

- ~{window.ship} + {cite(window.ship)}

diff --git a/pkg/interface/groups/src/js/components/lib/header-bar.js b/pkg/interface/groups/src/js/components/lib/header-bar.js index cf3be78dd9..aa03afd4e3 100644 --- a/pkg/interface/groups/src/js/components/lib/header-bar.js +++ b/pkg/interface/groups/src/js/components/lib/header-bar.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import classnames from "classnames"; +import { cite } from '../../lib/util'; import { IconHome } from "/components/lib/icons/icon-home"; import { Sigil } from "/components/lib/icons/sigil"; @@ -51,7 +51,7 @@ export class HeaderBar extends Component { color={"#000000"} classes={"v-mid mix-blend-diff"} /> - {"~" + window.ship} + {cite(window.ship)}
); diff --git a/pkg/interface/groups/src/js/components/lib/icons/sigil.js b/pkg/interface/groups/src/js/components/lib/icons/sigil.js index 89cdd95371..8bd10a3791 100644 --- a/pkg/interface/groups/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/groups/src/js/components/lib/icons/sigil.js @@ -10,7 +10,7 @@ export class Sigil extends Component { if (props.ship.length > 14) { return (
); } else { diff --git a/pkg/interface/groups/src/js/lib/util.js b/pkg/interface/groups/src/js/lib/util.js index 96288a87b6..f34fd5e0a6 100644 --- a/pkg/interface/groups/src/js/lib/util.js +++ b/pkg/interface/groups/src/js/lib/util.js @@ -67,7 +67,26 @@ export function uxToHex(ux) { let value = ux.substr(2).replace('.', '').padStart(6, '0'); return value; } - + let value = ux.replace('.', '').padStart(6, '0'); return value; } + +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file diff --git a/pkg/interface/launch/src/js/components/header.js b/pkg/interface/launch/src/js/components/header.js index f89fbd369e..f60f2d31be 100644 --- a/pkg/interface/launch/src/js/components/header.js +++ b/pkg/interface/launch/src/js/components/header.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import { Sigil } from './sigil'; +import { cite } from '../lib/util'; import _ from 'lodash'; export default class Header extends Component { @@ -49,10 +50,11 @@ export default class Header extends Component { return (
- {"~" + window.ship} + {cite(window.ship)}
diff --git a/pkg/interface/launch/src/js/components/sigil.js b/pkg/interface/launch/src/js/components/sigil.js index d02aa3526e..49650987bd 100644 --- a/pkg/interface/launch/src/js/components/sigil.js +++ b/pkg/interface/launch/src/js/components/sigil.js @@ -10,7 +10,7 @@ export class Sigil extends Component { if (props.ship.length > 14) { return (
); } else { diff --git a/pkg/interface/launch/src/js/lib/util.js b/pkg/interface/launch/src/js/lib/util.js index 45662f6f99..708c5accfe 100644 --- a/pkg/interface/launch/src/js/lib/util.js +++ b/pkg/interface/launch/src/js/lib/util.js @@ -9,4 +9,21 @@ export function daToDate(st) { return new Date(ds); } - +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file diff --git a/pkg/interface/link/src/js/components/lib/comment-item.js b/pkg/interface/link/src/js/components/lib/comment-item.js index f552e8f39a..c916897c76 100644 --- a/pkg/interface/link/src/js/components/lib/comment-item.js +++ b/pkg/interface/link/src/js/components/lib/comment-item.js @@ -1,5 +1,6 @@ import React, { Component } from 'react' import { Sigil } from './icons/sigil'; +import { cite } from '../../lib/util'; import moment from 'moment'; export class CommentItem extends Component { @@ -44,8 +45,9 @@ export class CommentItem extends Component { classes={(member ? "mix-blend-diff" : "")} />

- - {props.nickname ? props.nickname : '~'+props.ship} + + {props.nickname ? props.nickname : cite(props.ship)} {this.state.timeSinceComment} diff --git a/pkg/interface/link/src/js/components/lib/header-bar.js b/pkg/interface/link/src/js/components/lib/header-bar.js index 0639f0bde3..fcfb3d9353 100644 --- a/pkg/interface/link/src/js/components/lib/header-bar.js +++ b/pkg/interface/link/src/js/components/lib/header-bar.js @@ -1,6 +1,7 @@ import React, { Component } from "react"; import { IconHome } from "/components/lib/icons/icon-home"; import { Sigil } from "/components/lib/icons/sigil"; +import { cite } from "../../lib/util"; export class HeaderBar extends Component { constructor(props) { @@ -50,7 +51,7 @@ export class HeaderBar extends Component { size={16} color={"#000000"} /> - {"~" + window.ship} + {cite(window.ship)} ); diff --git a/pkg/interface/link/src/js/components/lib/icons/sigil.js b/pkg/interface/link/src/js/components/lib/icons/sigil.js index bae6c4f78c..2ef775e8bc 100644 --- a/pkg/interface/link/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/link/src/js/components/lib/icons/sigil.js @@ -10,7 +10,7 @@ export class Sigil extends Component { if (props.ship.length > 14) { return (

); } else { diff --git a/pkg/interface/link/src/js/components/lib/link-detail-preview.js b/pkg/interface/link/src/js/components/lib/link-detail-preview.js index d62cb1a67a..5590c45970 100644 --- a/pkg/interface/link/src/js/components/lib/link-detail-preview.js +++ b/pkg/interface/link/src/js/components/lib/link-detail-preview.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { Route, Link } from "react-router-dom"; -import { makeRoutePath } from "../../lib/util"; +import { makeRoutePath, cite } from "../../lib/util"; import moment from "moment"; export class LinkPreview extends Component { @@ -107,8 +107,9 @@ export class LinkPreview extends Component { {hostname} ↗
- - {props.nickname ? props.nickname : "~" + props.ship} + + {props.nickname ? props.nickname : cite(props.ship)} {this.state.timeSinceLinkPost} diff --git a/pkg/interface/link/src/js/components/lib/link-item.js b/pkg/interface/link/src/js/components/lib/link-item.js index 55ae417a64..1abc625326 100644 --- a/pkg/interface/link/src/js/components/lib/link-item.js +++ b/pkg/interface/link/src/js/components/lib/link-item.js @@ -3,7 +3,7 @@ import moment from 'moment'; import { Sigil } from '/components/lib/icons/sigil'; import { Route, Link } from 'react-router-dom'; -import { makeRoutePath } from '../../lib/util'; +import { makeRoutePath, cite } from '../../lib/util'; export class LinkItem extends Component { constructor(props) { @@ -79,9 +79,12 @@ export class LinkItem extends Component { {hostname} ↗
- {(props.nickname) - ? props.nickname - : "~" + props.ship} + + {(props.nickname) + ? props.nickname + : cite(props.ship)} + diff --git a/pkg/interface/link/src/js/components/lib/member-element.js b/pkg/interface/link/src/js/components/lib/member-element.js index 7f660055ea..df78e83b55 100644 --- a/pkg/interface/link/src/js/components/lib/member-element.js +++ b/pkg/interface/link/src/js/components/lib/member-element.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import classnames from 'classnames'; import { Sigil } from '/components/lib/icons/sigil'; -import { uxToHex } from '/lib/util'; +import { uxToHex, cite } from '/lib/util'; export class MemberElement extends Component { @@ -36,15 +36,17 @@ export class MemberElement extends Component { } let name = !!props.contact - ? `${props.contact.nickname} (~${props.ship})` : `~${props.ship}`; + ? `${props.contact.nickname} (${cite(props.ship)})` + : `${cite(props.ship)}`; let color = !!props.contact ? uxToHex(props.contact.color) : '000000'; return (
-

{name}

+

+ {name} +

{actionElem}
); diff --git a/pkg/interface/link/src/js/lib/util.js b/pkg/interface/link/src/js/lib/util.js index 9ebc884161..8f1c2b2eb9 100644 --- a/pkg/interface/link/src/js/lib/util.js +++ b/pkg/interface/link/src/js/lib/util.js @@ -146,3 +146,22 @@ export function uxToHex(ux) { return ux.replace('.', '').padStart(6, '0'); } } + +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file 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 416b62c203..80215431bd 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,7 @@ import React, { Component } from 'react'; import moment from 'moment'; import { Sigil } from './icons/sigil'; -import { uxToHex } from '../../lib/util'; +import { uxToHex, cite } from '../../lib/util'; export class CommentItem extends Component { constructor(props){ @@ -50,6 +50,9 @@ export class CommentItem extends Component { classes = ""; } + if (name === commentData.author) { + name = cite(commentData.author); + } return (
@@ -60,8 +63,9 @@ export class CommentItem extends Component { color={color} classes={classes} /> -
+
{name}
{date}
diff --git a/pkg/interface/publish/src/js/components/lib/header-bar.js b/pkg/interface/publish/src/js/components/lib/header-bar.js index 1f21aff916..73e660d0f5 100644 --- a/pkg/interface/publish/src/js/components/lib/header-bar.js +++ b/pkg/interface/publish/src/js/components/lib/header-bar.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { IconHome } from '/components/lib/icons/icon-home'; import { Sigil } from '/components/lib/icons/sigil'; +import { cite } from '../../lib/util'; export class HeaderBar extends Component { constructor(props) { @@ -52,7 +53,7 @@ export class HeaderBar extends Component { size={16} color={"#000000"} /> - {"~" + window.ship} + {cite(window.ship)}
); 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 68fa449d96..55336013d3 100644 --- a/pkg/interface/publish/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/publish/src/js/components/lib/icons/sigil.js @@ -10,7 +10,9 @@ export class Sigil extends Component { if (props.ship.length > 14) { return ( -
+
); } else { diff --git a/pkg/interface/publish/src/js/components/lib/note.js b/pkg/interface/publish/src/js/components/lib/note.js index 889298b6d5..ef509cd6f7 100644 --- a/pkg/interface/publish/src/js/components/lib/note.js +++ b/pkg/interface/publish/src/js/components/lib/note.js @@ -5,6 +5,7 @@ import { Comments } from './comments'; import { NoteNavigation } from './note-navigation'; import moment from 'moment'; import ReactMarkdown from 'react-markdown'; +import { cite } from '../../lib/util'; export class Note extends Component { constructor(props){ @@ -125,6 +126,10 @@ export class Note extends Component { ? contact.nickname : author; } + if (name === author) { + name = cite(author); + } + if (!file) { return null; } @@ -197,8 +202,9 @@ export class Note extends Component {
+ "di f9 gray2 mr2 " + (contact.nickname ? null : "mono") + } + title={author}> {name}
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 519b88c0c8..1c2a1d21e3 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook-item.js +++ b/pkg/interface/publish/src/js/components/lib/notebook-item.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import { Route, Link } from 'react-router-dom'; +import { cite } from '../../lib/util'; export class NotebookItem extends Component { render() { @@ -24,13 +25,18 @@ export class NotebookItem extends Component { ? contact.nickname : props.author; } + if (name === props.author) { + name = cite(props.author); + } + return (

{props.title}

by - + {name}

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 2511d0ec82..b5fff27c0c 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook-posts.js +++ b/pkg/interface/publish/src/js/components/lib/notebook-posts.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import moment from 'moment'; import { Link } from 'react-router-dom'; import ReactMarkdown from 'react-markdown' +import { cite } from '../../lib/util'; export class NotebookPosts extends Component { constructor(props){ @@ -48,6 +49,9 @@ export class NotebookPosts extends Component { name = (contact.nickname.length > 0) ? contact.nickname : note.author; } + if (name === note.author) { + name = cite(note.author); + } let comment = "No Comments"; if (note["num-comments"] == 1) { comment = "1 Comment"; @@ -70,8 +74,9 @@ export class NotebookPosts extends Component { {note.snippet}

-
{name}
+
{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 5709ab9f51..872bfd2265 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook.js +++ b/pkg/interface/publish/src/js/components/lib/notebook.js @@ -5,6 +5,7 @@ import { NotebookPosts } from './notebook-posts'; import { Subscribers } from './subscribers'; import { Settings } from './settings'; import Sidebar from './sidebar'; +import { cite } from '../../lib/util'; export class Notebook extends Component { constructor(props){ @@ -133,6 +134,10 @@ export class Notebook extends Component { ? contact.nickname : props.ship; } + if (name === props.ship) { + name = cite(props.ship); + } + let popout = (props.popout) ? "popout/" : ""; let base = `/~publish/${popout}notebook/${props.ship}/${props.book}`; let about = base + '/about'; @@ -204,7 +209,8 @@ export class Notebook extends Component {
{notebook.title}
by - + {name} diff --git a/pkg/interface/publish/src/js/components/lib/subscribers.js b/pkg/interface/publish/src/js/components/lib/subscribers.js index c503de4894..0df0c4e5c2 100644 --- a/pkg/interface/publish/src/js/components/lib/subscribers.js +++ b/pkg/interface/publish/src/js/components/lib/subscribers.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import { Dropdown } from './dropdown'; +import { cite } from '../../lib/util'; export class Subscribers extends Component { constructor(props){ @@ -68,7 +69,7 @@ export class Subscribers extends Component { } return (
-
{`~${who}`}
+
{`${cite(who)}`}
-
{who}
+
{cite(who)}
Host
-
{this.props.host}
+
{cite(this.props.host)}
diff --git a/pkg/interface/publish/src/js/lib/util.js b/pkg/interface/publish/src/js/lib/util.js index 98ce0d06b2..efac3e2937 100644 --- a/pkg/interface/publish/src/js/lib/util.js +++ b/pkg/interface/publish/src/js/lib/util.js @@ -70,4 +70,24 @@ export function writeText(str) { }).catch(function (error) { console.error(error); });; -}; \ No newline at end of file +}; + + +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file diff --git a/pkg/interface/soto/src/js/components/input.js b/pkg/interface/soto/src/js/components/input.js index 1bbe530ec5..8d43f8e283 100644 --- a/pkg/interface/soto/src/js/components/input.js +++ b/pkg/interface/soto/src/js/components/input.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { store } from '../store'; import { api } from '../api'; +import { cite } from '../lib/util'; export class Input extends Component { constructor(props) { @@ -66,7 +67,7 @@ export class Input extends Component { render() { return (
-
~{this.props.ship}:dojo +
{cite(this.props.ship)}:dojo
{this.props.prompt} diff --git a/pkg/interface/soto/src/js/components/lib/header-bar.js b/pkg/interface/soto/src/js/components/lib/header-bar.js index 61dc0620e7..1cb4c3130b 100644 --- a/pkg/interface/soto/src/js/components/lib/header-bar.js +++ b/pkg/interface/soto/src/js/components/lib/header-bar.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import classnames from 'classnames'; import { IconHome } from '/components/lib/icons/icon-home'; import { Sigil } from '/components/lib/icons/sigil'; +import { cite } from '../../lib/util'; export class HeaderBar extends Component { render() { @@ -41,7 +42,7 @@ export class HeaderBar extends Component { verticalAlign: "text-top", paddingTop: 3 }}>{title} -
- {"~" + window.ship} + + {cite(window.ship)} +
); diff --git a/pkg/interface/soto/src/js/components/lib/icons/sigil.js b/pkg/interface/soto/src/js/components/lib/icons/sigil.js index 7cc563c762..8bd10a3791 100644 --- a/pkg/interface/soto/src/js/components/lib/icons/sigil.js +++ b/pkg/interface/soto/src/js/components/lib/icons/sigil.js @@ -1,21 +1,23 @@ -import React, { Component } from 'react'; -import { sigil, reactRenderer } from 'urbit-sigil-js'; - +import React, { Component } from "react"; +import { sigil, reactRenderer } from "urbit-sigil-js"; export class Sigil extends Component { render() { const { props } = this; - let classes = !!this.props.classes ? this.props.classes : ""; + let classes = props.classes || ""; if (props.ship.length > 14) { return ( -
-
+
); } else { return ( -
+
{sigil({ patp: props.ship, renderer: reactRenderer, diff --git a/pkg/interface/soto/src/js/lib/util.js b/pkg/interface/soto/src/js/lib/util.js new file mode 100644 index 0000000000..90d7dc1550 --- /dev/null +++ b/pkg/interface/soto/src/js/lib/util.js @@ -0,0 +1,18 @@ +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ""; + if (patp.startsWith("~")) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = "~" + patp.slice(0, 6) + "_" + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = "~" + patp.slice(14, 20) + "^" + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} \ No newline at end of file