Added methods for retrieving the correct directory in which resources resided (like js, jsp etc)

This commit is contained in:
Nanne Baars 2015-06-22 13:13:48 +02:00
parent d1d31e158c
commit 08beac23b5
2 changed files with 18 additions and 2 deletions

View File

@ -355,8 +355,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
* @return The lessonPlan value * @return The lessonPlan value
*/ */
protected String getLessonName() { protected String getLessonName() {
int index = this.getClass().getName().indexOf("lessons."); return this.getClass().getSimpleName();
return this.getClass().getName().substring(index + "lessons.".length());
} }
/** /**
@ -738,6 +737,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
Form form = new Form(getFormAction(), Form.POST).setName("form").setEncType(""); Form form = new Form(getFormAction(), Form.POST).setName("form").setEncType("");
form.addElement(createContent(s)); form.addElement(createContent(s));
setContent(form); setContent(form);
s.getRequest().getRequestURL();
} }
public String getFormAction() { public String getFormAction() {
@ -806,4 +806,17 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
} }
return labelManager; return labelManager;
} }
protected final String buildImagePath(WebSession w, String imgResourceName) {
return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/images/" + imgResourceName;
}
protected final String buildJspPath(WebSession w, String jspResourceName) {
return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/jsp/" + jspResourceName;
}
protected final String buildJsPath(WebSession w, String jsResourceName) {
return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/js/" + jsResourceName;
}
} }

View File

@ -10,6 +10,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -119,6 +120,8 @@ public class Plugin {
pluginTarget.getFileName().toString() + "/plugin/" + this.lesson pluginTarget.getFileName().toString() + "/plugin/" + this.lesson
.getSimpleName() + "/lessonPlans/en/" + this.lesson.getSimpleName() + "_files", .getSimpleName() + "/lessonPlans/en/" + this.lesson.getSimpleName() + "_files",
lessonPlansLanguageFiles.values()); lessonPlansLanguageFiles.values());
replaceInFiles("setSrc\\(\"js\\/", "setSrc\\(\"" + pluginTarget.getFileName().toString() + "/plugin/" + this.lesson
.getSimpleName() + "/js/", Arrays.asList(lessonSourceFile));
replaceInFiles("url\\(images", "url\\(" + pluginTarget.getFileName().toString() + "/plugin/" + this.lesson replaceInFiles("url\\(images", "url\\(" + pluginTarget.getFileName().toString() + "/plugin/" + this.lesson
.getSimpleName() + "/jsp/images", cssFiles); .getSimpleName() + "/jsp/images", cssFiles);
} catch (IOException e) { } catch (IOException e) {