Absolute url on themes

This commit is contained in:
Diego Najar 2017-05-30 20:28:55 +02:00
parent a90ff3e635
commit 85f863f586
9 changed files with 45 additions and 38 deletions

View File

@ -21,7 +21,6 @@ function setSettings($args)
global $dbPages; global $dbPages;
// Add slash at the begin and end // Add slash at the begin and end
$args['url'] = Text::addSlashes($args['url'],false,true);
$args['uriPage'] = Text::addSlashes($args['uriPage']); $args['uriPage'] = Text::addSlashes($args['uriPage']);
$args['uriTag'] = Text::addSlashes($args['uriTag']); $args['uriTag'] = Text::addSlashes($args['uriTag']);
$args['uriCategory'] = Text::addSlashes($args['uriCategory']); $args['uriCategory'] = Text::addSlashes($args['uriCategory']);

View File

@ -259,6 +259,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
// This paths are absolutes for the user / web browsing. // This paths are absolutes for the user / web browsing.
define('DOMAIN', $Site->domain()); define('DOMAIN', $Site->domain());
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT); define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME);
define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS); define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS);
define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS); define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS);
define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG); define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG);

View File

@ -18,7 +18,7 @@ class dbPages extends dbJSON
'category'=> array('inFile'=>false, 'value'=>''), 'category'=> array('inFile'=>false, 'value'=>''),
'md5file'=> array('inFile'=>false, 'value'=>''), 'md5file'=> array('inFile'=>false, 'value'=>''),
'uuid'=> array('inFile'=>false, 'value'=>''), 'uuid'=> array('inFile'=>false, 'value'=>''),
'allowComments'=> array('inFile'=>false, 'value'=>false) 'allowComments'=> array('inFile'=>false, 'value'=>true)
); );
function __construct() function __construct()

View File

