Adding source view and editing
This commit is contained in:
parent
14377933a7
commit
1bfc7170b1
4 changed files with 40 additions and 1 deletions
|
@ -93,6 +93,15 @@
|
|||
</section>
|
||||
<% } %>
|
||||
|
||||
<% if (ctx.canEditPostSource) { %>
|
||||
<section class='post-source'>
|
||||
<%= ctx.makeTextInput({
|
||||
text: 'Source',
|
||||
name: 'source',
|
||||
}) %>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<% if (ctx.canFeaturePosts || ctx.canDeletePosts || ctx.canMergePosts) { %>
|
||||
<section class='management'>
|
||||
<ul>
|
||||
|
|
|
@ -44,6 +44,21 @@
|
|||
<a href='https://www.google.com/searchbyimage?&image_url=<%- encodeURIComponent(ctx.post.fullContentUrl) %>'>Google Images</a>
|
||||
</section>
|
||||
|
||||
<section class='source'>
|
||||
Source:
|
||||
<% if (ctx.post.source) { %>
|
||||
<a href='<%- ctx.post.source %>'>
|
||||
<% if (ctx.post.source.length > 30) { %>
|
||||
<%- ctx.post.source.substr(0,27) + '...' %>
|
||||
<% } else { %>
|
||||
<%- ctx.post.source %>
|
||||
<% } %>
|
||||
</a>
|
||||
<% } else { %>
|
||||
None!
|
||||
<% } %>
|
||||
</section>
|
||||
|
||||
<section class='social'>
|
||||
<div class='score-container'></div>
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class PostEditSidebarControl extends events.EventTarget {
|
|||
canEditPostFlags: api.hasPrivilege('posts:edit:flags'),
|
||||
canEditPostContent: api.hasPrivilege('posts:edit:content'),
|
||||
canEditPostThumbnail: api.hasPrivilege('posts:edit:thumbnail'),
|
||||
canEditPostSource : api.hasPrivilege('posts:edit:source'),
|
||||
canCreateAnonymousPosts: api.hasPrivilege('posts:create:anonymous'),
|
||||
canDeletePosts: api.hasPrivilege('posts:delete'),
|
||||
canFeaturePosts: api.hasPrivilege('posts:feature'),
|
||||
|
@ -58,7 +59,7 @@ class PostEditSidebarControl extends events.EventTarget {
|
|||
new ExpanderControl(
|
||||
'post-content',
|
||||
'Content',
|
||||
this._hostNode.querySelectorAll('.post-content, .post-thumbnail'));
|
||||
this._hostNode.querySelectorAll('.post-content, .post-thumbnail, .post-source'));
|
||||
new ExpanderControl(
|
||||
'post-management',
|
||||
'Management',
|
||||
|
@ -349,6 +350,10 @@ class PostEditSidebarControl extends events.EventTarget {
|
|||
thumbnail: this._newPostThumbnail !== undefined ?
|
||||
this._newPostThumbnail :
|
||||
undefined,
|
||||
|
||||
source: this._sourceInputNode ?
|
||||
this._sourceInputNode.value :
|
||||
undefined,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
@ -402,6 +407,10 @@ class PostEditSidebarControl extends events.EventTarget {
|
|||
return this._formNode.querySelector('.post-thumbnail a');
|
||||
}
|
||||
|
||||
get _sourceInputNode() {
|
||||
return this._formNode.querySelector('.post-source input');
|
||||
}
|
||||
|
||||
get _featureLinkNode() {
|
||||
return this._formNode.querySelector('.management .feature');
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ class Post extends events.EventTarget {
|
|||
get contentUrl() { return this._contentUrl; }
|
||||
get fullContentUrl() { return this._fullContentUrl; }
|
||||
get thumbnailUrl() { return this._thumbnailUrl; }
|
||||
get source() { return this._source; }
|
||||
get canvasWidth() { return this._canvasWidth || 800; }
|
||||
get canvasHeight() { return this._canvasHeight || 450; }
|
||||
get fileSize() { return this._fileSize || 0; }
|
||||
|
@ -57,6 +58,7 @@ class Post extends events.EventTarget {
|
|||
set relations(value) { this._relations = value; }
|
||||
set newContent(value) { this._newContent = value; }
|
||||
set newThumbnail(value) { this._newThumbnail = value; }
|
||||
set source(value) { this._source = value; }
|
||||
|
||||
static fromResponse(response) {
|
||||
const ret = new Post();
|
||||
|
@ -122,6 +124,9 @@ class Post extends events.EventTarget {
|
|||
if (this._newThumbnail !== undefined) {
|
||||
files.thumbnail = this._newThumbnail;
|
||||
}
|
||||
if (this._source !== this._orig._source) {
|
||||
detail.source = this._source;
|
||||
}
|
||||
|
||||
let apiPromise = this._id ?
|
||||
api.put(uri.formatApiLink('post', this.id), detail, files) :
|
||||
|
@ -278,6 +283,7 @@ class Post extends events.EventTarget {
|
|||
_contentUrl: response.contentUrl,
|
||||
_fullContentUrl: new URL(response.contentUrl, document.getElementsByTagName('base')[0].href).href,
|
||||
_thumbnailUrl: response.thumbnailUrl,
|
||||
_source: response.source,
|
||||
_canvasWidth: response.canvasWidth,
|
||||
_canvasHeight: response.canvasHeight,
|
||||
_fileSize: response.fileSize,
|
||||
|
|
Reference in a new issue