1 package be
.nikiroo
.fanfix
.library
;
4 static public final String INDEX_URL
= "/";
6 static public final String VERSION_URL
= "/version";
8 static public final String LOGOUT_URL
= "/logout";
10 static public final String EXIT_URL
= "/exit";
12 static private final String VIEWER_URL_BASE
= "/view/story/";
13 static private final String VIEWER_URL
= VIEWER_URL_BASE
14 + "{luid}/{chap}/{para}";
16 static private final String STORY_URL_BASE
= "/story/";
17 static private final String STORY_URL
= STORY_URL_BASE
18 + "{luid}/{chap}/{para}";
19 static private final String STORY_URL_COVER
= STORY_URL_BASE
21 static private final String STORY_URL_JSON
= STORY_URL_BASE
+ "{luid}/json";
22 static private final String STORY_URL_METADATA
= STORY_URL_BASE
25 // GET/SET ("value" param -> set STA to this value)
26 static private final String STORY_URL_SOURCE
= STORY_URL_BASE
28 static private final String STORY_URL_TITLE
= STORY_URL_BASE
30 static private final String STORY_URL_AUTHOR
= STORY_URL_BASE
33 static private final String LIST_URL_BASE
= "/list/";
35 static public final String LIST_URL_METADATA
= LIST_URL_BASE
+ "metadata";
37 // "import" requires param "url" and return an luid, "/{luid}" return
38 // progress status as a JSON Progress or 404 if none (done or failed)
39 static private final String IMPRT_URL_BASE
= "/import/";
40 static private final String IMPRT_URL_PROGRESS
= IMPRT_URL_BASE
+ "{luid}";
41 static public final String IMPRT_URL_IMPORT
= IMPRT_URL_BASE
+ "import";
43 static private final String DELETE_URL_BASE
= "/delete/";
44 static private final String DELETE_URL_STORY
= DELETE_URL_BASE
+ "{luid}";
46 // GET/SET ("luid" param -> set cover to the cover of this story -- not ok
48 static private final String COVER_URL_BASE
= "/cover/";
49 static private final String COVER_URL_STORY
= COVER_URL_BASE
51 static private final String COVER_URL_AUTHOR
= COVER_URL_BASE
53 static private final String COVER_URL_SOURCE
= COVER_URL_BASE
56 static public String
getViewUrl(String luid
, Integer chap
, Integer para
) {
58 .replace("{luid}", luid
) //
59 .replace("/{chap}", chap
== null ?
"" : "/" + chap
) //
61 (chap
== null || para
== null) ?
"" : "/" + para
);
64 static public String
getStoryUrl(String luid
, int chap
, Integer para
) {
66 .replace("{luid}", luid
) //
67 .replace("{chap}", Integer
.toString(chap
)) //
68 .replace("{para}", para
== null ?
"" : Integer
.toString(para
));
71 static public String
getStoryUrlCover(String luid
) {
72 return STORY_URL_COVER
//
73 .replace("{luid}", luid
);
76 static public String
getStoryUrlJson(String luid
) {
77 return STORY_URL_JSON
//
78 .replace("{luid}", luid
);
81 static public String
getStoryUrlSource(String luid
) {
82 return STORY_URL_SOURCE
//
83 .replace("{luid}", luid
);
86 static public String
getStoryUrlTitle(String luid
) {
87 return STORY_URL_TITLE
//
88 .replace("{luid}", luid
);
91 static public String
getStoryUrlAuthor(String luid
) {
92 return STORY_URL_AUTHOR
//
93 .replace("{luid}", luid
);
96 static public String
getStoryUrlMetadata(String luid
) {
97 return STORY_URL_METADATA
//
98 .replace("{luid}", luid
);
101 static public String
getImprtProgressUrl(String luid
) {
102 return IMPRT_URL_PROGRESS
//
103 .replace("{luid}", luid
);
106 static public boolean isSupportedUrl(String url
,
107 boolean requiresLoginOnly
) {
108 if (requiresLoginOnly
) {
109 return INDEX_URL
.equals(url
) || LOGOUT_URL
.equals(url
)
110 || EXIT_URL
.equals(url
) || isViewUrl(url
) || isStoryUrl(url
)
111 || isListUrl(url
) || isCoverUrl(url
) || isImprtUrl(url
)
115 return isSupportedUrl(url
, true) || VERSION_URL
.equals(url
);
118 static public String
getCoverUrlStory(String luid
) {
119 return COVER_URL_STORY
//
120 .replace("{luid}", luid
);
123 static public String
getCoverUrlSource(String source
) {
124 return COVER_URL_SOURCE
//
125 .replace("{source}", source
);
128 static public String
getCoverUrlAuthor(String author
) {
129 return COVER_URL_AUTHOR
//
130 .replace("{author}", author
);
133 static public String
getDeleteUrlStory(String luid
) {
134 return DELETE_URL_STORY
//
135 .replace("{luid}", luid
);
138 static public boolean isViewUrl(String url
) {
139 return url
!= null && url
.startsWith(VIEWER_URL_BASE
);
142 static public boolean isStoryUrl(String url
) {
143 return url
!= null && url
.startsWith(STORY_URL_BASE
);
146 static public boolean isListUrl(String url
) {
147 return url
!= null && url
.startsWith(LIST_URL_BASE
);
150 static public boolean isCoverUrl(String url
) {
151 return url
!= null && url
.startsWith(COVER_URL_BASE
);
154 static public boolean isImprtUrl(String url
) {
155 return url
!= null && url
.startsWith(IMPRT_URL_BASE
);
158 static public boolean isDeleteUrl(String url
) {
159 return url
!= null && url
.startsWith(DELETE_URL_BASE
);