Merge f29811307f3dcec74fc9e668206eaae73076c266 into d1c88a6fdb28f06da85e4376e7935d8d67eb4b2b
This commit is contained in:
commit
6e23a4a559
@ -136,6 +136,12 @@ class Content {
|
|||||||
return $this->getField('readMore');
|
return $this->getField('readMore');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the unique identifier
|
||||||
|
public function uniqueId()
|
||||||
|
{
|
||||||
|
return $this->getField('uniqueId');
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the field key
|
// Returns the field key
|
||||||
public function key()
|
public function key()
|
||||||
{
|
{
|
||||||
@ -291,6 +297,7 @@ class Content {
|
|||||||
public function json($returnsArray=false)
|
public function json($returnsArray=false)
|
||||||
{
|
{
|
||||||
$tmp['key'] = $this->key();
|
$tmp['key'] = $this->key();
|
||||||
|
$tmp['uniqueId'] = $this->uniqueId();
|
||||||
$tmp['title'] = $this->title();
|
$tmp['title'] = $this->title();
|
||||||
$tmp['content'] = $this->content(); // Markdown parsed
|
$tmp['content'] = $this->content(); // Markdown parsed
|
||||||
$tmp['contentRaw'] = $this->contentRaw(); // No Markdown parsed
|
$tmp['contentRaw'] = $this->contentRaw(); // No Markdown parsed
|
||||||
|
@ -32,6 +32,12 @@ function updateBludit()
|
|||||||
$checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
|
$checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
|
||||||
$dbPosts->setPostDb($key, 'md5file', $checksum);
|
$dbPosts->setPostDb($key, 'md5file', $checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unique identifier
|
||||||
|
if( empty($post['uniqueId']) ) {
|
||||||
|
$uniqueId = generateUniqueId();
|
||||||
|
$dbPosts->setPostDb($key, 'uniqueId', $uniqueId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbPosts->save();
|
$dbPosts->save();
|
||||||
@ -48,10 +54,16 @@ function updateBludit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checksum
|
// Checksum
|
||||||
if( empty($post['md5file']) ) {
|
if( empty($page['md5file']) ) {
|
||||||
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
$checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
|
||||||
$dbPages->setPageDb($key, 'md5file', $checksum);
|
$dbPages->setPageDb($key, 'md5file', $checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unique identifier
|
||||||
|
if( empty($page['uniqueId']) ) {
|
||||||
|
$uniqueId = generateUniqueId();
|
||||||
|
$dbPages->setPageDb($key, 'uniqueId', $uniqueId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbPages->save();
|
$dbPages->save();
|
||||||
|
@ -16,6 +16,12 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
|||||||
'value'=>$_Page->key()
|
'value'=>$_Page->key()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Unique identifier
|
||||||
|
HTML::formInputHidden(array(
|
||||||
|
'name'=>'uniqueId',
|
||||||
|
'value'=>$_Page->uniqueId()
|
||||||
|
));
|
||||||
|
|
||||||
// LEFT SIDE
|
// LEFT SIDE
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
echo '<div class="uk-grid uk-grid-medium">';
|
echo '<div class="uk-grid uk-grid-medium">';
|
||||||
|
@ -16,6 +16,12 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
|||||||
'value'=>$_Post->key()
|
'value'=>$_Post->key()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Unique identifier
|
||||||
|
HTML::formInputHidden(array(
|
||||||
|
'name'=>'uniqueId',
|
||||||
|
'value'=>$_Post->uniqueId()
|
||||||
|
));
|
||||||
|
|
||||||
// LEFT SIDE
|
// LEFT SIDE
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
echo '<div class="uk-grid uk-grid-medium">';
|
echo '<div class="uk-grid uk-grid-medium">';
|
||||||
|
@ -273,3 +273,9 @@ $Url->checkFilters( $Site->uriFilters() );
|
|||||||
|
|
||||||
// --- Objects shortcuts ---
|
// --- Objects shortcuts ---
|
||||||
$L = $Language;
|
$L = $Language;
|
||||||
|
|
||||||
|
// Function for generating unique identifiers
|
||||||
|
function generateUniqueId()
|
||||||
|
{
|
||||||
|
return md5(uniqid('', true));
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@ class dbPages extends dbJSON
|
|||||||
private $dbFields = array(
|
private $dbFields = array(
|
||||||
'title'=> array('inFile'=>true, 'value'=>''),
|
'title'=> array('inFile'=>true, 'value'=>''),
|
||||||
'content'=> array('inFile'=>true, 'value'=>''),
|
'content'=> array('inFile'=>true, 'value'=>''),
|
||||||
|
'uniqueId'=> array('inFile'=>false, 'value'=>''),
|
||||||
'description'=> array('inFile'=>false, 'value'=>''),
|
'description'=> array('inFile'=>false, 'value'=>''),
|
||||||
'username'=> array('inFile'=>false, 'value'=>''),
|
'username'=> array('inFile'=>false, 'value'=>''),
|
||||||
'tags'=> array('inFile'=>false, 'value'=>array()),
|
'tags'=> array('inFile'=>false, 'value'=>array()),
|
||||||
@ -28,6 +29,11 @@ class dbPages extends dbJSON
|
|||||||
$dataForFile = array(); // This data will be saved in the file
|
$dataForFile = array(); // This data will be saved in the file
|
||||||
|
|
||||||
$key = $this->generateKey($args['slug'], $args['parent']);
|
$key = $this->generateKey($args['slug'], $args['parent']);
|
||||||
|
|
||||||
|
// Generate unique identifier
|
||||||
|
if( empty($args['uniqueId']) ) {
|
||||||
|
$args['uniqueId'] = generateUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
// The user is always the one loggued.
|
// The user is always the one loggued.
|
||||||
$args['username'] = Session::get('username');
|
$args['username'] = Session::get('username');
|
||||||
@ -105,6 +111,11 @@ class dbPages extends dbJSON
|
|||||||
$dataForFile = array();
|
$dataForFile = array();
|
||||||
|
|
||||||
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
|
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
|
||||||
|
|
||||||
|
// Generate unique identifier
|
||||||
|
if( empty($args['uniqueId']) ) {
|
||||||
|
$args['uniqueId'] = generateUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
// The user is always the one loggued.
|
// The user is always the one loggued.
|
||||||
$args['username'] = Session::get('username');
|
$args['username'] = Session::get('username');
|
||||||
|
@ -5,6 +5,7 @@ class dbPosts extends dbJSON
|
|||||||
private $dbFields = array(
|
private $dbFields = array(
|
||||||
'title'=> array('inFile'=>true, 'value'=>''),
|
'title'=> array('inFile'=>true, 'value'=>''),
|
||||||
'content'=> array('inFile'=>true, 'value'=>''),
|
'content'=> array('inFile'=>true, 'value'=>''),
|
||||||
|
'uniqueId'=> array('inFile'=>false, 'value'=>''),
|
||||||
'description'=> array('inFile'=>false, 'value'=>''),
|
'description'=> array('inFile'=>false, 'value'=>''),
|
||||||
'username'=> array('inFile'=>false, 'value'=>''),
|
'username'=> array('inFile'=>false, 'value'=>''),
|
||||||
'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled
|
'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled
|
||||||
@ -113,6 +114,11 @@ class dbPosts extends dbJSON
|
|||||||
|
|
||||||
// Generate the database key / index
|
// Generate the database key / index
|
||||||
$key = $this->generateKey($args['slug']);
|
$key = $this->generateKey($args['slug']);
|
||||||
|
|
||||||
|
// Generate unique identifier
|
||||||
|
if( empty($args['uniqueId']) ) {
|
||||||
|
$args['uniqueId'] = generateUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
// The user is always who is loggued
|
// The user is always who is loggued
|
||||||
$args['username'] = Session::get('username');
|
$args['username'] = Session::get('username');
|
||||||
|
@ -8,9 +8,9 @@ class pluginDisqus extends Plugin {
|
|||||||
{
|
{
|
||||||
$this->dbFields = array(
|
$this->dbFields = array(
|
||||||
'shortname'=>'',
|
'shortname'=>'',
|
||||||
'enablePages'=>0,
|
'enablePages'=>1,
|
||||||
'enablePosts'=>0,
|
'enablePosts'=>1,
|
||||||
'enableDefaultHomePage'=>1
|
'enableDefaultHomePage'=>0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +98,30 @@ class pluginDisqus extends Plugin {
|
|||||||
|
|
||||||
public function siteBodyEnd()
|
public function siteBodyEnd()
|
||||||
{
|
{
|
||||||
|
global $Page, $Post, $Url, $posts;
|
||||||
|
|
||||||
|
switch($Url->whereAmI())
|
||||||
|
{
|
||||||
|
case 'post':
|
||||||
|
$absolutePermalink = $Post->permalink(true);
|
||||||
|
$uniqueId = $Post->uniqueId();
|
||||||
|
$disqusTitle = $Post->title();
|
||||||
|
break;
|
||||||
|
case 'page':
|
||||||
|
$absolutePermalink = $Page->permalink(true);
|
||||||
|
$uniqueId = $Page->uniqueId();
|
||||||
|
$disqusTitle = $Page->title();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Homepage - use the first post
|
||||||
|
if(isset($posts[0])) {
|
||||||
|
$absolutePermalink = $posts[0]->permalink(true);
|
||||||
|
$uniqueId = $posts[0]->uniqueId();
|
||||||
|
$disqusTitle = $posts[0]->title();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $this->enable ) {
|
if( $this->enable ) {
|
||||||
|
|
||||||
$html = '
|
$html = '
|
||||||
@ -105,6 +129,12 @@ class pluginDisqus extends Plugin {
|
|||||||
|
|
||||||
var disqus_shortname = "'.$this->getDbField('shortname').'";
|
var disqus_shortname = "'.$this->getDbField('shortname').'";
|
||||||
|
|
||||||
|
var disqus_config = function () {
|
||||||
|
this.page.url = "'.$absolutePermalink.'";
|
||||||
|
this.page.identifier = "'.$uniqueId.'";
|
||||||
|
this.page.title = "'.$disqusTitle.'";
|
||||||
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
|
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
|
||||||
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
|
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user