Final touches to the new website:

* htaccess for ‘nice looking’ URLs.
* download-edge overwritten upon stable releases.
* fixes to the build system.
* Added google analytics pagetracker.
This commit is contained in:
Reinier Zwitserloot
2017-05-29 21:03:04 +02:00
parent f447b13adb
commit 7c8f9fa445
7 changed files with 245 additions and 131 deletions
+26 -54
View File
@@ -55,6 +55,19 @@ such as applying the templates to produce the website, converting the changelog
</javac>
</target>
<target name="changelogToHtml" depends="-compile-webclasses">
<mkdir dir="build/website" />
<java classname="lombok.website.WebsiteMaker" failonerror="true">
<classpath>
<path refid="build.path" />
<pathelement location="build/webclasses" />
</classpath>
<arg value="${lombok.version}" />
<arg value="${lombok.fullversion}" />
<arg value="changelog" />
</java>
</target>
<target name="-website-main" depends="-ensure-version, -ensure-fullversion, -website-clean, -compile-webclasses, javadoc, changelogToHtml">
<mkdir dir="build/website" />
<copy todir="build/website">
@@ -63,6 +76,7 @@ such as applying the templates to produce the website, converting the changelog
<include name="LICENSE" />
</fileset>
</copy>
<copy file="website/extra/htaccess" tofile="build/website/.htaccess" />
<java classname="lombok.website.WebsiteMaker" failonerror="true">
<classpath>
<path refid="build.path" />
@@ -70,6 +84,7 @@ such as applying the templates to produce the website, converting the changelog
</classpath>
<arg value="${lombok.version}" />
<arg value="${lombok.fullversion}" />
<arg value="all" />
</java>
</target>
@@ -97,50 +112,33 @@ such as applying the templates to produce the website, converting the changelog
</target>
<target name="latestChanges" depends="-compile-webclasses, -ensure-version, -ensure-fullversion">
<java fork="true" classname="lombok.website.CompileChangelog" failonerror="true">
<mkdir dir="build/website" />
<java classname="lombok.website.WebsiteMaker" failonerror="true">
<classpath>
<path refid="build.path" />
<pathelement location="build/webclasses" />
</classpath>
<arg value="doc/changelog.markdown" />
<arg value="build/latestchanges.html" />
<arg value="-latest" />
<arg value="${lombok.version}" />
<arg value="${lombok.fullversion}" />
<arg value="changelog-latest" />
<arg value="website" />
<arg value="build/latestchanges.html" />
</java>
</target>
<target name="edgeRelease-build" depends="-compile-webclasses, -ensure-version, -ensure-fullversion">
<mkdir dir="build/website-edge" />
<property name="CHANGELOG_FILE" location="doc/changelog.markdown" />
<property name="CHANGELOG_HTML" location="build/website-edge/changelog-edge.html" />
<java fork="true" classname="lombok.website.CompileChangelog" failonerror="true">
<java classname="lombok.website.WebsiteMaker" failonerror="true">
<classpath>
<path refid="build.path" />
<pathelement location="build/webclasses" />
</classpath>
<arg value="${CHANGELOG_FILE}" />
<arg value="${CHANGELOG_HTML}" />
<arg value="-edge" />
<arg value="${lombok.version}" />
<arg value="${lombok.fullversion}" />
<arg value="download-edge" />
<arg value="website" />
<arg value="build/website-edge/download-edge.html" />
</java>
<loadfile property="changelog.edge" srcFile="build/website-edge/changelog-edge.html" encoding="UTF-8" />
<tstamp>
<format property="edgeRelease-timestamp" pattern="yyyy-MM-dd HH:mm 'UTC'" timezone="UTC" />
</tstamp>
<copy todir="build/website-edge" overwrite="true">
<fileset dir="website/extra">
<include name="download-edge.html" />
</fileset>
<filterchain>
<replacetokens>
<token key="VERSION-EDGE" value="${lombok.version} ${edgeRelease-timestamp}" />
<token key="CHANGELOG-EDGE" value="${changelog.edge}" />
</replacetokens>
</filterchain>
</copy>
<delete file="build/website-edge/changelog-edge.html" />
<copy file="dist/lombok.jar" tofile="build/website-edge/lombok-edge.jar" />
<tar destfile="dist/website-edge.tar.bz2" compression="bzip2">
@@ -163,32 +161,6 @@ such as applying the templates to produce the website, converting the changelog
trust="true" command="/data/lombok/stagingCmd/deployEdge" />
</target>
<target name="changelogToHtml" depends="-compile-webclasses">
<mkdir dir="build/website-old" />
<property name="CHANGELOG_FILE" location="doc/changelog.markdown" />
<property name="CHANGELOG_HTML" location="build/website-old/changelog-raw.html" />
<java fork="true" classname="lombok.website.CompileChangelog" failonerror="true">
<classpath>
<path refid="build.path" />
<pathelement location="build/webclasses" />
</classpath>
<arg value="${CHANGELOG_FILE}" />
<arg value="${CHANGELOG_HTML}" />
</java>
<loadfile property="changelog.main" srcFile="build/website-old/changelog-raw.html" />
<delete file="build/website-old/changelog-raw.html" />
<copy todir="build/website-old" overwrite="true">
<fileset dir="website-old">
<include name="changelog.html" />
</fileset>
<filterchain>
<replacetokens>
<token key="CHANGELOG" value="${changelog.main}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="javadoc" description="Generates the javadoc" depends="-ensure-version, -ensure-fullversion">
<delete dir="build/api" quiet="true" />
<delete dir="doc/api" quiet="true" />
+185 -74
View File
@@ -67,9 +67,97 @@ public class WebsiteMaker {
}
}
public static void main(String[] args) throws Exception {
private static void buildAll(String version, String fullVersion, String argIn, String argOut) throws Exception {
File in, out;
if (argIn == null) {
in = new File(".");
if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
} else {
in = new File(argIn);
}
if (argOut == null) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
out = new File("./build/website");
} else {
out = new File(in, "output");
}
} else {
out = new File(argOut);
}
WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out);
maker.buildWebsite();
}
private static void buildChangelog(String version, String fullVersion, String argIn, String argOut) throws Exception {
File in, out;
if (argIn == null) {
in = new File(".");
if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
} else {
in = new File(argIn);
}
if (argOut == null) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
out = new File("./build/website/changelog.html");
} else {
out = new File(in, "output/changelog.html");
}
} else {
out = new File(argOut);
}
WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out.getParentFile());
maker.buildChangelog(out);
}
private static void buildDownloadEdge(String version, String fullVersion, String argIn, String argOut) throws Exception {
File in, out;
if (argIn == null) {
in = new File(".");
if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
} else {
in = new File(argIn);
}
if (argOut == null) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
out = new File("./build/website-edge/download-edge.html");
} else {
out = new File(in, "output/download-edge.html");
}
} else {
out = new File(argOut);
}
WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out.getParentFile());
maker.buildDownloadEdge(out);
}
private static void buildChangelogLatest(String version, String fullVersion, String argIn, String argOut) throws Exception {
File in, out;
if (argIn == null) {
in = new File(".");
if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
} else {
in = new File(argIn);
}
if (argOut == null) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
out = new File("./build/latestchanges.html");
} else {
out = new File(in, "output/latestchanges.html");
}
} else {
out = new File(argOut);
}
WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out.getParentFile());
maker.buildChangelogLatest(out);
}
public static void main(String[] args) throws Exception {
String version, fullVersion;
if (args.length < 2) {
version = VersionFinder.getVersion();
fullVersion = VersionFinder.getFullVersion();
@@ -78,101 +166,115 @@ public class WebsiteMaker {
fullVersion = args[1];
}
if (args.length < 3) {
in = new File(".");
if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
if (args.length < 3 || args[2].equalsIgnoreCase("all")) {
buildAll(version, fullVersion, args.length < 4 ? null : args[3], args.length < 5 ? null : args[4]);
} else if (args[2].equalsIgnoreCase("changelog")) {
buildChangelog(version, fullVersion, args.length < 4 ? null : args[3], args.length < 5 ? null : args[4]);
} else if (args[2].equalsIgnoreCase("download-edge")) {
buildDownloadEdge(version, fullVersion, args.length < 4 ? null : args[3], args.length < 5 ? null : args[4]);
} else if (args[2].equalsIgnoreCase("changelog-latest")) {
buildChangelogLatest(version, fullVersion, args.length < 4 ? null : args[3], args.length < 5 ? null : args[4]);
} else {
in = new File(args[2]);
throw new IllegalArgumentException("3rd argument must be one of 'all', 'changelog', 'download-edge', 'changelog-latest'");
}
if (args.length < 4) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
out = new File("./build/website");
} else {
out = new File(in, "output");
}
} else {
out = new File(args[3]);
}
WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out);
maker.buildWebsite();
}
public void buildWebsite() throws Exception {
private Configuration makeFreemarkerConfig() throws IOException {
Configuration freemarkerConfig = new Configuration(Configuration.VERSION_2_3_25);
freemarkerConfig.setEncoding(Locale.ENGLISH, "UTF-8");
freemarkerConfig.setOutputEncoding("UTF-8");
freemarkerConfig.setOutputFormat(HTMLOutputFormat.INSTANCE);
freemarkerConfig.setTemplateLoader(createLoader());
freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
return freemarkerConfig;
}
public void buildChangelog(File out) throws Exception {
Configuration freemarkerConfig = makeFreemarkerConfig();
outputDir.mkdirs();
convertChangelog(freemarkerConfig, out);
}
public void buildChangelogLatest(File out) throws Exception {
outputDir.mkdirs();
String htmlForLatest = CompileChangelog.getHtmlForLatest(baseDir.getParentFile(), version);
FileOutputStream fos = new FileOutputStream(out);
try {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(htmlForLatest);
bw.close();
} finally {
fos.close();
}
}
public void buildDownloadEdge(File out) throws Exception {
Configuration freemarkerConfig = new Configuration(Configuration.VERSION_2_3_25);
freemarkerConfig.setEncoding(Locale.ENGLISH, "UTF-8");
freemarkerConfig.setOutputEncoding("UTF-8");
freemarkerConfig.setOutputFormat(HTMLOutputFormat.INSTANCE);
freemarkerConfig.setTemplateLoader(createLoader("extra"));
freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
deleteAll(outputDir, 0);
outputDir.mkdirs();
convertDownloadEdge(freemarkerConfig, out);
}
public void buildWebsite() throws Exception {
Configuration freemarkerConfig = makeFreemarkerConfig();
outputDir.mkdirs();
copyResources();
convertTemplates(freemarkerConfig);
}
private static void deleteAll(File outputDir, int depth) {
if (!outputDir.isDirectory()) return;
if (depth > 50) throw new IllegalArgumentException("50 levels is too deep: " + outputDir);
for (File f : outputDir.listFiles()) {
String n = f.getName();
if (n.equals(".") || n.equals("..")) continue;
if (f.isDirectory()) deleteAll(f, depth + 1);
f.delete();
}
}
private void copyResources() throws Exception {
File resourcesLoc = new File(baseDir, "resources");
byte[] b = new byte[65536];
copyResources_(resourcesLoc, outputDir, b, 0);
}
private void copyResources_(File from, File to, byte[] b, int depth) throws IOException {
if (depth > 50) throw new IllegalArgumentException("50 levels is too deep: " + from);
if (!to.exists()) to.mkdirs();
for (File f : from.listFiles()) {
if (f.isDirectory()) copyResources_(f, new File(to, f.getName()), b, depth + 1);
if (!f.isFile()) continue;
FileInputStream fIn = new FileInputStream(f);
try {
FileOutputStream fOut = new FileOutputStream(new File(to, f.getName()));
try {
while (true) {
int r = fIn.read(b);
if (r == -1) break;
fOut.write(b, 0, r);
}
} finally {
fOut.close();
}
} finally {
fIn.close();
}
}
}
private TemplateLoader createLoader() throws IOException {
return new FileTemplateLoader(new File(baseDir, "templates"));
return createLoader("templates");
}
private TemplateLoader createLoader(String base) throws IOException {
return new FileTemplateLoader(new File(baseDir, base));
}
private void convertChangelog(Configuration freemarker, File outFile) throws Exception {
Map<String, Object> dataModel = createBasicDataModel();
Template template = freemarker.getTemplate("changelog.html");
FileOutputStream fileOut = new FileOutputStream(outFile);
try {
Writer wr = new BufferedWriter(new OutputStreamWriter(fileOut, "UTF-8"));
template.process(dataModel, wr);
wr.close();
} finally {
fileOut.close();
}
}
private void convertDownloadEdge(Configuration freemarker, File outFile) throws Exception {
Map<String, Object> dataModel = createBasicDataModel();
Template template = freemarker.getTemplate("download-edge.html");
FileOutputStream fileOut = new FileOutputStream(outFile);
try {
Writer wr = new BufferedWriter(new OutputStreamWriter(fileOut, "UTF-8"));
template.process(dataModel, wr);
wr.close();
} finally {
fileOut.close();
}
}
private void convertTemplates(Configuration freemarker) throws Exception {
File basePagesLoc = new File(baseDir, "templates");
convertTemplates_(freemarker, "", basePagesLoc, outputDir, 0);
Map<String, Object> dataModel = createBasicDataModel();
dataModel.putAll(createExtendedDataModel());
convertTemplates_(freemarker, "", basePagesLoc, outputDir, 0, dataModel);
}
private void convertTemplates_(Configuration freemarker, String prefix, File from, File to, int depth) throws Exception {
private void convertTemplates_(Configuration freemarker, String prefix, File from, File to, int depth, Map<String, Object> dataModel) throws Exception {
if (depth > 50) throw new IllegalArgumentException("50 levels is too deep: " + from);
Map<String, Object> dataModel = createDataModel();
for (File f : from.listFiles()) {
if (f.isDirectory()) convertTemplates_(freemarker, prefix + f.getName() + "/", f, new File(to, f.getName()), depth + 1);
if (f.isDirectory()) convertTemplates_(freemarker, prefix + f.getName() + "/", f, new File(to, f.getName()), depth + 1, dataModel);
if (!f.isFile() || !f.getName().endsWith(".html") || f.getName().startsWith("_")) continue;
to.mkdirs();
Template template = freemarker.getTemplate(prefix + f.getName());
@@ -187,12 +289,22 @@ public class WebsiteMaker {
}
}
private static final Pattern LOMBOK_LINK = Pattern.compile("^.*<a(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)* href=\"(downloads/[^\"]+)\"(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)*>([^<]+)</a>.*$");
private Map<String, Object> createDataModel() throws IOException {
private Map<String, Object> createBasicDataModel() throws IOException {
Map<String, Object> data = new HashMap<String, Object>();
data.put("version", version);
data.put("fullVersion", fullVersion);
data.put("year", "" + new GregorianCalendar().get(Calendar.YEAR));
data.put("changelog", CompileChangelog.getHtml(baseDir.getParentFile()));
data.put("changelogEdge", CompileChangelog.getHtmlForEdge(baseDir.getParentFile(), version));
return data;
}
private static final Pattern LOMBOK_LINK = Pattern.compile("^.*<a(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)* href=\"(downloads/[^\"]+)\"(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)*>([^<]+)</a>.*$");
private Map<String, Object> createExtendedDataModel() throws IOException {
Map<String, Object> data = new HashMap<String, Object>();
data.put("usages", new HtmlMaker(new File(baseDir, "usageExamples")));
InputStream in = new URL("https://projectlombok.org/all-versions.html").openStream();
ArrayList<List<String>> links = new ArrayList<List<String>>();
@@ -207,7 +319,6 @@ public class WebsiteMaker {
}
data.put("linksToVersions", links);
data.put("changelog", CompileChangelog.getHtml(baseDir.getParentFile()));
return data;
}
+2 -2
View File
@@ -35,10 +35,10 @@
<div class="meat download edge">
<h1>Download Lombok Cutting Edge build</h1>
<div class="versionInfo">
version: @VERSION-EDGE@
version: ${version}
</div>
<p id="changelog">
@CHANGELOG-EDGE@
${changelogEdge?no_esc}
</p>
<a href="lombok-edge.jar" id="downloadLink">
Download now!
+15
View File
@@ -0,0 +1,15 @@
RewriteRule ^/features/all$ /features/index.html [L]
RewriteRule ^/features/experimental/all$ /features/experimental/index.html [L]
RewriteRule ^/features/.*\.html$ - [L]
RewriteRule ^/features/(.*)$ /features/$1.html [L]
RewriteRule ^/features$ /features/index.html [L]
RewriteRule ^/features/experimental$ /features/experimental/index.html [L]
RewriteRule ^/changelog$ /changelog.html [L]
RewriteRule ^/?$ /main.html [L]
RewriteRule ^/index(.html)?$ /main.html [L]
RewriteRule ^/credits$ /credits.html [L]
RewriteRule ^/download$ /download.html [L]
RewriteRule ^/all(-v|V)ersions(.html)?$ /all-versions.html [L]
RewriteRule ^/setup/.*\.html$ - [L]
RewriteRule ^/setup/(.*) /setup/$1.html [L]
+8
View File
@@ -13,6 +13,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="google-site-verification" content="uCgX3Or3kDRGpbJ6JCsQc3Ub4JsnR5-p0itfsKAYZ_U" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-9884254-1', 'auto');
ga('send', 'pageview');
</script>
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<title>Project Lombok</title>
+8
View File
@@ -0,0 +1,8 @@
<#import "/_scaffold.html" as main>
<@main.scaffold>
<div class="page-header top5">
<div class="row text-center versionInfo">
No edge build has been released since the last <a href="/download">stable release</a> of lombok.
</div>
</div>
</@main.scaffold>
+1 -1
View File
@@ -70,7 +70,7 @@
<div class="header-group">
<h1>${title}</h1>
<h3>${logline}</h3>
<h3>${logline?no_esc}</h3>
</div>
</div>
<#nested>