Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
work in progress: dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jul 18, 2013
1 parent df00dc1 commit 7348ca3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 11 deletions.
Expand Up @@ -250,7 +250,7 @@ else if (identity.isLoggedIn())
{
return "redirect";
}
return "home";
return "dashboard";
}
return "home";
}
Expand Down
23 changes: 18 additions & 5 deletions zanata-war/src/main/java/org/zanata/security/UserRedirectBean.java
Expand Up @@ -29,6 +29,8 @@
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.Redirect;
import org.jboss.seam.security.Identity;
import org.jboss.seam.web.ServletContexts;

/**
Expand All @@ -38,8 +40,9 @@
* parameter by adding child element
* <code>&lt;param name="continue" value="#{userRedirect.encodedUrl}" /></code>
* to the login page's {@code <page>} element in pages.xml
*
* TODO Use {@link org.jboss.seam.faces.Redirect} instead of this class (by extension or otherwise).
*
* TODO Use {@link org.jboss.seam.faces.Redirect} instead of this class (by
* extension or otherwise).
*/
@Name("userRedirect")
// TODO verify that SESSION scope will not persist this too long
Expand All @@ -49,6 +52,7 @@ public class UserRedirectBean implements Serializable
{
private static final String HOME_URL = "/";
private static final String ERROR_URL = "/error";
private static final String DASHBOARD_HOME_URL = "/dashboard/home.xhtml";

/**
*
Expand Down Expand Up @@ -89,7 +93,6 @@ private String applyRedirectModifications(String originalUrl)
queryString = originalUrl.substring(qsIndex);
}


if (newUrl.endsWith(ERROR_URL))
{
newUrl = newUrl.substring(0, newUrl.length() - ERROR_URL.length());
Expand All @@ -105,14 +108,14 @@ private String applyRedirectModifications(String originalUrl)

/**
* Sets the redirect url to a context local url.
*
*
* @param url The context local url to redirect to.
* @see UserRedirectBean#setUrl(String)
*/
public void setLocalUrl(String url)
{
String ctxPath = ServletContexts.instance().getRequest().getContextPath();
setUrl( ctxPath + url );
setUrl(ctxPath + url);
}

/**
Expand Down Expand Up @@ -173,4 +176,14 @@ public boolean isRedirect()
{
return url != null && !url.isEmpty();
}

public void redirectToDashboard()
{
if (Identity.instance().isLoggedIn())
{
Redirect redirect = Redirect.instance();
redirect.setViewId(DASHBOARD_HOME_URL);
redirect.execute();
}
}
}
3 changes: 3 additions & 0 deletions zanata-war/src/main/resources/messages.properties
Expand Up @@ -103,6 +103,9 @@ jsf.server.EditHomePage.label=Edit Page Content
jsf.server.EditHomePageCode.label=Edit Page Code
jsf.server.EditHomePageCode.tooltip=Edit the home page code as persisted. Useful when the home page cannot be edited via the edit page.

#------ [dashboard] -----
jsf.Dashboard=Dashboard


#------ [home] > Edit Page Content ------
jsf.EditHomePage=Edit Home Page
Expand Down
2 changes: 2 additions & 0 deletions zanata-war/src/main/webapp/WEB-INF/layout/template.xhtml
Expand Up @@ -19,6 +19,8 @@
<h:outputStylesheet library="css" name="menu.css" />
<h:outputStylesheet library="css" name="jsf-skin.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/fontello/css/fontello.css"/>
<link type="text/css" rel="stylesheet" href="//webassets-zanata.rhcloud.com/1/assets/css/style.css"/>
<link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic"/>
<ui:insert name="head" />
</h:head>

Expand Down
13 changes: 10 additions & 3 deletions zanata-war/src/main/webapp/WEB-INF/pages.xml
Expand Up @@ -11,7 +11,11 @@
</rule>
</navigation>
</page>


<page view-id="/home.xhtml">
<action execute="#{userRedirect.redirectToDashboard}"/>
</page>

<!-- Landing page for open id authentication -->
<page view-id="/openid.xhtml">
<navigation>
Expand All @@ -25,7 +29,7 @@
<redirect view-id="/account/login_input.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and !userRedirect.redirect}">
<redirect view-id="/home.xhtml" />
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirect}">
<redirect url="#{userRedirect.url}" />
Expand Down Expand Up @@ -73,6 +77,9 @@
<rule if-outcome="inactive">
<redirect view-id="/account/inactive_account.xhtml"/>
</rule>
<rule if-outcome="dashboard">
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if-outcome="home">
<redirect view-id="/home.xhtml" />
</rule>
Expand All @@ -98,7 +105,7 @@
<redirect view-id="/account/inactive_account.xhtml"/>
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and !userRedirect.redirect}">
<redirect view-id="/home.xhtml" />
<redirect view-id="/dashboard/home.xhtml" />
</rule>
<rule if="#{authenticationManager.authenticated and !authenticationManager.newUser and userRedirect.redirect}">
<redirect url="#{userRedirect.url}" />
Expand Down
14 changes: 12 additions & 2 deletions zanata-war/src/main/webapp/WEB-INF/urlrewrite.xml
Expand Up @@ -17,7 +17,13 @@
<from>.*</from>
<to last="true" type="temporary-redirect">/robots.txt</to>
</rule>


<!-- Dashboard Rules -->
<rule>
<from casesensitive="true">^/dashboard/?(\?.*)?$</from>
<to last="true">/dashboard/home.seam$1</to>
</rule>

<!-- Admin Rules -->
<rule>
<from casesensitive="true">^/admin/([^/\?\.]+)(\?.*)?$</from>
Expand All @@ -26,7 +32,6 @@


<!-- Language rules -->

<rule>
<from casesensitive="true">^/language/view/(.+)$</from>
<to last="true">/language/language.seam\?id=$1</to>
Expand Down Expand Up @@ -302,6 +307,11 @@
<to last="true">/webtrans/Application.seam$1</to>
</rule>

<outbound-rule>
<from>^(/.+)?/dashboard/home.seam(.+)?$</from>
<to>$1/dashboard/$2</to>
</outbound-rule>

<outbound-rule>
<from>^(/.+)?/admin/(.+).seam(.*)$</from>
<to>$1/admin/$2$3</to>
Expand Down
15 changes: 15 additions & 0 deletions zanata-war/src/main/webapp/dashboard/home.xhtml
@@ -0,0 +1,15 @@
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="../WEB-INF/layout/template.xhtml">

<ui:define name="page_title">#{messages['jsf.Dashboard']}</ui:define>
<ui:define name="center_content">

</ui:define>
</ui:composition>

0 comments on commit 7348ca3

Please sign in to comment.