Code beautifications and some little improvments

This commit is contained in:
Giuseppe Di Terlizzi 2020-08-25 12:13:34 +02:00
parent f4c544df9b
commit 879939ea3e
7 changed files with 49 additions and 61 deletions

View file

@ -8,10 +8,6 @@ php:
env: env:
- DOKUWIKI=master - DOKUWIKI=master
- DOKUWIKI=stable - DOKUWIKI=stable
matrix:
include:
- php: "5.6"
env: DOKUWIKI=old-stable
before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh
install: sh travis.sh install: sh travis.sh
script: cd _test && ./phpunit.phar --stderr --group plugin_semantic script: cd _test && ./phpunit.phar --stderr --group plugin_semantic

View file

@ -6,12 +6,14 @@
* @group plugin_semantic * @group plugin_semantic
* @group plugins * @group plugins
*/ */
class general_plugin_semantic_test extends DokuWikiTest { class general_plugin_semantic_test extends DokuWikiTest
{
/** /**
* Simple test to make sure the plugin.info.txt is in correct format * Simple test to make sure the plugin.info.txt is in correct format
*/ */
public function test_plugininfo() { public function test_plugininfo()
{
$file = __DIR__ . '/../plugin.info.txt'; $file = __DIR__ . '/../plugin.info.txt';
$this->assertFileExists($file); $this->assertFileExists($file);
@ -32,4 +34,3 @@ class general_plugin_semantic_test extends DokuWikiTest {
$this->assertTrue(false !== strtotime($info['date'])); $this->assertTrue(false !== strtotime($info['date']));
} }
} }

View file

@ -4,13 +4,9 @@
* *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
* @copyright (C) 2015-2019, Giuseppe Di Terlizzi * @copyright (C) 2015-2020, Giuseppe Di Terlizzi
*/ */
// must be run within Dokuwiki
if (!defined('DOKU_INC')) {
die();
}
/** /**
* Class Semantic Action Plugin * Class Semantic Action Plugin
@ -108,10 +104,8 @@ class action_plugin_semantic extends DokuWiki_Action_Plugin
$this->helper->getMetadata($id); $this->helper->getMetadata($id);
$json_ld = $this->helper->getJsonLD(); $json_ld = $this->helper->getJsonLD();
$json = new JSON();
header('Content-Type: application/ld+json'); header('Content-Type: application/ld+json');
print $json->encode($json_ld); print json_encode($json_ld);
return true; return true;
} }

View file

@ -12,5 +12,5 @@ $conf['useMetaDescription'] = 1;
$conf['useMetaAuthor'] = 1; $conf['useMetaAuthor'] = 1;
$conf['useDublinCore'] = 0; $conf['useDublinCore'] = 0;
$conf['useOpenGraph'] = 0; $conf['useOpenGraph'] = 0;
$conf['excludedPages'] = '(wiki|playground)'; $conf['excludedPages'] = '(wiki)';
$conf['hideMail'] = 0; $conf['hideMail'] = 0;

View file

@ -4,14 +4,9 @@
* *
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
* @copyright (C) 2015-2019, Giuseppe Di Terlizzi * @copyright (C) 2015-2020, Giuseppe Di Terlizzi
*/ */
// must be run within Dokuwiki
if (!defined('DOKU_INC')) {
die();
}
class helper_plugin_semantic extends DokuWiki_Plugin class helper_plugin_semantic extends DokuWiki_Plugin
{ {

View file

@ -5,22 +5,22 @@
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
*/ */
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); class syntax_plugin_semantic extends DokuWiki_Syntax_Plugin
{
class syntax_plugin_semantic extends DokuWiki_Syntax_Plugin {
private $macros = array( private $macros = array(
'~~NewsArticle~~', '~~Article~~', '~~TechArticle~~', '~~NewsArticle~~', '~~Article~~', '~~TechArticle~~',
'~~BlogPosting~~', '~~Recipe~~', '~~NOSEMANTIC~~' '~~BlogPosting~~', '~~Recipe~~', '~~NOSEMANTIC~~',
); );
function getType() { return 'substition'; } public function getType()
function getSort() { return 99; } {return 'substition';}
public function getSort()
{return 99;}
function connectTo($mode) { public function connectTo($mode)
{
foreach ($this->macros as $macro) { foreach ($this->macros as $macro) {
$this->Lexer->addSpecialPattern($macro, $mode, 'plugin_semantic'); $this->Lexer->addSpecialPattern($macro, $mode, 'plugin_semantic');
@ -28,11 +28,13 @@ class syntax_plugin_semantic extends DokuWiki_Syntax_Plugin {
} }
function handle($match, $state, $pos, Doku_Handler $handler) { public function handle($match, $state, $pos, Doku_Handler $handler)
{
return array($match, $state, $pos); return array($match, $state, $pos);
} }
function render($mode, Doku_Renderer $renderer, $data) { public function render($mode, Doku_Renderer $renderer, $data)
{
if ($mode == 'metadata') { if ($mode == 'metadata') {