weblib: set custom covers
[fanfix.git] / src / be / nikiroo / fanfix / library / WebLibraryUrls.java
CommitLineData
5ee0fc14
NR
1package be.nikiroo.fanfix.library;
2
33d40b9f 3class WebLibraryUrls {
5ee0fc14
NR
4 static public final String INDEX_URL = "/";
5
6 static public final String VERSION_URL = "/version";
7
8 static public final String LOGOUT_URL = "/logout";
9
10 static private final String VIEWER_URL_BASE = "/view/story/";
11 static private final String VIEWER_URL = VIEWER_URL_BASE
12 + "{luid}/{chap}/{para}";
13
14 static private final String STORY_URL_BASE = "/story/";
15 static private final String STORY_URL = STORY_URL_BASE
16 + "{luid}/{chap}/{para}";
17 static private final String STORY_URL_COVER = STORY_URL_BASE
18 + "{luid}/cover";
19 static private final String STORY_URL_JSON = STORY_URL_BASE + "{luid}/json";
20
21 static private final String LIST_URL_BASE = "/list/";
22
d5581157 23 static public final String LIST_URL_METADATA = LIST_URL_BASE + "metadata";
5ee0fc14 24
e4b1b70c
NR
25 // GET/SET ("luid" param -> set cover to the cover of this story -- not ok
26 // for /cover/story/)
6673ec59
NR
27 static private final String COVER_URL_BASE = "/cover/";
28 static private final String COVER_URL_STORY = COVER_URL_BASE
29 + "story/{luid}";
30 static private final String COVER_URL_AUTHOR = COVER_URL_BASE
31 + "author/{author}";
32 static private final String COVER_URL_SOURCE = COVER_URL_BASE
33 + "source/{source}";
34
5ee0fc14
NR
35 static public String getViewUrl(String luid, Integer chap, Integer para) {
36 return VIEWER_URL //
37 .replace("{luid}", luid) //
38 .replace("/{chap}", chap == null ? "" : "/" + chap) //
39 .replace("/{para}",
40 (chap == null || para == null) ? "" : "/" + para);
41 }
42
43 static public String getStoryUrl(String luid, int chap, Integer para) {
44 return STORY_URL //
45 .replace("{luid}", luid) //
46 .replace("{chap}", Integer.toString(chap)) //
47 .replace("{para}", para == null ? "" : Integer.toString(para));
48 }
49
50 static public String getStoryUrlCover(String luid) {
51 return STORY_URL_COVER //
52 .replace("{luid}", luid);
53 }
54
55 static public String getStoryUrlJson(String luid) {
56 return STORY_URL_JSON //
57 .replace("{luid}", luid);
58 }
59
60 static public boolean isSupportedUrl(String url) {
61 return INDEX_URL.equals(url) || VERSION_URL.equals(url)
62 || LOGOUT_URL.equals(url) || isViewUrl(url) || isStoryUrl(url)
6673ec59
NR
63 || isListUrl(url) || isCoverUrl(url);
64 }
65
66 static public String getCoverUrlStory(String luid) {
67 return COVER_URL_STORY //
68 .replace("{luid}", luid);
69 }
70
71 static public String getCoverUrlSource(String source) {
72 return COVER_URL_SOURCE //
73 .replace("{source}", source);
74 }
75
76 static public String getCoverUrlAuthor(String author) {
77 return COVER_URL_AUTHOR //
78 .replace("{author}", author);
5ee0fc14
NR
79 }
80
81 static public boolean isViewUrl(String url) {
82 return url != null && url.startsWith(VIEWER_URL_BASE);
83 }
84
85 static public boolean isStoryUrl(String url) {
86 return url != null && url.startsWith(STORY_URL_BASE);
87 }
88
89 static public boolean isListUrl(String url) {
90 return url != null && url.startsWith(LIST_URL_BASE);
91 }
6673ec59
NR
92
93 static public boolean isCoverUrl(String url) {
94 return url != null && url.startsWith(COVER_URL_BASE);
95 }
5ee0fc14 96}