@ -57,7 +57,7 @@ class Theme {
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL; return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
} }
public static function css($files, $path=HTML_PATH_THEME) public static function css($files)
{ {
if( !is_array($files) ) { if( !is_array($files) ) {
$files = array($files); $files = array($files);
@ -65,13 +65,13 @@ class Theme {
$links = ''; $links = '';
foreach($files as $file) { foreach($files as $file) {
$links .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL; $links .= '<link rel="stylesheet" type="text/css" href="'.DOMAIN_THEME.$file.'">'.PHP_EOL;
} }
return $links; return $links;
} }
public static function javascript($files, $path=HTML_PATH_THEME) public static function javascript($files)
{ {
if( !is_array($files) ) { if( !is_array($files) ) {
$files = array($files); $files = array($files);
@ -79,15 +79,15 @@ class Theme {
$scripts = ''; $scripts = '';
foreach($files as $file) { foreach($files as $file) {
$scripts .= '<script src="'.$path.$file.'"></script>'.PHP_EOL; $scripts .= '<script src="'.DOMAIN_THEME.$file.'"></script>'.PHP_EOL;
} }
return $scripts; return $scripts;
} }
public static function js($files, $path=HTML_PATH_THEME) public static function js($files)
{ {
self::javascript($files, $path); return self::javascript($files);
} }
public static function plugins($type) public static function plugins($type)
@ -116,13 +116,6 @@ class Theme {
return $tmp; return $tmp;
} }
public static function keywords($keywords, $echo=true) public static function keywords($keywords, $echo=true)
{ {
if(is_array($keywords)) { if(is_array($keywords)) {
@ -138,12 +131,6 @@ class Theme {
return $tmp; return $tmp;
} }
public static function jquery($echo=true) public static function jquery($echo=true)
{ {
$tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL; $tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL;

View File

@ -149,7 +149,7 @@ class Page {
// Returns the permalink // Returns the permalink
// (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN // (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
public function permalink($absolute=false) public function permalink($absolute=true)
{ {
global $Url; global $Url;
global $Site; global $Site;
@ -366,6 +366,12 @@ class Page {
return $this->getField('title'); return $this->getField('title');
} }
// Returns TRUE if the page has enabled the comments, FALSE otherwise
public function allowComments()
{
return $this->getField('allowComments');
}
// Returns the page position // Returns the page position
public function position() public function position()
{ {

View File

@ -29,8 +29,8 @@ class pluginDisqus extends Plugin {
$html = '<div id="disqus_thread"></div>'; $html = '<div id="disqus_thread"></div>';
$html .= '<script type="text/javascript"> $html .= '<script type="text/javascript">
var disqus_config = function () { var disqus_config = function () {
this.page.url = '.$page->permalink().'; this.page.url = "'.$page->permalink().'";
this.page.identifier = '.$page->uuid().'; this.page.identifier = "'.$page->uuid().'";
}; };
(function() { (function() {
@ -43,14 +43,10 @@ class pluginDisqus extends Plugin {
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
'; ';
return $html;
} }
return false; return false;
} }
public function siteHead()
{
return '<style>#disqus_thread { margin: 20px 0 }</style>';
}
} }

View File

@ -53,3 +53,9 @@ div.plugin-menu span.category-name {
div.plugin-menu a.page-title { div.plugin-menu a.page-title {
padding: 0; padding: 0;
} }
/* Plugin Disqus
------------------------------------------------------------------------------ */
#disqus_thread {
margin-top: 60px;
}

View File

@ -18,7 +18,9 @@
<!-- Header --> <!-- Header -->
<header id="header"> <header id="header">
<a href="<?php echo $Site->url() ?>" class="logo"><strong><?php echo $Site->title() ?></strong> <?php echo $Site->slogan() ?></a> <a href="<?php echo $Site->url() ?>" class="logo">
<strong><?php echo $Site->title() ?></strong> <?php echo $Site->slogan() ?>
</a>
<ul class="icons"> <ul class="icons">
<li><a href="<?php echo $Site->twitter() ?>" class="icon fa-twitter"><span class="label">Twitter</span></a></li> <li><a href="<?php echo $Site->twitter() ?>" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="<?php echo $Site->facebook() ?>" class="icon fa-facebook"><span class="label">Facebook</span></a></li> <li><a href="<?php echo $Site->facebook() ?>" class="icon fa-facebook"><span class="label">Facebook</span></a></li>
@ -44,6 +46,7 @@
<?php include(THEME_DIR_PHP.'sidebar.php') ?> <?php include(THEME_DIR_PHP.'sidebar.php') ?>
</div> </div>
</div> </div>
</div> </div>
<!-- Scripts --> <!-- Scripts -->

View File

@ -324,7 +324,7 @@ function install($adminPassword, $email, $timezone)
'status'=>'published', 'status'=>'published',
'date'=>$currentDate, 'date'=>$currentDate,
'dateModified'=>'', 'dateModified'=>'',
'allowComments'=>false, 'allowComments'=>true,
'position'=>2, 'position'=>2,
'coverImage'=>'', 'coverImage'=>'',
'md5file'=>'', 'md5file'=>'',
@ -338,7 +338,7 @@ function install($adminPassword, $email, $timezone)
'status'=>'published', 'status'=>'published',
'date'=>$currentDate, 'date'=>$currentDate,
'dateModified'=>'', 'dateModified'=>'',
'allowComments'=>false, 'allowComments'=>true,
'position'=>1, 'position'=>1,
'coverImage'=>'', 'coverImage'=>'',
'md5file'=>'', 'md5file'=>'',
@ -350,6 +350,15 @@ function install($adminPassword, $email, $timezone)
file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
// File site.php // File site.php
// If the website is not installed inside a folder the URL not need finish with /
// Example (root): https://domain.com
// Example (inside a folder): https://domain.com/folder/
if(HTML_PATH_ROOT=='/') {
$siteUrl = PROTOCOL.DOMAIN;
} else {
$siteUrl = PROTOCOL.DOMAIN.HTML_PATH_ROOT;
}
$data = array( $data = array(
'title'=>'BLUDIT', 'title'=>'BLUDIT',
'slogan'=>'CMS', 'slogan'=>'CMS',
@ -365,7 +374,7 @@ function install($adminPassword, $email, $timezone)
'uriPage'=>'/', 'uriPage'=>'/',
'uriTag'=>'/tag/', 'uriTag'=>'/tag/',
'uriCategory'=>'/category/', 'uriCategory'=>'/category/',
'url'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT, 'url'=>$siteUrl,
'emailFrom'=>'no-reply@'.DOMAIN 'emailFrom'=>'no-reply@'.DOMAIN
); );