-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from silverstripe/feature/platform
Making the docs site ready for SilverStripe Platform
- Loading branch information
Showing
17 changed files
with
710 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
/staticpublisher/ | ||
/toolbar/ | ||
/display_logic/ | ||
/silverstripe-dynamodb/ | ||
/crontask/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ StaticExporter: | |
disable_sitetree_export: true | ||
Controller: | ||
extensions: | ||
- ControllerExtension | ||
- ControllerExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
Name: docs-repos | ||
After: | ||
- framework/* | ||
- cms/* | ||
--- | ||
RefreshMarkdownTask: | ||
documentation_repositories: | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- master | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- "3.3" | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- "3.2" | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- "3.1" | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- "3.0" | ||
- | ||
- silverstripe/silverstripe-framework | ||
- framework | ||
- "2.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
Name: docs | ||
Name: docs-routes | ||
After: framework/routes#coreroutes | ||
--- | ||
Director: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
|
||
class RefreshMarkdownTask extends BuildTask | ||
{ | ||
/** | ||
* @var array | ||
* @config documentation_repositories | ||
*/ | ||
private static $documentation_repositories; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $title = "Refresh markdown files"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = "Downloads a fresh version of markdown documentation files from source"; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $enabled = true; | ||
|
||
/** | ||
* @var SS_HTTPRequest $request | ||
* | ||
* @todo test the initial unlink works with cloned modules | ||
*/ | ||
public function run($request) | ||
{ | ||
$this->printLine("refreshing markdown files..."); | ||
|
||
$repositories = $this->getRepositories(); | ||
|
||
foreach ($repositories as $repository) { | ||
$this->cloneRepository($repository); | ||
$this->cleanRepository($repository); | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
* | ||
* @todo document this new configuration parameter | ||
*/ | ||
private function getPath() | ||
{ | ||
return ASSETS_PATH; | ||
} | ||
|
||
/** | ||
* @param string $message | ||
*/ | ||
private function printLine($message) | ||
{ | ||
$this->eol = Director::is_cli() ? PHP_EOL : "<br>"; | ||
print $message . $this->eol; | ||
flush(); | ||
} | ||
|
||
/** | ||
* Returns the array of repos to source markdown docs from | ||
* | ||
* @return array | ||
* | ||
*/ | ||
private function getRepositories() | ||
{ | ||
if($repos = $this->config()->documentation_repositories) | ||
{ | ||
return $repos; | ||
} else { | ||
user_error("You need to set 'RefreshMarkdownTask:documentation_repositories' array in a yaml configuration file", E_USER_WARNING); | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* @param array $repository | ||
* | ||
* @todo test this works with all modules | ||
*/ | ||
private function cloneRepository(array $repository) | ||
{ | ||
list($remote, $folder, $branch) = $repository; | ||
|
||
$path = $this->getPath(); | ||
|
||
exec("mkdir -p {$path}/src"); | ||
exec("rm -rf {$path}/src/{$folder}_{$branch}"); | ||
|
||
$this->printLine("cloning " . $remote . "/" . $branch); | ||
|
||
chdir("{$path}/src"); | ||
exec("git clone -q git://github.com/{$remote}.git {$folder}_{$branch} --quiet"); | ||
|
||
chdir("{$path}/src/{$folder}_{$branch}"); | ||
exec("git fetch origin"); | ||
exec("git checkout -q origin/{$branch}"); | ||
} | ||
|
||
/** | ||
* Clears out any non markdown files stored in assets | ||
* | ||
* @param array $repository | ||
*/ | ||
private function cleanRepository(array $repository) | ||
{ | ||
$paths = array_merge(glob("*"), glob(".*")); | ||
|
||
foreach ($paths as $path) { | ||
if ($path !== "docs" && $path !== "." && $path !== "..") { | ||
exec("rm -rf {$path}"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.