Compare commits

...

22 Commits

Author SHA1 Message Date
Maxime Rainville 71d7345a3b
Merge pull request #157 from creative-commoners/pulls/master/abandoned
Mark as abandoned
2023-03-17 10:29:18 +13:00
Guy Sartorelli 446bb12a88
Mark as abandoned 2023-03-17 10:26:53 +13:00
Guy Marriott 619d3e9dd7
Merge branch '2' 2019-08-01 14:23:29 +12:00
Guy Marriott de147fb1a2
Merge branch '2.0' into 2 2019-08-01 14:23:12 +12:00
Guy Marriott 5e8b45f200
Update Travis config 2019-08-01 14:22:53 +12:00
Mateusz Uzdowski 8d1523346e
jQuery 3 compatibility. 2019-08-01 14:22:53 +12:00
Guy Marriott fc7c658b00
jQuery 3 compatibility. (#153)
jQuery 3 compatibility.

Co-authored-by: Guy Marriott <guy@scopey.co.nz>
2019-08-01 14:03:16 +12:00
Guy Marriott a5f7e6f22d
Update Travis config 2019-08-01 14:01:07 +12:00
Mateusz Uzdowski f259e97e13 jQuery 3 compatibility. 2019-08-01 13:55:00 +12:00
Robbie Averill eba2d4536c Update branch alias for master to 3.x-dev 2019-04-29 16:57:06 +12:00
Robbie Averill 5f7a4f7e23 Merge branch '2' 2019-04-29 16:56:49 +12:00
Robbie Averill a539c38091 Remove obsolete branch alias 2019-04-29 16:56:22 +12:00
Robbie Averill 57857836e9 Merge branch '2.0' 2019-02-14 17:43:43 +07:00
Robbie Averill 6dd75a2884 Remove obsolete branch alias 2019-02-14 17:43:28 +07:00
Guy Marriott 171652b338
Merge pull request #151 from creative-commoners/pulls/2.0/extensible-edit-link
FIX getEditLink is now extensible and Lang route handling has a fallback
2019-02-14 20:56:02 +13:00
Robbie Averill e0c20ddf2b FIX getEditLink is now extensible and Lang route handling has a fallback
In some cases the Lang is not available in the route, this fixes that as well as
making the getEditLink() method extensible
2019-02-01 12:19:52 +03:00
Sam Minnee 03ec3d287e MINOR: Alias dev-master as 2.x 2018-06-08 16:14:53 +12:00
Ingo Schommer 8f7ebf42a0
Merge pull request #148 from sminnee/safe-urls
NEW: Ensure internal URLs are domain-relative
2018-06-08 13:26:29 +12:00
Sam Minnee f7377865d4 NEW: Ensure internal URLs are domain-relative
Domain relative URLs (i.e. those starting with “/“) are safer; less
likely to break webcrawlers. Other parts of SilverStripe output URLs
in this form by default.
2018-06-08 11:18:39 +12:00
Sam Minnée 691f5dddb8
FIX: Relaxed parsedown requirement for PHP 7 support (#138)
FIX: Modernise travis build matrix
 - SS 3.6 works with PHP 7.1
 - PHP 5.3 testing is no longer feasible
* FIX: Drop use of precise.

Precise is deprecated, we shouldn’t use it. Instead we should drop php
5.3 testing.
2018-06-08 11:16:16 +12:00
Sam Minnee e28613b1be FIX: Modernise travis build matrix
- SS 3.6 works with PHP 7.1
 - PHP 5.3 testing is no longer feasible
 - Deprecated use of precise no longer needed
2018-06-08 11:15:33 +12:00
Petar Simic e8ab218ffc FIX: Relax parsedown / parsedown-extra requirement, for PHP7 support
Dependency for parsedown increased to minor semver version ~1.1 . Reason: other modules that require parsedown as dependency need higher version of it.
2018-06-08 11:14:56 +12:00
11 changed files with 101 additions and 73 deletions

View File

@ -1,31 +1,26 @@
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
sudo: false
dist: trusty
language: php
dist: precise
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
env:
- DB=MYSQL CORE_RELEASE=3
- DB=MYSQL CORE_RELEASE=3.7
matrix:
allow_failures:
- php: 7.0
include:
- php: '7.1'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.2'
env: DB=MYSQL CORE_RELEASE=3.7
- php: '7.3'
env: DB=MYSQL CORE_RELEASE=3.7
before_script:
- composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
- composer install
script:
- vendor/bin/phpunit docsviewer/tests

View File

@ -1,5 +1,9 @@
# Documentation Viewer Module
## ABANDONED
This package is abandoned. See [silverstripe/doc.silverstripe.org](https://github.com/silverstripe/doc.silverstripe.org) instead.
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-docsviewer.png?branch=master)](http://travis-ci.org/silverstripe/silverstripe-docsviewer)
## Maintainer Contact

View File

@ -418,14 +418,15 @@ class DocumentationManifest
*/
protected function stripLinkBase($link)
{
return ltrim(
str_replace(
Config::inst()->get('DocumentationViewer', 'link_base'),
'',
$link
),
'/'
);
// Trim baseURL
$link = preg_replace('/^' . preg_quote(Director::baseURL(), '/') .'/', '', $link);
// Trim link_base
if ($linkBase = Config::inst()->get('DocumentationViewer', 'link_base')) {
$link = preg_replace('/^' . preg_quote($linkBase, '/') .'\/?/', '', $link);
}
return $link;
}
/**
@ -569,6 +570,19 @@ class DocumentationManifest
return $output;
}
/**
* Create a clean domain-relative URL form a docuetn URL
*/
protected function buildUrl($url)
{
return Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$url,
'/'
);
}
/**
* Determine the next page from the given page.
*
@ -589,7 +603,7 @@ class DocumentationManifest
if ($grabNext && strpos($page['filepath'], $entityBase) !== false) {
return new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url),
'Link' => $this->buildUrl($url),
'Title' => $page['title']
)
);
@ -600,7 +614,7 @@ class DocumentationManifest
} elseif (!$fallback && strpos($page['filepath'], $filepath) !== false) {
$fallback = new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url),
'Link' => $this->buildUrl($url),
'Title' => $page['title'],
'Fallback' => true
)
@ -635,7 +649,7 @@ class DocumentationManifest
if ($previousUrl) {
return new ArrayData(
array(
'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $previousUrl),
'Link' => $this->buildUrl($previousUrl),
'Title' => $previousPage['title']
)
);
@ -684,7 +698,6 @@ class DocumentationManifest
}
$output = new ArrayList();
$base = Config::inst()->get('DocumentationViewer', 'link_base');
$entityPath = $this->normalizeUrl($entityPath);
$recordPath = $this->normalizeUrl($recordPath);
$recordParts = explode('/', trim($recordPath, '/'));
@ -720,7 +733,7 @@ class DocumentationManifest
$output->push(
new ArrayData(
array(
'Link' => Controller::join_links($base, $url, '/'),
'Link' => $this->buildUrl($url),
'Title' => $page['title'],
'LinkingMode' => $mode,
'Summary' => $page['summary'],

View File

@ -62,7 +62,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
/**
* @config
*
* @var string same as the routing pattern set through Director::addRules().
* @var string Site-relative root URL of documentation. Same as the routing pattern set through Director::addRules().
*/
private static $link_base = 'dev/docs/';
@ -213,7 +213,6 @@ class DocumentationViewer extends Controller implements PermissionProvider
ltrim($url, '/'),
strlen($base)
);
} else {
}
//
@ -276,6 +275,11 @@ class DocumentationViewer extends Controller implements PermissionProvider
// return $redirect->redirect($cleaned, 302);
// }
if ($record = $this->getManifest()->getPage($url)) {
// In SS 3 offsetSet() isn't implemented for some reason... this is a workaround
$routeParams = $this->request->routeParams();
$routeParams['Lang'] = $lang;
$this->request->setRouteParams($routeParams);
$this->record = $record;
$this->init();
@ -567,6 +571,7 @@ class DocumentationViewer extends Controller implements PermissionProvider
public function Link($action = '')
{
$link = Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$this->getLanguage(),
$action,
@ -686,10 +691,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
/**
* Returns an edit link to the current page (optional).
*
* @return string
* @return string|false
*/
public function getEditLink()
{
$editLink = false;
$entity = null;
$page = $this->getPage();
if ($page) {
@ -705,13 +713,13 @@ class DocumentationViewer extends Controller implements PermissionProvider
}
if ($version == 'trunk' && (isset($url['options']['rewritetrunktomaster']))) {
if ($version === 'trunk' && (isset($url['options']['rewritetrunktomaster']))) {
if ($url['options']['rewritetrunktomaster']) {
$version = "master";
}
}
return str_replace(
$editLink = str_replace(
array('%entity%', '%lang%', '%version%', '%path%'),
array(
$entity->title,
@ -724,7 +732,9 @@ class DocumentationViewer extends Controller implements PermissionProvider
}
}
return false;
$this->extend('updateDocumentationEditLink', $editLink, $entity);
return $editLink;
}
@ -786,7 +796,10 @@ class DocumentationViewer extends Controller implements PermissionProvider
*/
public function getDocumentationBaseHref()
{
return Config::inst()->get('DocumentationViewer', 'link_base');
return Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base')
);
}
/**

View File

@ -137,12 +137,14 @@ class DocumentationEntity extends ViewableData
{
if ($this->getIsDefaultEntity()) {
$base = Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$this->getLanguage(),
'/'
);
} else {
$base = Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$this->getLanguage(),
$this->getKey(),
@ -150,8 +152,6 @@ class DocumentationEntity extends ViewableData
);
}
$base = ltrim(str_replace('//', '/', $base), '/');
if ($short && $this->stable) {
return $base;
}

View File

@ -262,12 +262,9 @@ class DocumentationPage extends ViewableData
*/
public function Link($short = false)
{
return ltrim(
Controller::join_links(
$this->entity->Link($short),
$this->getRelativeLink()
),
'/'
return Controller::join_links(
$this->entity->Link($short),
$this->getRelativeLink()
);
}

View File

@ -15,11 +15,17 @@
},
"require": {
"silverstripe/framework": "~3.1",
"erusev/parsedown-extra": "0.2.2",
"erusev/parsedown": "~1.1.0",
"erusev/parsedown-extra": "~0.2",
"erusev/parsedown": "~1.1",
"mnapoli/front-yaml": "^1.5"
},
"suggest": {
"silverstripe/staticpublisher": "Allows publishing documentation as HTML"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"abandoned": true
}

View File

@ -55,7 +55,7 @@
}
};
$(window).load(updateTables);
$(window).on('load', updateTables);
$(window).on(
"redraw",function() {
switched = false;

View File

@ -42,7 +42,7 @@ class DocumentationPageTest extends SapphireTest
// single layer
$this->assertEquals(
'dev/docs/en/doctest/2.4/test/',
Director::baseURL() . 'dev/docs/en/doctest/2.4/test/',
$page->Link(),
'The page link should have no extension and have a language'
);
@ -53,7 +53,7 @@ class DocumentationPageTest extends SapphireTest
DOCSVIEWER_PATH . '/tests/docs/en/sort/'
);
$this->assertEquals('dev/docs/en/doctest/2.4/sort/', $page->Link());
$this->assertEquals(Director::baseURL() . 'dev/docs/en/doctest/2.4/sort/', $page->Link());
$page = new DocumentationFolder(
$this->entity,
@ -61,7 +61,7 @@ class DocumentationPageTest extends SapphireTest
DOCSVIEWER_PATH . '/tests/docs/en/sort/1-basic.md'
);
$this->assertEquals('dev/docs/en/doctest/2.4/sort/basic/', $page->Link());
$this->assertEquals(Director::baseURL() . 'dev/docs/en/doctest/2.4/sort/basic/', $page->Link());
}
public function testGetBreadcrumbTitle()

View File

@ -174,7 +174,7 @@ HTML;
);
$this->assertContains(
'[link: subfolder index](dev/docs/en/documentationparsertest/2.4/subfolder/)',
'[link: subfolder index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/)',
$result
);
@ -186,11 +186,11 @@ HTML;
);
$this->assertContains(
'[link: subfolder index](dev/docs/en/documentationparsertest/2.4/subfolder/)',
'[link: subfolder index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/)',
$result
);
$this->assertContains(
'[link: subfolder page](dev/docs/en/documentationparsertest/2.4/subfolder/subpage/)',
'[link: subfolder page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/subpage/)',
$result
);
$this->assertContains(
@ -199,12 +199,12 @@ HTML;
);
$this->assertContains(
'[link: with anchor](dev/docs/en/documentationparsertest/2.4/test/#anchor)',
'[link: with anchor](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/#anchor)',
$result
);
$this->assertContains(
'[link: relative anchor](dev/docs/en/documentationparsertest/2.4/test/#relative-anchor)',
'[link: relative anchor](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/#relative-anchor)',
$result
);
@ -215,33 +215,33 @@ HTML;
// @todo this should redirect to /subpage/
$this->assertContains(
'[link: relative](dev/docs/en/documentationparsertest/2.4/subfolder/subpage.md/)',
'[link: relative](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/subpage.md/)',
$result
);
$this->assertContains(
'[link: absolute index](dev/docs/en/documentationparsertest/2.4/)',
'[link: absolute index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/)',
$result
);
// @todo this should redirect to /
$this->assertContains(
'[link: absolute index with name](dev/docs/en/documentationparsertest/2.4/index/)',
'[link: absolute index with name](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/index/)',
$result
);
$this->assertContains(
'[link: relative index](dev/docs/en/documentationparsertest/2.4/)',
'[link: relative index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/)',
$result
);
$this->assertContains(
'[link: relative parent page](dev/docs/en/documentationparsertest/2.4/test/)',
'[link: relative parent page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/)',
$result
);
$this->assertContains(
'[link: absolute parent page](dev/docs/en/documentationparsertest/2.4/test/)',
'[link: absolute parent page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/)',
$result
);
@ -251,27 +251,27 @@ HTML;
);
$this->assertContains(
'[link: absolute index](dev/docs/en/documentationparsertest/2.4/)',
'[link: absolute index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/)',
$result
);
$this->assertContains(
'[link: relative index](dev/docs/en/documentationparsertest/2.4/subfolder/)',
'[link: relative index](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/)',
$result
);
$this->assertContains(
'[link: relative parent page](dev/docs/en/documentationparsertest/2.4/subfolder/subpage/)',
'[link: relative parent page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/subfolder/subpage/)',
$result
);
$this->assertContains(
'[link: relative grandparent page](dev/docs/en/documentationparsertest/2.4/test/)',
'[link: relative grandparent page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/)',
$result
);
$this->assertContains(
'[link: absolute page](dev/docs/en/documentationparsertest/2.4/test/)',
'[link: absolute page](' . Director::baseURL() . 'dev/docs/en/documentationparsertest/2.4/test/)',
$result
);
}

