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
browser(String selectedValue
, String filter
,
38 List
<Template
> selects
) {
39 return new Template(getClass(), "browser.html") //
40 .set("sourcesSelected",
41 "sources".equals(selectedValue
) ?
"selected='selected'"
43 .set("authorsSelected",
44 "authors".equals(selectedValue
) ?
"selected='selected'"
47 "tags".equals(selectedValue
) ?
"selected='selected'"
49 .set("filter", filter
) //
50 .set("selects", selects
) //
54 public Template
browserOption(String name
, String value
,
55 String selectedValue
) {
56 return new Template(getClass(), "browser.option.html") //
57 .set("value", value
) //
59 value
.equals(selectedValue
) ?
"selected='selected'"
65 public Template
browserSelect(String name
, String value
,
66 List
<Template
> options
) {
67 return new Template(getClass(), "browser.select.html") //
69 .set("value", value
) //
70 .set("options", options
) //
74 public Template
index(boolean banner
, List
<Template
> content
) {
75 String favicon
= "favicon.ico";
76 String icon
= Instance
.getInstance().getUiConfig()
77 .getString(UiConfig
.PROGRAM_ICON
);
79 favicon
= "icon_" + icon
.replace("-", "_") + ".png";
82 Template index
= new Template(getClass(), "index.html") //
83 .set("title", "Fanfix") //
84 .set("favicon", favicon
) //
85 .set("content", content
) //
89 index
.set("banner", new Template(getClass(), "index.banner.html") //
90 .set("favicon", favicon
) //
91 .set("version", Version
.getCurrentVersion().toString()) //
94 index
.set("banner", "");
100 public Template
viewer(Template browser
, List
<Template
> booklines
) {
105 public Template
viewerImage(String src
, String href
, String zoomStyle
) {
106 return new Template(getClass(), "viewer.image.html") //
108 .set("href", href
) //
109 .set("zoomStyle", zoomStyle
) //
113 public Template
viewerText(List
<Template
> desc
, List
<Template
> content
) {
114 return new Template(getClass(), "viewer.text.html") //
115 .set("desc", desc
) //
116 .set("content", content
) //
120 public Template
viewerLink(String name
, String link
, String className
) {
121 return new Template(getClass(), "viewer.link.html") //
122 .set("link", link
) //
123 .set("class", className
) //
124 .set("name", name
) //
128 public Template
viewerNavbar(int current
, List
<Template
> links
,
129 String hrefFirst
, String hrefPrevious
, String hrefNext
,
130 String hrefLast
, boolean disabledFirst
, boolean disabledPrevious
,
131 boolean disabledNext
, boolean disabledLast
) {
132 return new Template(getClass(), "viewer.navbar.html") //
133 .set("disabledFirst",
134 disabledFirst ?
"disabled='disabled'" : "") //
135 .set("disabledPrevious",
136 disabledPrevious ?
"disabled='disabled'" : "") //
137 .set("disabledNext", disabledNext ?
"disabled='disabled'" : "") //
138 .set("disabledLast", disabledLast ?
"disabled='disabled'" : "") //
139 .set("hrefFirst", hrefFirst
) //
140 .set("hrefPrevious", hrefPrevious
) //
141 .set("hrefNext", hrefNext
) //
142 .set("hrefLast", hrefLast
) //
143 .set("current", Integer
.toString(current
)) //
144 .set("links", links
) //
148 // numberOfButtons = 4 or 1 or the moment
149 public Template
viewerOptionbar(int numberOfButtons
,
150 List
<Template
> buttons
) {
151 return new Template(getClass(), "viewer.optionbar.html") //
152 .set("classSize", "s" + numberOfButtons
) //
153 .set("buttons", buttons
) //
157 public Template
viewerOptionbarButton(String value
, String href
,
158 String className
, boolean disabled
) {
159 return new Template(getClass(), "viewer.optionbar.button.html") //
160 .set("disabled", disabled ?
"disabled='disabled'" : "") //
161 .set("class", className
) //
162 .set("href", href
) //
163 .set("value", value
) //