-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.xml
More file actions
313 lines (289 loc) · 12.9 KB
/
Copy pathstatic.xml
File metadata and controls
313 lines (289 loc) · 12.9 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="static" xmlns:if="ant:if" xmlns:unless="ant:unless" default="createStatic">
<description>
NOTE: MUCH OF THIS FILE IS NOW BASICALLY OBSOLETE.
The /rebuild/ folder contains the remediated website content,
and the only build process required is that which
copies the content to the output folder and generates
the static search page and index.
Older targets used in the
</description>
<property name="echo.separator" value="************************************************"/>
<!-- We'll need access to the date. -->
<tstamp>
<format property="today" pattern="yyyy-MM-dd" locale="en,CA"/>
</tstamp>
<!-- For building only a few documents at one go in the HTML. -->
<property name="docsToBuild" value=""/>
<!-- Folder for HTML website output. -->
<property name="siteDir" value="${basedir}/products/benjonson"/>
<!-- Location of Saxon jar. -->
<property name="saxon" value="${basedir}/lib/saxon-he-12.jar"/>
<!-- Jing task for validation of XML. -->
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask" classpath="${basedir}/lib/jing.jar"/>
<!-- For publication to the live site. -->
<property name="remoteServerUser" value="hcmc"/>
<property name="remoteServerLiveLocation" value="nfs.hcmc.uvic.ca:/home1t/hcmc/www/eol/cambridge/benjonson/"/>
<target name="checkGitStatus">
<description>
TARGET checkGitStatus
This checks to see whether there are any uncommitted changes to
tracked files, and stores the result in a property, which can be
checked later on.
</description>
<exec executable="git" failonerror="false" resultProperty="gitStatus">
<arg value="diff-index"/>
<arg value="--quiet"/>
<arg value="HEAD"/>
<arg value="--"/>
</exec>
<condition property="uncommittedChanges">
<not>
<equals arg1="${gitStatus}" arg2="0"/>
</not>
</condition>
</target>
<target name="askToProceed" if="uncommittedChanges">
<description>
TARGET askToProceed
If there are uncommitted changes, this checks with the user
to make sure they want to proceed with the build.
</description>
<input
message="There seem to be uncommitted changes in the local repo. Proceed anyway? (y/n)"
validargs="y,n"
addproperty="userChoice"
defaultvalue="y"
/>
<condition property="abortBuild">
<equals arg1="${userChoice}" arg2="n"/>
</condition>
<fail if="abortBuild" message="Build aborted due to uncommitted changes."/>
</target>
<target name="softClean">
<description>
TARGET softClean
This target removes all files from the output location, but leaves
the folders intact, so any running web server will not be thrown into
confusion and need to be restarted. In case nothing is there anyway,
it does create the base "products/benjonson" dir if needed. If the docsToBuild
parameter has content, then it does not do anything, on the assumption
that existing files should be retained.
</description>
<echo message="${echo.separator}"/>
<echo message="Cleaning files from the output location (but leaving folders intact)..." if:blank="${docsToBuild}"/>
<mkdir dir="${siteDir}"/>
<delete failonerror="false" if:blank="${docsToBuild}">
<fileset dir="${siteDir}">
<include name="**/*"/>
<type type="file"/>
</fileset>
</delete>
<delete file="${basedir}/gitHash.txt"/>
<echo message="${echo.separator}"/>
<echo message="Soft clean completed." if:blank="${docsToBuild}"/>
<echo message="Soft clean not done, because docsToBuild parameter supplied." unless:blank="${docsToBuild}"/>
</target>
<target name="hardClean">
<description>
TARGET hardClean
This target removes all files and folders from the output location, but leaves
the root "products/benjonson" folder.
</description>
<mkdir dir="${siteDir}"/>
<echo message="${echo.separator}"/>
<echo message="Cleaning all files and folders from the output location..."/>
<delete includeemptydirs="true">
<fileset dir="${siteDir}" includes="**/*"/>
</delete>
<delete file="${basedir}/gitHash.txt"/>
<echo message="${echo.separator}"/>
<echo message="Hard clean completed."/>
</target>
<target name="gitHash">
<description>
TARGET gitHash
This simply outputs the first four characters of the
current git commit hash for use by staticSearch as a
suffix for versioning and for the version/edition info.
</description>
<echo message="${echo.separator}"/>
<echo message="Creating a git hash file."/>
<exec executable="git" dir="${basedir}" outputproperty="gitHash">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<echo file="${basedir}/gitHash.txt" message="${gitHash}"/>
<replaceregexp file="${basedir}/gitHash.txt" match="^(.{4,4}).+$" replace="\1" flags="s"/>
<echo file="${basedir}/gitHashFull.txt" message="${gitHash}"/>
</target>
<target name="copyRebuildToSiteFolder">
<description>
TARGET copyRebuildToSiteFolder
This simply copies the entirety of the rebuild
folder to the output location, so that the
staticSearch process can be run on it.
</description>
<echo message="${echo.separator}"/>
<echo message="Copying rebuild pages to the output folder."/>
<copy todir="${siteDir}">
<fileset dir="${basedir}/rebuild">
<include name="**/*"/>
</fileset>
</copy>
<!-- We also include the highlight.js from staticSearch. -->
<copy todir="${siteDir}/js">
<file file="${basedir}/staticSearch/js/ssHighlight.js"/>
</copy>
</target>
<target name="createVersionFile">
<description>
TARGET createVersionFile
Because the original KCL site did not include any versioning
information in the footer of its pages, we don't either, but
we do need a mechanism to record when a version of the site
was created and what Git hash the repo was at when it was
created. This target does that.
</description>
<echo message="${echo.separator}"/>
<echo message="Creating an edition version file."/>
<echo file="${basedir}/products/benjonson/EDITION.txt">
Ben Jonson static website.
Created by the Humanities Computing and Media Centre,
University of Victoria.
Contact: mholmes@uvic.ca.
</echo>
<echo file="${basedir}/products/benjonson/EDITION.txt" append="true">
Build date:
</echo>
<echo file="${basedir}/products/benjonson/EDITION.txt" append="true" message="${today}"/>
<echo file="${basedir}/products/benjonson/EDITION.txt" append="true">
Git hash:
</echo>
<concat destfile="${basedir}/products/benjonson/EDITION.txt" append="true">
<filelist dir="${basedir}" files="gitHashFull.txt"/>
</concat>
</target>
<target name="validateRebuild">
<description>
TARGET validateRebuild
This target validates the output of the remediation phase. During
initial build work, we output the errors to a log file and
open that file for easier assessment.
</description>
<echo message="${echo.separator}"/>
<echo message="Validating the HTML pages in the rebuild folder using the VNU validator."/>
<java jar="${basedir}/lib/vnu.jar" failonerror="true" fork="true">
<arg value="--format text"/>
<arg value="--skip-non-html"/>
<arg value="--errors-only"/>
<arg value="--xml"/>
<arg value="${basedir}/rebuild"/>
</java><!--
<exec executable="gedit" dir="${basedir}">
<arg value="validateRebuildLog.txt"/>
</exec>-->
</target>
<target name="validateOutput">
<description>
TARGET validateOutput
This target validates the output of the site build. During
initial build work, we output the errors to a log file and
open that file for easier assessment.
</description>
<echo message="${echo.separator}"/>
<echo message="Validating the HTML pages produced in the build using the VNU validator."/>
<java jar="${basedir}/lib/vnu.jar" failonerror="true" fork="true">
<arg value="--format text"/>
<arg value="--skip-non-html"/>
<arg value="--errors-only"/>
<arg value="--xml"/>
<arg value="${siteDir}"/>
</java><!--
<exec executable="gedit" dir="${basedir}">
<arg value="validateOutputLog.txt"/>
</exec>-->
</target>
<target name="buildStaticSearch">
<description>
TARGET buildStaticSearch
This runs the staticSearch build against the copy of
the site in the products/static folder.
</description>
<echo message="${echo.separator}"/>
<echo message="Building static search..."/>
<ant antfile="build.xml" dir="staticSearch">
<property name="ssConfig" value="../config_staticSearch.xml"/>
</ant>
</target>
<target name="postprocessSearchPage">
<description>
TARGET postProcessSearchPage
This target tweaks the output search page from the static search
build process to make a range of tweaks and fixes.
</description>
<echo message="${echo.separator}"/>
<echo message="Postprocessing search page..."/>
<java fork="true" classname="net.sf.saxon.Transform" classpath="${saxon}" failonerror="true">
<jvmarg value="-Xmx1024m"/>
<arg value="-s:${siteDir}/search.html"/>
<arg value="-xsl:xsl/postprocess_search_master.xsl"/>
<arg value="-o:${siteDir}/search.html"/>
<arg value="--suppressXsltNamespaceCheck:on"/>
</java>
<echo message="Search page postprocessing done."/>
</target>
<target name="bjRsyncToLiveServer">
<description>
TARGET bjRsyncToLiveServer
This uses rsync (with delete) to replace
the existing version of the site in
hcmc/www/eol/cambridge/benjonson/ with the
current build in products/benjonson/.
</description>
<echo message="${echo.separator}"/>
<echo message="About to push content up to the live server."/>
<echo message="${echo.separator}"/>
<echo message="Before doing that, we'll create a dated archive of this build."/>
<zip destfile="benjonson_site_${today}.zip" basedir="${basedir}/products/benjonson"/>
<echo message="${echo.separator}"/>
<echo message="Now we do the sync..."/>
<exec executable="rsync" dir="${basedir}">
<arg value="--stats"/>
<arg value="--recursive"/>
<arg value="--times"/>
<arg value="--delete"/>
<arg value="--verbose"/>
<arg line="-e ssh"/>
<arg line="products/benjonson/"/>
<arg line="${remoteServerUser}@${remoteServerLiveLocation}"/>
</exec>
</target>
<target name="moveSearchReport">
<description>
TARGET moveSearchReport
This simply moves the staticSearch build report
out of the output folder.
</description>
<echo message="${echo.separator}"/>
<echo message="Moving search report..."/>
<copy file="${siteDir}/staticSearch/staticSearch_report.html" todir="${basedir}"/>
<delete file="${siteDir}/staticSearch/staticSearch_report.html"/>
</target>
<target name="createStatic" depends="checkGitStatus, askToProceed">
<description>
TARGET createStatic
This runs the entire static output creation
process.
</description>
<antcall target="validateRebuild"/>
<antcall target="hardClean"/>
<antcall target="gitHash"/>
<antcall target="createVersionFile"/>
<antcall target="copyRebuildToSiteFolder"/>
<antcall target="buildStaticSearch"/>
<antcall target="postprocessSearchPage"/>
<antcall target="moveSearchReport"/>
<antcall target="validateOutput"/>
</target>
</project>