forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-32667 Initial commit of Noodle's SiteDescription widget (sakaipro…
- Loading branch information
1 parent
cb53f0f
commit fada42c
Showing
10 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>Site Description</name> | ||
<groupId>org.sakaiproject.sitedescription</groupId> | ||
<artifactId>sitedescription</artifactId> | ||
<parent> | ||
<groupId>org.sakaiproject</groupId> | ||
<artifactId>master</artifactId> | ||
<version>12-SNAPSHOT</version> | ||
<relativePath>../master/pom.xml</relativePath> | ||
</parent> | ||
<packaging>war</packaging> | ||
<dependencies> | ||
<!-- third party dependencies --> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket</artifactId> | ||
<version>6.18.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket-spring</artifactId> | ||
<version>6.18.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket-extensions</artifactId> | ||
<version>6.18.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.sakaiproject.kernel</groupId> | ||
<artifactId>sakai-kernel-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.sakaiproject.kernel</groupId> | ||
<artifactId>sakai-component-manager</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.sakaiproject.kernel</groupId> | ||
<artifactId>sakai-kernel-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<scope>provided</scope> <!-- to satisfy EB and eclipse --> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<resources> | ||
<!-- include everything except the Java source --> | ||
<resource> | ||
<directory>src/java</directory> | ||
<includes> | ||
<include>**</include> | ||
</includes> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</resource> | ||
<!-- include our log4j.properties --> | ||
<resource> | ||
<directory>src/resources</directory> | ||
<includes> | ||
<include>*.properties</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
sitedescription/src/java/org/sakaiproject/sitedescription/WidgetApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.sakaiproject.sitedescription; | ||
|
||
import org.apache.wicket.protocol.http.WebApplication; | ||
import org.apache.wicket.request.Url; | ||
import org.apache.wicket.request.resource.UrlResourceReference; | ||
import org.apache.wicket.spring.injection.annot.SpringComponentInjector; | ||
import org.sakaiproject.sitedescription.ui.WidgetPage; | ||
|
||
/** | ||
* App class for the Site Description widget | ||
* | ||
* @author Steve Swinsburg ([email protected]) | ||
* | ||
*/ | ||
public class WidgetApplication extends WebApplication { | ||
|
||
@Override | ||
public void init() { | ||
|
||
super.init(); | ||
|
||
// Configure for Spring injection | ||
getComponentInstantiationListeners().add(new SpringComponentInjector(this)); | ||
|
||
// Don't throw an exception if we are missing a property, just fallback | ||
getResourceSettings().setThrowExceptionOnMissingResource(false); | ||
|
||
// Remove the wicket specific tags from the generated markup | ||
getMarkupSettings().setStripWicketTags(true); | ||
|
||
// Don't add any extra tags around a disabled link (default is <em></em>) | ||
getMarkupSettings().setDefaultBeforeDisabledLink(null); | ||
getMarkupSettings().setDefaultAfterDisabledLink(null); | ||
|
||
// On Wicket session timeout, redirect to main page | ||
getApplicationSettings().setPageExpiredErrorPage(getHomePage()); | ||
|
||
// cleanup the HTML | ||
getMarkupSettings().setStripWicketTags(true); | ||
getMarkupSettings().setStripComments(true); | ||
getMarkupSettings().setCompressWhitespace(true); | ||
|
||
// Suppress internal javascript references | ||
// When rendered inline, the URLs these generate are incorrect - the context path is /page/ instead of the webapp name. | ||
// However it is cleaner if we just handle this manually in the page | ||
getJavaScriptLibrarySettings().setJQueryReference(new UrlResourceReference(Url.parse("/sitedescription/scripts/wicket/empty.js"))); | ||
getJavaScriptLibrarySettings().setWicketEventReference(new UrlResourceReference(Url.parse("/sitedescription/scripts/wicket/empty.js"))); | ||
|
||
// to put this app into deployment mode, see web.xml | ||
} | ||
|
||
/** | ||
* The main page for our app | ||
* | ||
* @see org.apache.wicket.Application#getHomePage() | ||
*/ | ||
@Override | ||
public Class<WidgetPage> getHomePage() { | ||
return WidgetPage.class; | ||
} | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public WidgetApplication() { | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
sitedescription/src/java/org/sakaiproject/sitedescription/WidgetApplication.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
app.title=Site Description |
9 changes: 9 additions & 0 deletions
9
sitedescription/src/java/org/sakaiproject/sitedescription/ui/WidgetPage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" > | ||
<head> | ||
<title><wicket:message key="app.title" /></title> | ||
</head> | ||
<body> | ||
<div wicket:id="siteinfo" style="padding: 5px;"/> | ||
</body> | ||
</html> |
82 changes: 82 additions & 0 deletions
82
sitedescription/src/java/org/sakaiproject/sitedescription/ui/WidgetPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.sakaiproject.sitedescription.ui; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.apache.wicket.markup.head.IHeaderResponse; | ||
import org.apache.wicket.markup.head.JavaScriptHeaderItem; | ||
import org.apache.wicket.markup.head.OnLoadHeaderItem; | ||
import org.apache.wicket.markup.head.PriorityHeaderItem; | ||
import org.apache.wicket.markup.head.StringHeaderItem; | ||
import org.apache.wicket.markup.html.WebPage; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.Model; | ||
import org.apache.wicket.spring.injection.annot.SpringBean; | ||
import org.sakaiproject.component.api.ServerConfigurationService; | ||
import org.sakaiproject.exception.IdUnusedException; | ||
import org.sakaiproject.site.api.Site; | ||
import org.sakaiproject.site.api.SiteService; | ||
import org.sakaiproject.tool.api.ToolManager; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* Main page for the Site Description widget | ||
*/ | ||
@Slf4j | ||
public class WidgetPage extends WebPage { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@SpringBean(name = "org.sakaiproject.site.api.SiteService") | ||
private SiteService siteService; | ||
|
||
@SpringBean(name = "org.sakaiproject.tool.api.ToolManager") | ||
private ToolManager toolManager; | ||
|
||
@SpringBean(name = "org.sakaiproject.component.api.ServerConfigurationService") | ||
private ServerConfigurationService serverConfigurationService; | ||
|
||
public WidgetPage() { | ||
log.debug("WidgetPage()"); | ||
} | ||
|
||
@Override | ||
public void onInitialize() { | ||
|
||
super.onInitialize(); | ||
|
||
final String currentSiteId = this.toolManager.getCurrentPlacement().getContext(); | ||
|
||
try { | ||
Site site = siteService.getSite(currentSiteId); | ||
add(new Label("siteinfo", Model.of(site.getDescription())).setEscapeModelStrings(false)); | ||
} catch (IdUnusedException e) { | ||
//almost impossible since we just got the tool placement, but anyway... | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void renderHead(final IHeaderResponse response) { | ||
|
||
super.renderHead(response); | ||
|
||
final String version = this.serverConfigurationService.getString("portal.cdn.version", ""); | ||
|
||
// get the Sakai skin header fragment from the request attribute | ||
final HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest(); | ||
|
||
response.render(StringHeaderItem.forString((String) request.getAttribute("sakai.html.head"))); | ||
response.render(OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )")); | ||
|
||
// Tool additions (at end so we can override if required) | ||
response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />")); | ||
|
||
// render jQuery and the Wicket event library | ||
// Both must be priority so they are emitted into the head | ||
response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery/1.11.3/jquery.min.js?version=%s", version)))); | ||
response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/site-description/scripts/wicket/wicket-event-jquery.min.js?version=%s", version)))); | ||
|
||
// NOTE: All libraries apart from jQuery and Wicket Event must be rendered inline with the application. See WidgetPage.html. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> | ||
|
||
<beans> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
version="2.5"> | ||
|
||
<display-name>sakai.sitedescription</display-name> | ||
|
||
<!-- This application's servlet class --> | ||
<servlet> | ||
<servlet-name>sakai.sitedescription</servlet-name> | ||
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class> | ||
<init-param> | ||
<param-name>applicationClassName</param-name> | ||
<param-value>org.sakaiproject.sitedescription.WidgetApplication</param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>sakai.sitedescription</servlet-name> | ||
<url-pattern>/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
<servlet-mapping> | ||
<servlet-name>default</servlet-name> | ||
<url-pattern>/fonts/*</url-pattern> | ||
<url-pattern>/images/*</url-pattern> | ||
<url-pattern>/scripts/*</url-pattern> | ||
<url-pattern>/styles/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
<filter> | ||
<description>Response Header Filter to enable caching</description> | ||
<display-name>Cache Filter For One Week</display-name> | ||
<filter-name>CacheFilterForWeek</filter-name> | ||
<filter-class>org.sakaiproject.util.ResponseHeaderFilter</filter-class> | ||
<init-param> | ||
<param-name>Cache-Control</param-name> | ||
<param-value>max-age=2678400, public</param-value> | ||
</init-param> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>CacheFilterForWeek</filter-name> | ||
<url-pattern>/fonts/*</url-pattern> | ||
<url-pattern>/images/*</url-pattern> | ||
<url-pattern>/scripts/*</url-pattern> | ||
<url-pattern>/styles/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<!-- Deploy mode --> | ||
<context-param> | ||
<param-name>configuration</param-name> | ||
<!-- <param-value>development</param-value> --> | ||
<param-value>deployment</param-value> | ||
</context-param> | ||
|
||
|
||
<!-- Sakai Request Filter --> | ||
<filter> | ||
<filter-name>sakai.request</filter-name> | ||
<filter-class>org.sakaiproject.util.RequestFilter</filter-class> | ||
<init-param> | ||
<param-name>upload.enabled</param-name> | ||
<param-value>false</param-value> | ||
</init-param> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>sakai.request</filter-name> | ||
<servlet-name>sakai.sitedescription</servlet-name> | ||
<dispatcher>REQUEST</dispatcher> | ||
<dispatcher>FORWARD</dispatcher> | ||
<dispatcher>INCLUDE</dispatcher> | ||
</filter-mapping> | ||
|
||
|
||
<!-- Sakai Tool Listener --> | ||
<listener> | ||
<listener-class>org.sakaiproject.util.ToolListener</listener-class> | ||
</listener> | ||
|
||
<!-- Sakai Spring Listener --> | ||
<listener> | ||
<listener-class>org.sakaiproject.util.SakaiContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
This file is needed by Wicket. It's used to override Wicket's jQuery and event js files and allow us | ||
to use the same version the rest of Sakai uses. | ||
*/ |
1 change: 1 addition & 0 deletions
1
sitedescription/src/webapp/scripts/wicket/wicket-event-jquery.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
sitedescription/src/webapp/tools/sakai.sitedescription.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
|
||
<registration> | ||
<tool id="sakai.sitedescription" | ||
title="Site Description Widget" | ||
description="A widget that shows the site description"> | ||
|
||
<category name="project" /> | ||
<category name="course" /> | ||
|
||
<configuration name="reset.button" value="false" /> | ||
<configuration name="help.button" value="false" /> | ||
<configuration name="sakai:tool-directurl-enabled" value="false" /> | ||
|
||
<configuration name="renderInline" value="true" /> | ||
<configuration name="suppressTitle" value="true" /> | ||
|
||
</tool> | ||
</registration> |