import be.nikiroo.fanfix.library.Template;
import be.nikiroo.utils.Version;
+/**
+ * Utility class to retrieve and fill HTML templates for Fanfix web server.
+ *
+ * @author niki
+ */
public class WebLibraryServerTemplates {
static private WebLibraryServerTemplates instance = new WebLibraryServerTemplates();
+ /**
+ * Get the (unique) instance of this {@link WebLibraryServerTemplates}.
+ *
+ * @return the (unique) instance
+ */
static public WebLibraryServerTemplates getInstance() {
return instance;
}
;
}
+ public Template index(boolean banner, List<Template> content) {
+ String favicon = "favicon.ico";
+ String icon = Instance.getInstance().getUiConfig()
+ .getString(UiConfig.PROGRAM_ICON);
+ if (icon != null) {
+ favicon = "icon_" + icon.replace("-", "_") + ".png";
+ }
+
+ Template index = new Template(getClass(), "index.html") //
+ .set("title", "Fanfix") //
+ .set("favicon", favicon) //
+ .set("content", content) //
+ ;
+
+ if (banner) {
+ index.set("banner", new Template(getClass(), "index.banner.html") //
+ .set("favicon", favicon) //
+ .set("version", Version.getCurrentVersion().toString()) //
+ );
+ } else {
+ index.set("banner", "");
+ }
+
+ return index;
+ }
+
+ public Template login(String url) {
+ return new Template(getClass(), "login.html") //
+ .set("url", url) //
+ ;
+ }
+
+ public Template message(String message, boolean error) {
+ return new Template(getClass(), "message.html") //
+ .set("class", error ? "message error" : "message") //
+ .set("message", message) //
+ ;
+ }
+
public Template browser(String selectedValue, String filter,
List<Template> selects) {
return new Template(getClass(), "browser.html") //
;
}
- public Template index(boolean banner, List<Template> content) {
- String favicon = "favicon.ico";
- String icon = Instance.getInstance().getUiConfig()
- .getString(UiConfig.PROGRAM_ICON);
- if (icon != null) {
- favicon = "icon_" + icon.replace("-", "_") + ".png";
- }
-
- Template index = new Template(getClass(), "index.html") //
- .set("title", "Fanfix") //
- .set("favicon", favicon) //
- .set("content", content) //
+ public Template viewerDesc(String title, String href, String cover,
+ List<Template> desclines) {
+ return new Template(getClass(), "viewer.desc.html") //
+ .set("title", title) //
+ .set("href", href) //
+ .set("cover", cover) //
+ .set("details", desclines) //
;
-
- if (banner) {
- index.set("banner", new Template(getClass(), "index.banner.html") //
- .set("favicon", favicon) //
- .set("version", Version.getCurrentVersion().toString()) //
- );
- } else {
- index.set("banner", "");
- }
-
- return index;
}
- public Template viewer(Template browser, List<Template> booklines) {
- // TODO
- return null;
+ public Template viewerDescline(String key, String value) {
+ return new Template(getClass(), "viewer.descline.html") //
+ .set("key", key) //
+ .set("value", value) //
+ ;
}
public Template viewerImage(String src, String href, String zoomStyle) {
;
}
- public Template viewerText(List<Template> desc, List<Template> content) {
+ public Template viewerText(Template desc, String content) {
return new Template(getClass(), "viewer.text.html") //
.set("desc", desc) //
.set("content", content) //
;
}
- public Template viewerLink(String name, String link, String className) {
+ public Template viewerLink(String name, String link, boolean selected) {
return new Template(getClass(), "viewer.link.html") //
.set("link", link) //
- .set("class", className) //
+ .set("class", selected ? "selected" : "") //
.set("name", name) //
;
}
;
}
- // numberOfButtons = 4 or 1 or the moment
+ // supported numberOfButtons = 4 or 1 or the moment
public Template viewerOptionbar(int numberOfButtons,
List<Template> buttons) {
return new Template(getClass(), "viewer.optionbar.html") //