<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>${metadata.alias!}</title>
    <style>
        .red{color:#f00;}
    </style>
</head>
<body>
    <header data-diy="page">
        <h1>${(site.name)!}</h1>
    </header>
    <nav data-diy="category">
        <a href="${site.dynamicPath}">Home</a>
<@cms.categoryList>
    <#list page.list as a>
        <a href="${a.url!}" target="_blank" data-diy-item="${a.id}">${a.name}</a>
    </#list>
</@cms.categoryList>
    </nav>
    <main data-diy="config" data-diy-id="site">
        <#if user?has_content>
            <p>${user.nickname},You are already logged in!<a href="javascript:logout();">You can logout</a></p>
            <form action="${site.dynamicPath}doLogout" method="post">
                <input type="hidden" name="userId" value="${(user.id)!}"/>
                <input type="hidden" name="returnUrl" value="${returnUrl!site.sitePath!}"/>
            </form>
        <#else>
            <form action="${site.dynamicPath}doRegister" method="post">
                <#if error?has_content>
                    <p class="red">${springMacroRequestContext.getMessage(error,error)}</p>
                </#if>
                <p><input type="text" name="name" placeholder="User name" title="User name" value="${name!}"/></p>
                <p><input type="text" name="nickname" placeholder="Nickname" title="Nickname" value="${nickname!}"/></p>
                <p><input type="password" name="password" placeholder="Password" title="Password"/></p>
                <p><input type="password" name="repassword" placeholder="Repeat password" title="Repeat password"/></p>
                <@sys.configData code="safe">
                    <#if object.captcha?has_content && object.captcha?split(",")?seq_contains("register")>
                <p>
                    <input name="captcha" type="text" autocomplete="off" placeholder="Captcha" title="Captcha"/>
                    <img src="${site.dynamicPath}getCaptchaImage?${.now?long}" alt="captcha" onclick="this.src=this.src+'&'+new Date().getTime()"/>
                </p>
                    </#if>
                </@sys.configData>
                <p>
                    <input type="hidden" name="returnUrl" value="${returnUrl!}"/>
                    <input type="hidden" name="clientId" value="${clientId!}"/>
                    <input type="hidden" name="uuid" value="${uuid!}"/>
                    <input type="submit" value="Register"/>
                </p>
                <p>Already have an account?<a href="login.html?clientId=${clientId!}&uuid=${uuid!}&returnUrl=${returnUrl!}">Please login</a></p>
            </form>
        </#if>
    </main>
    <footer>
        Copyright &copy; ${.now?string('yyyy')}
    </footer>
    <script src="${site.dynamicPath!}resource/plugins/jquery/jquery.min.js"></script>
    <script>
    function logout(){
        $("form").trigger("submit");
    }
    </script>
    <script>
    var templatePath='${.current_template_name?keep_after('/')}';
    </script>
    <script src="${site.dynamicPath}resource/js/cms.support.js"></script>
    <script>
        var ca = cmsAnalytics();
        var url='${site.dynamicPath}api/visit/record';
        if("string" ==typeof itemString){
            url=url+"?"+itemString;
        }
        ca.setDomain('${site.sitePath?keep_after('//')?keep_before('/')?keep_before(':')}');
        ca.setPath('/');
        ca.report(url);
    </script>
</body>
</html>