aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2017-05-22 21:35:35 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-05-29 21:03:04 +0200
commit7c8f9fa445e0b21f691367210dc5fb79e79b2afa (patch)
tree69a66f3c017c5c17dac1efa758209fb2adcd26ee
parentf447b13adb346ad92ab0c33d073a158ea5c968b5 (diff)
downloadlombok-7c8f9fa445e0b21f691367210dc5fb79e79b2afa.tar.gz
lombok-7c8f9fa445e0b21f691367210dc5fb79e79b2afa.tar.bz2
lombok-7c8f9fa445e0b21f691367210dc5fb79e79b2afa.zip
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.
-rw-r--r--buildScripts/website.ant.xml80
-rw-r--r--src/website/lombok/website/WebsiteMaker.java239
-rw-r--r--website/extra/download-edge.html4
-rw-r--r--website/extra/htaccess15
-rw-r--r--website/templates/_scaffold.html8
-rw-r--r--website/templates/download-edge.html8
-rw-r--r--website/templates/features/_features.html2
7 files changed, 235 insertions, 121 deletions
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index 8a2851fb..ff37b726 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -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" />
diff --git a/src/website/lombok/website/WebsiteMaker.java b/src/website/lombok/website/WebsiteMaker.java
index 85ae5156..4b1c0b01 100644
--- a/src/website/lombok/website/WebsiteMaker.java
+++ b/src/website/lombok/website/WebsiteMaker.java
@@ -67,112 +67,214 @@ 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;
- String version, fullVersion;
- if (args.length < 2) {
- version = VersionFinder.getVersion();
- fullVersion = VersionFinder.getFullVersion();
+ if (argIn == null) {
+ in = new File(".");
+ if (new File(in, "build.xml").isFile() && new File(in, "website").isDirectory()) in = new File(in, "website");
} else {
- version = args[0];
- fullVersion = args[1];
+ in = new File(argIn);
}
- if (args.length < 3) {
+ 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(args[2]);
+ in = new File(argIn);
}
- if (args.length < 4) {
+ if (argOut == null) {
if (new File("./build.xml").isFile() && new File("./website").isDirectory() && new File("./build").isDirectory()) {
- out = new File("./build/website");
+ out = new File("./build/website/changelog.html");
} else {
- out = new File(in, "output");
+ out = new File(in, "output/changelog.html");
}
} else {
- out = new File(args[3]);
+ 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);
}
- WebsiteMaker maker = new WebsiteMaker(version, fullVersion, in, out);
+ 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);
+ }
- maker.buildWebsite();
+ 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 void buildWebsite() throws Exception {
+ public static void main(String[] args) throws Exception {
+ String version, fullVersion;
+
+ if (args.length < 2) {
+ version = VersionFinder.getVersion();
+ fullVersion = VersionFinder.getFullVersion();
+ } else {
+ version = args[0];
+ fullVersion = args[1];
+ }
+
+ 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 {
+ throw new IllegalArgumentException("3rd argument must be one of 'all', 'changelog', 'download-edge', 'changelog-latest'");
+ }
+ }
+
+ 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();
- copyResources();
- convertTemplates(freemarkerConfig);
+ convertDownloadEdge(freemarkerConfig, out);
}
- private static void deleteAll(File outputDir, int depth) {
- if (!outputDir.isDirectory()) return;
- if (depth > 50) throw new IllegalArgumentException("50 levels is too deep: " + outputDir);
+ public void buildWebsite() throws Exception {
+ Configuration freemarkerConfig = makeFreemarkerConfig();
- for (File f : outputDir.listFiles()) {
- String n = f.getName();
- if (n.equals(".") || n.equals("..")) continue;
- if (f.isDirectory()) deleteAll(f, depth + 1);
- f.delete();
- }
+ outputDir.mkdirs();
+ convertTemplates(freemarkerConfig);
}
- private void copyResources() throws Exception {
- File resourcesLoc = new File(baseDir, "resources");
- byte[] b = new byte[65536];
- copyResources_(resourcesLoc, outputDir, b, 0);
+ private TemplateLoader createLoader() throws IOException {
+ return createLoader("templates");
}
- 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(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 TemplateLoader createLoader() throws IOException {
- return new FileTemplateLoader(new File(baseDir, "templates"));
+ 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;
}
diff --git a/website/extra/download-edge.html b/website/extra/download-edge.html
index 4cf794a6..e4c72dfc 100644
--- a/website/extra/download-edge.html
+++ b/website/extra/download-edge.html
@@ -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!
diff --git a/website/extra/htaccess b/website/extra/htaccess
new file mode 100644
index 00000000..a4c3f83d
--- /dev/null
+++ b/website/extra/htaccess
@@ -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]
+
diff --git a/website/templates/_scaffold.html b/website/templates/_scaffold.html
index f0198fa3..f20a839d 100644
--- a/website/templates/_scaffold.html
+++ b/website/templates/_scaffold.html
@@ -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>
diff --git a/website/templates/download-edge.html b/website/templates/download-edge.html
new file mode 100644
index 00000000..469f1284
--- /dev/null
+++ b/website/templates/download-edge.html
@@ -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>
diff --git a/website/templates/features/_features.html b/website/templates/features/_features.html
index d7c75761..c0c63a76 100644
--- a/website/templates/features/_features.html
+++ b/website/templates/features/_features.html
@@ -70,7 +70,7 @@
<div class="header-group">
<h1>${title}</h1>
- <h3>${logline}</h3>
+ <h3>${logline?no_esc}</h3>
</div>
</div>
<#nested>