package io.loli.box.controller;

import io.loli.box.startup.LoliBoxConfig;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import jetbrick.template.JetEngine;
import jetbrick.template.JetTemplate;

import org.glassfish.jersey.server.mvc.Template;

/**
 * Action for index page "/" and "index.html"
 * 
 * @author choco
 *
 */
@Template
@Path("/")
public class IndexAction {

    /**
     * Template engine to generate html
     */
    private static JetEngine engine = JetEngine.create();

    /**
     * Default encoding
     */
    private static final String encoding = "UTF-8";

    @Produces("text/html;charset=" + encoding)
    @GET
    public String index() {
        JetTemplate template = engine.getTemplate("/html/fullIndex.html");
        Map<String, Object> context = new HashMap<String, Object>();
        context.put("email", LoliBoxConfig.getInstance().getEmail());
        StringWriter writer = new StringWriter();
        template.render(context, writer);
        return writer.toString();
    }

    /**
     * Index page for http method POST
     * <p>
     * Some browsers like QQBrowser will send post request while change to
     * chrome model from IE model
     * 
     * @return Generated html of index page
     */
    @Produces("text/html;charset=" + encoding)
    @POST
    public String indexPost() {
        return index();
    }

    @Produces("text/html;charset=" + encoding)
    @GET
    @Path("index.html")
    public String indexHtml() {
        return index();
    }
}

@@ -240,24 +240,29 @@
 x.ws.rs.
-Produces
+core.Response
 ;%0A%0Aimpor
@@ -627,148 +627,8 @@
 );%0A%0A
-    /**%0A     * Default encoding%0A     */%0A    private static final String encoding = %22UTF-8%22;%0A%0A    @Produces(%22text/html;charset=%22 + encoding)%0A
     
@@ -639,30 +639,32 @@
 %0A    public 
-String
+Response
  index() %7B%0A 
@@ -983,16 +983,28 @@
  return 
+Response.ok(
 writer.t
@@ -1012,16 +1012,52 @@
 String()
+, %22text/html;charset=UTF-8%22).build()
 ;%0A    %7D%0A
@@ -1288,55 +1288,8 @@
  */%0A
-    @Produces(%22text/html;charset=%22 + encoding)%0A
     
@@ -1301,30 +1301,32 @@
 %0A    public 
-String
+Response
  indexPost()
@@ -1363,55 +1363,8 @@
  %7D%0A%0A
-    @Produces(%22text/html;charset=%22 + encoding)%0A
     
@@ -1403,22 +1403,24 @@
  public 
-String
+Response
  indexHt

Add charset=UTF-8 to response Charset in @Produces annotation doesn't work