Add option to control whether boards and pages are indexed by search engines, using the X-Robots-Tag header

This commit is contained in:
Kijin Sung 2023-08-13 02:03:02 +09:00
parent fde3609f70
commit 2197b0a982
7 changed files with 37 additions and 9 deletions

View file

@ -125,6 +125,12 @@ class DisplayHandler extends Handler
header('X-Content-Type-Options: ' . $header_value);
}
// Print robot headers.
if (isset($oModule->module_info->robots_tag) && $oModule->module_info->robots_tag === 'noindex')
{
header('X-Robots-Tag: noindex');
}
// flush output buffer
while (ob_get_level())
{

View file

@ -343,6 +343,8 @@ $lang->filter['invalid_float'] = 'The format of %s is invalid. Please enter numb
$lang->filter['invalid_extension'] = 'The format of %s is invalid. e.g. gif, jpg, png';
$lang->security_warning_embed = 'Due to security concern, administrators are not allowed to view embedded items.<BR /> To view them, please use another non-administrator ID.';
$lang->msg_pc_to_mobile = 'View mobile optimized version of this page';
$lang->cmd_robots_tag = 'Search Engine Indexing';
$lang->msg_about_robots_tag = 'Allow search engines to index this page.';
$lang->cmd_yes = 'Yes';
$lang->cmd_no = 'No';
$lang->cmd_set_multilingual = 'Select Language';

View file

@ -347,6 +347,8 @@ $lang->filter['invalid_extension'] = '%s의 형식이 잘못되었습니다. gif
$lang->security_invalid_session = '바르지 않은 접근입니다. 인증을 위해 다시 로그인해야 합니다.';
$lang->security_warning_embed = '보안 문제로 관리자 아이디로는 embed를 볼 수 없습니다. 확인하려면 다른 아이디로 접속하세요';
$lang->msg_pc_to_mobile = '모바일에 최적화된 화면으로 보기';
$lang->cmd_robots_tag = '검색엔진 색인';
$lang->msg_about_robots_tag = '검색엔진이 이 페이지를 색인하는 것을 허용합니다.';
$lang->cmd_yes = '예';
$lang->cmd_no = '아니오';
$lang->cmd_set_multilingual = '다국어 설정';

View file

@ -83,6 +83,7 @@ class BoardAdminController extends Board {
$args->skip_bottom_list_days = max(0, intval($args->skip_bottom_list_days));
$args->browser_title = trim(utf8_normalize_spaces($args->browser_title));
$args->robots_tag = ($args->robots_tag === 'noindex') ? 'noindex' : 'all';
$args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : '';
$args->meta_description = trim(utf8_normalize_spaces($args->meta_description));
$args->header_text = Rhymix\Modules\Admin\Models\Utility::cleanHeaderAndFooterScripts($args->header_text ?? '');

View file

@ -36,6 +36,14 @@
<p id="browser_title_help" class="x_help-block" hidden>{$lang->about_browser_title}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_robots_tag}</label>
<div class="x_controls">
<label class="x_inline" for="robots_tag_all"><input type="radio" name="robots_tag" id="robots_tag_all" value="all" checked="checked"|cond="$module_info->robots_tag !== 'noindex'" /> {$lang->cmd_yes}</label>
<label class="x_inline" for="robots_tag_noindex"><input type="radio" name="robots_tag" id="robots_tag_noindex" value="noindex" checked="checked"|cond="$module_info->robots_tag === 'noindex'" /> {$lang->cmd_no}</label>
<p class="x_help-inline">{$lang->msg_about_robots_tag}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="lang_meta_keywords">{$lang->meta_keywords}</label>
<div class="x_controls">

View file

@ -38,6 +38,7 @@ class PageAdminController extends Page
if($args->use_mobile != 'Y') $args->use_mobile = '';
$args->browser_title = trim(utf8_normalize_spaces($args->browser_title));
$args->robots_tag = ($args->robots_tag === 'noindex') ? 'noindex' : 'all';
$args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : '';
$args->meta_description = trim(utf8_normalize_spaces($args->meta_description));

View file

@ -44,6 +44,14 @@
<input type="text" name="browser_title" id="browser_title" value="<!--@if(strpos($module_info->browser_title, '$user_lang->') === false)-->{$module_info->browser_title}<!--@else-->{htmlspecialchars($module_info->browser_title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)}<!--@end-->" class="lang_code" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_robots_tag}</label>
<div class="x_controls">
<label class="x_inline" for="robots_tag_all"><input type="radio" name="robots_tag" id="robots_tag_all" value="all" checked="checked"|cond="$module_info->robots_tag !== 'noindex'" /> {$lang->cmd_yes}</label>
<label class="x_inline" for="robots_tag_noindex"><input type="radio" name="robots_tag" id="robots_tag_noindex" value="noindex" checked="checked"|cond="$module_info->robots_tag === 'noindex'" /> {$lang->cmd_no}</label>
<p class="x_help-inline">{$lang->msg_about_robots_tag}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="lang_meta_keywords">{$lang->meta_keywords}</label>
<div class="x_controls">
@ -56,6 +64,15 @@
<input type="text" name="meta_description" id="meta_description" value="<!--@if(strpos($module_info->meta_description, '$user_lang->') === false)-->{$module_info->meta_description}<!--@else-->{htmlspecialchars($module_info->meta_description)}<!--@end-->" class="lang_code" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->mobile_view}</label>
<div class="x_controls">
<label for="use_mobile">
<input type="checkbox" name="use_mobile" id="use_mobile" value="Y" checked="checked"|cond="$module_info->use_mobile == 'Y'" />
{$lang->about_mobile_view}
</label>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="layout_srl">{$lang->layout}</label>
<div class="x_controls">
@ -66,15 +83,6 @@
<p class="x_help-block" id="aboutLayout">{$lang->about_layout}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->mobile_view}</label>
<div class="x_controls">
<label for="use_mobile">
<input type="checkbox" name="use_mobile" id="use_mobile" value="Y" checked="checked"|cond="$module_info->use_mobile == 'Y'" />
{$lang->about_mobile_view}
</label>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="mlayout_srl">{$lang->mobile_layout}</label>
<div class="x_controls">