Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new javascript tree based at Fancytree #254

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
18472eb
action.php update PHPDOCS, signatures, INPUT, visibility
Klap-in Aug 2, 2020
c7986a7
admin.php update signatures, phpdocs, httpclient, visibility
Klap-in Aug 2, 2020
808dade
tag.php update signatures, phpdocs, visibility
Klap-in Aug 2, 2020
ddcbc96
ajax.php remove old functions, update phpdocs
Klap-in Aug 2, 2020
a143e62
indexmenu.php phpdocs, reformat, replace json
Klap-in Aug 2, 2020
92555e4
javascript jsdocs, explanation, stricter, some renaming
Klap-in Aug 2, 2020
f709187
rename index.obj to .treeName, PHPDocs, globals
Klap-in Aug 9, 2020
10a8bfa
fancytree treemenu library
Klap-in Jul 5, 2021
00f34eb
jquery ui contextmenu plugin
Klap-in Jul 5, 2021
ce42931
first basic implementation of fancytree
Klap-in Jul 5, 2021
7be2863
Move parts to Search class
Klap-in Jul 6, 2021
75682dd
refactoring, switch between trees, ajax loading fancytree
Klap-in Jul 7, 2022
adc30c5
Merge remote-tracking branch 'origin/master' into deferjs
Klap-in Jul 7, 2022
2fcc157
unittest for sorting
Klap-in Sep 14, 2022
0418bdf
check for empty is not useful, skipf/skipns where not checked for empty
Klap-in Sep 14, 2022
fbf842a
php8 warning fixes, reformating
Klap-in Sep 14, 2022
8437fb1
fix looping over unset entries
Klap-in Sep 15, 2022
5ef2ce0
move syntax test
Klap-in Sep 30, 2023
1c0c7a8
extend tests
Klap-in Sep 30, 2023
a3507a2
refactor, php8 fixes from master, cleanup
Klap-in Sep 30, 2023
6c8660a
load css for skin seperately
Klap-in Sep 30, 2023
b633d25
Update Fancytree Plugin from 2.38.0 to 2.38.3
Klap-in Oct 2, 2023
208beef
import all styles for fancytree skins
Klap-in Nov 2, 2023
ff62de4
add Github action and GeneralTests
Klap-in Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/dokuwiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: DokuWiki Default Tasks
on:
push:
pull_request:
schedule:
- cron: '14 17 21 * *'


jobs:
all:
uses: dokuwiki/github-action/.github/workflows/all.yml@main
659 changes: 659 additions & 0 deletions Search.php

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions _test/ActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* Test namespace includes
*
* @group plugin_indexmenu
* @group plugins
*/
class ActionTest extends DokuWikiTest {
/**

/**
* Setup - enable and load the include plugin and create the test pages
*/
public function setUp() : void
{
$this->pluginsEnabled[] = 'indexmenu';
parent::setUp(); // this enables the include plugin
// $this->helper = plugin_load('helper', 'include');

// global $conf;
// $conf['hidepages'] = 'inclhidden:hidden';

// for testing hidden pages
saveWikiText('ns2:bpage', "======H1======\nText", 'Sort different naturally/title/page');
saveWikiText('ns2:apage', "======H3======\nText", 'Sort different naturally/title/page');
saveWikiText('ns2:cpage', "======H2======\nText", 'Sort different naturally/title/page');

// pages on different levels
saveWikiText('ns1:ns1:apage', 'Page on level 1', 'Created page on level 1');
saveWikiText('ns1:lvl2:lvl3:lvl4:apage', 'Page on level 4', 'Created page on level 4');
saveWikiText('ns1:ns2:apage', 'Page on level 2', 'Created page on level 2');
saveWikiText('ns1:ns0:bpage', 'Page on level 2', 'Created page on level 2');
}

}
322 changes: 322 additions & 0 deletions _test/AjaxRequestsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
<?php

