使用Nginx SSI功能輔助HTML碎片設計
SSI,Server Side Include,支援html靜態檔案內以
<!--#include file="/layout/header.html"--> 的方式引入其他html靜態檔案,這一功能特性有助於頁面設計的碎片化和效率效果提升(設計頁面主要關心content內容的設計,而且碎片不會在多個頁面存在N個copy,而是一次性都可以修改更新),demo內容見附件qingbo_design_demo。
demo目錄檔案結構:
設計頁面目錄在svn的同步管理下,可以使用eclipse或者dreamwaver等修改html頁面,然後同步提交到svn即可
readme檔案內容
1,解壓安裝nginx windows版本
2,配置eclipse的external tool configuration
Location,選擇Browse File System,找到nginx.exe
Working Derectory,選擇nginx解壓目錄
Arguments,執行nginx 空,停止nginx -s quit,重啟nginx -s reload
3,將nginx/conf/nginx.conf連結到eclipse,方便編輯配置nginx
配置http,或server,或location
ssi on;
配置預設服務的根
location / {
root E:\sapling\demo\qingbo_design_demo; #設計頁面路徑
index index.html;
}
4,執行nginx,訪問http://localhost/index.html
5,編輯html,並按碎片劃分,按以下方式拼接碎片程式碼
<!--#include file="/layout/header.html"-->
6,一級頁面的佈局,
/layout/head.html,引入資源css+js等(一定要是公共的資源)
/laytou/header.html,導航區
/layout/footer.html,尾部
7,二級頁面的佈局和選單
/user/layout/head.html,二級頁面可以有自己的特有碎片(引入特有的樣式和指令碼),也可以使用一級頁面的碎片
/user/layout/left.html,二級頁面可能有選單,甚至是兩級選單
8,index.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="keywords" content="Demo,Index">
<meta name="description" content="Demo HTML design">
<title>index</title>
<!--#include file="/layout/head.html"-->
<!-- 還可以引入頁面特有的資源和樣式 -->
</head>
<body>
<!--#include file="/layout/header.html"-->
index body content
<br/>
<button onclick="clickme()">Click Me</button>
<!--#include file="/layout/footer.html"-->
</body>
</html>
效果圖:http://localhost/index.html
index+about,全域性佈局碎片
使用者中心+我的賬戶,特有佈局碎片
eclipse配置圖:
配置nginx.conf