macros.vm
5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#** -------------------------------------------
* 显示所有headers
* -------------------------------------------- *#
#macro (showHead $defaultTitle)
#showTitle ($defaultTitle)
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Cache-Control" CONTENT="no-store">
<meta http-equiv="Pragma" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-title" content="AnotherU">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="email=no">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
#showMetaTags ()
#showHttpEquiv ()
#end
#** -------------------------------------------
* 显示所有headers
* -------------------------------------------- *#
#macro (showMobileHead $defaultTitle)
#showTitle ($defaultTitle)
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-title" content="AnotherU">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="email=no">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta name="author" content="">
#showMetaTags ()
#showHttpEquiv ()
#showStylesheets ()
#end
#** -------------------------------------------
* 显示js,
* -------------------------------------------- *#
#macro (showfoot)
#showJavascripts()
#end
#** -------------------------------------------
* 显示标题,如果未提供标题,则使用默认值
* -------------------------------------------- *#
#macro (showTitle $defaultTitle)
#if( $page.title != "" )
<title>$page.title</title>
#else
<title>$!defaultTitle</title>
#end
#end
#** -------------------------------------------
* 显示meta tags
* -------------------------------------------- *#
#macro (showMetaTags)
#foreach($metaTag in $page.metaTags.keySet())
<meta name="$metaTag" content="$!page.metaTags.get($!metaTag)">#end
#end
#** -------------------------------------------
* 显示meta http-equiv
* -------------------------------------------- *#
#macro (showHttpEquiv)
#foreach($httpEquiv in $page.httpEquivs.keySet())
<meta http-equiv="$httpEquiv" content="$page.httpEquivs.get($httpEquiv)">#end
#end
#** -------------------------------------------
* 显示stylesheets
* -------------------------------------------- *#
#macro (showStylesheets)
#foreach( $styleSheet in $page.styleSheets )
<link rel="stylesheet" href="$styleSheet.Url"#if($styleSheet.Type != "" ) type="$styleSheet.Type" #end#if($styleSheet.Media != "") media="$styleSheet.Media" #end#if($styleSheet.Title != "") title="$styleSheet.Title" #end>
#end
#end
#** -------------------------------------------
* 显示javascripts
* -------------------------------------------- *#
#macro (showJavascripts)
#foreach( $script in $page.scripts )
<script type="text/javascript" src="$script" language="JavaScript"></script>
#end
#end
#** -------------------------------------------
* 显示body attributes
* -------------------------------------------- *#
#macro (bodyAttributes)
#foreach( $attributeName in $page.bodyAttributes.keySet() )
$attributeName="$page.bodyAttributes.get($attributeName)"
#end
#end
#** -------------------------------------------
* 显示select box
* -------------------------------------------- *#
#macro (select $name $map $selected $hint)
#set ($_map = $map)
#set ($_selected = $selected)
<select name="$name">
<option value="">$hint</option>
#foreach ($_key in $_map.keySet())
<option value="$_key" #if ($_key == $_selected) selected #end>$_map.get($_key)</option>
#end
</select>
#end
#** -------------------------------------------
* 显示当前完整路径
* -------------------------------------------- *#
#macro(showUrl)
#set ($url = $rundata.request.getRequestURL())
#if($rundata.request.getQueryString() && $rundata.request.getQueryString().length()>0)
#if($url.contains("?"))
#set($param = "&" + $!rundata.request.getQueryString())
#else
#set($param = "?" + $!rundata.request.getQueryString())
#end
#end$url$!param#end
#** -------------------------------------------
* 显示目标完整路径
* -------------------------------------------- *#
#macro(showTargetUrl $target)
#if($rundata.request.getQueryString() && $rundata.request.getQueryString().length()>0)
#if($target.contains("?"))
#set($param = "&" + $!rundata.request.getQueryString())
#else
#set($param = "?" + $!rundata.request.getQueryString())
#end
#end
$target$!param#end
#** -------------------------------------------
* 显示当前导航栏
* -------------------------------------------- *#
#macro(showNav $index)
#set ($navIndex = $index)
#end
#** -------------------------------------------
* 显示当前导航栏
* -------------------------------------------- *#
#macro(showNavChild $parent $child)
#set ($navIndex = $parent)
#if($child)
#set($navChild = $child)
#end
#end