/**
* Principle copied from _test/tests/lib/exe/ajax_requests.test.php
*
* @group ajax
* @group plugin_indexmenu
* @group plugins
*/
class AjaxRequestsTest extends DokuWikiTest
{
public function setUp(): void
{
$this->pluginsEnabled[] = 'indexmenu';
parent::setUp(); // this enables the indexmenu plugin

//needed for 'tsort' to use First headings, sets title during search, otherwise as fallback page name used.
global $conf;
$conf['useheading'] = 'navigation';


// for testing sorting pages
saveWikiText('ns2:cpage', "======Bb======\nText", 'Sort different page/title/creation date');
sleep(1); // ensure different timestamps for 'dsort'
saveWikiText('ns2:bpage', "======Aa======\nText", 'Sort different page/title/creation date');
sleep(1);
saveWikiText('ns2:apage', "======Cc======\nText", 'Sort different page/title/creation date');

//ensures title is added to metadata of page
idx_addPage('ns2:cpage');
idx_addPage('ns2:bpage');
idx_addPage('ns2:apage');

// pages on different levels
saveWikiText('ns1:ns2:apage', "======Bb======\nPage on level 2", 'Created page on level 2');
saveWikiText('ns1:ns1:apage', "======Ee======\nPage on level 2", 'Created page on level 2');
saveWikiText('ns1:ns1:lvl3:lvl4:apage', "======Cc======\nPage on levl 4", 'Page on level 4');
saveWikiText('ns1:ns1:start', "======Aa======\nPage on level 2", 'Startpage on level 2');
saveWikiText('ns1:ns0:bpage', "======Aa2======\nPage on level 2", 'Created page on level 2');
saveWikiText('ns1:apage', "======Dd======\nPage on level 1", 'Created page on level 1');

//ensures title is added to metadata
idx_addPage('ns1:ns1:apage');
idx_addPage('ns1:ns1:lvl3:lvl4:apage');
idx_addPage('ns1:ns1:start');
idx_addPage('ns1:ns2:apage');
idx_addPage('ns1:ns0:bpage');
idx_addPage('ns1:apage');
}

/**
* DataProvider for the builtin Ajax calls
*
* @return array
*/
public static function indexmenuCalls()
{
return [
// Call, POST parameters, result function
[
'indexmenu',
AjaxRequestsTest::prepareParams(['level' => 1]),
'expectedResultWiki'
],
[
'indexmenu',
AjaxRequestsTest::prepareParams(['ns' => 'ns2', 'level' => 1]),
'expectedResultNs2PageSort'
],
[
'indexmenu',
AjaxRequestsTest::prepareParams(['ns' => 'ns2', 'level' => 1, 'sort' => 't']),
'expectedResultNs2TitleSort'
],
[
'indexmenu',
AjaxRequestsTest::prepareParams(['ns' => 'ns2', 'level' => 1, 'sort' => 'd']),
'expectedResultNs2CreationDateSort'
],
[
'indexmenu',
AjaxRequestsTest::prepareParams(['ns' => 'ns1', 'level' => 1, 'sort' => 't']),
'expectedResultNs1TitleSort'
],
[
'indexmenu',
AjaxRequestsTest::prepareParams(['ns' => 'ns1', 'level' => 1, 'sort' => 't', 'nsort' => 1]),
'expectedResultNs1TitleSortNamespaceSort'
]
];
}

/**
* @dataProvider indexmenuCalls
*
* @param string $call
* @param array $post
* @param $expectedResult
*/
public function testBasicSorting($call, $post, $expectedResult)
{
$request = new TestRequest();
$response = $request->post(['call' => $call] + $post, '/lib/exe/ajax.php');
// $this->assertNotEquals("AJAX call '$call' unknown!\n", $response->getContent());

//var_export(json_decode($response->getContent()), true); // print as PHP array

$actualArray = json_decode($response->getContent(), true);
unset($actualArray['debug']);
unset($actualArray['sort']);
unset($actualArray['opts']);

$this->assertEquals($this->$expectedResult(), $actualArray);

// $regexp: null, or regexp pattern to match
// example: '/^<div class="odd type_d/'
// if (!empty($regexp)) {
// $this->assertRegExp($regexp, $response->getContent());
// }

}

public function test_params()
{
print_r(AjaxRequestsTest::prepareParams(['level' => 2]));

$this->assertTrue(true);
}

public static function prepareParams($params = [])
{
$defaults = [
'ns' => 'wiki',
'req' => 'fancytree',
'level' => 1,
'nons' => 0,
'nopg' => 0,
'max' => 0,
'skipns' => ['/^board:(first|second|third|fourth|fifth)$/'],
'skipfile' => ['/(:start$)/'],
'sort' => 0,
'msort' => 0,
'rsort' => 0,
'nsort' => 0,
'hsort' => 0,
'init' => 1
];
$return = [];
foreach ($defaults as $key => $default) {
$return[$key] = $params[$key] ?? $default;
}
return $return;
}

public function expectedResultWiki()
{
return [
'children' => [
0 => [
'title' => 'dokuwiki',
'key' => 'wiki:dokuwiki',
'hns' => false,
],
1 => [
'title' => 'syntax',
'key' => 'wiki:syntax',
'hns' => false,
]
]];
}

public function expectedResultNs1()
{
return [
'children' => [
0 => [
'title' => 'dokuwiki',
'key' => 'wiki:dokuwiki',
'hns' => false,
],
1 => [
'title' => 'syntax',
'key' => 'wiki:syntax',
'hns' => false,
]
]];
}

public function expectedResultNs2PageSort()
{
return [
'children' => [
0 => [
'title' => 'Cc',
'key' => 'ns2:apage',
'hns' => false
],
1 => [
'title' => 'Aa',
'key' => 'ns2:bpage',
'hns' => false
],
2 => [
'title' => 'Bb',
'key' => 'ns2:cpage',
'hns' => false
]
]];
}

public function expectedResultNs2TitleSort()
{
return [
'children' => [
0 => [
'title' => 'Aa',
'key' => 'ns2:bpage',
'hns' => false
],
1 => [
'title' => 'Bb',
'key' => 'ns2:cpage',
'hns' => false
],
2 => [
'title' => 'Cc',
'key' => 'ns2:apage',
'hns' => false
]
]];
}

public function expectedResultNs2CreationDateSort()
{
return [
'children' => [
0 => [
'title' => 'Bb',
'key' => 'ns2:cpage',
'hns' => false
],
1 => [
'title' => 'Aa',
'key' => 'ns2:bpage',
'hns' => false
],
2 => [
'title' => 'Cc',
'key' => 'ns2:apage',
'hns' => false
]
]];
}

public function expectedResultNs1TitleSort()
{
return [
'children' => [
0 => [
'title' => 'ns0',
'key' => 'ns1:ns0:',
'hns' => false,
'folder' => true,
'lazy' => true
],
1 => [
'title' => 'Aa',
'key' => 'ns1:ns1:',
'hns' => 'ns1:ns1:start',
'folder' => true,
'lazy' => true
],
2 => [
'title' => 'ns2',
'key' => 'ns1:ns2:',
'hns' => false,
'folder' => true,
'lazy' => true
],
3 => [
'title' => 'Dd',
'key' => 'ns1:apage',
'hns' => false
]
]];
}

public function expectedResultNs1TitleSortNamespaceSort()
{
// 'nsort' let the sort explicitly use the namespace name as sort key.
// 'nsort' + 'tsort' works only for nsort if head pages are used.
return [
'children' => [
0 => [
'title' => 'Aa',
'key' => 'ns1:ns1:',
'hns' => 'ns1:ns1:start',
'folder' => true,
'lazy' => true
],
1 => [
'title' => 'ns0',
'key' => 'ns1:ns0:',
'hns' => false,
'folder' => true,
'lazy' => true
],
2 => [
'title' => 'ns2',
'key' => 'ns1:ns2:',
'hns' => false,
'folder' => true,
'lazy' => true
],
3 => [
'title' => 'Dd',
'key' => 'ns1:apage',
'hns' => false
]
]];
}
}
Loading
Loading