Skip to content

Commit

Permalink
SAK-42467 Add portalCDNQuery to any js downloads (sakaiproject#7336)
Browse files Browse the repository at this point in the history
Roster
Gradebook
Profile2
Commons
  • Loading branch information
adrianfish authored Sep 9, 2019
1 parent c72be94 commit 8b54416
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 62 deletions.
4 changes: 4 additions & 0 deletions commons/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.portal</groupId>
<artifactId>sakai-portal-util</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.sakaiproject.commons.api.SakaiProxy;
import org.sakaiproject.component.api.ComponentManager;
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.util.RequestFilter;
import org.sakaiproject.util.ResourceLoader;
Expand Down Expand Up @@ -116,6 +117,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
request.setAttribute("commonsId", isUserSite ? CommonsConstants.SOCIAL : siteId);
String maxUploadSize = serverConfigurationService.getString("content.upload.max", "20");
request.setAttribute("maxUploadSize", maxUploadSize);
request.setAttribute("portalCDNQuery", PortalUtils.getCDNQuery());

String pathInfo = request.getPathInfo();

Expand Down
23 changes: 10 additions & 13 deletions commons/tool/src/webapp/WEB-INF/bootstrap.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@
</script>
${sakaiHtmlHead}
<link rel="stylesheet" type="text/css" href="/library/webjars/jquery-ui/1.12.1/jquery-ui.min.css"></script>
<link href="/profile2-tool/css/profile2-profile-entity.css" type="text/css" rel="stylesheet" media="all" />
<link rel="stylesheet" type="text/css" href="/library/webjars/qtip2/3.0.3/jquery.qtip.min.css" media="all"/>
<link href="/profile2-tool/css/profile2-profile-entity.css${portalCDNQuery}" type="text/css" rel="stylesheet" media="all" />
</head>
<body>

<script src="/library/webjars/jquery/1.12.4/jquery.min.js"></script>
<script src="/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js"></script>
<script src="/library/webjars/qtip2/3.0.3/jquery.qtip.min.js"></script>
<script src="/commons-tool/lib/handlebars.runtime-v4.0.5.js"></script>
<script src="/commons-tool/templates/templates.js"></script>
<script src="/commons-tool/lib/autosize.min.js"></script>
<script src="/commons-tool/js/commons_utils.js"></script>
<script src="/commons-tool/js/commons_permissions.js"></script>
<script src="/profile2-tool/javascript/profile2-eb.js"></script>
<script>includeLatestJQuery("commons");</script>
<script>includeWebjarLibrary("qtip2");</script>
<script>includeWebjarLibrary("handlebars");</script>
<script src="/commons-tool/templates/templates.js${portalCDNQuery}"></script>
<script src="/commons-tool/lib/autosize.min.js${portalCDNQuery}"></script>
<script src="/commons-tool/js/commons_utils.js${portalCDNQuery}"></script>
<script src="/commons-tool/js/commons_permissions.js${portalCDNQuery}"></script>
<script src="/profile2-tool/javascript/profile2-eb.js${portalCDNQuery}"></script>

<div id="Mrphs-sakai-commons" class="portletBody commons-portletBody">

Expand All @@ -50,7 +47,7 @@

</div> <!-- /portletBody-->

<script src="/commons-tool/js/commons.js"></script>
<script src="/commons-tool/js/commons.js${portalCDNQuery}"></script>

</body>
</html>
4 changes: 4 additions & 0 deletions gradebookng/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
<groupId>org.sakaiproject.rubrics</groupId>
<artifactId>rubrics-service-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.portal</groupId>
<artifactId>sakai-portal-util</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.gradebookng.business.GradebookNgBusinessService;
import org.sakaiproject.gradebookng.tool.model.GbChartData;
import org.sakaiproject.portal.util.PortalUtils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -40,15 +41,16 @@ public BaseChart(final String id) {

@Override
public void renderHead(final IHeaderResponse response) {
final String version = serverConfigService.getString("portal.cdn.version", "");

final String version = PortalUtils.getCDNQuery();

// chart requires ChartJS
response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/chartjs/2.7.0/Chart.min.js?version=%s", version)));
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/chartjs/2.7.0/Chart.min.js%s", version)));

// our chart functions
response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-chart.js?version=%s", version)));
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-chart.js%s", version)));

// render immediately (for all subclasses)
final GbChartData data = getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.sakaiproject.gradebookng.tool.actions.ActionResponse;
import org.sakaiproject.gradebookng.tool.model.GbGradeTableData;
import org.sakaiproject.gradebookng.tool.model.GbGradebookData;
import org.sakaiproject.portal.util.PortalUtils;

public class GbGradeTable extends Panel implements IHeaderContributor {

Expand Down Expand Up @@ -107,16 +108,16 @@ protected void onEvent(final AjaxRequestTarget target) {
public void renderHead(final IHeaderResponse response) {
final GbGradeTableData gbGradeTableData = (GbGradeTableData) getDefaultModelObject();

final String version = serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

response.render(JavaScriptHeaderItem.forUrl("/library/js/sakai-reminder.js"));

response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-gbgrade-table.js?version=%s", version)));
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-gbgrade-table.js%s", version)));

response.render(
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/handsontable/6.2.2/handsontable.full.min.js?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/handsontable/6.2.2/handsontable.full.min.css?version=%s", version)));
JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/handsontable/6.2.2/handsontable.full.min.js%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/webjars/handsontable/6.2.2/handsontable.full.min.css%s", version)));

final GbGradebookData gradebookData = new GbGradebookData(
gbGradeTableData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.sakaiproject.gradebookng.business.GradebookNgBusinessService;
import org.sakaiproject.gradebookng.business.exception.GbAccessDeniedException;
import org.sakaiproject.gradebookng.tool.component.GbFeedbackPanel;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.rubrics.logic.RubricsService;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -202,7 +203,7 @@ public void clearFeedback() {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

// get the Sakai skin header fragment from the request attribute
final HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
Expand All @@ -222,15 +223,15 @@ public void renderHead(final IHeaderResponse response) {
response.render(
new PriorityHeaderItem(
JavaScriptHeaderItem
.forUrl(String.format("/library/webjars/jquery/1.12.4/jquery.min.js?version=%s", version))));
.forUrl(String.format("/library/webjars/jquery/1.12.4/jquery.min.js%s", version))));
// And pair this instance of jQuery with a Bootstrap version we've tested with
response.render(
new PriorityHeaderItem(
JavaScriptHeaderItem
.forUrl(String.format("/library/webjars/bootstrap/3.3.7/js/bootstrap.min.js?version=%s", version))));
.forUrl(String.format("/library/webjars/bootstrap/3.3.7/js/bootstrap.min.js%s", version))));
// Some global gradebookng styles
response.render(CssHeaderItem
.forUrl(String.format("/gradebookng-tool/styles/gradebook-shared.css?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/styles/gradebook-shared.css%s", version)));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.sakaiproject.gradebookng.tool.panels.BulkEditItemsPanel;
import org.sakaiproject.gradebookng.tool.panels.SortGradeItemsPanel;
import org.sakaiproject.gradebookng.tool.panels.ToggleGradeItemsToolbarPanel;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.service.gradebook.shared.Assignment;
import org.sakaiproject.service.gradebook.shared.GraderPermission;
Expand Down Expand Up @@ -556,15 +557,15 @@ public void setUiSettings(final GradebookUiSettings settings) {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

// Drag and Drop/Date Picker (requires jQueryUI)
response.render(JavaScriptHeaderItem
.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js?version=%s", version)));
.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js%s", version)));

// Include Sakai Date Picker
response.render(JavaScriptHeaderItem
.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js?version=%s", version)));
.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js%s", version)));

// tablesorted used by student grade summary
response.render(JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter')", null));
Expand All @@ -577,21 +578,21 @@ public void renderHead(final IHeaderResponse response) {

// GradebookNG Grade specific styles and behaviour
response.render(CssHeaderItem
.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css%s", version)));
response.render(CssHeaderItem
.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css%s", version)));
response.render(CssHeaderItem
.forUrl(String.format("/gradebookng-tool/styles/gradebook-sorter.css?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/styles/gradebook-sorter.css%s", version)));
response.render(CssHeaderItem
.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css?version=%s", version), "print"));
.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css%s", version), "print"));
response.render(JavaScriptHeaderItem
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js%s", version)));
response.render(JavaScriptHeaderItem
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-update-ungraded.js?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-update-ungraded.js%s", version)));
response.render(JavaScriptHeaderItem
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-sorter.js?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-sorter.js%s", version)));
response.render(JavaScriptHeaderItem
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-connection-poll.js?version=%s", version)));
.forUrl(String.format("/gradebookng-tool/scripts/gradebook-connection-poll.js%s", version)));

final StringValue focusAssignmentId = getPageParameters().get(FOCUS_ASSIGNMENT_ID_PARAM);
final StringValue showPopupForNewItem = getPageParameters().get(NEW_GBITEM_POPOVER_PARAM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.sakaiproject.gradebookng.tool.component.GbFeedbackPanel;
import org.sakaiproject.gradebookng.tool.panels.importExport.GradeImportUploadStep;
import org.sakaiproject.portal.util.PortalUtils;

/**
* Import Export page
Expand Down Expand Up @@ -72,14 +73,14 @@ public ImportExportPage() {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

// Include Sakai Date Picker
response.render(JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js?version=%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js?version=%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js%s", version)));

// Gradebook Import/Export styles
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-importexport.css?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-importexport.css%s", version)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.sakaiproject.gradebookng.business.model.GbGroup;
import org.sakaiproject.gradebookng.business.model.GbUser;
import org.sakaiproject.gradebookng.tool.component.GbAjaxButton;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.service.gradebook.shared.CategoryDefinition;
import org.sakaiproject.service.gradebook.shared.GraderPermission;
import org.sakaiproject.service.gradebook.shared.PermissionDefinition;
Expand Down Expand Up @@ -516,9 +517,7 @@ public PermissionsPageModel() {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = serverConfigService.getString("portal.cdn.version", "");

response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-permissions.css?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-permissions.css%s", PortalUtils.getCDNQuery())));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.sakaiproject.gradebookng.tool.panels.SettingsGradeReleasePanel;
import org.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel;
import org.sakaiproject.gradebookng.tool.panels.SettingsStatisticsPanel;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.service.gradebook.shared.CategoryDefinition;
import org.sakaiproject.service.gradebook.shared.ConflictingCategoryNameException;
import org.sakaiproject.service.gradebook.shared.GradebookInformation;
Expand Down Expand Up @@ -299,14 +300,14 @@ public void onClick(final AjaxRequestTarget target) {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = this.serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

// Drag and Drop (requires jQueryUI)
response.render(
JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js?version=%s", version)));
JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js%s", version)));

response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-settings.css?version=%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-settings.js?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-settings.css%s", version)));
response.render(JavaScriptHeaderItem.forUrl(String.format("/gradebookng-tool/scripts/gradebook-settings.js%s", version)));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sakaiproject.gradebookng.business.GbRole;
import org.sakaiproject.gradebookng.business.util.EventHelper;
import org.sakaiproject.gradebookng.tool.panels.StudentGradeSummaryGradesPanel;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.rubrics.logic.RubricsConstants;
import org.sakaiproject.user.api.User;

Expand Down Expand Up @@ -64,18 +65,18 @@ public StudentPage() {
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);

final String version = serverConfigService.getString("portal.cdn.version", "");
final String version = PortalUtils.getCDNQuery();

// tablesorted used by student grade summary
response.render(JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter')", null));
response.render(JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter/2.27.7/dist/css/theme.bootstrap.min.css')", null));

// GradebookNG Grade specific styles and behaviour
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css?version=%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css?version=%s", version), "print"));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css%s", version)));
response.render(CssHeaderItem.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css%s", version), "print"));
response.render(
JavaScriptHeaderItem.forUrl(
String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js?version=%s", version)));
String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js%s", version)));
}
}
7 changes: 7 additions & 0 deletions library/src/webapp/js/headscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@ function includeWebjarLibrary(library) {
} else if (library == 'mathjs') {
libraryVersion = "6.0.3";
document.write('\x3Cscript src="' + webjars + 'mathjs/' + libraryVersion + '/dist/math.min.js' + ver + '">' + '\x3C/script>');
} else if (library == 'handlebars') {
libraryVersion = "4.0.6";
document.write('\x3Cscript src="' + webjars + 'handlebars/' + libraryVersion + '/handlebars.runtime.min.js' + ver + '">' + '\x3C/script>');
} else if (library == 'qtip2') {
libraryVersion = "3.0.3";
document.write('\x3Cscript src="' + webjars + 'qtip2/' + libraryVersion + '/jquery.qtip.min.js' + ver + '">' + '\x3C/script>');
document.write('\x3Clink rel="stylesheet" href="' + webjars + 'qtip2/' + libraryVersion + '/jquery.qtip.min.css' + ver + '"/>');
} else {
if (library.endsWith(".js")) {
document.write('\x3Cscript src="' + webjars + library + ver + '">' + '\x3C/script>');
Expand Down
4 changes: 4 additions & 0 deletions profile2/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-util</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.portal</groupId>
<artifactId>sakai-portal-util</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
Expand Down
Loading

0 comments on commit 8b54416

Please sign in to comment.