Updated caching for the documentation manifest to use the new system
Fixed pathing for the css and js requirements Updated composer type to a vendor module Updated the requirement for mnapoli/front-yaml to be compatible with SS4 Removed unsupported language file Updated translations Updated namespaces in language files
This commit is contained in:
parent
40b8043c43
commit
2f0ec132f3
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
Name: docsviewer_cache
|
||||
After:
|
||||
- "#corecache"
|
||||
---
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
Psr\SimpleCache\CacheInterface.DocsViewerManifest:
|
||||
factory: SilverStripe\Core\Cache\CacheFactory
|
||||
constructor:
|
||||
namespace: "DocsViewerManifest"
|
||||
defaultLifetime: 0
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "silverstripe/docsviewer",
|
||||
"description": "Documentation viewer module for SilverStripe",
|
||||
"type": "silverstripe-module",
|
||||
"type": "silverstripe-vendormodule",
|
||||
"keywords": ["silverstripe", "documentation"],
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [{
|
||||
|
@ -17,7 +17,7 @@
|
|||
"silverstripe/framework": "~4.3",
|
||||
"erusev/parsedown-extra": "~0.7",
|
||||
"erusev/parsedown": "~1.7",
|
||||
"mnapoli/front-yaml": "^1.5"
|
||||
"mnapoli/front-yaml": "^1.6"
|
||||
},
|
||||
"suggest": {
|
||||
"silverstripe/staticpublisher": "Allows publishing documentation as HTML"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
en:
|
||||
DocumentationSearch:
|
||||
SilverStripe\DocsViewer\Search\DocumentationSearch:
|
||||
SEARCH: Search
|
||||
SEARCHRESULTS: 'Search Results'
|
||||
DocumentationViewer:
|
||||
SilverStripe\DocsViewer\Controllers\DocumentationViewer:
|
||||
CHANGE: Change
|
||||
KEYWORDS: Keywords
|
||||
LANGUAGE: Language
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
use SilverStripe\DocsViewer\DocumentationSearch;
|
||||
use SilverStripe\DocsViewer\Controllers\DocumentationViewer;
|
||||
|
||||
global $lang;
|
||||
|
||||
$lang['en_US'][DocumentationSearch::class]['SEARCHRESULTS'] = 'Search Results';
|
||||
$lang['en_US'][DocumentationViewer::class]['CHANGE'] = 'Change';
|
||||
$lang['en_US'][DocumentationViewer::class]['LANGUAGE'] = 'Language';
|
||||
$lang['en_US'][DocumentationViewer::class]['SEARCH'] = 'Search';
|
||||
|
||||
?>
|
|
@ -1,8 +1,8 @@
|
|||
hr:
|
||||
DocumentationSearch:
|
||||
SilverStripe\DocsViewer\Search\DocumentationSearch:
|
||||
SEARCH: Traži
|
||||
SEARCHRESULTS: 'Rezultati pretraživanja'
|
||||
DocumentationViewer:
|
||||
SilverStripe\DocsViewer\Controllers\DocumentationViewer:
|
||||
CHANGE: Promjeni
|
||||
KEYWORDS: Ključne riječi
|
||||
LANGUAGE: Jezik
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
hr_HR:
|
||||
DocumentationSearch:
|
||||
SilverStripe\DocsViewer\Search\DocumentationSearch:
|
||||
SEARCH: Traži
|
||||
SEARCHRESULTS: 'Rezultati pretraživanja'
|
||||
DocumentationViewer:
|
||||
SilverStripe\DocsViewer\Controllers\DocumentationViewer:
|
||||
CHANGE: Promjeni
|
||||
KEYWORDS: Ključne riječi
|
||||
LANGUAGE: Jezik
|
||||
|
|
|
@ -131,21 +131,21 @@ class DocumentationViewer extends Controller implements PermissionProvider
|
|||
Requirements::combine_files(
|
||||
'docs.js',
|
||||
array(
|
||||
THIRDPARTY_DIR .'/jquery/jquery.js',
|
||||
DOCSVIEWER_DIR .'/thirdparty/highlight/highlight.pack.js',
|
||||
DOCSVIEWER_DIR .'/javascript/DocumentationViewer.js',
|
||||
'silverstripe/admin: thirdparty/jquery/jquery.js',
|
||||
'silverstripe/docsviewer: thirdparty/highlight/highlight.pack.js',
|
||||
'silverstripe/docsviewer: javascript/DocumentationViewer.js',
|
||||
)
|
||||
);
|
||||
Requirements::combine_files(
|
||||
'docs.css',
|
||||
array(
|
||||
DOCSVIEWER_DIR .'/css/highlight.css',
|
||||
DOCSVIEWER_DIR .'/css/normalize.css',
|
||||
DOCSVIEWER_DIR .'/css/utilities.css',
|
||||
DOCSVIEWER_DIR .'/css/typography.css',
|
||||
DOCSVIEWER_DIR .'/css/forms.css',
|
||||
DOCSVIEWER_DIR .'/css/layout.css',
|
||||
DOCSVIEWER_DIR .'/css/small.css'
|
||||
'silverstripe/docsviewer: css/highlight.css',
|
||||
'silverstripe/docsviewer: css/normalize.css',
|
||||
'silverstripe/docsviewer: css/utilities.css',
|
||||
'silverstripe/docsviewer: css/typography.css',
|
||||
'silverstripe/docsviewer: css/forms.css',
|
||||
'silverstripe/docsviewer: css/layout.css',
|
||||
'silverstripe/docsviewer: css/small.css'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace SilverStripe\DocsViewer;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
|
@ -13,7 +14,6 @@ use SilverStripe\ORM\ArrayList;
|
|||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use Exception;
|
||||
use SS_Cache;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -105,14 +105,7 @@ class DocumentationManifest
|
|||
$this->forceRegen = $forceRegen;
|
||||
$this->registeredEntities = new ArrayList();
|
||||
|
||||
$this->cache = SS_Cache::factory(
|
||||
DocumentationManifest::class,
|
||||
'Core',
|
||||
array(
|
||||
'automatic_serialization' => true,
|
||||
'lifetime' => null
|
||||
)
|
||||
);
|
||||
$this->cache = Injector::inst()->get(CacheInterface::class.'.DocsViewerManifest');
|
||||
|
||||
$this->setupEntities();
|
||||
}
|
||||
|
@ -169,10 +162,10 @@ class DocumentationManifest
|
|||
$langs = scandir($path);
|
||||
|
||||
if ($langs) {
|
||||
$possible = i18n::get_common_languages(true);
|
||||
$possible = i18n::getData()->getLanguages();
|
||||
|
||||
foreach ($langs as $k => $lang) {
|
||||
if (isset($possible[$lang])) {
|
||||
foreach ($langs as $lang) {
|
||||
if (array_key_exists($lang, $possible)) {
|
||||
/**
|
||||
* @var DocumentationEntity $entity
|
||||
*/
|
||||
|
@ -237,6 +230,8 @@ class DocumentationManifest
|
|||
return;
|
||||
}
|
||||
|
||||
$entities = [];
|
||||
|
||||
foreach (scandir(BASE_PATH) as $key => $entity) {
|
||||
if ($key == "themes") {
|
||||
continue;
|
||||
|
@ -274,7 +269,8 @@ class DocumentationManifest
|
|||
*/
|
||||
protected function init()
|
||||
{
|
||||
if (!$this->forceRegen && $data = $this->cache->load($this->cacheKey)) {
|
||||
if (!$this->forceRegen && $this->cache->has($this->cacheKey)) {
|
||||
$data = $this->cache->get($this->cacheKey);
|
||||
$this->pages = $data['pages'];
|
||||
$this->redirects = $data['redirects'];
|
||||
$this->inited = true;
|
||||
|
@ -414,12 +410,12 @@ class DocumentationManifest
|
|||
}
|
||||
|
||||
if ($cache) {
|
||||
$this->cache->save(
|
||||
$this->cache->set(
|
||||
$this->cacheKey,
|
||||
array(
|
||||
'pages' => $this->pages,
|
||||
'redirects' => $this->redirects
|
||||
),
|
||||
$this->cacheKey
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -853,7 +849,7 @@ class DocumentationManifest
|
|||
if ($entity->getVersion()) {
|
||||
$versions[$entity->getVersion()] = $entity->getVersion();
|
||||
} else {
|
||||
$versions['0.0'] = _t('DocumentationManifest.MASTER', 'Master');
|
||||
$versions['0.0'] = _t('SilverStripe\\DocsViewer\\DocumentationManifest.MASTER', 'Master');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ class DocumentationSearch
|
|||
'Query' => null,
|
||||
'Versions' => DBField::create_field('Text', implode(', ', $this->versions)),
|
||||
'Modules' => DBField::create_field('Text', implode(', ', $this->modules)),
|
||||
'Title' => _t('DocumentationSearch.SEARCHRESULTS', 'Search Results'),
|
||||
'Title' => _t('SilverStripe\\DocsViewer\\DocumentationSearch.SEARCHRESULTS', 'Search Results'),
|
||||
'TotalResults' => null,
|
||||
'TotalPages' => null,
|
||||
'ThisPage' => null,
|
||||
|
@ -376,7 +376,7 @@ class DocumentationSearch
|
|||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return ($this->outputController) ? $this->outputController->Title : _t('DocumentationSearch.SEARCH', 'Search');
|
||||
return ($this->outputController) ? $this->outputController->Title : _t('SilverStripe\\DocsViewer\\DocumentationSearch.SEARCH', 'Search');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,10 +406,10 @@ class DocumentationSearch
|
|||
$data = self::$meta_data;
|
||||
|
||||
$defaults = array(
|
||||
'Description' => _t('DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'),
|
||||
'Tags' => _t('DocumentationViewer.OPENSEARCHTAGS', 'documentation'),
|
||||
'Description' => _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'),
|
||||
'Tags' => _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.OPENSEARCHTAGS', 'documentation'),
|
||||
'Contact' => Config::inst()->get(Email::class, 'admin_email'),
|
||||
'ShortName' => _t('DocumentationViewer.OPENSEARCHNAME', 'Documentation Search'),
|
||||
'ShortName' => _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.OPENSEARCHNAME', 'Documentation Search'),
|
||||
'Author' => 'SilverStripe'
|
||||
);
|
||||
|
||||
|
|
|
@ -38,18 +38,18 @@ class DocumentationAdvancedSearchForm extends Form
|
|||
}
|
||||
|
||||
$fields = FieldList::create(
|
||||
TextField::create('q', _t('DocumentationViewer.KEYWORDS', 'Keywords'), $q),
|
||||
TextField::create('q', _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.KEYWORDS', 'Keywords'), $q),
|
||||
//CheckboxSetField::create('Entities', _t('DocumentationViewer.MODULES', 'Modules'), $entities, $searchedEntities),
|
||||
CheckboxSetField::create(
|
||||
'Versions',
|
||||
_t('DocumentationViewer.VERSIONS', 'Versions'),
|
||||
_t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.VERSIONS', 'Versions'),
|
||||
$versions,
|
||||
$searchedVersions
|
||||
)
|
||||
);
|
||||
|
||||
$actions = FieldList::create(
|
||||
FormAction::create('results', _t('DocumentationViewer.SEARCH', 'Search'))
|
||||
FormAction::create('results', _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.SEARCH', 'Search'))
|
||||
);
|
||||
|
||||
$required = RequiredFields::create(array('Search'));
|
||||
|
|
|
@ -13,8 +13,8 @@ class DocumentationSearchForm extends Form
|
|||
public function __construct($controller)
|
||||
{
|
||||
$fields = new FieldList(
|
||||
TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '')
|
||||
->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search'))
|
||||
TextField::create('q', _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.SEARCH', 'Search'), '')
|
||||
->setAttribute('placeholder', _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.SEARCH', 'Search'))
|
||||
);
|
||||
|
||||
$page = $controller->getPage();
|
||||
|
@ -22,7 +22,7 @@ class DocumentationSearchForm extends Form
|
|||
if ($page) {
|
||||
$versions = HiddenField::create(
|
||||
'Versions',
|
||||
_t('DocumentationViewer.VERSIONS', 'Versions'),
|
||||
_t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.VERSIONS', 'Versions'),
|
||||
$page->getEntity()->getVersion()
|
||||
);
|
||||
|
||||
|
@ -30,7 +30,7 @@ class DocumentationSearchForm extends Form
|
|||
}
|
||||
|
||||
$actions = new FieldList(
|
||||
new FormAction('results', _t('DocumentationViewer.SEARCH', 'Search'))
|
||||
new FormAction('results', _t('SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.SEARCH', 'Search'))
|
||||
);
|
||||
|
||||
parent::__construct($controller, DocumentationSearchForm::class, $fields, $actions);
|
||||
|
|
|
@ -404,4 +404,15 @@ class DocumentationPage extends ViewableData
|
|||
}
|
||||
return $this->canonicalUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of this documentation page
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
$classPath=explode('\\', get_class($this));
|
||||
return array_pop($classPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="menu-bar">
|
||||
<a class="logo" href="https://userhelp.silverstripe.org/"></a>
|
||||
<a class="menu-open">
|
||||
<%t DocumentationViewer.MENU "Menu" %>
|
||||
<%t SilverStripe\\DocsViewer\\Controllers\\DocumentationViewer.MENU "Menu" %>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue