mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 17:05:50 +02:00
Updated sapphiredocs to latest master
git-svn-id: http://svn.silverstripe.com/projects/ss2doc/branches/v2@119990 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b53b3c5c89
commit
7abc39f423
@ -34,7 +34,7 @@ class DocumentationParser {
|
||||
if(!$page || (!$page instanceof DocumentationPage)) return false;
|
||||
|
||||
$md = $page->getMarkdown();
|
||||
|
||||
|
||||
// Pre-processing
|
||||
$md = self::rewrite_image_links($md, $page);
|
||||
$md = self::rewrite_relative_links($md, $page, $baselink);
|
||||
|
@ -108,10 +108,9 @@ class DocumentationSearch {
|
||||
|
||||
if($modules) {
|
||||
foreach($modules as $module) {
|
||||
|
||||
foreach($module->getLanguages() as $language) {
|
||||
foreach($module->getVersions() as $version) {
|
||||
try {
|
||||
$pages = DocumentationService::get_pages_from_folder($module);
|
||||
$pages = DocumentationService::get_pages_from_folder($module, false, true, $version);
|
||||
|
||||
if($pages) {
|
||||
foreach($pages as $page) {
|
||||
|
@ -145,8 +145,8 @@ class DocumentationService {
|
||||
*/
|
||||
public static function get_registered_versions($module = false) {
|
||||
if($module) {
|
||||
if(isset($registered_modules[$module])) {
|
||||
return $registered_modules[$module]->getVersions();
|
||||
if(isset(self::$registered_modules[$module])) {
|
||||
return self::$registered_modules[$module]->getVersions();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
@ -256,26 +256,26 @@ class DocumentationService {
|
||||
* @param Float $version Version of module.
|
||||
* @param String $title Nice title to use
|
||||
* @param bool $major is this a major release
|
||||
* @param bool $latest - return is this the latest release.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return DocumentationEntity
|
||||
*/
|
||||
public static function register($module, $path, $version = '', $title = false, $major = false) {
|
||||
public static function register($module, $path, $version = '', $title = false, $major = false, $latest = false) {
|
||||
if(!file_exists($path)) throw new InvalidArgumentException(sprintf('Path "%s" doesn\'t exist', $path));
|
||||
|
||||
// add the module to the registered array
|
||||
if(!isset(self::$registered_modules[$module])) {
|
||||
// module is completely new
|
||||
$entity = new DocumentationEntity($module, $version, $path, $title);
|
||||
|
||||
|
||||
self::$registered_modules[$module] = $entity;
|
||||
}
|
||||
else {
|
||||
// module exists so add the version to it
|
||||
$entity = self::$registered_modules[$module];
|
||||
|
||||
$entity->addVersion($version, $path, true);
|
||||
$entity->addVersion($version, $path);
|
||||
}
|
||||
|
||||
if($major) {
|
||||
@ -286,6 +286,11 @@ class DocumentationService {
|
||||
}
|
||||
}
|
||||
|
||||
if($latest) {
|
||||
$entity->setLatestVersion($version);
|
||||
}
|
||||
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -362,14 +367,16 @@ class DocumentationService {
|
||||
*
|
||||
* @param DocumentationEntity
|
||||
* @param array exploded url string
|
||||
* @param string version number
|
||||
* @param string lang code
|
||||
*
|
||||
* @return String|false - File path
|
||||
*/
|
||||
static function find_page($module, $path) {
|
||||
if($module = self::is_registered_module($module)) {
|
||||
return self::find_page_recursive($module->getPath(), $path);
|
||||
static function find_page($module, $path, $version = '', $lang = 'en') {
|
||||
if($module = self::is_registered_module($module, $version, $lang)) {
|
||||
return self::find_page_recursive($module->getPath($version, $lang), $path);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -503,19 +510,24 @@ class DocumentationService {
|
||||
* @param DocumentationEntity path
|
||||
* @param string - an optional path within a module
|
||||
* @param bool enable several recursive calls (more than 1 level)
|
||||
* @param string - version to use
|
||||
* @param string - lang to use
|
||||
*
|
||||
* @throws Exception
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public static function get_pages_from_folder($module, $relativePath = false, $recursive = true) {
|
||||
// var_dump("START: get pages from $module | $relativePath");
|
||||
public static function get_pages_from_folder($module, $relativePath = false, $recursive = true, $version = 'trunk', $lang = 'en') {
|
||||
$output = new DataObjectSet();
|
||||
|
||||
$pages = array();
|
||||
if(!$module instanceof DocumentationEntity) user_error("get_pages_from_folder must be passed a module", E_USER_ERROR);
|
||||
|
||||
if(!$module instanceof DocumentationEntity)
|
||||
user_error("get_pages_from_folder must be passed a module", E_USER_ERROR);
|
||||
|
||||
$path = $module->getPath($version, $lang);
|
||||
|
||||
|
||||
if(self::is_registered_module($module)) {
|
||||
self::get_pages_from_folder_recursive($module->getPath(), $relativePath, $recursive, $pages);
|
||||
self::get_pages_from_folder_recursive($path, $relativePath, $recursive, $pages);
|
||||
}
|
||||
else {
|
||||
return user_error("$module is not registered", E_USER_WARNING);
|
||||
@ -524,22 +536,27 @@ class DocumentationService {
|
||||
if(count($pages) > 0) {
|
||||
natsort($pages);
|
||||
|
||||
foreach($pages as $key => $path) {
|
||||
foreach($pages as $key => $pagePath) {
|
||||
|
||||
// get file name from the path
|
||||
$file = ($pos = strrpos($path, '/')) ? substr($path, $pos + 1) : $path;
|
||||
$file = ($pos = strrpos($pagePath, '/')) ? substr($pagePath, $pos + 1) : $pagePath;
|
||||
|
||||
$page = new DocumentationPage();
|
||||
$page->setTitle(self::clean_page_name($file));
|
||||
$relative = str_replace($module->getPath(), '', $path);
|
||||
$relative = str_replace($path, '', $pagePath);
|
||||
|
||||
// if no extension, put a slash on it
|
||||
if(strpos($relative, '.') === false) $relative .= '/';
|
||||
|
||||
$page->setEntity($module);
|
||||
$page->setRelativePath($relative);
|
||||
// var_dump("ADDING FILE: ". $relative . " [$path]");
|
||||
$page->setVersion($version);
|
||||
$page->setLang($lang);
|
||||
|
||||
$output->push($page);
|
||||
}
|
||||
}
|
||||
// var_dump("END get pages");
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
$this->Remaining = $request->shift(10);
|
||||
DocumentationService::load_automatic_registration();
|
||||
|
||||
|
||||
if(isset($firstParam)) {
|
||||
// allow assets
|
||||
if($firstParam == "assets") return parent::handleRequest($request);
|
||||
@ -145,10 +145,8 @@ class DocumentationViewer extends Controller {
|
||||
// the first param is a shortcode for a page so redirect the user to
|
||||
// the short code.
|
||||
$this->response = new SS_HTTPResponse();
|
||||
|
||||
$this->redirect($link, 301); // permanent redirect
|
||||
|
||||
|
||||
$this->redirect($link, 301); // 301 permanent redirect
|
||||
|
||||
return $this->response;
|
||||
|
||||
}
|
||||
@ -157,45 +155,36 @@ class DocumentationViewer extends Controller {
|
||||
$this->lang = $secondParam;
|
||||
|
||||
if(isset($thirdParam) && (is_numeric($thirdParam) || in_array($thirdParam, array('master', 'trunk')))) {
|
||||
$this->version = $thirdParam;
|
||||
$this->version = $thirdParam;
|
||||
}
|
||||
else {
|
||||
// current version so store one area para
|
||||
array_unshift($this->Remaining, $thirdParam);
|
||||
|
||||
$this->version = "";
|
||||
$this->version = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 'current' version mapping
|
||||
$module = DocumentationService::is_registered_module($this->module, null, $this->getLang());
|
||||
|
||||
|
||||
if($module) {
|
||||
$current = $module->getCurrentVersion();
|
||||
|
||||
$current = $module->getLatestVersion();
|
||||
$version = $this->getVersion();
|
||||
|
||||
|
||||
if(!$version || $version == '') {
|
||||
$this->version = $current;
|
||||
} else if($current == $version) {
|
||||
$this->version = '';
|
||||
|
||||
$link = $this->Link($this->Remaining);
|
||||
$this->response = new SS_HTTPResponse();
|
||||
|
||||
$this->redirect($link, 301); // permanent redirect
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
// Check if page exists, otherwise return 404
|
||||
if(!$this->locationExists()) {
|
||||
$body = $this->renderWith(get_class($this));
|
||||
$this->response = new SS_HTTPResponse($body, 404);
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return parent::handleRequest($request);
|
||||
}
|
||||
|
||||
@ -206,6 +195,7 @@ class DocumentationViewer extends Controller {
|
||||
// count the number of parameters after the language, version are taken
|
||||
// into account. This automatically includes ' ' so all the counts
|
||||
// are 1 more than what you would expect
|
||||
|
||||
if($this->module || $this->Remaining) {
|
||||
|
||||
$paramCount = count($this->Remaining);
|
||||
@ -214,11 +204,10 @@ class DocumentationViewer extends Controller {
|
||||
return parent::getViewer('folder');
|
||||
}
|
||||
else if($module = $this->getModule()) {
|
||||
$params = $this->Remaining;
|
||||
|
||||
$path = implode('/', array_unique($params));
|
||||
|
||||
if(is_dir($module->getPath() . $path)) return parent::getViewer('folder');
|
||||
// if this is a folder return the folder listing
|
||||
if($this->locationExists() == 2) {
|
||||
return parent::getViewer('folder');
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -230,12 +219,20 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
/**
|
||||
* Returns the current version. If no version is set then it is the current
|
||||
* set version so need to pull that from the module
|
||||
* set version so need to pull that from the module.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
function getVersion() {
|
||||
return $this->version;
|
||||
if($this->version) return $this->version;
|
||||
|
||||
if($module = $this->getModule()) {
|
||||
$this->version = $module->getLatestVersion();
|
||||
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,25 +296,35 @@ class DocumentationViewer extends Controller {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
function getVersions($module = false) {
|
||||
$versions = DocumentationService::get_registered_versions($module);
|
||||
$output = new DataObjectSet();
|
||||
if(!$module) $module = $this->module;
|
||||
|
||||
foreach($versions as $key => $version) {
|
||||
// work out the link to this version of the documentation.
|
||||
//
|
||||
// @todo Keep the user on their given page rather than redirecting to module.
|
||||
// @todo Get links working
|
||||
$linkingMode = ($this->Version == $version) ? 'current' : 'link';
|
||||
$entity = DocumentationService::is_registered_module($module);
|
||||
if(!$entity) return false;
|
||||
|
||||
$versions = DocumentationService::get_registered_versions($module);
|
||||
|
||||
$output = new DataObjectSet();
|
||||
$currentVersion = $this->getVersion();
|
||||
|
||||
if($versions) {
|
||||
$lang = $this->getLang();
|
||||
|
||||
if(!$version) $version = 'Current';
|
||||
$major = (in_array($version, DocumentationService::get_major_versions())) ? true : false;
|
||||
foreach($versions as $key => $version) {
|
||||
// work out the link to this version of the documentation.
|
||||
// @todo Keep the user on their given page rather than redirecting to module.
|
||||
$linkingMode = ($currentVersion == $version) ? 'current' : 'link';
|
||||
|
||||
$output->push(new ArrayData(array(
|
||||
'Title' => $version,
|
||||
'Link' => $_SERVER['REQUEST_URI'],
|
||||
'LinkingMode' => $linkingMode,
|
||||
'MajorRelease' => $major
|
||||
)));
|
||||
if(!$version) $version = 'Current';
|
||||
$major = (in_array($version, DocumentationService::get_major_versions())) ? true : false;
|
||||
|
||||
|
||||
$output->push(new ArrayData(array(
|
||||
'Title' => $version,
|
||||
'Link' => $entity->Link($version, $lang),
|
||||
'LinkingMode' => $linkingMode,
|
||||
'MajorRelease' => $major
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
@ -331,22 +338,24 @@ class DocumentationViewer extends Controller {
|
||||
* @return DataObject
|
||||
*/
|
||||
function getModules($version = false, $lang = false) {
|
||||
if(!$version) $version = $this->Version;
|
||||
if(!$lang) $lang = $this->Lang;
|
||||
if(!$version) $version = $this->getVersion();
|
||||
if(!$lang) $lang = $this->getLang();
|
||||
|
||||
$modules = DocumentationService::get_registered_modules($version, $lang);
|
||||
$output = new DataObjectSet();
|
||||
|
||||
if($modules) {
|
||||
foreach($modules as $module) {
|
||||
$absFilepath = $module->getPath() . '/index.md';
|
||||
$relativeFilePath = str_replace($module->getPath(), '', $absFilepath);
|
||||
$path = $module->getPath($version, $lang);
|
||||
$absFilepath = $path . '/index.md';
|
||||
$relativeFilePath = str_replace($path, '', $absFilepath);
|
||||
|
||||
if(file_exists($absFilepath)) {
|
||||
$page = new DocumentationPage();
|
||||
$page->setRelativePath($relativeFilePath);
|
||||
$page->setEntity($module);
|
||||
$page->setLang($this->Lang);
|
||||
$page->setVersion($this->Version);
|
||||
$page->setLang($lang);
|
||||
$page->setVersion($version);
|
||||
|
||||
$content = DocumentationParser::parse($page, $this->Link(array_slice($this->Remaining, -1, -1)));
|
||||
} else {
|
||||
@ -373,7 +382,11 @@ class DocumentationViewer extends Controller {
|
||||
*/
|
||||
function getModule() {
|
||||
if($this->module) {
|
||||
return DocumentationService::is_registered_module($this->module, $this->version, $this->lang);
|
||||
return DocumentationService::is_registered_module(
|
||||
$this->module,
|
||||
$this->version,
|
||||
$this->language
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -381,21 +394,34 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
/**
|
||||
* Simple way to check for existence of page of folder
|
||||
* without constructing too much object state.
|
||||
* Useful for generating 404 pages.
|
||||
*
|
||||
* @return boolean
|
||||
* without constructing too much object state. Useful for
|
||||
* generating 404 pages. Returns 0 for not a page or
|
||||
* folder, returns 1 for a page and 2 for folder
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function locationExists() {
|
||||
$module = $this->getModule();
|
||||
|
||||
if($module) {
|
||||
$has_dir = is_dir(Controller::join_links(
|
||||
$module->getPath($this->getVersion(), $this->getLang()),
|
||||
implode('/', $this->Remaining)
|
||||
));
|
||||
|
||||
if($has_dir) return 2;
|
||||
|
||||
$has_page = DocumentationService::find_page(
|
||||
$module,
|
||||
$this->Remaining,
|
||||
$this->getVersion(),
|
||||
$this->getLang()
|
||||
);
|
||||
|
||||
return (
|
||||
$module
|
||||
&& (
|
||||
DocumentationService::find_page($module, $this->Remaining)
|
||||
|| is_dir($module->getPath() . implode('/', $this->Remaining))
|
||||
)
|
||||
);
|
||||
if($has_page) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,20 +429,31 @@ class DocumentationViewer extends Controller {
|
||||
*/
|
||||
function getPage() {
|
||||
$module = $this->getModule();
|
||||
|
||||
|
||||
if(!$module) return false;
|
||||
|
||||
$absFilepath = DocumentationService::find_page($module, $this->Remaining);
|
||||
|
||||
$version = $this->getVersion();
|
||||
$lang = $this->getLang();
|
||||
|
||||
$absFilepath = DocumentationService::find_page(
|
||||
$module,
|
||||
$this->Remaining,
|
||||
$version,
|
||||
$lang
|
||||
);
|
||||
|
||||
if($absFilepath) {
|
||||
$relativeFilePath = str_replace($module->getPath(), '', $absFilepath);
|
||||
|
||||
$relativeFilePath = str_replace(
|
||||
$module->getPath($version, $lang),
|
||||
'',
|
||||
$absFilepath
|
||||
);
|
||||
|
||||
$page = new DocumentationPage();
|
||||
$page->setRelativePath($relativeFilePath);
|
||||
|
||||
$page->setEntity($module);
|
||||
$page->setLang($this->Lang);
|
||||
$page->setVersion($this->Version);
|
||||
$page->setLang($lang);
|
||||
$page->setVersion($version);
|
||||
|
||||
return $page;
|
||||
}
|
||||
@ -433,7 +470,7 @@ class DocumentationViewer extends Controller {
|
||||
*/
|
||||
function getModulePages() {
|
||||
if($module = $this->getModule()) {
|
||||
$pages = DocumentationService::get_pages_from_folder($module, null, false);
|
||||
$pages = DocumentationService::get_pages_from_folder($module, null, false, $this->getVersion(), $this->getLang());
|
||||
|
||||
if($pages) {
|
||||
foreach($pages as $page) {
|
||||
@ -447,10 +484,10 @@ class DocumentationViewer extends Controller {
|
||||
$page->Children = $this->_getModulePagesNested($page, $module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -458,7 +495,7 @@ class DocumentationViewer extends Controller {
|
||||
* Get the module pages under a given page. Recursive call for {@link getModulePages()}
|
||||
*
|
||||
* @todo Need to rethink how to support pages which are pulling content from their children
|
||||
* i.e if a folder doesn't have index.md then it will load the first file in the folder
|
||||
* i.e if a folder doesn't have 2 then it will load the first file in the folder
|
||||
* however it doesn't yet pass the highlighting to it.
|
||||
*
|
||||
* @param ArrayData CurrentPage
|
||||
@ -468,24 +505,30 @@ class DocumentationViewer extends Controller {
|
||||
* @return DataObjectSet|false
|
||||
*/
|
||||
private function _getModulePagesNested(&$page, $module, $level = 0) {
|
||||
// only support 2 more levels
|
||||
if(isset($this->Remaining[$level])) {
|
||||
// compare segment successively, e.g. with "changelogs/alpha/2.4.0-alpha",
|
||||
// first comparison on $level=0 is against "changelogs",
|
||||
// second comparison on $level=1 is against "changelogs/alpha", etc.
|
||||
$segments = array_slice($this->Remaining, 0, $level+1);
|
||||
|
||||
if(strtolower(implode('/', $segments)) == trim($page->getRelativeLink(), '/')) {
|
||||
|
||||
// its either in this section or is the actual link
|
||||
$page->LinkingMode = (isset($this->Remaining[$level + 1])) ? 'section' : 'current';
|
||||
|
||||
$relativePath = Controller::join_links(
|
||||
$module->getPath($page->getVersion(), $page->getLang()),
|
||||
$module->getPath($this->getVersion(), $this->getLang()),
|
||||
$page->getRelativePath()
|
||||
);
|
||||
|
||||
if(is_dir($relativePath)) {
|
||||
$children = DocumentationService::get_pages_from_folder($module, $page->getRelativePath(), false);
|
||||
$children = DocumentationService::get_pages_from_folder(
|
||||
$module,
|
||||
$page->getRelativePath(),
|
||||
false,
|
||||
$this->getVersion(),
|
||||
$this->getLang()
|
||||
);
|
||||
|
||||
$segments = array();
|
||||
for($x = 0; $x <= $level; $x++) {
|
||||
@ -519,11 +562,10 @@ class DocumentationViewer extends Controller {
|
||||
* @return HTMLText
|
||||
*/
|
||||
function getContent() {
|
||||
if($page = $this->getPage()) {
|
||||
$page = $this->getPage();
|
||||
|
||||
// Remove last portion of path (filename), we want a link to the folder base
|
||||
$html = DocumentationParser::parse($page);
|
||||
return DBField::create("HTMLText", $html);
|
||||
if($page) {
|
||||
return DBField::create("HTMLText", $page->getHTML($this->getVersion(), $this->getLang()));
|
||||
}
|
||||
else {
|
||||
// If no page found then we may want to get the listing of the folder.
|
||||
@ -532,7 +574,14 @@ class DocumentationViewer extends Controller {
|
||||
$url = $this->Remaining;
|
||||
|
||||
if($url && $module) {
|
||||
$pages = DocumentationService::get_pages_from_folder($module, implode('/', $url), false);
|
||||
$pages = DocumentationService::get_pages_from_folder(
|
||||
$module,
|
||||
implode('/', $url),
|
||||
false,
|
||||
$this->getVersion(),
|
||||
$this->getLang()
|
||||
);
|
||||
|
||||
// If no pages are found, the 404 is handled in the same template
|
||||
return $this->customise(array(
|
||||
'Title' => DocumentationService::clean_page_name(array_pop($url)),
|
||||
@ -572,10 +621,10 @@ class DocumentationViewer extends Controller {
|
||||
if($title) {
|
||||
// Don't add module name, already present in Link()
|
||||
if($i > 0) $path[] = $title;
|
||||
|
||||
|
||||
$output->push(new ArrayData(array(
|
||||
'Title' => DocumentationService::clean_page_name($title),
|
||||
'Link' => $this->Link($path)
|
||||
'Link' => rtrim($this->Link($path), "/"). "/"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@ -611,21 +660,16 @@ class DocumentationViewer extends Controller {
|
||||
public function Link($path = false, $module = false) {
|
||||
$base = Director::absoluteBaseURL();
|
||||
|
||||
$version = ($this->version) ? $this->version . '/' : false;
|
||||
$lang = ($this->language) ? $this->language .'/' : false;
|
||||
$module = (!$module && $this->module) ? $this->module .'/' : $module;
|
||||
$version = $this->getVersion();
|
||||
$lang = $this->getLang();
|
||||
|
||||
$module = (!$module && $this->module) ? $this->module : $module;
|
||||
|
||||
$action = '';
|
||||
|
||||
if(is_string($path)) {
|
||||
$action = $path . '/';
|
||||
}
|
||||
if(is_string($path)) $action = $path;
|
||||
else if(is_array($path)) {
|
||||
foreach($path as $key => $value) {
|
||||
if($value) {
|
||||
$action .= $value .'/';
|
||||
}
|
||||
}
|
||||
$action = implode('/', $path);
|
||||
}
|
||||
|
||||
$link = Controller::join_links($base, self::get_link_base(), $module, $lang, $version, $action);
|
@ -11,9 +11,10 @@
|
||||
*
|
||||
* Versions are assumed to be in numeric format (e.g. '2.4'),
|
||||
* mainly as an easy way to distinguish them from language codes in the routing logic.
|
||||
* They're also parsed through version_compare() in {@link getCurrentVersion()} which assumes a certain format.
|
||||
* They're also parsed through version_compare() in {@link getLatestVersion()} which assumes a certain format.
|
||||
*
|
||||
* @package sapphiredocs
|
||||
* @subpackage model
|
||||
*/
|
||||
|
||||
class DocumentationEntity extends ViewableData {
|
||||
@ -40,7 +41,7 @@ class DocumentationEntity extends ViewableData {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $currentVersion;
|
||||
private $latestVersion;
|
||||
|
||||
/**
|
||||
* @var Array $langs a list of available langauges
|
||||
@ -124,14 +125,15 @@ class DocumentationEntity extends ViewableData {
|
||||
/**
|
||||
* @return String|Boolean
|
||||
*/
|
||||
public function getCurrentVersion() {
|
||||
public function getLatestVersion() {
|
||||
if(!$this->hasVersions()) return false;
|
||||
|
||||
if($this->currentVersion) {
|
||||
return $this->currentVersion;
|
||||
if($this->latestVersion) {
|
||||
return $this->latestVersion;
|
||||
} else {
|
||||
$sortedVersions = $this->getVersions();
|
||||
usort($sortedVersions, create_function('$a,$b', 'return version_compare($a,$b);'));
|
||||
|
||||
return array_pop($sortedVersions);
|
||||
}
|
||||
}
|
||||
@ -139,10 +141,9 @@ class DocumentationEntity extends ViewableData {
|
||||
/**
|
||||
* @param String $version
|
||||
*/
|
||||
public function setCurrentVersion($version) {
|
||||
public function setLatestVersion($version) {
|
||||
if(!$this->hasVersion($version)) throw new InvalidArgumentException(sprintf('Version "%s" does not exist', $version));
|
||||
|
||||
$this->currentVersion = $version;
|
||||
$this->latestVersion = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,13 +169,10 @@ class DocumentationEntity extends ViewableData {
|
||||
*
|
||||
* @param Float $version Version number
|
||||
* @param String $path path to folder
|
||||
* @param Boolean $current
|
||||
*/
|
||||
public function addVersion($version = '', $path, $current = false) {
|
||||
// determine the langs in this path
|
||||
|
||||
public function addVersion($version = '', $path) {
|
||||
|
||||
$langs = scandir($path);
|
||||
|
||||
$available = array();
|
||||
|
||||
if($langs) {
|
||||
@ -189,8 +187,6 @@ class DocumentationEntity extends ViewableData {
|
||||
|
||||
$this->addLanguage($available);
|
||||
$this->versions[$version] = $path;
|
||||
|
||||
if($current) $this->setCurrentVersion($version);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,8 +207,7 @@ class DocumentationEntity extends ViewableData {
|
||||
* @return string
|
||||
*/
|
||||
public function getPath($version = false, $lang = false) {
|
||||
|
||||
if(!$version) $version = '';
|
||||
if(!$version) $version = $this->getLatestVersion();
|
||||
if(!$lang) $lang = 'en';
|
||||
|
||||
if($this->hasVersion($version)) {
|
||||
@ -239,7 +234,7 @@ class DocumentationEntity extends ViewableData {
|
||||
}
|
||||
|
||||
function getRelativeLink($version = false, $lang = false) {
|
||||
if(!$version) $version = '';
|
||||
if(!$version) $version = $this->getLatestVersion();
|
||||
if(!$lang) $lang = 'en';
|
||||
|
||||
return Controller::join_links(
|
@ -5,6 +5,7 @@
|
||||
* filesystem.
|
||||
*
|
||||
* @package sapphiredocs
|
||||
* @subpackage model
|
||||
*/
|
||||
class DocumentationPage extends ViewableData {
|
||||
|
||||
@ -76,7 +77,11 @@ class DocumentationPage extends ViewableData {
|
||||
*/
|
||||
function getPath($defaultFile = false) {
|
||||
if($this->entity) {
|
||||
$path = rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . trim($this->getRelativePath(), '/');
|
||||
|
||||
$path = Controller::join_links(
|
||||
$this->entity->getPath($this->getVersion(), $this->lang),
|
||||
$this->getRelativePath()
|
||||
);
|
||||
|
||||
if(!is_dir($path)) $path = realpath($path);
|
||||
else if($defaultFile) {
|
||||
@ -88,7 +93,6 @@ class DocumentationPage extends ViewableData {
|
||||
else {
|
||||
$path = $this->getRelativePath();
|
||||
}
|
||||
|
||||
if(!file_exists($path)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Path could not be found. Module path: %s, file path: %s',
|
||||
@ -107,7 +111,12 @@ class DocumentationPage extends ViewableData {
|
||||
*/
|
||||
function getBreadcrumbTitle($divider = ' - ') {
|
||||
$pathParts = explode('/', $this->getRelativePath());
|
||||
|
||||
// add the module to the breadcrumb trail.
|
||||
array_unshift($pathParts, $this->entity->getTitle());
|
||||
|
||||
$titleParts = array_map(array('DocumentationService', 'clean_page_name'), $pathParts);
|
||||
|
||||
return implode($divider, $titleParts + array($this->getTitle()));
|
||||
}
|
||||
|
||||
@ -118,7 +127,7 @@ class DocumentationPage extends ViewableData {
|
||||
*/
|
||||
function Link() {
|
||||
if($entity = $this->getEntity()) {
|
||||
$link = Controller::join_links($entity->Link($this->version, $this->lang), $this->getRelativeLink());
|
||||
$link = Controller::join_links($entity->Link($this->getVersion(), $this->lang), $this->getRelativeLink());
|
||||
|
||||
$link = rtrim(DocumentationService::trim_extension_off($link), '/');
|
||||
|
||||
@ -160,7 +169,7 @@ class DocumentationPage extends ViewableData {
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
return $this->version;
|
||||
return $this->version ? $this->version : $this->entity->getLatestVersion();
|
||||
}
|
||||
|
||||
function setVersion($version) {
|
||||
@ -174,7 +183,7 @@ class DocumentationPage extends ViewableData {
|
||||
function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a variable from the metadata field on this class
|
||||
*
|
||||
@ -200,6 +209,9 @@ class DocumentationPage extends ViewableData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw markdown for a given documentation page
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @return String
|
||||
*/
|
||||
function getMarkdown() {
|
||||
@ -212,15 +224,17 @@ class DocumentationPage extends ViewableData {
|
||||
}
|
||||
catch(InvalidArgumentException $e) {}
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a file (with a lang and a version).
|
||||
*
|
||||
* @param String $baselink
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
function getHTML($baselink = null) {
|
||||
// if this is not a directory then we can to parse the file
|
||||
return DocumentationParser::parse($this, $baselink);
|
||||
function getHTML($version, $lang = 'en') {
|
||||
return DocumentationParser::parse($this, $this->entity->getRelativeLink($version, $lang));
|
||||
}
|
||||
}
|
@ -1,24 +1,24 @@
|
||||
<div class="warningBox" id="pageNotFoundWarning">
|
||||
<div class="warningBoxTop">
|
||||
<h1>We're sorry…</h1>
|
||||
<p>The page you are looking for does not exist, or might have moved.
|
||||
<h5>Perhaps you could…</h5>
|
||||
<p>return to the <a href="$BaseHref">homepage</a> or try searching (see input box on the top right).</p>
|
||||
|
||||
<!--
|
||||
<h5>Search results for similar/related phrases</h5>
|
||||
<ul class="resetStyle">
|
||||
<li><a href="#">Installing</a></li>
|
||||
<li><a href="#">Upgrading</a></li>
|
||||
<li><a href="#">Server-requirements</a></li>
|
||||
<li><a href="#">Suggested-web-hosts</a></li>
|
||||
</ul>
|
||||
-->
|
||||
</div>
|
||||
<!-- <div class="warningBoxBottom">
|
||||
<ul>
|
||||
<li><a href="#">Report a missing link</a></li>
|
||||
<li><a href="#">Report a bug or a concren</a></li>
|
||||
</ul>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="warningBox" id="pageNotFoundWarning">
|
||||
<div class="warningBoxTop">
|
||||
<h1>We're sorry…</h1>
|
||||
<p>The page you are looking for does not exist, or might have moved.
|
||||
<h5>Perhaps you could…</h5>
|
||||
<p>Return to the <a href="$BaseHref">homepage</a> or try searching for the page (see input box on the top right).</p>
|
||||
|
||||
<!--
|
||||
<h5>Search results for similar/related phrases</h5>
|
||||
<ul class="resetStyle">
|
||||
<li><a href="#">Installing</a></li>
|
||||
<li><a href="#">Upgrading</a></li>
|
||||
<li><a href="#">Server-requirements</a></li>
|
||||
<li><a href="#">Suggested-web-hosts</a></li>
|
||||
</ul>
|
||||
-->
|
||||
</div>
|
||||
<!-- <div class="warningBoxBottom">
|
||||
<ul>
|
||||
<li><a href="#">Report a missing link</a></li>
|
||||
<li><a href="#">Report a bug or a concren</a></li>
|
||||
</ul>
|
||||
</div> -->
|
||||
</div>
|
@ -1,12 +1,11 @@
|
||||
<div id="module-home">
|
||||
|
||||
<div id="left-column">
|
||||
<% if Content %>
|
||||
$Content
|
||||
<% else %>
|
||||
<h2>$Title</h2>
|
||||
<% end_if %>
|
||||
</div>
|
||||
<div id="left-column">
|
||||
<% if Content %>
|
||||
$Content
|
||||
<% else %>
|
||||
<h2>$Title</h2>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
||||
<div id="right-column">
|
||||
<% include DocInThisModule %>
|
||||
|
@ -19,15 +19,15 @@ class DocumentationEntityTest extends SapphireTest {
|
||||
$this->assertFalse($entity->hasLanguage('fr'));
|
||||
}
|
||||
|
||||
function testGetCurrentVersion() {
|
||||
function testgetLatestVersion() {
|
||||
$entity = new DocumentationEntity('docs', '1.0', '../sapphiredocs/tests/docs/', 'My Test');
|
||||
$entity->addVersion('1.1', '../sapphiredocs/tests/docs-2/');
|
||||
$entity->addVersion('0.0', '../sapphiredocs/tests/docs-3/');
|
||||
$this->assertEquals('1.1', $entity->getCurrentVersion(), 'Automatic version sorting');
|
||||
$entity->addVersion('1.1', '../sapphiredocs/tests/docs-v2.4/');
|
||||
$entity->addVersion('0.0', '../sapphiredocs/tests/docs-v3.0/');
|
||||
$this->assertEquals('1.1', $entity->getLatestVersion(), 'Automatic version sorting');
|
||||
|
||||
$entity = new DocumentationEntity('docs', '1.0', '../sapphiredocs/tests/docs/', 'My Test');
|
||||
$entity->addVersion('1.1.', '../sapphiredocs/tests/docs-2/');
|
||||
$entity->setCurrentVersion('1.0');
|
||||
$this->assertEquals('1.0', $entity->getCurrentVersion(), 'Manual setting');
|
||||
$entity->addVersion('1.1.', '../sapphiredocs/tests/docs-v2.4/');
|
||||
$entity->setLatestVersion('1.0');
|
||||
$this->assertEquals('1.0', $entity->getLatestVersion(), 'Manual setting');
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ class DocumentationPageTest extends SapphireTest {
|
||||
$this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link());
|
||||
|
||||
// test with version.
|
||||
$entity = DocumentationService::register("versionlinks", BASE_PATH . "/sapphiredocs/tests/docs-2/", '1');
|
||||
$entity = DocumentationService::register("versionlinks", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '1');
|
||||
$page = new DocumentationPage();
|
||||
$page->setRelativePath('test.md');
|
||||
$page->setEntity($entity);
|
||||
@ -84,4 +84,20 @@ class DocumentationPageTest extends SapphireTest {
|
||||
$this->assertEquals($absPath . 'en/subfolder/subpage.md', $page->getPath());
|
||||
}
|
||||
|
||||
function testGetBreadcrumbTitle() {
|
||||
$entity = new DocumentationEntity('testmodule', null, BASE_PATH . '/sapphiredocs/tests/docs/');
|
||||
|
||||
$page = new DocumentationPage();
|
||||
$page->setRelativePath('test.md');
|
||||
$page->setEntity($entity);
|
||||
|
||||
$this->assertEquals("Testmodule - Test", $page->getBreadcrumbTitle());
|
||||
|
||||
$page = new DocumentationPage();
|
||||
$page->setRelativePath('subfolder/subpage.md');
|
||||
$page->setEntity(new DocumentationEntity('mymodule', null, BASE_PATH . '/sapphiredocs/tests/docs/'));
|
||||
|
||||
$this->assertEquals('Mymodule - Subfolder - Subpage', $page->getBreadcrumbTitle());
|
||||
}
|
||||
|
||||
}
|
@ -26,9 +26,9 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
}
|
||||
|
||||
// We set 3.0 as current, and test most assertions against 2.4 - to avoid 'current' rewriting issues
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs/", '2.4');
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-2/", '2.3');
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-3/", '3.0');
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs/", '2.3');
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '2.4', 'Doc Test', true);
|
||||
DocumentationService::register("DocumentationViewerTests", BASE_PATH . "/sapphiredocs/tests/docs-v3.0/", '3.0', 'Doc Test', true, true);
|
||||
}
|
||||
|
||||
function tearDownOnce() {
|
||||
@ -39,31 +39,71 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
DocumentationViewer::set_link_base($this->origLinkBase);
|
||||
}
|
||||
|
||||
// TODO Works with phpunit executable, but not with sake.
|
||||
// Also works in actual URL routing, just not in tests...
|
||||
// function testLocationExists() {
|
||||
// $response = $this->get('DocumentationViewerTests/en/2.4/');
|
||||
// $this->assertEquals($response->getStatusCode(), 200, 'Existing base folder');
|
||||
//
|
||||
// $response = $this->get('DocumentationViewerTests/en/2.4/subfolder');
|
||||
// $this->assertEquals($response->getStatusCode(), 200, 'Existing subfolder');
|
||||
//
|
||||
// $response = $this->get('DocumentationViewerTests/en/2.4/nonexistant-subfolder');
|
||||
// $this->assertEquals($response->getStatusCode(), 404, 'Nonexistant subfolder');
|
||||
//
|
||||
// $response = $this->get('DocumentationViewerTests/en/2.4/nonexistant-file.txt');
|
||||
// $this->assertEquals($response->getStatusCode(), 404, 'Nonexistant file');
|
||||
//
|
||||
// $response = $this->get('DocumentationViewerTests/en/2.4/test');
|
||||
// $this->assertEquals($response->getStatusCode(), 200, 'Existing file');
|
||||
// }
|
||||
/**
|
||||
* This tests that all the locations will exist if we access it via the urls.
|
||||
*/
|
||||
function testLocationsExists() {
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.3/subfolder');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing base folder');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing base folder');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4/');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing base folder');
|
||||
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.3/nonexistant-subfolder');
|
||||
$this->assertEquals($response->getStatusCode(), 404, 'Nonexistant subfolder');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.3/nonexistant-file.txt');
|
||||
$this->assertEquals($response->getStatusCode(), 404, 'Nonexistant file');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.3/test');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing file');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/empty?foo');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/empty.md');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/empty/');
|
||||
$this->assertEquals($response->getStatusCode(), 200, 'Existing page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/test');
|
||||
$this->assertEquals($response->getStatusCode(), 404, 'Missing page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/test.md');
|
||||
$this->assertEquals($response->getStatusCode(), 404, 'Missing page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/test/');
|
||||
$this->assertEquals($response->getStatusCode(), 404, 'Missing page');
|
||||
}
|
||||
|
||||
|
||||
function testRouting() {
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4');
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('english test', $response->getBody(), 'Toplevel content page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4/');
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('english test', $response->getBody(), 'Toplevel content page');
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4/index.md');
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('english test', $response->getBody(), 'Toplevel content page');
|
||||
}
|
||||
|
||||
function testGetModulePagesShort() {
|
||||
$v = new DocumentationViewer();
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/'));
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/'));
|
||||
$pages = $v->getModulePages();
|
||||
|
||||
|
||||
$arr = $pages->toArray();
|
||||
|
||||
$page = $arr[2];
|
||||
|
||||
$this->assertEquals('Subfolder', $page->Title);
|
||||
@ -71,7 +111,7 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
|
||||
function testGetModulePages() {
|
||||
$v = new DocumentationViewer();
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/'));
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/'));
|
||||
$pages = $v->getModulePages();
|
||||
$this->assertEquals(
|
||||
array('sort/', 'subfolder/', 'test.md'),
|
||||
@ -83,14 +123,14 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
);
|
||||
|
||||
foreach($pages as $page) {
|
||||
$page->setVersion('2.4');
|
||||
$page->setVersion('2.3');
|
||||
}
|
||||
|
||||
$links = $pages->column('Link');
|
||||
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/sort/', $links[0]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/subfolder/', $links[1]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/test', $links[2]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.3/sort/', $links[0]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.3/subfolder/', $links[1]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.3/test', $links[2]);
|
||||
|
||||
// Children
|
||||
$pagesArr = $pages->toArray();
|
||||
@ -109,36 +149,14 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
$children = $child2->Children;
|
||||
|
||||
foreach($children as $child) {
|
||||
$child->setVersion('2.4');
|
||||
$child->setVersion('2.3');
|
||||
}
|
||||
|
||||
$child2Links = $children->column('Link');
|
||||
$subpage = $children->First();
|
||||
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/subfolder/subpage', $child2Links[0]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/subfolder/subsubfolder/', $child2Links[1]);
|
||||
}
|
||||
|
||||
function testCurrentRedirection() {
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0/test');
|
||||
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
$this->assertEquals(
|
||||
Director::absoluteBaseURL() . 'dev/docs/DocumentationViewerTests/en/test/',
|
||||
$response->getHeader('Location'),
|
||||
'Redirection to current on page'
|
||||
);
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/3.0');
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
$this->assertEquals(
|
||||
Director::absoluteBaseURL() . 'dev/docs/DocumentationViewerTests/en/',
|
||||
$response->getHeader('Location'),
|
||||
'Redirection to current on index'
|
||||
);
|
||||
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.3');
|
||||
$this->assertEquals(200, $response->getStatusCode(), 'No redirection on older versions');
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.3/subfolder/subpage', $child2Links[0]);
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.3/subfolder/subsubfolder/', $child2Links[1]);
|
||||
}
|
||||
|
||||
function testUrlParsing() {
|
||||
@ -198,20 +216,15 @@ class DocumentationViewerTest extends FunctionalTest {
|
||||
$this->assertStringEndsWith('DocumentationViewerTests/en/2.4/subfolder/subpage/', $crumbLinks[2]);
|
||||
}
|
||||
|
||||
function testRouting() {
|
||||
$response = $this->get('dev/docs/DocumentationViewerTests/en/2.4/test');
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('english test', $response->getBody(), 'Toplevel content page');
|
||||
function testGetVersion() {
|
||||
$v = new DocumentationViewer();
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'));
|
||||
$this->assertEquals('2.4', $v->getVersion());
|
||||
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/1'));
|
||||
$this->assertEquals('1', $v->getVersion());
|
||||
|
||||
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0'));
|
||||
$this->assertEquals('3.0', $v->getVersion());
|
||||
}
|
||||
|
||||
// function testGetPage() {
|
||||
// $v = new DocumentationViewer();
|
||||
// $v->handleRequest(new SS_HTTPRequest('GET', '2.4/en/cms'));
|
||||
// $p = $v->getPage();
|
||||
// $this->assertType('DocumentationPage', $p);
|
||||
// $this->assertEquals('/', $p->getRelativePath());
|
||||
// $this->assertEquals('en', $p->getLang());
|
||||
// $this->assertEquals('2.4', $p->getVersion());
|
||||
// }
|
||||
|
||||
}
|
1
sapphiredocs/tests/docs-v3.0/en/empty.md
Executable file
1
sapphiredocs/tests/docs-v3.0/en/empty.md
Executable file
@ -0,0 +1 @@
|
||||
english test
|
Loading…
Reference in New Issue
Block a user