View File

@ -157,9 +157,9 @@ class DocumentationViewerTest extends FunctionalTest
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/doc_test/2.3/'), DataModel::inst());
$expected = array(
'dev/docs/en/doc_test/2.3/sort/' => 'Sort',
'dev/docs/en/doc_test/2.3/subfolder/' => 'Subfolder',
'dev/docs/en/doc_test/2.3/test/' => 'Test'
Director::baseURL() . 'dev/docs/en/doc_test/2.3/sort/' => 'Sort',
Director::baseURL() . 'dev/docs/en/doc_test/2.3/subfolder/' => 'Subfolder',
Director::baseURL() . 'dev/docs/en/doc_test/2.3/test/' => 'Test'
);
$actual = $v->getMenu()->first()->Children->map('Link', 'Title');
@ -174,9 +174,9 @@ class DocumentationViewerTest extends FunctionalTest
// menu should contain all the english entities
$expected = array(
'dev/docs/en/doc_test/2.4/' => 'Doc Test',
'dev/docs/en/documentationvieweraltmodule1/' => 'DocumentationViewerAltModule1',
'dev/docs/en/documentationvieweraltmodule2/' => 'DocumentationViewerAltModule2'
Director::baseURL() . 'dev/docs/en/doc_test/2.4/' => 'Doc Test',
Director::baseURL() . 'dev/docs/en/documentationvieweraltmodule1/' => 'DocumentationViewerAltModule1',
Director::baseURL() . 'dev/docs/en/documentationvieweraltmodule2/' => 'DocumentationViewerAltModule2'
);
$this->assertEquals($expected, $v->getMenu()->map('Link', 'Title'));