Skip to content

Commit

Permalink
将login.jsp页面中引用的JS(CSS)合并为一个文件
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed Jul 4, 2013
1 parent 651f8db commit f1ef9e6
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class APDPlatMultiMergeNamingStrategy implements NamingStrategy{
map.put("js_merge.js", "js/");
map.put("platform_css_merge.css", "platform/css/");
map.put("platform_js_merge.js", "platform/js/");
map.put("login_merge.js", "js/");
map.put("login_merge.css", "css/");
}
@Override
public String rename(String originalName, InputStream inputStream) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@
*/

/**
*
*SingleMerge是指对platform/include/common.jsp所引用的JS(CSS)合并为一个文件
* @author 杨尚川
*/
public class APDPlatSingleMergeNamingStrategy implements NamingStrategy{
@Override
public String rename(String originalName, InputStream inputStream) throws IOException {
System.out.println("originalName:"+originalName);
originalName="platform/include/"+originalName;
if(originalName.contains("apdplat_merge")){
originalName="platform/include/"+originalName;
}
if(originalName.contains("login_merge.js")){
originalName="js/"+originalName;
}
if(originalName.contains("login_merge.css")){
originalName="css/"+originalName;
}

System.out.println("originalName:"+originalName);
return originalName;
}
Expand Down
15 changes: 15 additions & 0 deletions APDPlat_Web/src/main/resources/wro4j_multi_merge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,19 @@
<js>/platform/js/IconCombo.js</js>
<js>/platform/js/PageSizePlugin.js</js>
</group>

<group name="login_merge">
<css>/extjs/css/ext-all.css</css>
<css>/extjs/css/ext-patch.css</css>
<css>/css/login.css</css>

<js>/extjs/js/adapter/ext/ext-base.js</js>
<js>/extjs/js/ext-all.js</js>
<js>/extjs/ux/Toast.js</js>
<js>/extjs/js/ext-lang-zh_CN.js</js>
<js>/js/validate.js</js>
<js>/js/md5.js</js>
<js>/js/login.js</js>
<js>/js/MSIE.PNG.js</js>
</group>
</groups>
14 changes: 14 additions & 0 deletions APDPlat_Web/src/main/resources/wro4j_single_merge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@
<js>/platform/js/IconCombo.js</js>
<js>/platform/js/PageSizePlugin.js</js>
</group>
<group name="login_merge">
<css>/extjs/css/ext-all.css</css>
<css>/extjs/css/ext-patch.css</css>
<css>/css/login.css</css>

<js>/extjs/js/adapter/ext/ext-base.js</js>
<js>/extjs/js/ext-all.js</js>
<js>/extjs/ux/Toast.js</js>
<js>/extjs/js/ext-lang-zh_CN.js</js>
<js>/js/validate.js</js>
<js>/js/md5.js</js>
<js>/js/login.js</js>
<js>/js/MSIE.PNG.js</js>
</group>
</groups>
15 changes: 3 additions & 12 deletions APDPlat_Web/src/main/webapp/login.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ String shortcut=PropertyHolder.getProperty("module.short.name");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><%=appName%></title>
<link rel="shortcut icon" href="images/<%= shortcut %>.ico" />
<link rel="stylesheet" type="text/css" href="extjs/css/ext-all.css"/>
<link rel="stylesheet" type="text/css" href="extjs/css/ext-patch.css"/>
<link rel="stylesheet" type="text/css" href="css/login.css"/>
<script type="text/javascript" src="extjs/js/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/js/ext-all.js"></script>
<script type="text/javascript" src="extjs/ux/Toast.js"></script>
<script type="text/javascript" src="extjs/js/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/validate.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<link rel="stylesheet" type="text/css" href="css/login_merge.css"/>
<script type="text/javascript" src="js/login_merge.js"></script>
<script type="text/javascript">
//解决Ext在ie9报错:不支持extjs对象的“createContextualFragment属性或方法”
if ((typeof Range !== "undefined") && !Range.prototype.createContextualFragment) {
Expand Down Expand Up @@ -167,7 +159,6 @@ String shortcut=PropertyHolder.getProperty("module.short.name");
}
})
</script>
<script type="text/javascript" src="js/MSIE.PNG.js"></script>

