<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>${metadata.alias!}</title>
    <style>
        .red{color:#f00;}
    </style>
</head>
<body>
    <header>
        <h1>${(site.name)!}</h1>
    </header>
    <nav>
        <a href="${base}">Home</a>
<@_categoryList>
    <#list page.list as a>
        <a href="${a.url!}" target="_blank">${a.name}</a>
    </#list>
</@_categoryList>
    </nav>
    <main>
        <#macro message code>${springMacroRequestContext.getMessage(code)}</#macro>
        <#if error?has_content>
            <p class="message red"><@message 'message.'+error/></p>
        <#elseif message?has_content>
            <p class="message"><@message "message."+message/></p>
        <#else>
            <#if user?has_content>
                <p>${user.nickName},You are already logged in!<a href="javascript:logout();">You can logout</a></p>
                <form name="logout" action="${site.dynamicPath}doLogout" method="post">
                    <input type="hidden" name="userId" value="${(user.id)!}"/>
                    <input type="hidden" name="returnUrl" value="${returnUrl!site.sitePath!}"/>
                </form>
                <#if !user.emailChecked>
                    <form action="${site.dynamicPath}user/saveEmail" method="post" class="center login-form">
                        <input type="hidden" name="_csrf" value="<@_csrfToken/>"/>
                        <input type="hidden" name="returnUrl" value="${site.dynamicPath}login.html"/>
                        <p>
                            <input type="email" class="input-text" name="email" placeholder="Email" title="Email" value="${user.email!}"/>
                            <input type="submit" class="button" value="Verify Email"/>
                        </p>
                    </form>
                </#if>
            <#else>
                <form action="${site.dynamicPath}doLogin" method="post">
                    <#if error??>
                        <p class="red">${springMacroRequestContext.getMessage(error,error)}</p>
                    </#if>
                    <p><input type="text" name="username" placeholder="User name" title="User name"/></p>
                    <p><input type="password" name="password" placeholder="Password" title="Password"/></p>
                    <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="Login"/>
                    </p>
                    <#if _oauthList??&&_oauthList?is_directive>
                        <@_oauthList>
                            <p><#list list as o><a href="${site.dynamicPath}oauth/login/${o}">Login by ${o}</a><#sep> </#list></p>
                        </@_oauthList>
                    </#if>
                    <p>No account?<a href="register.html?clientId=${clientId!}&uuid=${uuid!}&returnUrl=${returnUrl!}">Please register</a></p>
                </form>
            </#if>
        </#if>
    </main>
    <footer>
        Copyright &copy; ${.now?string('yyyy')}
    </footer>
    <script src="${site.dynamicPath!}resource/js/jquery-1.12.4.min.js"></script>
    <script>
    function logout(){
        $("form[name=logout]").submit();
    }
    </script>
    <script src="${site.dynamicPath}resource/js/cms.analytics.js"></script>
    <script>
        var ca = cmsAnalytics();
        var url='${site.dynamicPath}api/visit/record';
        if("string" ==typeof itemString){
            url=url+"?"+itemString;
        }
        ca.report(url);
    </script>
</body>
</html>