Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public DailyDigestBean(Container c, User recipient, Settings settings, Permissio
this.announcementModels = announcementModels;
this.boardPath = c.getPath();
this.boardURL = AnnouncementsController.getBeginURL(c);
this.siteUrl = ActionURL.getBaseServerURL();
this.siteUrl = ActionURL.getBaseServerURLWithContextPath();
this.removeURL = new ActionURL(AnnouncementsController.EmailPreferencesAction.class, c);
this.includeGroups = perm.includeGroups();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ public EmailNotificationBean(Container c,
this.threadParentURL = AnnouncementsController.getThreadURL(c, recipient, parent);
this.boardPath = c.getPath();
this.boardURL = AnnouncementsController.getBeginURL(c);
this.siteURL = ActionURL.getBaseServerURL();
this.siteURL = ActionURL.getBaseServerURLWithContextPath();
this.announcementModel = a;
this.parentModel = parent;
this.isResponse = isResponse;
Expand Down
2 changes: 1 addition & 1 deletion announcements/src/org/labkey/announcements/rss.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<rss version="2.0">
<channel>
<title><%=h(laf.getShortName())%>: <%=h(laf.getDescription())%></title>
<link><%=h(ActionURL.getBaseServerURL())%></link>
<link><%=h(ActionURL.getBaseServerURLWithContextPath())%></link>
<description><%=h(laf.getShortName())%>: <%=h(laf.getDescription())%></description>
<%
for (AnnouncementModel ann : bean.announcementModels)
Expand Down
3 changes: 1 addition & 2 deletions api/src/org/labkey/api/util/ExceptionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1299,8 +1299,7 @@ private static void renderErrorPage(Throwable ex, int responseStatus, String mes

if (errorView == null)
{
// context can be null for configuration exceptions depending on how far server got through initialization
errorView = PageConfig.Template.Body.getTemplate(new ViewContext(request, response, new ActionURL(ActionURL.getBaseServerURL())), new ErrorView(renderer), pageConfig);
errorView = PageConfig.Template.Body.getTemplate(context, new ErrorView(renderer), pageConfig);
}

addDependenciesAndRender(responseStatus, pageConfig, errorView, ex, request, response);
Expand Down
1 change: 1 addition & 0 deletions api/src/org/labkey/api/util/URLHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public String getURIString(boolean allowSubstSyntax)
}


/** Scheme, host, and port only; no context path. Use getURIString() for a full URL. */
public String getBaseServerURI()
{
return getBaseServer(getScheme(), getHost(), getPort()).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public boolean isEditableIn(Container c)
replacements.add("folderName", String.class, "Name of the folder that generated the email, if it is scoped to a folder", ContentType.Plain, c -> c.isRoot() ? null : c.getName());
replacements.add("folderPath", String.class, "Full path of the folder that generated the email, if it is scoped to a folder", ContentType.Plain, c -> c.isRoot() ? null : c.getPath());
replacements.add("folderURL", String.class, "URL to the folder that generated the email, if it is scoped to a folder", ContentType.Plain, c -> c.isRoot() ? null : PageFlowUtil.urlProvider(ProjectUrls.class).getStartURL(c).getURIString());
replacements.add("homePageURL", String.class, "The home page of this installation", ContentType.Plain, c -> ActionURL.getBaseServerURL()); // TODO: Use AppProps.getHomePageUrl() instead?
replacements.add("homePageURL", String.class, "The home page of this installation", ContentType.Plain, c -> ActionURL.getBaseServerURLWithContextPath()); // TODO: Use AppProps.getHomePageUrl() instead?
}

public EmailTemplate(@NotNull String name, String description, String subject, String body, @NotNull ContentType contentType, Scope scope)
Expand Down
14 changes: 4 additions & 10 deletions api/src/org/labkey/api/view/ActionURL.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,14 @@ public String getHost()
return super.getHost();
}

private static String getBaseServerURL(String scheme, String host, int port)
{
StringBuilder sb = getBaseServer(scheme, host, port);
sb.append(AppProps.getInstance().getContextPath());
return sb.toString();
}

public static String getBaseServerURL()
public static String getBaseServerURLWithContextPath()
{
AppProps props = AppProps.getInstance();
return getBaseServerURL(props.getScheme(), props.getServerName(), props.getServerPort());
return getBaseServer(props.getScheme(), props.getServerName(), props.getServerPort())
.append(props.getContextPath())
.toString();
}


public ActionURL()
{
this(true);
Expand Down
2 changes: 1 addition & 1 deletion core/src/org/labkey/core/login/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ private Pair<Boolean, String> resetPasswordResponse(User user, @Nullable String
LookAndFeelProperties laf = LookAndFeelProperties.getInstance(c);
Message msg = MailHelper.createMessage(laf.getSystemEmailAddress(), user.getEmail());
msg.setSubject(laf.getShortName() + " Password Reset Attempt Failed");
msg.setText(failureEmailMessage + "\n\nThe " + laf.getCompanyName() + " " + laf.getShortName() + " home page is " + ActionURL.getBaseServerURL() + ".");
msg.setText(failureEmailMessage + "\n\nThe " + laf.getCompanyName() + " " + laf.getShortName() + " home page is " + ActionURL.getBaseServerURLWithContextPath() + ".");
MailHelper.send(msg, user, c);
}
catch (MessagingException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,19 @@ public Notification sendMessageForRecipient(Container c, User createdByUser, Use
{
if (recipient != null)
{
String fullUrlStr = linkUrl.getBaseServerURI() + linkUrl;
String fullUrlStr = linkUrl.getURIString();

// create the notification message email
MailHelper.MultipartMessage m = MailHelper.createMultipartMessage();
m.setFrom(LookAndFeelProperties.getInstance(c).getSystemEmailAddress());
m.addRecipients(Message.RecipientType.TO, recipient.getEmail());
m.setSubject(subject);
m.setTextContent(body + "\n" + linkUrl);
m.setTextContent(body + "\n" + fullUrlStr);

// replicate the message body as html with an <a> tag
String html = "<html><head></head><body>" +
PageFlowUtil.filter(body, true, true) +
"<br/><a href='" + fullUrlStr + "'>" + fullUrlStr + "</a>" +
"<br/><a href='" + PageFlowUtil.filter(fullUrlStr) + "'>" + PageFlowUtil.filter(fullUrlStr) + "</a>" +
"</body></html>";
m.setEncodedHtmlContent(html);

Expand Down
2 changes: 1 addition & 1 deletion core/src/org/labkey/core/view/styleGuide.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
</div>
<br>
<h2>Context Content</h2>
<% HtmlString helpText = DOM.createHtmlFragment("Go to home: ", DOM.A(DOM.at(DOM.Attribute.href, ActionURL.getBaseServerURL()), "Server Home")); %>
<% HtmlString helpText = DOM.createHtmlFragment("Go to home: ", DOM.A(DOM.at(DOM.Attribute.href, ActionURL.getBaseServerURLWithContextPath()), "Server Home")); %>

<labkey:form action="some-action" layout="horizontal">
<labkey:input name="name" label="Rich Content" placeholder="URL of page" contextContent="<%= helpText %>" id="exampleRichContext"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
%>
<html>
<head>
<base href="<%=h(ActionURL.getBaseServerURL())%>">
<base href="<%=h(ActionURL.getBaseServerURLWithContextPath())%>">
<%=PageFlowUtil.getStylesheetIncludes(form.getContainer())
%></head>

Expand Down
3 changes: 1 addition & 2 deletions study/src/org/labkey/study/view/sendParticipantGroup.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<%@ page import="org.labkey.api.data.Container" %>
<%@ page import="org.labkey.api.security.SecurityUrls" %>
<%@ page import="org.labkey.api.study.Study" %>
<%@ page import="org.labkey.api.util.PageFlowUtil" %>
<%@ page import="org.labkey.api.view.ActionURL" %>
<%@ page import="org.labkey.api.view.HttpView" %>
<%@ page import="org.labkey.api.view.JspView" %>
Expand Down Expand Up @@ -72,7 +71,7 @@
<br/><br/>

<b>Message link:</b>
<div><%=h(sendGroupUrl.getBaseServerURI() + PageFlowUtil.decode(sendGroupUrl.toString()))%></div>
<div><%=h(sendGroupUrl.getURIString())%></div>
<div><a class="labkey-text-link" target="_blank" href="<%=h(sendGroupUrl)%>" rel="noopener noreferrer">Preview Link</a></div>
<br/>

Expand Down
Loading