rhymix/common/tpl/common_layout.html
Kijin Sung e2511a0269 Insert CSRF token using meta tag in common_layout.html
<body> 태그의 속성이나 그 밖의 태그를 사용하지 않는 이유는
<body>가 로딩되기 전에 먼저 AJAX 요청을 시도하는 서드파티 자료가 있기 때문이다.
<head> 상단에 CSRF 토큰을 넣어야 이런 자료에서도 토큰이 누락되지 않는다.

다른 CSM나 프레임워크들도 <head> 상단에 <meta> 태그를 사용하여
CSRF 토큰을 삽입하는 사례가 많으며, csrf-token은 이런 용도로
WHATWG에 공식적으로 등록된 meta name이다.

cf. https://wiki.whatwg.org/wiki/MetaExtensions
2017-03-06 11:46:37 +09:00

85 lines
3.6 KiB
HTML

<!DOCTYPE html>
<html lang="{$lang_type = Context::getLangType()}" class="xe-mobilelayout"|cond="$m">
<head>
<!-- META -->
<meta charset="utf-8">
<meta name="generator" content="Rhymix">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" cond="$m" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<block loop="Context::getMetaTag() => $no, $val">
<meta http-equiv="{$val['name']}"|cond="$val['is_http_equiv']" name="{$val['name']}"|cond="!$val['is_http_equiv']" content="{$val['content']}" />
</block>
<meta name="csrf-token" content="{$is_logged ? \Rhymix\Framework\Session::getGenericToken() : ''}" />
<!-- TITLE -->
<title>{Context::getBrowserTitle()}</title>
<!-- CSS -->
<block loop="Context::getCssFile(true) => $key, $css_file">
<block cond="$css_file['targetie']"><!--[if {$css_file['targetie']}]><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--></block></block>
<link rel="stylesheet" href="{$css_file['file']}" media="{$css_file['media']}"|cond="$css_file['media'] != 'all'" />
<block cond="$css_file['targetie']"><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
</block>
<!-- JS -->
<block loop="Context::getJsFile('head', true) => $key, $js_file">
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--></block></block>
<script src="{$js_file['file']}"></script>
<block cond="$js_file['targetie']"><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
</block>
<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="{$rss_url}" cond="$rss_url" />
<link rel="alternate" type="application/rss+xml" title="Site RSS" href="{$general_rss_url}" cond="$general_rss_url" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="{$atom_url}" cond="$rss_url" />
<link rel="alternate" type="application/atom+xml" title="Site Atom" href="{$general_atom_url}" cond="$general_rss_url" />
<!-- ICONS AND OTHER LINKS -->
<link cond="$canonical_url" rel="canonical" href="{$canonical_url}" />
<link cond="$favicon_url" rel="shortcut icon" href="{$favicon_url}" />
<link cond="$mobicon_url" rel="apple-touch-icon" href="{$mobicon_url}" />
<!-- OTHER HEADERS -->
<block loop="Context::getOpenGraphData() => $og_metadata">
<meta property="{$og_metadata['property']}" content="{$og_metadata['content']}" />
</block>
{Context::getHtmlHeader()}
<!-- COMMON JS VARIABLES -->
<script>
var default_url = "{Context::getDefaultUrl()}";
var current_url = "{$current_url}";
var request_uri = "{$request_uri}";
var current_lang = xe.current_lang = "{$lang_type}";
var current_mid = {json_encode($mid ?: null)};
var http_port = {Context::get("_http_port") ?: 'null'};
var https_port = {Context::get("_https_port") ?: 'null'};
var enforce_ssl = {Context::get('_use_ssl') === 'always' ? 'true' : 'false'};
var ssl_actions = {json_encode(array_keys(Context::getSSLActions()))};
var xeVid = {json_encode($vid ?: null)};
</script>
</head>
<!-- BODY START -->
<body{Context::getBodyClass()}>
<!-- PAGE CONTENT -->
{Context::getBodyHeader()}
{$content}
{Context::getHtmlFooter()}
<!-- ETC -->
<div id="rhymix_waiting" class="wfsr" cond="!$m">{$lang->msg_call_server}</div>
<div id="rhymix_debug_panel"></div>
<div id="rhymix_debug_button"></div>
<!-- BODY JS -->
<block loop="Context::getJsFile('body', true) => $key, $js_file">
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]></block>
<script src="{$js_file['file']}"></script>
<block cond="$js_file['targetie']"><![endif]-->{"\n"}</block>
</block>
</body>
</html>