package page.misc;

import org.wikiwebserver.core.ConfigManager;
import org.wikiwebserver.core.WareHouse;
import org.wikiwebserver.core.WikiWebServer;
import org.wikiwebserver.handler.http.HTTPException;
import org.wikiwebserver.handler.http.interfaces.HTTPResponder;
import page.config.SiteTemplatedPage;

import page.tools.admin.UserProfile;
import static org.wikiwebserver.html.HTMLHelper.*;

public class DistributeWikiWebServer extends SiteTemplatedPage implements HTTPResponder {
	
    public void generate() throws HTTPException {
        
        setTitle("Distribute - WikiWebServer");       
        
        append(h(1, "Launch WikiWebServer on your computer") +
               p("WikiWebServer can be downloaded and launched locally providing" +
                 " the ability to host web pages, share files and modify any part of " +
                 " the web server.") +  
               p("To launch WikiWebServer only the core is needed (about 50kb)." +
                 " Additional classes and resources will be dynamically downloaded from" +
                 " www.wikiwebserver.org as they are required."));
        
        String localRegister = WareHouse.getUrlPathForClass(UserProfile.class);
        String localManage = WareHouse.getUrlPathForClass(page.tools.admin.ManagementTools.class);
        append(ul(new String[] { 
                "Create a new directory where you would like to keep WikiWebServer.",
                "Download " + a("/WikiWebServerCore.jar", "WikiWebServerCore.jar") + " to the directory",
                "Launch WikiWebServer " + codeBox("java -jar WikiWebServerCore.jar 8080"),
                "Point a web browser at: " + a("http://127.0.0.1:8080/", "http://127.0.0.1:8080/", "target='localWiki'"),
                "Register a " + a("http://127.0.0.1:8080" + localRegister, "new user account", "target='localWiki'"),
                "Give yourself " + a("http://127.0.0.1:8080" + localManage, "super admin privilege", "target='localWiki'") 
                    + " using the super password <b>" + ConfigManager.DEFAULT_SERVER_PASSWORD + "</b>",
                "Now go customise WikiWebServer..." }));  
        
        append(h(2, "Command line options") + codeBox(WikiWebServer.getCommandLineOptions()));
    } 
}

