Skip to content

Commit

Permalink
Fix thumbnail expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Merrell committed Jul 9, 2018
1 parent c7642cd commit 7ef47e9
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 59 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
gochan.json
config.cfg
gochan
lib/
log/access.log
log/error.log
log/mod.log
log/
releases/
vagrant/.vagrant/
vagrant/ubuntu-xenial-16.04-cloudimg-console.log
html/boards.json
html/index.html
html/test/
releases/
html/test/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ release: LDFLAGS=-w -s
release: build

# includes debugging info in the gochan executable
debug: LDFLAGS=""
debug: LDFLAGS=
debug: build

build:
Expand Down
2 changes: 1 addition & 1 deletion html/error/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<h1>404: File not found</h1>
<img src="/error/lol 404.gif" border="0" alt="">
<p>The requested file could not be found on this server. Are you just typing random stuff in the address bar? If you followed a link from this site here, then post <a href="/site">here</a></p>
<hr><address>http://gochan.org powered by Gochan v1.10.2</address>
<hr><address>http://gochan.org powered by Gochan v1.10.3</address>
</body>
</html>
2 changes: 1 addition & 1 deletion html/error/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<h1>500: Internal Server error</h1>
<img src="/error/derpy server.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon has he/she/it can.</p>
<hr><address>http://gochan.org powered by Gochan v1.10.2</address>
<hr><address>http://gochan.org powered by Gochan v1.10.3</address>
</body>
</html>
79 changes: 34 additions & 45 deletions html/javascript/gochan.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,54 +67,43 @@ function prepareThumbnails() {
$jq("a.upload-container").click(function(e) {
var a = $jq(this);
var thumb = a.find("img.upload");
var video;
var thumbURL;
if(thumb.attr("alt") == undefined) thumbURL = thumb.attr("src");
else thumbURL = thumb.attr("alt");
var thumb_width = thumb.attr("width");
var thumb_height = thumb.attr("height");
var thumbURL = thumb.attr("src");
var uploadURL = thumb.attr("alt");
thumb.removeAttr("width").removeAttr("height");

var file_info_elem = a.prevAll(".file-info:first");
var uploadURL = file_info_elem.children("a:first")[0].href;
var viewBtn = a.nextAll("span.post-links:first");
if(thumb.attr("src") == thumbURL) {
// Expanding thumbnail
if(uploadURL.indexOf(".webm") > 0) {
// Upload is a video
thumb.hide();
video = $jq("<video />")
.prop({
src: uploadURL,
autoplay: true,
controls: true,
class: "upload",
loop: true
}).insertAfter(file_info_elem);

var close_video_btn = $jq("<a />")
.prop("href", "javascript:;")
.click(function(e) {
video.remove();
thumb.show();
this.remove();
}).css({
"padding-left": "8px"
})
.html("[Close]<br />");
file_info_elem.append(close_video_btn);
} else {
thumb.attr({
src: uploadURL,
alt: thumbURL
})
.removeAttr("width")
.removeAttr("height");
}

if((thumbURL+uploadURL).indexOf(".webm") > 0) {
// Upload is a video
thumb.hide();
var video = $jq("<video />")
.prop({
src: uploadURL,
autoplay: true,
controls: true,
class: "upload",
loop: true
}).insertAfter(file_info_elem);

file_info_elem.append($jq("<a />")
.prop("href", "javascript:;")
.click(function(e) {
video.remove();
thumb.show();
this.remove();
thumb.prop({
src: thumbURL,
alt: uploadURL
});
}).css({
"padding-left": "8px"
})
.html("[Close]<br />"));
} else {
// Shrinking back to thumbnail
// upload is an image
thumb.attr({
"src": thumbURL,
"width": thumb_width,
"height": thumb_height
src: uploadURL,
alt: thumbURL
});
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions templates/img_boardpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{if ne $op.Filename ""}}
{{if ne $op.Filename "deleted"}}
<div class="file-info">File: <a href="src/{{$op.Filename}}" target="_blank">{{$op.Filename}}</a> - ({{formatFilesize $op.Filesize}} , {{$op.ImageW}}x{{$op.ImageH}}, {{$op.FilenameOriginal}})</div>
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$op.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $op.Filename}}" width="{{$op.ThumbW}}" height="{{$op.ThumbH}}" class="upload" alt="" /></a>
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$op.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $op.Filename}}" alt="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$op.Filename}}" width="{{$op.ThumbW}}" height="{{$op.ThumbH}}" class="upload" /></a>
{{else}}
<div class="file-deleted-box" style="text-align:center;">File removed</div>
{{end}}
Expand All @@ -32,7 +32,7 @@
{{if ne $reply.Filename ""}}
{{if ne $reply.Filename "deleted"}}
<span class="file-info">File: <a href="src/{{$reply.Filename}}" target="_blank">{{$reply.Filename}}</a> - ({{formatFilesize $reply.Filesize}} , {{$reply.ImageW}}x{{$reply.ImageH}}, {{$reply.FilenameOriginal}})</span><br />
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $reply.Filename}}" width="{{$reply.ThumbW}}" height="{{$reply.ThumbH}}" class="upload" alt=""/></a>
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $reply.Filename}}" alt="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}" width="{{$reply.ThumbW}}" height="{{$reply.ThumbH}}" class="upload" /></a>
{{else}}
<div class="file-deleted-box" style="text-align:center;">File removed</div>
{{end}}{{end}}
Expand Down
4 changes: 2 additions & 2 deletions templates/img_threadpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{{if ne $.op.Filename ""}}
{{if ne $.op.Filename "deleted"}}
<div class="file-info">File: <a href="../src/{{.op.Filename}}" target="_blank">{{.op.Filename}}</a> - ({{formatFilesize .op.Filesize}} , {{.op.ImageW}}x{{.op.ImageH}}, {{.op.FilenameOriginal}})</div>
<a class="upload-container" href="{{.config.SiteWebfolder}}{{.board.Dir}}/src/{{.op.Filename}}"><img src="{{.config.SiteWebfolder}}{{.board.Dir}}/thumb/{{imageToThumbnailPath .op.Filename}}" width="{{.op.ThumbW}}" height="{{.op.ThumbH}}" class="upload" /></a>
<a class="upload-container" href="{{.config.SiteWebfolder}}{{.board.Dir}}/src/{{.op.Filename}}"><img src="{{.config.SiteWebfolder}}{{.board.Dir}}/thumb/{{imageToThumbnailPath .op.Filename}}" alt="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{.op.Filename}}" width="{{.op.ThumbW}}" height="{{.op.ThumbH}}" class="upload" /></a>
{{else}}
<div class="file-deleted-box" style="text-align:center;">File removed</div>
{{end}}{{end}}
Expand All @@ -36,7 +36,7 @@
{{if ne $reply.Filename ""}}
{{if ne $reply.Filename "deleted"}}
<span class="file-info">File: <a href="../src/{{$reply.Filename}}" target="_blank">{{$reply.Filename}}</a> - ({{formatFilesize $reply.Filesize}} , {{$reply.ImageW}}x{{$reply.ImageH}}, {{$reply.FilenameOriginal}})</span><br />
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $reply.Filename}}" width="{{$reply.ThumbW}}" height="{{$reply.ThumbH}}" class="upload" /></a>
<a class="upload-container" href="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}"><img src="{{$.config.SiteWebfolder}}{{$.board.Dir}}/thumb/{{imageToThumbnailPath $reply.Filename}}" alt="{{$.config.SiteWebfolder}}{{$.board.Dir}}/src/{{$reply.Filename}}" width="{{$reply.ThumbW}}" height="{{$reply.ThumbH}}" class="upload" /></a>
{{else}}
<div class="file-deleted-box" style="text-align:center;">File removed</div>
{{end}}{{end}}
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.2
1.10.3

0 comments on commit 7ef47e9

Please sign in to comment.