package act_site;

import act.Act;
import act.Version;
import act.app.conf.AppConfigurator;
import act.boot.app.RunApp;
import act.db.morphia.MorphiaDao;
import act.util.ActContext;
import act.view.TemplatePathResolver;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.result.Result;

import java.io.File;
import java.util.Locale;

import static act.controller.Controller.Util.download;
import static act.controller.Controller.Util.render;

public class WebSite {

    public static class MyConfiguration extends AppConfigurator {
        @Override
        public void configure() {
            templatePathResolver(new TemplatePathResolver() {
                @Override
                protected String resolveTemplatePath(String path, ActContext context) {
                    String resolved = super.resolveTemplatePath(path, context);
                    Locale locale = context.locale(true);
                    if ("zh".equals(locale.getLanguage())) {
                        resolved = "/cn" + (resolved.startsWith("/") ? "" : "/") + resolved;
                    }
                    return resolved;
                }
            });
        }
    }

    @GetAction
    public void home(MorphiaDao<Skeleton> skeletonDao, Video.Dao videoDao) {
        Iterable<Skeleton> skeletons = skeletonDao.findAll();
        Iterable<Video> videos = videoDao.findAll();
        render(skeletons, videos);
    }

    public static void main(String[] args) throws Exception {
        Act.start("Act", Version.appVersion(), WebSite.class);
    }

}

@@ -32,28 +32,8 @@
 ct;%0A
-import act.Version;%0A
 impo
@@ -69,36 +69,8 @@
 or;%0A
-import act.boot.app.RunApp;%0A
 impo
@@ -211,145 +211,34 @@
 on;%0A
-import org.osgl.mvc.result.Result;%0A%0Aimport java.io.File;%0Aimport java.util.Locale;%0A%0Aimport static act.controller.Controller.Util.download;
+%0Aimport java.util.Locale;%0A
 %0Aimp
@@ -1343,48 +1343,20 @@
 t(%22A
-ct%22, Version.appVersion(), WebSite.class
+CT WEB SITE%22
 );%0A 

rename app to ACT WEB SITE