Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions client/html/post_content.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
'Your browser doesn\'t support HTML5 videos.')
%>

<% } else if (ctx.post.type === 'document' && ctx.post.mimeType === 'application/pdf') { %>

<object class='resize-listener'
data='<%- ctx.post.contentUrl %>'
type='application/pdf'
width='<%- ctx.post.canvasWidth %>' height='<%- ctx.post.canvasHeight %>'>
</object>

<% } else { console.log(new Error('Unknown post type')); } %>

<div class='post-overlay resize-listener'>
Expand Down
15 changes: 9 additions & 6 deletions client/html/post_readonly_sidebar.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'video/mp4': 'MPEG-4',
'video/quicktime': 'MOV',
'application/x-shockwave-flash': 'SWF',
'application/pdf': 'PDF',
}[ctx.post.mimeType] %><!--
--></a>
(<%- ctx.post.canvasWidth %>x<%- ctx.post.canvasHeight %>)
Expand Down Expand Up @@ -54,12 +55,14 @@
</section>
<% } %>

<section class='search'>
Search on
<a href='http://iqdb.org/?url=<%- encodeURIComponent(ctx.post.fullContentUrl) %>'>IQDB</a> &middot;
<a href='https://danbooru.donmai.us/posts?tags=md5:<%- ctx.post.checksumMD5 %>'>Danbooru</a> &middot;
<a href='https://lens.google.com/uploadbyurl?url=<%- encodeURIComponent(ctx.post.fullContentUrl) %>'>Google Images</a>
</section>
<% if (ctx.post.type !== 'document') { %>
<section class='search'>
Search on
<a href='http://iqdb.org/?url=<%- encodeURIComponent(ctx.post.fullContentUrl) %>'>IQDB</a> &middot;
<a href='https://danbooru.donmai.us/posts?tags=md5:<%- ctx.post.checksumMD5 %>'>Danbooru</a> &middot;
<a href='https://lens.google.com/uploadbyurl?url=<%- encodeURIComponent(ctx.post.fullContentUrl) %>'>Google Images</a>
</section>
<% } %>

<section class='social'>
<div class='score-container'></div>
Expand Down
12 changes: 8 additions & 4 deletions client/js/controls/post_content_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PostContentControl {
this._currentFitFunction = this.fitWidth;
const mul = this._post.canvasHeight / this._post.canvasWidth;
let width = this._viewportWidth;
if (!settings.get().upscaleSmallPosts) {
if (!this._shouldUpscale) {
width = Math.min(this._post.canvasWidth, width);
}
this._resize(width, width * mul);
Expand All @@ -49,7 +49,7 @@ class PostContentControl {
this._currentFitFunction = this.fitHeight;
const mul = this._post.canvasWidth / this._post.canvasHeight;
let height = this._viewportHeight;
if (!settings.get().upscaleSmallPosts) {
if (!this._shouldUpscale) {
height = Math.min(this._post.canvasHeight, height);
}
this._resize(height * mul, height);
Expand All @@ -60,13 +60,13 @@ class PostContentControl {
let mul = this._post.canvasHeight / this._post.canvasWidth;
if (this._viewportWidth * mul < this._viewportHeight) {
let width = this._viewportWidth;
if (!settings.get().upscaleSmallPosts) {
if (!this._shouldUpscale) {
width = Math.min(this._post.canvasWidth, width);
}
this._resize(width, width * mul);
} else {
let height = this._viewportHeight;
if (!settings.get().upscaleSmallPosts) {
if (!this._shouldUpscale) {
height = Math.min(this._post.canvasHeight, height);
}
this._resize(height / mul, height);
Expand All @@ -86,6 +86,10 @@ class PostContentControl {
return this._viewportSizeCalculator()[1];
}

get _shouldUpscale() {
return settings.get().upscaleSmallPosts || this._post.type === "document";
}

_evtPostContentChange(e) {
this._post = e.detail.post;
this._post.mutateContentUrl();
Expand Down
2 changes: 1 addition & 1 deletion client/js/views/post_upload_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class PostUploadView extends events.EventTarget {
this._contentInputNode,
{
extraText:
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic",
"Allowed extensions: .jpg, .png, .gif, .webm, .mp4, .swf, .avif, .heif, .heic, .pdf",
allowUrls: true,
allowMultiple: true,
lock: false,
Expand Down
Loading