From af6eff9ff885eb647a52331c6db4c23e0ac4af4a Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Sun, 26 Jan 2020 17:49:04 -0500 Subject: [PATCH] client/posts: allow for multiple source URLs to be entered and viewed --- client/html/post_edit_sidebar.tpl | 3 +-- client/html/post_readonly_sidebar.tpl | 7 ++++--- client/js/controls/post_edit_sidebar_control.js | 2 +- client/js/controls/post_readonly_sidebar_control.js | 1 + client/js/models/post.js | 5 +---- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/client/html/post_edit_sidebar.tpl b/client/html/post_edit_sidebar.tpl index 78e90aab..ecc65699 100644 --- a/client/html/post_edit_sidebar.tpl +++ b/client/html/post_edit_sidebar.tpl @@ -60,9 +60,8 @@ <% if (ctx.canEditPostSource) { %>
- <%= ctx.makeTextInput({ + <%= ctx.makeTextarea({ text: 'Source', - name: 'source', value: ctx.post.source, }) %>
diff --git a/client/html/post_readonly_sidebar.tpl b/client/html/post_readonly_sidebar.tpl index 48372f49..ab3f1491 100644 --- a/client/html/post_readonly_sidebar.tpl +++ b/client/html/post_readonly_sidebar.tpl @@ -42,9 +42,10 @@ <% if (ctx.post.source) { %>
- Source: - <%- ctx.post.prettyPrintSource() %> - + Source: <% for (let i = 0; i < ctx.post.sourceSplit.length; i++) { %> + <% if (i != 0) { %>·<% } %> + <%- ctx.extractRootDomain(ctx.post.sourceSplit[i]) %> + <% } %>
<% } %> diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index 2180d4b5..030bb7a2 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -408,7 +408,7 @@ class PostEditSidebarControl extends events.EventTarget { } get _sourceInputNode() { - return this._formNode.querySelector('.post-source input'); + return this._formNode.querySelector('.post-source textarea'); } get _featureLinkNode() { diff --git a/client/js/controls/post_readonly_sidebar_control.js b/client/js/controls/post_readonly_sidebar_control.js index f3d1e94f..0d662524 100644 --- a/client/js/controls/post_readonly_sidebar_control.js +++ b/client/js/controls/post_readonly_sidebar_control.js @@ -27,6 +27,7 @@ class PostReadonlySidebarControl extends events.EventTarget { canEditPosts: api.hasPrivilege('posts:edit'), canViewTags: api.hasPrivilege('tags:view'), escapeColons: uri.escapeColons, + extractRootDomain: uri.extractRootDomain, getPrettyTagName: misc.getPrettyTagName, })); diff --git a/client/js/models/post.js b/client/js/models/post.js index 90ff300c..d2124adb 100644 --- a/client/js/models/post.js +++ b/client/js/models/post.js @@ -33,6 +33,7 @@ class Post extends events.EventTarget { get fullContentUrl() { return this._fullContentUrl; } get thumbnailUrl() { return this._thumbnailUrl; } get source() { return this._source; } + get sourceSplit() { return this._source.split('\n'); } get canvasWidth() { return this._canvasWidth || 800; } get canvasHeight() { return this._canvasHeight || 450; } get fileSize() { return this._fileSize || 0; } @@ -271,10 +272,6 @@ class Post extends events.EventTarget { Math.round(Math.random() * 1000); } - prettyPrintSource() { - return uri.extractRootDomain(this._source); - } - _updateFromResponse(response) { const map = () => ({ _version: response.version,