homepage, twitter card, improves
This commit is contained in:
parent
325d6f79d5
commit
c3271298eb
|
@ -83,5 +83,10 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
$allPublishedPages = buildAllpages(false);
|
||||||
|
|
||||||
|
// Homepage select options
|
||||||
|
$homepageOptions = array();
|
||||||
|
foreach($allPublishedPages as $key=>$page) {
|
||||||
|
$homepageOptions[$key] = $page->title();
|
||||||
|
}
|
|
@ -28,6 +28,18 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
'tip'=>$L->g('the-url-of-your-site')
|
'tip'=>$L->g('the-url-of-your-site')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
HTML::legend(array('value'=>$L->g('Home page')));
|
||||||
|
|
||||||
|
HTML::formSelect(array(
|
||||||
|
'name'=>'homepage',
|
||||||
|
'label'=>$L->g('Default home page'),
|
||||||
|
'options'=>$homepageOptions,
|
||||||
|
'selected'=>$Site->homepage(),
|
||||||
|
'class'=>'uk-width-1-3 uk-form-medium',
|
||||||
|
'tip'=>'',
|
||||||
|
'addEmptySpace'=>true
|
||||||
|
));
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('Website or Blog')));
|
HTML::legend(array('value'=>$L->g('Website or Blog')));
|
||||||
|
|
||||||
HTML::formSelect(array(
|
HTML::formSelect(array(
|
||||||
|
|
|
@ -4,27 +4,34 @@
|
||||||
// Variables
|
// Variables
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// Array with pages, each page is a Object Page
|
// Array with pages, each page is a Page Object
|
||||||
$pages = array();
|
$pages = array();
|
||||||
|
|
||||||
// Page filtered by the user, is a Object Page
|
// Page filtered by the user, is a Page Object
|
||||||
$page = $Page = false;
|
$page = $Page = false;
|
||||||
|
|
||||||
// Array with pages order by parent
|
// Array with pages order by parent
|
||||||
// This variable is initializade only when the site is order by position
|
// This variable is initializade only when the site is order by position to not degradate the peromance on blogs
|
||||||
// This is for not degradate the peromance on blogs
|
|
||||||
/*
|
/*
|
||||||
array(
|
array(
|
||||||
PARENT => array(), // all parent pages
|
PARENT => array(), // all parent pages
|
||||||
parentKey1 => array(), // all children of parentKey1
|
parentKey1 => array(), // all children of parentKey1
|
||||||
parentKey2 => array(), // all children of parentKey2
|
parentKey2 => array(), // all children of parentKey2
|
||||||
...
|
...
|
||||||
parentKeyN => array(), // all children of parentKeyN
|
parentKeyN => array(), // all children of parentKeyN
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
$pagesByParent = array(PARENT=>array());
|
$pagesByParent = array(PARENT=>array());
|
||||||
|
|
||||||
// Array with all published pages, the array is a key=>Page-object
|
// Array with pages,
|
||||||
|
/*
|
||||||
|
array(
|
||||||
|
pageKey1 => Page Object,
|
||||||
|
pageKey2 => Page Object,
|
||||||
|
...
|
||||||
|
pageKeyN => Page Object,
|
||||||
|
)
|
||||||
|
*/
|
||||||
$pagesByKey = array();
|
$pagesByKey = array();
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -46,6 +53,12 @@ if( $dbPages->scheduler() ) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $Site->homepage() && $Url->whereAmI()==='home' ) {
|
||||||
|
$Url->setWhereAmI('page');
|
||||||
|
$slug = $Site->homepage();
|
||||||
|
$Url->setSlug($slug);
|
||||||
|
}
|
||||||
|
|
||||||
// Build specific page
|
// Build specific page
|
||||||
if( $Url->whereAmI()==='page' ) {
|
if( $Url->whereAmI()==='page' ) {
|
||||||
// Build the page
|
// Build the page
|
||||||
|
|
|
@ -280,10 +280,14 @@ class dbSite extends dbJSON
|
||||||
return $short;
|
return $short;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the current homepage.
|
// Returns the current homepage, FALSE if not defined homepage
|
||||||
public function homepage()
|
public function homepage()
|
||||||
{
|
{
|
||||||
return $this->getField('homepage');
|
$homepage = $this->getField('homepage');
|
||||||
|
if( empty($homepage) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $homepage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the locale.
|
// Set the locale.
|
||||||
|
|
|
@ -171,6 +171,32 @@ function buildPagesByParent($allPages=true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns an Array with all pages existing on the system
|
||||||
|
// (boolean) $allPages, TRUE returns all pages with any status, FALSE all published pages
|
||||||
|
/*
|
||||||
|
array(
|
||||||
|
pageKey1 => Page object,
|
||||||
|
pageKey2 => Page object,
|
||||||
|
...
|
||||||
|
pageKeyN => Page object,
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
function buildAllpages($allPages=true) {
|
||||||
|
global $dbPages;
|
||||||
|
|
||||||
|
$tmp = array();
|
||||||
|
$keys = array_keys($dbPages->db);
|
||||||
|
foreach($keys as $pageKey) {
|
||||||
|
$page = buildPage($pageKey);
|
||||||
|
if($page!==false) {
|
||||||
|
if($allPages || $page->published()) {
|
||||||
|
$tmp[$page->key()] = $page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns TRUE if the plugin is enabled, FALSE otherwise
|
// Returns TRUE if the plugin is enabled, FALSE otherwise
|
||||||
function pluginEnabled($pluginName) {
|
function pluginEnabled($pluginName) {
|
||||||
global $plugins;
|
global $plugins;
|
||||||
|
|
|
@ -392,10 +392,10 @@ class Page {
|
||||||
// Returns the parent method output, if the page doesn't have a parent returns FALSE
|
// Returns the parent method output, if the page doesn't have a parent returns FALSE
|
||||||
public function parentMethod($method)
|
public function parentMethod($method)
|
||||||
{
|
{
|
||||||
global $pages;
|
$parentKey = $this->parentKey();
|
||||||
|
if( $parentKey ) {
|
||||||
if( isset($pages[$this->parentKey()]) ) {
|
$page = buildPage($parentKey);
|
||||||
return $pages[$this->parentKey()]->{$method}();
|
return $page->{$method}();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,6 +81,11 @@ class Url
|
||||||
return $this->slug;
|
return $this->slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSlug($slug)
|
||||||
|
{
|
||||||
|
$this->slug = $slug;
|
||||||
|
}
|
||||||
|
|
||||||
public function activeFilter()
|
public function activeFilter()
|
||||||
{
|
{
|
||||||
return $this->activeFilter;
|
return $this->activeFilter;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Open Graph ви позволява да свържете вашето съдържание със социални мрежи."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Plugin zur Verwendung des Open Graph Protocols."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Plugin zur Verwendung des Open Graph Protocols."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Twitter Card",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Mejora las publicaciones en las redes sociales con este plugin."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Permets à n’importe quelle page web de devenir l’objet enrichi d’un graphe social. Par exemple, il est utilisé sur Facebook pour permettre à une page web de bénéficier des mêmes fonctionnalités que n’importe quel autre objet sur Facebook."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Open Graph protocol(OGP)を有効にすると、Webページがソーシャルグラフ上のリッチなオブジェクトになります。"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "De Open Graph protocol kan van elke webpagina een rich object in een sociale grafiek maken."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Protokół Open Graph zezwala stronie na stosowanie meta tagów używanych w serwisach społecznościowych."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Протокол Open Graph дает возможность связывать свой контент с социальными сетями."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Open Graph",
|
||||||
|
"description": "Протокол Open Graph дозволяє ділитися будь-якою веб-сторінкою у соціальних мережах."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "開放社交關係圖",
|
||||||
|
"description": "開放社交關係圖協定可以讓任何網頁變成豐富的物件"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"author": "Bludit",
|
||||||
|
"email": "",
|
||||||
|
"website": "https://plugins.bludit.com",
|
||||||
|
"version": "2.0",
|
||||||
|
"releaseDate": "2017-05-26",
|
||||||
|
"license": "MIT",
|
||||||
|
"compatible": "2.0",
|
||||||
|
"notes": ""
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class pluginTwitterCard extends Plugin {
|
||||||
|
|
||||||
|
public function siteHead()
|
||||||
|
{
|
||||||
|
global $Url;
|
||||||
|
global $Site;
|
||||||
|
global $WHERE_AM_I;
|
||||||
|
global $pages;
|
||||||
|
global $page;
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'card' =>'summary',
|
||||||
|
'site' =>'',
|
||||||
|
'title' =>$Site->title(),
|
||||||
|
'description' =>$Site->description(),
|
||||||
|
'image' =>''
|
||||||
|
);
|
||||||
|
|
||||||
|
switch($WHERE_AM_I) {
|
||||||
|
// The user filter by page
|
||||||
|
case 'page':
|
||||||
|
$data['title'] = $page->title();
|
||||||
|
$data['description'] = $page->description();
|
||||||
|
$data['image'] = $page->coverImage($absolute=true);
|
||||||
|
|
||||||
|
$content = $page->content();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// The user is in the homepage
|
||||||
|
default:
|
||||||
|
$content = '';
|
||||||
|
// The image it's from the first page
|
||||||
|
if(isset($pages[0]) ) {
|
||||||
|
$data['image'] = $pages[0]->coverImage($absolute=true);
|
||||||
|
$content = $pages[0]->content();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = PHP_EOL.'<!-- Twitter Card -->'.PHP_EOL;
|
||||||
|
$html .= '<meta property="twitter:card" content="'.$data['card'].'">'.PHP_EOL;
|
||||||
|
$html .= '<meta property="twitter:site" content="'.$data['site'].'">'.PHP_EOL;
|
||||||
|
$html .= '<meta property="twitter:title" content="'.$data['title'].'">'.PHP_EOL;
|
||||||
|
$html .= '<meta property="twitter:description" content="'.$data['description'].'">'.PHP_EOL;
|
||||||
|
|
||||||
|
// If the page doesn't have a coverImage try to get an image from the HTML content
|
||||||
|
if( empty($data['image']) ) {
|
||||||
|
// Get the image from the content
|
||||||
|
$src = $this->getImage($content);
|
||||||
|
if($src!==false) {
|
||||||
|
$data['image'] = DOMAIN.$src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '<meta property="twitter:image" content="'.$data['image'].'">'.PHP_EOL;
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the first image from the HTML content
|
||||||
|
private function getImage($content)
|
||||||
|
{
|
||||||
|
$dom = new DOMDocument();
|
||||||
|
$dom->loadHTML('<meta http-equiv="content-type" content="text/html; charset=utf-8">'.$content);
|
||||||
|
$finder = new DomXPath($dom);
|
||||||
|
|
||||||
|
$images = $finder->query("//img");
|
||||||
|
|
||||||
|
if($images->length>0) {
|
||||||
|
// First image from the list
|
||||||
|
$image = $images->item(0);
|
||||||
|
// Get value from attribute src
|
||||||
|
$imgSrc = $image->getAttribute('src');
|
||||||
|
// Returns the image src
|
||||||
|
return $imgSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,8 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="<?php echo $Site->language() ?>">
|
<html lang="<?php echo $Site->language() ?>">
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<!-- Meta tags -->
|
<!-- Meta tags -->
|
||||||
<?php include('php/head.php') ?>
|
<?php include('php/head.php') ?>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -24,18 +22,11 @@
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<?php
|
<?php
|
||||||
if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') )
|
if($WHERE_AM_I=='page') {
|
||||||
{
|
include(THEME_DIR_PHP.'page.php');
|
||||||
include('php/home.php');
|
} else {
|
||||||
}
|
include(THEME_DIR_PHP.'home.php');
|
||||||
elseif($Url->whereAmI()=='post')
|
}
|
||||||
{
|
|
||||||
include('php/post.php');
|
|
||||||
}
|
|
||||||
elseif($Url->whereAmI()=='page')
|
|
||||||
{
|
|
||||||
include('php/page.php');
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?php
|
||||||
|
$GITHUB_BASE_URL = 'https://github.com/dignajar/bludit-documentation-english/tree/master/';
|
|
@ -1,47 +0,0 @@
|
||||||
<h1 class="subhead"><?php echo $Language->get('Recent posts') ?></h1>
|
|
||||||
|
|
||||||
<?php foreach ($posts as $Post): ?>
|
|
||||||
|
|
||||||
<section class="post">
|
|
||||||
|
|
||||||
<!-- Plugins Post Begin -->
|
|
||||||
<?php Theme::plugins('postBegin') ?>
|
|
||||||
|
|
||||||
<!-- Post header -->
|
|
||||||
<header class="post-header">
|
|
||||||
|
|
||||||
<!-- Post title -->
|
|
||||||
<h2 class="post-title">
|
|
||||||
<a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<!-- Post date and author -->
|
|
||||||
<div class="post-meta">
|
|
||||||
<span class="date"><?php echo $Post->date() ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Post content -->
|
|
||||||
<div class="post-content">
|
|
||||||
<?php
|
|
||||||
// Call the method with FALSE to get the first part of the post
|
|
||||||
echo $Post->content(false)
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if($Post->readMore()) { ?>
|
|
||||||
<a class="read-more" href="<?php echo $Post->permalink() ?>"><?php $Language->printMe('Read more') ?></a>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<!-- Plugins Post End -->
|
|
||||||
<?php Theme::plugins('postEnd') ?>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<!-- Paginator for posts -->
|
|
||||||
<?php
|
|
||||||
echo Paginator::html();
|
|
||||||
?>
|
|
|
@ -1,26 +1,29 @@
|
||||||
<h1 class="subhead"><?php echo isset($pages[$Page->parentKey()])?$pages[$Page->parentKey()]->title().' -> ':'' ?><?php echo $Page->title() ?></h1>
|
<h1 class="subhead">
|
||||||
|
<?php
|
||||||
|
echo $pagesByParent[PARENT][$page->parentKey()]->title();
|
||||||
|
echo ' -> ';
|
||||||
|
echo $page->title();
|
||||||
|
?>
|
||||||
|
</h1>
|
||||||
|
|
||||||
<section class="page">
|
<section class="page">
|
||||||
|
<?php Theme::plugins('pageBegin') ?>
|
||||||
|
|
||||||
<!-- Plugins Page Begin -->
|
<header class="page-header">
|
||||||
<?php Theme::plugins('pageBegin') ?>
|
<h2 class="page-title">
|
||||||
|
<a href="<?php echo $Page->permalink() ?>"><?php echo $Page->title() ?></a>
|
||||||
|
</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
<!-- page header -->
|
<div class="page-content">
|
||||||
<header class="page-header">
|
<?php echo $Page->content() ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- page title -->
|
<div class="edit-this-page">
|
||||||
<h2 class="page-title">
|
<?php
|
||||||
<a href="<?php echo $Page->permalink() ?>"><?php echo $Page->title() ?></a>
|
echo '<a href="'.$GITHUB_BASE_URL.$Page->key().'/'.FILENAME.'">Edit this page</a>';
|
||||||
</h2>
|
?>
|
||||||
|
</div>
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- page content -->
|
|
||||||
<div class="page-content">
|
|
||||||
<?php echo $Page->content() ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Plugins Page End -->
|
|
||||||
<?php Theme::plugins('pageEnd') ?>
|
|
||||||
|
|
||||||
|
<?php Theme::plugins('pageEnd') ?>
|
||||||
</section>
|
</section>
|
|
@ -1,31 +0,0 @@
|
||||||
<h1 class="subhead"><?php echo $Language->get('Post') ?></h1>
|
|
||||||
|
|
||||||
<section class="post">
|
|
||||||
|
|
||||||
<!-- Plugins Post Begin -->
|
|
||||||
<?php Theme::plugins('postBegin') ?>
|
|
||||||
|
|
||||||
<!-- Post header -->
|
|
||||||
<header class="post-header">
|
|
||||||
|
|
||||||
<!-- Post title -->
|
|
||||||
<h2 class="post-title">
|
|
||||||
<a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<!-- Post date and author -->
|
|
||||||
<div class="post-meta">
|
|
||||||
<span class="date"><?php echo $Post->date() ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Post content -->
|
|
||||||
<div class="post-content">
|
|
||||||
<?php echo $Post->content() ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Plugins Post End -->
|
|
||||||
<?php Theme::plugins('postEnd') ?>
|
|
||||||
|
|
||||||
</section>
|
|
Loading…
Reference in New Issue