[FIX] Links and upload paths when running in a subdir (#13982)

* Fix links to run correctly when the server is running in subdir

* Add quotes
pull/13732/head^2
Marcos Spessatto Defendi 6 years ago committed by Rodrigo Nascimento
parent 1e82c371a3
commit bc80e0ee56
  1. 6
      app/chatpal-search/client/template/result.html
  2. 8
      app/chatpal-search/client/template/result.js
  3. 6
      app/message-attachments/client/messageAttachment.html
  4. 3
      app/message-attachments/client/messageAttachment.js
  5. 6
      app/ui-flextab/client/tabs/uploadedFilesList.js
  6. 3
      app/ui-message/client/message.js

@ -110,7 +110,7 @@
</h2>
<div class="chatpal-avatar">
<div class="chatpal-avatar-image"
style="background-image:url(/avatar/{{username}}?_dc=undefined);"></div>
style="background-image:url({{getAvatarUrl cleanUsername }});"></div>
</div>
<span class="chatpal-name">{{username}}</span>
<span class="chatpal-time">{{time}}</span>
@ -121,11 +121,11 @@
<template name="ChatpalSearchSingleUser">
<div class="chatpal-search-result-user">
<div class="chatpal-avatar">
<div class="chatpal-avatar-image" style="background-image:url(/avatar/{{cleanUsername}}?_dc=undefined);"></div>
<div class="chatpal-avatar-image" style="background-image:url({{ getAvatarUrl cleanUsername }});"></div>
</div>
<h2>{{{user_name}}}</h2>
<div class="direct-message">
<a href="/direct/{{cleanUsername}}">{{_ "Chatpal_go_to_user"}}</a>
<a href="{{ getDMUrl cleanUsername }}">{{_ "Chatpal_go_to_user"}}</a>
</div>
</div>
</template>

@ -3,9 +3,12 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { roomTypes } from '../../../utils';
import { roomTypes, getURL } from '../../../utils';
import { Subscriptions } from '../../../models';
const getAvatarUrl = (username) => getURL(`/avatar/${ username }?_dc=undefined`);
const getDMUrl = (username) => getURL(`/direct/${ username }`);
Template.ChatpalSearchResultTemplate.onCreated(function() {
this.badRequest = new ReactiveVar(false);
this.resultType = new ReactiveVar(this.data.settings.DefaultResultType);
@ -111,6 +114,7 @@ Template.ChatpalSearchSingleMessage.helpers({
date() {
return DateFormat.formatDate(this.created);
},
getAvatarUrl,
});
Template.ChatpalSearchSingleRoom.helpers({
@ -131,4 +135,6 @@ Template.ChatpalSearchSingleUser.helpers({
cleanUsername() {
return this.user_username.replace(/<\/?em>/ig, '');
},
getAvatarUrl,
getDMUrl,
});

@ -91,7 +91,7 @@
<div class="attachment-image inline-image">
{{#if loadImage}}
<figure>
{{> lazyloadImage src=image_url preview=image_preview height=(getImageHeight image_dimensions.height) class="gallery-item" title=title description=description}}
{{> lazyloadImage src=(getURL image_url) preview=image_preview height=(getImageHeight image_dimensions.height) class="gallery-item" title=title description=description}}
{{#if labels}}
<div class="image-labels">
{{#each labels}}
@ -117,7 +117,7 @@
{{#unless mediaCollapsed}}
<div class="attachment-audio">
<audio controls>
<source src="{{audio_url}}" type="{{audio_type}}" data-description="{{description}}">
<source src="{{ getURL audio_url}}" type="{{audio_type}}" data-description="{{description}}">
Your browser does not support the audio element.
</audio>
</div>
@ -128,7 +128,7 @@
{{#unless mediaCollapsed}}
<div class="attachment-video">
<video controls class="inline-video">
<source src="{{video_url}}" type="{{video_type}}" data-description="{{description}}">
<source src="{{ getURL video_url}}" type="{{video_type}}" data-description="{{description}}">
Your browser does not support the video element.
</video>
</div>

@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { DateFormat } from '../../lib';
import { Template } from 'meteor/templating';
import { getUserPreference } from '../../utils';
import { getUserPreference, getURL } from '../../utils';
import { Users } from '../../models';
import { renderMessageBody } from '../../ui-utils';
@ -78,4 +78,5 @@ Template.messageAttachment.helpers({
}
return false;
},
getURL,
});

@ -1,7 +1,7 @@
import { Mongo } from 'meteor/mongo';
import { ReactiveVar } from 'meteor/reactive-var';
import { DateFormat } from '../../../lib';
import { t } from '../../../utils';
import { t, getURL } from '../../../utils';
import { popover } from '../../../ui-utils';
import { Template } from 'meteor/templating';
import _ from 'underscore';
@ -29,7 +29,7 @@ Template.uploadedFilesList.helpers({
},
url() {
return `/file-upload/${ this._id }/${ this.name }`;
return getURL(`/file-upload/${ this._id }/${ this.name }`);
},
fileTypeClass() {
@ -41,7 +41,7 @@ Template.uploadedFilesList.helpers({
thumb() {
if (/image/.test(this.type)) {
return this.url;
return getURL(this.url);
}
},
format(timestamp) {

@ -14,7 +14,7 @@ import { AutoTranslate } from '../../autotranslate/client';
import { hasAtLeastOnePermission } from '../../authorization';
import { callbacks } from '../../callbacks';
import { Markdown } from '../../markdown/client';
import { t, getUserPreference, roomTypes } from '../../utils';
import { t, getUserPreference, roomTypes, getURL } from '../../utils';
async function renderPdfToCanvas(canvasId, pdfLink) {
const isSafari = /constructor/i.test(window.HTMLElement) ||
@ -31,6 +31,7 @@ async function renderPdfToCanvas(canvasId, pdfLink) {
if (!pdfLink || !/\.pdf$/i.test(pdfLink)) {
return;
}
pdfLink = getURL(pdfLink);
const canvas = document.getElementById(canvasId);
if (!canvas) {

Loading…
Cancel
Save