</head>
<body>
Expand Down
182 changes: 182 additions & 0 deletions APDPlat_Web/src/main/webapp/login_no_merge.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<%--
APDPlat - Application Product Development Platform
Copyright (c) 2013, 杨尚川, [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="org.apdplat.module.security.service.OnlineUserService"%>
<%@page import="org.apdplat.module.security.service.SpringSecurityService"%>
<%@page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"%>
<%@page import="org.apdplat.module.security.service.UserDetailsServiceImpl"%>
<%@page import="org.apdplat.module.system.service.PropertyHolder"%>
<%@page import="java.util.Collection"%>
<%@page import="org.apdplat.platform.util.FileUtils"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
response.addHeader("login","true");
//供记录用户登录日志使用
String userAgent=request.getHeader("User-Agent");
request.getSession().setAttribute("userAgent", userAgent);
if(!SpringSecurityService.isSecurity()){
//如果没有启用安全机制则直接进入主界面
response.sendRedirect("platform/index.jsp");
return;
}
String name=OnlineUserService.getUsername(request.getSession(true).getId());
if(!"匿名用户".equals(name)){
//用户已经等登录直接进入主界面
response.sendRedirect("platform/index.jsp");
return;
}
String message="";
String state=request.getParameter("state");
if(state!=null){
response.addHeader("state",state);
}
if("checkCodeError".equals(state)){
response.addHeader("checkCodeError","true");
message="验证码错误";
response.getWriter().write(message);
response.getWriter().flush();
response.getWriter().close();
return;
}
Object obj=session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY);
String lastUsername="";
if(obj!=null){
lastUsername=obj.toString();
if(request.getParameter("login_error")!=null){
String tip=UserDetailsServiceImpl.getMessage(lastUsername);
if(tip!=null){
message=tip;
response.addHeader("login_error","true");
response.getWriter().write(message);
response.getWriter().flush();
response.getWriter().close();
return;
}
}
}
String contextPath=org.apdplat.module.system.service.SystemListener.getContextPath();
String appName=PropertyHolder.getProperty("app.name");
String requestCode="";
if(FileUtils.existsFile("/WEB-INF/licence")){
Collection<String> reqs = FileUtils.getTextFileContent("/WEB-INF/licence");
if(reqs!=null && reqs.size()==1){
requestCode=reqs.iterator().next().toString();
}
}
String shortcut=PropertyHolder.getProperty("module.short.name");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%=appName%></title>
<link rel="shortcut icon" href="images/<%= shortcut %>.ico" />
<link rel="stylesheet" type="text/css" href="extjs/css/ext-all.css"/>
<link rel="stylesheet" type="text/css" href="extjs/css/ext-patch.css"/>
<link rel="stylesheet" type="text/css" href="css/login.css"/>
<script type="text/javascript" src="extjs/js/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/js/ext-all.js"></script>
<script type="text/javascript" src="extjs/ux/Toast.js"></script>
<script type="text/javascript" src="extjs/js/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/validate.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script type="text/javascript">
//解决Ext在ie9报错:不支持extjs对象的“createContextualFragment属性或方法”
if ((typeof Range !== "undefined") && !Range.prototype.createContextualFragment) {
Range.prototype.createContextualFragment = function(html) {
var frag = document.createDocumentFragment(),div = document.createElement("div");
frag.appendChild(div);
div.outerHTML = html;
return frag;
};
}
var contextPath='<%=contextPath%>';
var requestCode='<%=requestCode%>';
var loginImage='<%=PropertyHolder.getProperty("login.image")%>';
var logoImage='<%=PropertyHolder.getProperty("logo.image")%>';
//判断当前登录窗口有没有被嵌在其他窗口内部
function is_toplevel(w){
return (w.parent == w);
}
function autoFit() {
if(!is_toplevel(this)){
parent.location.href=this.location.href;
}
window.moveTo(0, 0);
window.resizeTo(window.screen.availWidth,window.screen.availHeight);
}
function refreshTheme(){
var storeTheme=Ext.util.Cookies.get('theme');
if(storeTheme==null || storeTheme==''){
storeTheme='ext-all';
}
Ext.util.CSS.swapStyleSheet("theme", contextPath+"/extjs/css/"+storeTheme+".css");
}
var lastUsername="<%=lastUsername%>";
var message="<%=message%>";
Ext.onReady(function()
{
autoFit();
refreshTheme();
if("<%=state%>"=="checkCodeError"){
Ext.ux.Toast.msg('登录提示:','验证码错误,请重新登录!');
}
if("<%=state%>"=="session-invalid" || "<%=state%>"=="session-authentication-error"){
Ext.ux.Toast.msg('操作提示:','操作已经超时,请重新登录!');
}
if("<%=state%>"=="session-expired"){
Ext.ux.Toast.msg('操作提示:','您已被踢下线,请重新登录!');
}
if(message!=""){
Ext.ux.Toast.msg('登录提示:',message);
}
var win=new LoginWindow();
win.show();
if(lastUsername!=""){
parent.Ext.getCmp('j_username').setValue(lastUsername);
}
Ext.get('loading-mask').fadeOut( {
remove : true
});
fixPng();
if(""!=requestCode){
//购买产品
BuyModel.show(requestCode);
}
})
</script>
<script type="text/javascript" src="js/MSIE.PNG.js"></script>

</head>
<body>

<div id="loading-mask">
<div id="loading">
<div style="text-align:center;padding-top:26%"><img alt="Loading..." src="images/extanim32.gif" width="32" height="32" style="margin-right:8px;"/>Loading...</div>
</div>
</div>

</body>
</html>

0 comments on commit f1ef9e6

Please sign in to comment.