mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Make OpenGraph configurable, and fix canonical URL to include mid
This commit is contained in:
parent
da1b69c6b7
commit
f25e685209
10 changed files with 83 additions and 8 deletions
|
|
@ -2788,6 +2788,17 @@ class Context
|
|||
self::$_instance->opengraph_metadata[] = array($name, $content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set canonical URL
|
||||
*
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public static function setCanonicalURL($url)
|
||||
{
|
||||
self::addHtmlHeader(sprintf('<link rel="canonical" href="%s" />', escape($url)));
|
||||
}
|
||||
}
|
||||
/* End of file Context.class.php */
|
||||
/* Location: ./classes/context/Context.class.php */
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class HTMLDisplayHandler
|
|||
$output = preg_replace('/member\_\-([0-9]+)/s', 'member_0', $output);
|
||||
|
||||
// Add OpenGraph metadata
|
||||
if (Context::get('module') !== 'admin')
|
||||
if (config('seo.og_enabled') && Context::get('module') !== 'admin')
|
||||
{
|
||||
$this->_addOpenGraphMetadata();
|
||||
}
|
||||
|
|
@ -412,7 +412,7 @@ class HTMLDisplayHandler
|
|||
// Add basic metadata.
|
||||
Context::addOpenGraphData('og:title', Context::getBrowserTitle());
|
||||
Context::addOpenGraphData('og:site_name', Context::getSiteTitle());
|
||||
if ($page_type === 'article')
|
||||
if ($page_type === 'article' && config('seo.og_extract_description'))
|
||||
{
|
||||
Context::addOpenGraphData('og:description', trim(utf8_normalize_spaces($oDocument->getContentText(200))));
|
||||
}
|
||||
|
|
@ -426,7 +426,6 @@ class HTMLDisplayHandler
|
|||
if ($page_type === 'article')
|
||||
{
|
||||
$document_canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
|
||||
Context::addHtmlHeader(sprintf('<link rel="canonical" href="%s" />', escape($document_canonical_url)));
|
||||
Context::addOpenGraphData('og:url', $document_canonical_url);
|
||||
}
|
||||
elseif (($page = Context::get('page')) > 1)
|
||||
|
|
@ -455,7 +454,7 @@ class HTMLDisplayHandler
|
|||
}
|
||||
|
||||
// Add image.
|
||||
if ($page_type === 'article')
|
||||
if ($page_type === 'article' && config('seo.og_extract_images'))
|
||||
{
|
||||
if (($document_images = Rhymix\Framework\Cache::get("seo:document_images:$document_srl")) === null)
|
||||
{
|
||||
|
|
@ -515,7 +514,7 @@ class HTMLDisplayHandler
|
|||
}
|
||||
|
||||
// Add datetime for articles.
|
||||
if ($page_type === 'article')
|
||||
if ($page_type === 'article' && config('seo.og_use_timestamps'))
|
||||
{
|
||||
Context::addOpenGraphData('article:published_time', $oDocument->getRegdate('c'));
|
||||
Context::addOpenGraphData('article:modified_time', $oDocument->getUpdate('c'));
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ return array(
|
|||
'display_to' => 'admin',
|
||||
'allow' => array(),
|
||||
),
|
||||
'seo' => array(
|
||||
'og_enabled' => false,
|
||||
'og_extract_description' => false,
|
||||
'og_extract_images' => false,
|
||||
'og_use_timestamps' => false,
|
||||
),
|
||||
'mediafilter' => array(
|
||||
'iframe' => array(),
|
||||
'object' => array(),
|
||||
|
|
|
|||
|
|
@ -781,10 +781,17 @@ class adminAdminController extends admin
|
|||
$args = new stdClass;
|
||||
$args->meta_keywords = $vars->site_meta_keywords ? implode(', ', array_map('trim', explode(',', $vars->site_meta_keywords))) : '';
|
||||
$args->meta_description = trim(utf8_normalize_spaces($vars->site_meta_description));
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->updateModuleConfig('module', $args);
|
||||
|
||||
Rhymix\Framework\Config::set('seo.og_enabled', $vars->og_enabled === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_extract_description', $vars->og_extract_description === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_extract_images', $vars->og_extract_images === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_use_timestamps', $vars->og_use_timestamps === 'Y');
|
||||
|
||||
// Save
|
||||
Rhymix\Framework\Config::save();
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSEO'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -570,12 +570,18 @@ class adminAdminView extends admin
|
|||
*/
|
||||
function dispAdminConfigSEO()
|
||||
{
|
||||
// Site title and HTML footer
|
||||
// Meta keywords and description
|
||||
$oModuleModel = getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('module');
|
||||
Context::set('site_meta_keywords', escape($config->meta_keywords));
|
||||
Context::set('site_meta_description', escape($config->meta_description));
|
||||
|
||||
// OpenGraph metadata
|
||||
Context::set('og_enabled', Rhymix\Framework\Config::get('seo.og_enabled'));
|
||||
Context::set('og_extract_description', Rhymix\Framework\Config::get('seo.og_extract_description'));
|
||||
Context::set('og_extract_images', Rhymix\Framework\Config::get('seo.og_extract_images'));
|
||||
Context::set('og_use_timestamps', Rhymix\Framework\Config::get('seo.og_use_timestamps'));
|
||||
|
||||
$this->setTemplateFile('config_seo');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,12 @@ $lang->site_meta_keywords = 'SEO Keywords';
|
|||
$lang->about_site_meta_keywords = 'These keywords will be used on pages that do not have their own keywords.';
|
||||
$lang->site_meta_description = 'SEO Description';
|
||||
$lang->about_site_meta_description = 'This description will be used on pages that do not have their own description.';
|
||||
$lang->og_enabled = 'Add OpenGraph Tags';
|
||||
$lang->og_extract_description = 'Extract Description from Document';
|
||||
$lang->og_extract_description_fallback = 'Use general description only';
|
||||
$lang->og_extract_images = 'Extract Images from Document';
|
||||
$lang->og_extract_images_fallback = 'Use site default image only';
|
||||
$lang->og_use_timestamps = 'Include Timestamps';
|
||||
$lang->autoinstall = 'EasyInstall';
|
||||
$lang->last_week = 'Last Week';
|
||||
$lang->this_week = 'This Week';
|
||||
|
|
|
|||
|
|
@ -150,6 +150,12 @@ $lang->site_meta_keywords = 'SEO 키워드';
|
|||
$lang->about_site_meta_keywords = '별도의 키워드를 지정하지 않은 페이지에서는 이 키워드 목록이 표시됩니다.';
|
||||
$lang->site_meta_description = 'SEO 설명';
|
||||
$lang->about_site_meta_description = '별도의 설명을 지정하지 않은 페이지에서는 이 설명이 표시됩니다.';
|
||||
$lang->og_enabled = 'OpenGraph 태그 사용';
|
||||
$lang->og_extract_description = '본문에서 설명 추출';
|
||||
$lang->og_extract_description_fallback = '모듈 또는 사이트 전체 설명만 사용';
|
||||
$lang->og_extract_images = '본문에서 이미지 추출';
|
||||
$lang->og_extract_images_fallback = '사이트 대표 이미지 사용';
|
||||
$lang->og_use_timestamps = '글 작성/수정 시각 표시';
|
||||
$lang->autoinstall = '쉬운 설치';
|
||||
$lang->last_week = '지난주';
|
||||
$lang->this_week = '이번주';
|
||||
|
|
|
|||
|
|
@ -21,6 +21,34 @@
|
|||
<p class="x_help-block">{$lang->about_site_meta_description}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->og_enabled}</label>
|
||||
<div class="x_controls">
|
||||
<label for="og_enabled_y" class="x_inline"><input type="radio" name="og_enabled" id="og_enabled_y" value="Y" checked="checked"|cond="$og_enabled" /> {$lang->cmd_yes}</label>
|
||||
<label for="og_enabled_n" class="x_inline"><input type="radio" name="og_enabled" id="og_enabled_n" value="N" checked="checked"|cond="!$og_enabled" /> {$lang->cmd_no}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->og_extract_description}</label>
|
||||
<div class="x_controls">
|
||||
<label for="og_extract_description_y" class="x_inline"><input type="radio" name="og_extract_description" id="og_extract_description_y" value="Y" checked="checked"|cond="$og_extract_description" /> {$lang->cmd_yes}</label>
|
||||
<label for="og_extract_description_n" class="x_inline"><input type="radio" name="og_extract_description" id="og_extract_description_n" value="N" checked="checked"|cond="!$og_extract_description" /> {$lang->cmd_no} ({$lang->og_extract_description_fallback})</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->og_extract_images}</label>
|
||||
<div class="x_controls">
|
||||
<label for="og_extract_images_y" class="x_inline"><input type="radio" name="og_extract_images" id="og_extract_images_y" value="Y" checked="checked"|cond="$og_extract_images" /> {$lang->cmd_yes}</label>
|
||||
<label for="og_extract_images_n" class="x_inline"><input type="radio" name="og_extract_images" id="og_extract_images_n" value="N" checked="checked"|cond="!$og_extract_images" /> {$lang->cmd_no} ({$lang->og_extract_images_fallback})</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->og_use_timestamps}</label>
|
||||
<div class="x_controls">
|
||||
<label for="og_use_timestamps_y" class="x_inline"><input type="radio" name="og_use_timestamps" id="og_use_timestamps_y" value="Y" checked="checked"|cond="$og_use_timestamps" /> {$lang->cmd_yes}</label>
|
||||
<label for="og_use_timestamps_n" class="x_inline"><input type="radio" name="og_use_timestamps" id="og_use_timestamps_n" value="N" checked="checked"|cond="!$og_use_timestamps" /> {$lang->cmd_no}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_save}</button>
|
||||
|
|
|
|||
|
|
@ -338,6 +338,12 @@ class boardView extends board
|
|||
// setup the document oject on context
|
||||
$oDocument->add('module_srl', $this->module_srl);
|
||||
Context::set('oDocument', $oDocument);
|
||||
|
||||
// set canonical URL
|
||||
if ($oDocument->document_srl)
|
||||
{
|
||||
Context::setCanonicalURL($oDocument->getPermanentUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* add javascript filters
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ class documentItem extends Object
|
|||
|
||||
function getPermanentUrl()
|
||||
{
|
||||
return getFullUrl('','document_srl',$this->get('document_srl'));
|
||||
return getFullUrl('', 'mid', $this->getDocumentMid(), 'document_srl', $this->get('document_srl'));
|
||||
}
|
||||
|
||||
function getTrackbackUrl()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue