Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Update #168: add all generated JS files, remove old code, improve som…
Browse files Browse the repository at this point in the history
…e generated files.
  • Loading branch information
hdsdi3g committed Dec 26, 2015
1 parent 6a57be2 commit 3cf646a
Show file tree
Hide file tree
Showing 116 changed files with 10,716 additions and 857 deletions.
6 changes: 0 additions & 6 deletions app/ext/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import hd3gtv.mydmam.auth.AuthenticationBackend;
import hd3gtv.mydmam.db.CassandraDb;
import hd3gtv.mydmam.web.JSSourceManager;
import hd3gtv.mydmam.web.JSXTransformer;
import hd3gtv.mydmam.web.JsCompile;
import hd3gtv.mydmam.web.Privileges;
import models.ACLGroup;
import models.ACLRole;
Expand Down Expand Up @@ -183,10 +181,6 @@ public void doJob() {
Loggers.Play.error("Can't load all JS Databases", e);
}

JsCompile.purgeBinDirectory();
JSXTransformer.transformAllJSX();
JsCompile.prepareFiles();

try {
CassandraDb.getkeyspace();
} catch (ConnectionException e) {
Expand Down
47 changes: 46 additions & 1 deletion app/hd3gtv/mydmam/web/AJSController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -35,6 +38,7 @@
import hd3gtv.mydmam.web.AJSControllerItem.Verb;
import hd3gtv.tools.GsonIgnoreStrategy;
import models.UserProfile;
import play.Play;
import play.vfs.VirtualFile;

public class AJSController {
Expand Down Expand Up @@ -62,7 +66,7 @@ public class AJSController {
/**
* Get all class files from all ASYNC_CLASS_PATH directory, module by module.
*/
List<VirtualFileModule> main_dirs = JsCompile.getAllfromRelativePath(ASYNC_CLASS_PATH, true, true);
List<VirtualFileModule> main_dirs = getAllfromRelativePath(ASYNC_CLASS_PATH, true, true);
List<VirtualFile> class_vfiles = new ArrayList<VirtualFile>();
for (int pos = 0; pos < main_dirs.size(); pos++) {
class_vfiles.addAll(main_dirs.get(pos).getVfile().list());
Expand Down Expand Up @@ -104,6 +108,47 @@ public class AJSController {

}

/**
* Get all items named and on this path, from all modules, and not only the first.
*/
private static List<VirtualFileModule> getAllfromRelativePath(String path, boolean must_exists, boolean must_directory) {
List<VirtualFileModule> file_list = new ArrayList<VirtualFileModule>();

LinkedHashMap<VirtualFile, String> path_modules = new LinkedHashMap<VirtualFile, String>();
for (VirtualFile vfile : Play.roots) {
/**
* 1st pass : add all paths (main and modules).
*/
path_modules.put(vfile, "internal");
}
for (Map.Entry<String, VirtualFile> entry : Play.modules.entrySet()) {
/**
* 2nd pass : overload enties with modules names.
*/
path_modules.put(entry.getValue(), entry.getKey());
}

VirtualFile child;
for (Map.Entry<VirtualFile, String> entry : path_modules.entrySet()) {
child = entry.getKey().child(path);
if (must_exists & (child.exists() == false)) {
continue;
}
if (must_directory & (child.isDirectory() == false)) {
continue;
}
file_list.add(new VirtualFileModule(child, entry.getValue()));
}

Collections.sort(file_list, new Comparator<VirtualFileModule>() {
public int compare(VirtualFileModule o1, VirtualFileModule o2) {
return o1.getVfile().getName().compareToIgnoreCase(o2.getVfile().getName());
}
});

return file_list;
}

private static boolean isControllerIsEnabled(Class<?> controller) {
try {
Method[] ms = controller.getMethods();
Expand Down
6 changes: 3 additions & 3 deletions app/hd3gtv/mydmam/web/JSProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ public void writeTo(File filename) throws IOException {

public void wrapScopeDeclaration(String source_scope) {
StringBuilder sb = new StringBuilder(input.length() + 100);
sb.append("(function(");
sb.append("/** This file is automatically generated! Do not edit. */ (function(");
if (source_scope.lastIndexOf(".") > -1) {
sb.append(source_scope.substring(source_scope.lastIndexOf(".") + 1, source_scope.length()));
} else {
sb.append(source_scope);
}
sb.append(") {\n");
sb.append(") { ");
sb.append(input);
sb.append("\n})(window.");
sb.append(source_scope);
Expand All @@ -178,7 +178,7 @@ public void wrapScopeDeclaration(String source_scope) {
sb.append(getClass().getName());
sb.append(" the ");
sb.append(new Date());
sb.append(" on git version: ");
sb.append(" with MyDMAM git version: ");
sb.append(GitInfo.getFromRoot().getActualRepositoryInformation());
sb.append("\n");

Expand Down
Loading

0 comments on commit 3cf646a

Please sign in to comment.