Skip to content

Commit

Permalink
Merge pull request #164 from furbrain/master
Browse files Browse the repository at this point in the history
Add HideNoNs option
  • Loading branch information
gturri authored May 30, 2024
2 parents 8cdf572 + eac2477 commit 0dc41fb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
35 changes: 35 additions & 0 deletions _tests/src/test/java/nspages/Test_hideNoNs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package nspages;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class Test_hideNoNs extends Helper {
@Test
public void withoutOption(){
generatePage("noitems:start", "<nspages -exclude nonexistent>");

List<WebElement> sections = getDriver().findElements(By.className("catpageheadline"));
assertEquals(0, sections.size());

//Without this assert, the test would succeed even without the implementation commit
assertTrue(pagesContains("namespace doesn't exist:"));
}

@Test
public void withOption(){
generatePage("noitems:start", "<nspages -exclude -hideNoNs nonexistent>");

List<WebElement> sections = getDriver().findElements(By.className("catpageheadline"));
assertEquals(0, sections.size());

//Without this assert, the test would succeed even without the implementation commit
assertFalse(pagesContains("namespace doesn't exist:"));
}
}
10 changes: 7 additions & 3 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
optionParser::checkOption($match, "sort(By)?Date", $return['sortDate'], true);
optionParser::checkOption($match, "sort(By)?CreationDate", $return['sortByCreationDate'], true);
optionParser::checkOption($match, "hidenopages", $return['hidenopages'], true);
optionParser::checkOption($match, "hidenons", $return['hidenons'], true);
optionParser::checkOption($match, "hidenosubns", $return['hidenosubns'], true);
optionParser::checkOption($match, "showhidden", $return['showhidden'], true);
optionParser::checkOption($match, "(use)?Pictures?", $return['usePictures'], true);
Expand Down Expand Up @@ -124,7 +125,7 @@ private function _getDefaultOptions(){
'pagesinns' => false, 'anchorName' => null, 'actualTitleLevel' => false,
'idAndTitle' => false, 'nbItemsMax' => 0, 'numberedList' => false,
'natOrder' => false, 'sortDate' => false,
'hidenopages' => false, 'hidenosubns' => false, 'usePictures' => false,
'hidenopages' => false, 'hidenons' => false, 'hidenosubns' => false, 'usePictures' => false,
'showhidden' => false, 'dictOrder' => false,
'modificationDateOnPictures' => false,
'displayModificationDate' => false,
Expand Down Expand Up @@ -165,8 +166,11 @@ function render($mode, Doku_Renderer $renderer, $data) {
}


if( ! $this->_isNamespaceUsable($data)){
$printer->printUnusableNamespace($data['wantedNS']);
if( ! $this->_isNamespaceUsable($data))
{
if( ! $data['hidenons']) {
$printer->printUnusableNamespace($data['wantedNS']);
}
return TRUE;
}

Expand Down

0 comments on commit 0dc41fb

Please sign in to comment.