/*
 * Copyright 2015 Hippo Seven
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hippo.nimingban.client.ac;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class ACUrl {

    public static final String HOST = "http://h.nimingban.com";

    public static final String API_POST_LIST = HOST + "/Api/showf";

    public static final String API_POST = HOST + "/Api/thread";

    public static final String API_REFERENCE = HOST + "/Home/Forum/ref";

    public static final String API_FEED = HOST + "/Api/feed";

    public static final String API_ADD_FEED = HOST + "/Api/addFeed";

    public static final String API_DEL_FEED = HOST + "/Api/delFeed";

    public static final String API_CREATE_POST = HOST + "/Home/Forum/doPostThread.html";

    public static final String API_GET_COOKIE = HOST + "/Api/getCookie";

    public static final String API_GET_FORUM_LIST = HOST + "/Api/getForumList";

    public static final String API_REPLY = HOST + "/Home/Forum/doReplyThread.html";

    public static final String API_COMMON_POSTS = "http://nimingban.herokuapp.com/common_posts";

    public static final String API_SEARCH = HOST + "/Api/search";

    public static String getPostListUrl(String forum, int page) {
        return API_POST_LIST + "?id=" + forum + "&page=" + (page + 1);
    }

    public static String getPostUrl(String id, int page) {
        return API_POST + "?id=" + id + "&page=" + (page + 1);
    }

    public static String getReferenceUrl(String id) {
        return API_REFERENCE + "?id=" + id;
    }

    public static String getFeedUrl(String uuid, int page) {
        return API_FEED + "?uuid=" + uuid + "&page=" + (page + 1);
    }

    public static String getAddFeedUrl(String uuid, String tid) {
        return API_ADD_FEED + "?uuid=" + uuid + "&tid=" + tid;
    }

    public static String getDelFeedUrl(String uuid, String tid) {
        return API_DEL_FEED + "?uuid=" + uuid + "&tid=" + tid;
    }

    public static String getBrowsablePostUrl(String id, int page) {
        StringBuilder sb = new StringBuilder();
        sb.append(HOST).append("/t/").append(id);
        if (page != 0) {
            sb.append("?page=").append(page + 1);
        }
        return sb.toString();
    }

    public static String getBingSearchUrl(String keyword, int page) throws UnsupportedEncodingException {
        return "http://www.bing.com/search?q=" + URLEncoder.encode(keyword, "UTF-8") + "+site%3ah.nimingban.com&first=" + (page * 10 + 1);
    }

    public static String getSearchUrl(String keyword, int page) throws UnsupportedEncodingException {
        return API_SEARCH + "?q=" + URLEncoder.encode(keyword, "UTF-8") + "&pageNo=" + (page + 1);
    }
}

@@ -725,16 +725,70 @@
 CUrl %7B%0A%0A
+    public static final String APP_ID = %22nimingban%22;%0A%0A
     publ
@@ -909,17 +909,33 @@
 pi/showf
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -990,17 +990,33 @@
 i/thread
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1080,17 +1080,33 @@
 orum/ref
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1159,17 +1159,33 @@
 Api/feed
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1241,25 +1241,41 @@
 /Api/addFeed
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    publi
@@ -1331,17 +1331,33 @@
 /delFeed
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1429,33 +1429,49 @@
 oPostThread.html
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    public st
@@ -1527,17 +1527,33 @@
 etCookie
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1624,17 +1624,33 @@
 orumList
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1725,17 +1725,33 @@
 ead.html
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -1906,17 +1906,33 @@
 i/search
-%22
+?appid=%22 + APP_ID
 ;%0A%0A    p
@@ -2020,25 +2020,25 @@
 OST_LIST + %22
-?
+&
 id=%22 + forum
@@ -2152,25 +2152,25 @@
 API_POST + %22
-?
+&
 id=%22 + id + 
@@ -2285,17 +2285,17 @@
 ENCE + %22
-?
+&
 id=%22 + i
@@ -2384,33 +2384,33 @@
 urn API_FEED + %22
-?
+&
 uuid=%22 + uuid + 
@@ -2528,33 +2528,33 @@
 API_ADD_FEED + %22
-?
+&
 uuid=%22 + uuid + 
@@ -2672,17 +2672,17 @@
 FEED + %22
-?
+&
 uuid=%22 +
@@ -2925,17 +2925,17 @@
 append(%22
-?
+&
 page=%22).
@@ -3382,17 +3382,17 @@
 ARCH + %22
-?
+&
 q=%22 + UR

Add appid