mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Merge pull request #55 from camfindlay/branchalias
ENHANCEMENT optional branch property to allow version aliases.
This commit is contained in:
commit
9a2deea414
@ -128,6 +128,8 @@ class DocumentationManifest {
|
|||||||
|
|
||||||
$version = (isset($details['Version'])) ? $details['Version'] : '';
|
$version = (isset($details['Version'])) ? $details['Version'] : '';
|
||||||
|
|
||||||
|
$branch = (isset($details['Branch'])) ? $details['Branch'] : '';
|
||||||
|
|
||||||
$langs = scandir($path);
|
$langs = scandir($path);
|
||||||
|
|
||||||
if($langs) {
|
if($langs) {
|
||||||
@ -143,6 +145,7 @@ class DocumentationManifest {
|
|||||||
$entity->setTitle($details['Title']);
|
$entity->setTitle($details['Title']);
|
||||||
$entity->setLanguage($lang);
|
$entity->setLanguage($lang);
|
||||||
$entity->setVersion($version);
|
$entity->setVersion($version);
|
||||||
|
$entity->setBranch($branch);
|
||||||
|
|
||||||
if(isset($details['Stable'])) {
|
if(isset($details['Stable'])) {
|
||||||
$entity->setIsStable($details['Stable']);
|
$entity->setIsStable($details['Stable']);
|
||||||
@ -202,6 +205,7 @@ class DocumentationManifest {
|
|||||||
'Path' => $docs,
|
'Path' => $docs,
|
||||||
'Title' => DocumentationHelper::clean_page_name($entity),
|
'Title' => DocumentationHelper::clean_page_name($entity),
|
||||||
'Version' => 'master',
|
'Version' => 'master',
|
||||||
|
'Branch' => 'master',
|
||||||
'Stable' => true
|
'Stable' => true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -592,6 +592,11 @@ class DocumentationViewer extends Controller {
|
|||||||
$url = self::$edit_links[strtolower($entity->title)];
|
$url = self::$edit_links[strtolower($entity->title)];
|
||||||
$version = $entity->getVersion();
|
$version = $entity->getVersion();
|
||||||
|
|
||||||
|
if($entity->getBranch()){
|
||||||
|
$version = $entity->getBranch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if($version == "trunk" && (isset($url['options']['rewritetrunktomaster']))) {
|
if($version == "trunk" && (isset($url['options']['rewritetrunktomaster']))) {
|
||||||
if($url['options']['rewritetrunktomaster']) {
|
if($url['options']['rewritetrunktomaster']) {
|
||||||
$version = "master";
|
$version = "master";
|
||||||
|
@ -56,6 +56,13 @@ class DocumentationEntity extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
protected $version;
|
protected $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The repository branch name (allows for $version to be an alias on development branches).
|
||||||
|
*
|
||||||
|
* @var string $branch
|
||||||
|
*/
|
||||||
|
protected $branch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this entity is a stable release or not. If it is not stable (i.e it
|
* If this entity is a stable release or not. If it is not stable (i.e it
|
||||||
* could be a past or future release) then a warning message will be shown.
|
* could be a past or future release) then a warning message will be shown.
|
||||||
@ -213,6 +220,22 @@ class DocumentationEntity extends ViewableData {
|
|||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public function setBranch($branch) {
|
||||||
|
$this->branch = $branch;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getBranch() {
|
||||||
|
return $this->branch;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -269,6 +292,7 @@ class DocumentationEntity extends ViewableData {
|
|||||||
'Key' => $this->key,
|
'Key' => $this->key,
|
||||||
'Path' => $this->getPath(),
|
'Path' => $this->getPath(),
|
||||||
'Version' => $this->getVersion(),
|
'Version' => $this->getVersion(),
|
||||||
|
'Branch' => $this->getBranch(),
|
||||||
'IsStable' => $this->getIsStable(),
|
'IsStable' => $this->getIsStable(),
|
||||||
'Language' => $this->getLanguage()
|
'Language' => $this->getLanguage()
|
||||||
);
|
);
|
||||||
|
@ -25,6 +25,21 @@ In YAML this looks like:
|
|||||||
Path: "framework/docs/"
|
Path: "framework/docs/"
|
||||||
Title: "Framework Documentation"
|
Title: "Framework Documentation"
|
||||||
|
|
||||||
|
###Branch aliases for the edit link (optional)
|
||||||
|
When using entities with multiple versions, one of the branches of documentation may be a development version. For example the 'master' branch. You may have an internally assigned version number for this registered in your .yml configuration.
|
||||||
|
|
||||||
|
If this version number is not the same as the branch name on the git repository the `getEditLinks` method will return an incorrect link to go and edit the documentation. In this case you can simply set an optional `branch` property on the entity which will be used in the edit link instead.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
:::yml
|
||||||
|
DocumentationManifest:
|
||||||
|
register_entities:
|
||||||
|
-
|
||||||
|
Path: "framework/docs/"
|
||||||
|
Title: "Framework Documentation"
|
||||||
|
Version: "1.0"
|
||||||
|
Branch: "master"
|
||||||
|
|
||||||
## Permalinks
|
## Permalinks
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user