1 package be
.nikiroo
.fanfix
.library
.web
.templates
;
5 import be
.nikiroo
.fanfix
.Instance
;
6 import be
.nikiroo
.fanfix
.bundles
.UiConfig
;
7 import be
.nikiroo
.fanfix
.library
.Template
;
8 import be
.nikiroo
.utils
.Version
;
10 public class WebLibraryServerTemplates
{
11 static private WebLibraryServerTemplates instance
= new WebLibraryServerTemplates();
13 static public WebLibraryServerTemplates
getInstance() {
17 public Template
bookline(String luid
, String href
, String title
,
18 String author
, boolean cached
) {
20 String cachedClass
= "cached";
21 String cachedValue
= "◉";
23 cachedClass
= "uncached";
24 cachedValue
= "○";
27 return new Template(getClass(), "bookline.html") //
29 .set("cachedClass", cachedClass
) //
30 .set("cached", cachedValue
) //
32 .set("title", title
) //
33 .set("author", author
) //
37 public Template
index(boolean banner
, List
<Template
> content
) {
38 String favicon
= "favicon.ico";
39 String icon
= Instance
.getInstance().getUiConfig()
40 .getString(UiConfig
.PROGRAM_ICON
);
42 favicon
= "icon_" + icon
.replace("-", "_") + ".png";
45 Template index
= new Template(getClass(), "index.html") //
46 .set("title", "Fanfix") //
47 .set("favicon", favicon
) //
48 .set("content", content
) //
52 index
.set("banner", new Template(getClass(), "index.banner.html") //
53 .set("favicon", favicon
) //
54 .set("version", Version
.getCurrentVersion().toString()) //
57 index
.set("banner", "");
63 public Template
login(String url
) {
64 return new Template(getClass(), "login.html") //
69 public Template
message(String message
, boolean error
) {
70 return new Template(getClass(), "message.html") //
71 .set("class", error ?
"message error" : "message") //
72 .set("message", message
) //
76 public Template
browser(String selectedValue
, String filter
,
77 List
<Template
> selects
) {
78 return new Template(getClass(), "browser.html") //
79 .set("sourcesSelected",
80 "sources".equals(selectedValue
) ?
"selected='selected'"
82 .set("authorsSelected",
83 "authors".equals(selectedValue
) ?
"selected='selected'"
86 "tags".equals(selectedValue
) ?
"selected='selected'"
88 .set("filter", filter
) //
89 .set("selects", selects
) //
93 public Template
browserOption(String name
, String value
,
94 String selectedValue
) {
95 return new Template(getClass(), "browser.option.html") //
96 .set("value", value
) //
98 value
.equals(selectedValue
) ?
"selected='selected'"
100 .set("name", name
) //
104 public Template
browserSelect(String name
, String value
,
105 List
<Template
> options
) {
106 return new Template(getClass(), "browser.select.html") //
107 .set("name", name
) //
108 .set("value", value
) //
109 .set("options", options
) //
113 public Template
viewer(Template browser
, List
<Template
> booklines
) {
118 public Template
viewerImage(String src
, String href
, String zoomStyle
) {
119 return new Template(getClass(), "viewer.image.html") //
121 .set("href", href
) //
122 .set("zoomStyle", zoomStyle
) //
126 public Template
viewerText(List
<Template
> desc
, List
<Template
> content
) {
127 return new Template(getClass(), "viewer.text.html") //
128 .set("desc", desc
) //
129 .set("content", content
) //
133 public Template
viewerLink(String name
, String link
, String className
) {
134 return new Template(getClass(), "viewer.link.html") //
135 .set("link", link
) //
136 .set("class", className
) //
137 .set("name", name
) //
141 public Template
viewerNavbar(int current
, List
<Template
> links
,
142 String hrefFirst
, String hrefPrevious
, String hrefNext
,
143 String hrefLast
, boolean disabledFirst
, boolean disabledPrevious
,
144 boolean disabledNext
, boolean disabledLast
) {
145 return new Template(getClass(), "viewer.navbar.html") //
146 .set("disabledFirst",
147 disabledFirst ?
"disabled='disabled'" : "") //
148 .set("disabledPrevious",
149 disabledPrevious ?
"disabled='disabled'" : "") //
150 .set("disabledNext", disabledNext ?
"disabled='disabled'" : "") //
151 .set("disabledLast", disabledLast ?
"disabled='disabled'" : "") //
152 .set("hrefFirst", hrefFirst
) //
153 .set("hrefPrevious", hrefPrevious
) //
154 .set("hrefNext", hrefNext
) //
155 .set("hrefLast", hrefLast
) //
156 .set("current", Integer
.toString(current
)) //
157 .set("links", links
) //
161 // numberOfButtons = 4 or 1 or the moment
162 public Template
viewerOptionbar(int numberOfButtons
,
163 List
<Template
> buttons
) {
164 return new Template(getClass(), "viewer.optionbar.html") //
165 .set("classSize", "s" + numberOfButtons
) //
166 .set("buttons", buttons
) //
170 public Template
viewerOptionbarButton(String value
, String href
,
171 String className
, boolean disabled
) {
172 return new Template(getClass(), "viewer.optionbar.button.html") //
173 .set("disabled", disabled ?
"disabled='disabled'" : "") //
174 .set("class", className
) //
175 .set("href", href
) //
176 .set("value", value
) //