mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-27 11:26:22 -07:00
Show embed media URL in place of upload info
This commit is contained in:
parent
9915ed3975
commit
c648b41795
3 changed files with 15 additions and 7 deletions
|
@ -103,14 +103,19 @@ export function createPostElement(post: ThreadPost, boardDir: string, elementCla
|
|||
|
||||
export function shrinkOriginalFilenames(elem = $(document.body)) {
|
||||
elem.find<HTMLAnchorElement>("a.file-orig").each((i, el) => {
|
||||
const isEmbed = el.getAttribute("download") === null;
|
||||
console.log(el, isEmbed);
|
||||
const ext = extname(el.innerText);
|
||||
const noExt = el.innerText.slice(0,el.innerText.lastIndexOf("."));
|
||||
if(noExt.length > 16) {
|
||||
const trimmed = noExt.slice(0, 15).trim() + "…" + ext;
|
||||
const filenameMaxLength = isEmbed ? 32 : 16;
|
||||
if(noExt.length > filenameMaxLength) {
|
||||
const trimmed = noExt.slice(0, filenameMaxLength - 1).trim() + "…" + ext;
|
||||
const untrimmed = el.innerText;
|
||||
el.setAttribute("trimmed", trimmed);
|
||||
el.setAttribute("untrimmed", untrimmed);
|
||||
el.text = el.getAttribute("trimmed");
|
||||
$(el).on("mouseover", () => {
|
||||
el.text = el.getAttribute("download");
|
||||
el.text = el.getAttribute(isEmbed?"untrimmed":"download");
|
||||
}).on("mouseout", () => {
|
||||
el.text = el.getAttribute("trimmed");
|
||||
});
|
||||
|
|
|
@ -156,7 +156,8 @@ export function initPostPreviews($post: JQuery<HTMLElement> = null) {
|
|||
* @param $post the post (if set) to prepare the thumbnails for
|
||||
*/
|
||||
export function prepareThumbnails($parent: JQuery<HTMLElement> = null) {
|
||||
const $container = $parent === null ? $("a.upload-container") : $parent.find("a");
|
||||
const $container = ($parent ?? $(document.body)).find("a.upload-container")
|
||||
.filter((i, el) => $(el).find("img.upload").length > 0);
|
||||
$container.on("click", function(e) {
|
||||
const $a = $(this);
|
||||
const uploadHref = $a.siblings("div.file-info").children("a.file-orig").attr("href");
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{{define "uploadinfo" -}}
|
||||
<div class="file-info">
|
||||
{{- if not $.post.HasEmbed -}}
|
||||
File: <a href="{{.post.UploadPath}}" target="_blank">{{$.post.Filename}}</a> - ({{formatFilesize $.post.Filesize}}{{if and (gt $.post.UploadHeight 0) (gt $.post.UploadWidth 0)}}, {{$.post.UploadWidth}}x{{$.post.UploadHeight}}{{end}}, <a href="{{.post.UploadPath}}" class="file-orig" download="{{.post.OriginalFilename}}">{{.post.OriginalFilename}}</a>)
|
||||
{{- if .HasEmbed -}}
|
||||
Embed: <a href="{{.UploadPath}}" target="_blank" class="embed-orig">{{.UploadPath}}</a>
|
||||
{{- else -}}
|
||||
File: <a href="{{.UploadPath}}" target="_blank">{{.Filename}}</a> - ({{formatFilesize .Filesize}}{{if and (gt .UploadHeight 0) (gt .UploadWidth 0)}}, {{.UploadWidth}}x{{.UploadHeight}}{{end}}, <a href="{{.UploadPath}}" class="file-orig" download="{{.OriginalFilename}}">{{.OriginalFilename}}</a>)
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
@ -40,7 +42,7 @@
|
|||
{{- if eq $.post.Filename "deleted" -}}
|
||||
<div class="file-deleted-box" style="text-align:center;">File removed</div>
|
||||
{{- else if ne $.post.Filename "" -}}
|
||||
{{- template "uploadinfo" . -}}
|
||||
{{- template "uploadinfo" .post -}}
|
||||
<a class="upload-container" href="{{.post.UploadPath}}">
|
||||
{{- if $.post.HasEmbed -}}
|
||||
{{embedMedia .post}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue