TOMEE-2444 WIP fixing examples internationalization
diff --git a/src/main/java/org/apache/tomee/website/Configuration.java b/src/main/java/org/apache/tomee/website/Configuration.java
index 8b09b52..57a6c62 100644
--- a/src/main/java/org/apache/tomee/website/Configuration.java
+++ b/src/main/java/org/apache/tomee/website/Configuration.java
@@ -19,48 +19,48 @@
public class Configuration {
public static Source[] getSources() {
final Source[] microProfile2 = new Source[]{
- new Source("https://github.com/eclipse/microprofile-jwt-auth.git", "1.1.1", "microprofile-jwt-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-config.git", "1.3", "microprofile-config-1.3").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-fault-tolerance", "1.1.4", "microprofile-fault-tolerance-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-health", "1.0", "microprofile-health-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-metrics", "1.1.1", "microprofile-metrics-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-open-api", "1.0.2", "microprofile-open-api-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-opentracing", "1.1", "microprofile-opentracing-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
- new Source("https://github.com/eclipse/microprofile-rest-client", "1.1", "microprofile-rest-client-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-jwt-auth.git", "1.1.1", "microprofile-jwt-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-config.git", "1.3", "microprofile-config-1.3").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-fault-tolerance", "1.1.4", "microprofile-fault-tolerance-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-health", "1.0", "microprofile-health-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-metrics", "1.1.1", "microprofile-metrics-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-open-api", "1.0.2", "microprofile-open-api-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-opentracing", "1.1", "microprofile-opentracing-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+// new Source("https://github.com/eclipse/microprofile-rest-client", "1.1", "microprofile-rest-client-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
};
final Source[] jakartaEE8 = {
- new Source("https://github.com/eclipse-ee4j/common-annotations-api.git", "EE4J_8", "common-annotations-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/concurrency-api.git", "EE4J_8", "concurrency-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/ejb-api.git", "EE4J_8", "ejb-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/interceptor-api.git", "EE4J_8", "interceptor-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jax-rpc-api.git", "EE4J_8", "jax-rpc-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jax-ws-api.git", "EE4J_8", "jax-ws-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jaxb-api.git", "EE4J_8", "jaxb-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jaxr-api.git", "EE4J_8", "jaxr-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jaxrs-api.git", "EE4J_8", "jaxrs-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jca-api.git", "EE4J_8", "jca-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jms-api.git", "EE4J_8", "jms-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jpa-api.git", "EE4J_8", "jpa-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jsonb-api.git", "EE4J_8", "jsonb-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jsp-api.git", "EE4J_8", "jsp-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jstl-api.git", "EE4J_8", "jstl-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jta-api.git", "EE4J_8", "jta-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/jws-api.git", "EE4J_8", "jws-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/management-api.git", "EE4J_8", "management-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/saaj-api.git", "EE4J_8", "saaj-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/security-api.git", "EE4J_8", "security-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/servlet-api.git", "EE4J_8", "servlet-api-EE4J_81.0"),
- new Source("https://github.com/eclipse-ee4j/websocket-api.git", "EE4J_8", "websocket-api-EE4J_81.0")
+// new Source("https://github.com/eclipse-ee4j/common-annotations-api.git", "EE4J_8", "common-annotations-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/concurrency-api.git", "EE4J_8", "concurrency-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/ejb-api.git", "EE4J_8", "ejb-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/interceptor-api.git", "EE4J_8", "interceptor-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jax-rpc-api.git", "EE4J_8", "jax-rpc-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jax-ws-api.git", "EE4J_8", "jax-ws-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jaxb-api.git", "EE4J_8", "jaxb-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jaxr-api.git", "EE4J_8", "jaxr-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jaxrs-api.git", "EE4J_8", "jaxrs-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jca-api.git", "EE4J_8", "jca-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jms-api.git", "EE4J_8", "jms-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jpa-api.git", "EE4J_8", "jpa-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jsonb-api.git", "EE4J_8", "jsonb-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jsp-api.git", "EE4J_8", "jsp-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jstl-api.git", "EE4J_8", "jstl-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jta-api.git", "EE4J_8", "jta-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/jws-api.git", "EE4J_8", "jws-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/management-api.git", "EE4J_8", "management-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/saaj-api.git", "EE4J_8", "saaj-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/security-api.git", "EE4J_8", "security-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/servlet-api.git", "EE4J_8", "servlet-api-EE4J_81.0"),
+// new Source("https://github.com/eclipse-ee4j/websocket-api.git", "EE4J_8", "websocket-api-EE4J_81.0")
};
return new Source[]{
new Source("https://gitbox.apache.org/repos/asf/tomee.git", "master", "tomee-8.0", true).related(microProfile2).related(jakartaEE8),
new Source("https://gitbox.apache.org/repos/asf/tomee.git", "tomee-7.1.0", "tomee-7.1"),
- new Source("https://gitbox.apache.org/repos/asf/tomee.git", "tomee-7.0.5", "tomee-7.0"),
- new Source("https://gitbox.apache.org/repos/asf/tomee.git", "master", "master"),
- new Source("https://github.com/eclipse/microprofile-bom.git", "master", "microprofile-2.0").related(microProfile2),
- new Source("https://github.com/eclipse-ee4j/jakartaee-platform.git", "master", "jakartaee-8.0").related(jakartaEE8)
+// new Source("https://gitbox.apache.org/repos/asf/tomee.git", "tomee-7.0.5", "tomee-7.0"),
+// new Source("https://gitbox.apache.org/repos/asf/tomee.git", "master", "master"),
+// new Source("https://github.com/eclipse/microprofile-bom.git", "master", "microprofile-2.0").related(microProfile2),
+// new Source("https://github.com/eclipse-ee4j/jakartaee-platform.git", "master", "jakartaee-8.0").related(jakartaEE8)
};
}
}
diff --git a/src/main/java/org/apache/tomee/website/Docs.java b/src/main/java/org/apache/tomee/website/Docs.java
index 63fd515..2266a7b 100644
--- a/src/main/java/org/apache/tomee/website/Docs.java
+++ b/src/main/java/org/apache/tomee/website/Docs.java
@@ -37,7 +37,7 @@
public void prepare(final Source source) {
final File srcDocs = new File(source.getDir(), "docs");
- final File destDocs = sources.getJbakeContentDestFor(source, "docs");
+ final File destDocs = sources.getJbakeContentDestFor(source, "docs"); //target/jbake/<tomeeBranch>/docs
if (!srcDocs.exists()) return;
diff --git a/src/main/java/org/apache/tomee/website/Example.java b/src/main/java/org/apache/tomee/website/Example.java
index 937ee62..bdd72d9 100644
--- a/src/main/java/org/apache/tomee/website/Example.java
+++ b/src/main/java/org/apache/tomee/website/Example.java
@@ -53,14 +53,25 @@
this.language = language;
}
- public void updateDestination(final File examplesDir) {
+ public void updateDestination(final File examplesDir) { //target/jbake/<tomeeBranch>
+
+
+
+
if (this.language.equalsIgnoreCase("")) {
- this.setDestReadme(new File(examplesDir, this.getName() + "." + this.getExt()));
+ File languageDir = new File(examplesDir + File.separator + "en" + File.separator + "examples");
+ if (!languageDir.exists()) {
+ languageDir.mkdirs(); // anates tomee8.0/examples/es ahora tomee8.0/es/examples/
+ }
+ this.setDestReadme(new File(examplesDir+File.separator+"en"+File.separator+"examples", this.getName() + "." + this.getExt()));
} else {
- File languageDir = new File(examplesDir + File.separator + getLanguage());
+ //File languageDir = new File(examplesDir + File.separator + getLanguage());
+ //File languageDir = new File(examplesDir.getParentFile().getParent() + File.separator + getLanguage() + File.separator + "examples");
+ //target/jbake/<tomeeBranch>/es/examples
+ File languageDir = new File(examplesDir + File.separator + getLanguage() + File.separator + "examples");
if (!languageDir.exists()) {
- languageDir.mkdirs();
+ languageDir.mkdirs(); // anates tomee8.0/examples/es ahora tomee8.0/es/examples/
}
this.setDestReadme(new File(languageDir.getAbsolutePath(), this.getName() + "." + this.getExt()));
diff --git a/src/main/java/org/apache/tomee/website/Examples.java b/src/main/java/org/apache/tomee/website/Examples.java
index 9512f7b..716cbff 100644
--- a/src/main/java/org/apache/tomee/website/Examples.java
+++ b/src/main/java/org/apache/tomee/website/Examples.java
@@ -35,7 +35,8 @@
public void prepare(final Source source) {
final File srcDir = new File(source.getDir(), "examples");
- final File destDir = sources.getJbakeContentDestFor(source, "examples"); //target/jbake/<tomeeBranch>t/examples
+// final File destDir = sources.getJbakeContentDestFor(source, "en"+File.separator+"examples"); //target/jbake/<tomeeBranch>/
+ final File destDir = sources.getJbakeContentDestFor(source, ""); //target/jbake/<tomeeBranch>/
// If we don't have examples in this codebase, skip
if (!srcDir.exists()) return;
diff --git a/src/main/java/org/apache/tomee/website/GroupedIndex.java b/src/main/java/org/apache/tomee/website/GroupedIndex.java
index 868abb4..7218763 100644
--- a/src/main/java/org/apache/tomee/website/GroupedIndex.java
+++ b/src/main/java/org/apache/tomee/website/GroupedIndex.java
@@ -36,7 +36,8 @@
private final String type;
public GroupedIndex(final File directory, final String type) {
- this.directory = directory;
+ this.directory = directory;//target/jbake/<tomeeBranch>
+ // ahora target/jbake/<tomeeBranch> o tambien //target/jbake/<tomeeBranch>/docs
this.type = type;
}
@@ -59,6 +60,8 @@
for (String language : detectedLanguages) {
sortSectionsAndCreateIndexFiles(docs, language);
+ //target/jbake/<tomeeBranch>/en/examples
+ //target/jbake/<tomeeBranch>/es/examples
}
}
@@ -103,7 +106,7 @@
});
- try (final PrintStream out = print(directory.getAbsolutePath(), "index.html", language)) {
+ try (final PrintStream out = print(directory.getAbsolutePath(), "index.html", language, this.type)) {
out.printf("type=%s\n", type);
out.printf("status=published\n");
@@ -168,14 +171,22 @@
}
}
- public static PrintStream print(final String directory, final String child, String language) {
+ public static PrintStream print(final String directory, final String child, String language, String type) { //target/jbake/<tomeeBranch> o tambien //target/jbake/<tomeeBranch>/docs
try {
- File fileParentFolder;
+ File fileParentFolder = null;
- if (language.equalsIgnoreCase("en")) {
+// if (language.equalsIgnoreCase("en")) {
+// fileParentFolder = new File(directory);
+// } else {
+// fileParentFolder = new File(directory + File.separator + language);
+// }
+
+
+ if(type.equalsIgnoreCase("docsindex")){
fileParentFolder = new File(directory);
- } else {
- fileParentFolder = new File(directory + File.separator + language);
+ }else { //examplesindex
+// fileParentFolder = new File(directory + File.separator + language + File.separator + "examples");
+ fileParentFolder = new File(directory + File.separator + language + File.separator + "examples");
}
return new PrintStream(IO.write(new File(fileParentFolder, child)));
@@ -184,7 +195,8 @@
}
}
- public List<Doc> list(final File directory) {
+ public List<Doc> list(final File directory) {//target/jbake/<tomeeBranch>/examples
+ // ahora target/jbake/<tomeeBranch>
try {
return Files.walk(directory.toPath())
.map(Path::toFile)
@@ -197,19 +209,17 @@
}
}
- private static String getLanguageFromPath(File file, String expectedFileParentFolder) {
+ private static String getLanguageFromPath(File file, String type) { //target/jbake/<tomeeBranch>/examples/es/readme_es.adoc
+ //pero ahora //target/jbake/<tomeeBranch>/en/examples/index.html
+ //pero ahora //target/jbake/<tomeeBranch>/es/examples/index.html
- String fileParentFolder = file.getParentFile().getName();
- if (fileParentFolder != null) {
- if (fileParentFolder.equalsIgnoreCase(expectedFileParentFolder)) {
- return "";
- } else {
- return fileParentFolder;
- }
- } else {
+ if(type.equalsIgnoreCase("docsindex")){ //ToDo: this needs to be updated when we are going to proccess docs internationalization too.
return "";
+ }else { //examplesindex
+ return file.getParentFile().getParentFile().getName();
}
+
}
@@ -230,13 +240,14 @@
examples/es/file.adoc generates language es attribute inside the New Doc that is returned.
*/
- if (type.equalsIgnoreCase("examplesindex")) {
- String detectedLanguage = getLanguageFromPath(file, "examples");
- if (detectedLanguage.equalsIgnoreCase("")) {
- return new Doc(group, title, Docs.href(directory, file), file); //default to english "en"
- } else {
- return new Doc(group, title, Docs.href(directory, file), file, detectedLanguage);
- }
+ if (type.equalsIgnoreCase("examplesindex") && file.getParentFile().getName().equalsIgnoreCase("examples")) {
+ String detectedLanguage = getLanguageFromPath(file,this.type);
+ return new Doc(group, title, Docs.href(directory, file), file, detectedLanguage);
+// if (detectedLanguage.equalsIgnoreCase("en")) {
+// return new Doc(group, title, Docs.href(directory, file), file); //default to english "en"
+// } else {
+// return new Doc(group, title, Docs.href(directory, file), file, detectedLanguage);
+// }
} else {
// todo: Here we can implement later when doc type is docindex and not examplesindex
return new Doc(group, title, Docs.href(directory, file), file); //default to english
diff --git a/src/main/java/org/apache/tomee/website/Repos.java b/src/main/java/org/apache/tomee/website/Repos.java
index 2bfd949..69a37e0 100644
--- a/src/main/java/org/apache/tomee/website/Repos.java
+++ b/src/main/java/org/apache/tomee/website/Repos.java
@@ -28,13 +28,15 @@
public class Repos {
public static void download(final Source source) {
+
if (source.getDir().exists()) {
- try {
- pull(source);
- } catch (Exception e) {
- System.out.println("Pull Failed. " + source);
- e.printStackTrace();
- }
+// //temporal commented out for development purposes
+// try {
+// pull(source);
+// } catch (Exception e) {
+// System.out.println("Pull Failed. " + source);
+// e.printStackTrace();
+// }
} else {