Permalink
Browse files

Refactored documentation for consistent naming to 'docs'

  • Loading branch information...
1 parent c35f699 commit 96b65faaebf8a7ab44fe40db1552615c12159571 @zubinkhavarian zubinkhavarian committed Apr 17, 2012
@@ -14,17 +14,17 @@
*/
App::uses('Utility', 'Lib');
-App::uses('Documentation', 'Model');
+App::uses('Doc', 'Model');
/**
- * Cake shell to generate documentation (static and/or database) from documentation markdown
+ * Cake shell to generate doc (static and/or database) from documentation markdown
*
* @package app
* @subpackage app.console.command
*
* @author Zubin Khavarian (https://github.com/zubinkhavarian)
*/
-class DocumentationShell extends AppShell
+class DocShell extends AppShell
{
/**
* The folder location where all system documentation lives
@@ -75,8 +75,8 @@ class DocumentationShell extends AppShell
public function main()
{
//Set the proper values for the documentation paths
- $this->__docPath = ROOT .DS. APP_DIR .DS. '42viral' .DS. 'Documentation' .DS;
- $this->__docBuildBasePath = ROOT .DS. APP_DIR .DS. '42viral' .DS. 'Documentation' .DS;
+ $this->__docPath = ROOT .DS. APP_DIR .DS. '42viral' .DS. 'Doc' .DS;
+ $this->__docBuildBasePath = ROOT .DS. APP_DIR .DS. '42viral' .DS. 'Doc' .DS;
$this->__docBuildPath = $this->__docBuildBasePath . $this->__docBuildFolder .DS;
//Get a hierarchical structure of the source documentation
@@ -93,7 +93,7 @@ public function main()
$file['relative_path_structure'] = preg_split('~' .DS. '~', $tempRelPath, -1, PREG_SPLIT_NO_EMPTY);
}
- $docModel = new Documentation();
+ $docModel = new Doc();
$docModel->saveDocFile($files);
if($this->__buildStatic) {
@@ -28,7 +28,7 @@ class DocsController extends AppController
* @var array
* @access public
*/
- public $uses = array('Documentation');
+ public $uses = array('Doc');
/**
* @var array
@@ -48,39 +48,39 @@ public function beforeFilter()
}
/**
- * Action method to view the documentation index page
+ * Action method to view the doc index page
*
* @access public
* @return void
*/
public function index()
{
- $this->__prepareDocumentationIndex();
+ $this->__prepareDocIndex();
}
/**
- * Helper method to fetch the current documentation content and build a hierarchical table of contents data
+ * Helper method to fetch the current doc content and build a hierarchical table of contents data
* structure for the view to render
*
* @access private
* @return void
*/
- private function __prepareDocumentationIndex()
+ private function __prepareDocIndex()
{
- $docItems = $this->Documentation->fetchDocumentationsWith('doc_index');
+ $docItems = $this->Doc->fetchDocsWith('doc_index');
$docNavIndex = array(
'_root' => array()
);
foreach($docItems as $tempItem) {
- $hierarchy = preg_split('~::~', $tempItem['Documentation']['_before_seo'], -1, PREG_SPLIT_NO_EMPTY);
+ $hierarchy = preg_split('~::~', $tempItem['Doc']['_before_seo'], -1, PREG_SPLIT_NO_EMPTY);
if(!empty($hierarchy)) {
if(count($hierarchy) == 1) {
array_push($docNavIndex['_root'], array(
'label' => $hierarchy[0],
- 'url' => $tempItem['Documentation']['url']
+ 'url' => $tempItem['Doc']['url']
));
} else {
$arr = &$docNavIndex;
@@ -95,7 +95,7 @@ private function __prepareDocumentationIndex()
array_push($arr, array(
'label' => $hierarchy[0],
- 'url' => $tempItem['Documentation']['url']
+ 'url' => $tempItem['Doc']['url']
));
}
}
@@ -106,25 +106,25 @@ private function __prepareDocumentationIndex()
/**
- * Action method to display a single documentation page
+ * Action method to display a single doc page
*
* @access public
* @param string $slug
* @return void
*/
public function view($slug)
{
- $this->__prepareDocumentationIndex();
+ $this->__prepareDocIndex();
- $doc = $this->Documentation->getDocumentationWith($slug);
+ $doc = $this->Doc->getDocWith($slug);
if(empty($doc)){
$this->redirect('/', '404');
}
//[TODO] Make the documentation title more human friendly as opposed to the hierarchical coded form
- $this->set('title_for_layout', $doc['Documentation']['title']);
- $this->set('canonical_for_layout', $doc['Documentation']['canonical']);
+ $this->set('title_for_layout', $doc['Doc']['title']);
+ $this->set('canonical_for_layout', $doc['Doc']['canonical']);
$this->set('doc', $doc);
}
@@ -120,17 +120,18 @@ public function index() {
/**
* Advanced search, converts post data to named params then performs a self redirect to load the named params
- * creating a bookmarkable search results page.
- * @return void
+ * creating a bookmarkable search results page.
+ *
* @access public
+ * @return void
*/
- public function advanced() {
-
+ public function advanced()
+ {
$display = 'none';
- if(!empty($this->data)){
+ if(!empty($this->data)) {
$q =''; //holds the final query string in the form of a Pretty URL
- foreach($this->data['Content'] as $key => $value){
+ foreach($this->data['Content'] as $key => $value) {
//Converts MUTLI option arrays to a string
$a = '';
@@ -164,14 +165,14 @@ public function advanced() {
//IN array conditions
$conditions['status'] = explode(' ', $this->request->params['named']['status']);
$conditions['object_type'] = explode(' ', $this->request->params['named']['object_type']);
-
+
$this->paginate = array(
'conditions' => $this->Content->parseCriteria($conditions),
'limit' => 10
);
$data = $this->paginate('Content');
-
+
$this->set(compact('data'));
$this->request->data['Content'] = $conditions;
@@ -113,30 +113,6 @@ public function acl()
}
}
- /**
- * Import the default data set from PMA XML
- *
- * @access public
- * @return void
- */
- public function import()
- {
-
- $this->acl();
-
- $path = ROOT . DS . APP_DIR . DS . 'Config' . DS . 'Data' . DS . 'Required';
-
- foreach (scandir($path) as $file) {
- $this->buildPMA($path, $file);
- }
-
- $this->_setupLog('setup_import');
- $this->_setupLog('setup_build_database');
-
- $this->Session->setFlash('Core data imported', 'success');
- $this->redirect('/setup');
- }
-
/**
* A utility for populating DB tables from an XML file.
*
File renamed without changes.
@@ -18,19 +18,23 @@
App::uses('Content', 'Model');
/**
- * Model class representing the documentation model
+ * Model class representing the doc (documentation) model
+ *
+ * @package app
+ * @subpackage app.model
+ *
* @author Jason D Snider <jason.snider@42viral.org>
* @author Zubin Khavarian (https://github.com/zubinkhavarian)
* @package 42viral\Content\Documentation
*/
-class Documentation extends Content
+class Doc extends Content
{
/**
* @access public
* @var string
*/
- public $name = 'Documentation';
+ public $name = 'Doc';
/**
* Predefined data sets
@@ -52,15 +56,15 @@ class Documentation extends Content
'doc_index' => array(
'contain' => array(),
'conditions' => array(
- 'Documentation.object_type' => 'docs'
+ 'Doc.object_type' => 'doc'
),
'fields' => array(
- 'Documentation.url',
- 'Documentation.short_cut',
- 'Documentation.base_slug',
- 'Documentation._before_seo',
- 'Documentation.slug'
+ 'Doc.url',
+ 'Doc.short_cut',
+ 'Doc.base_slug',
+ 'Doc._before_seo',
+ 'Doc.slug'
)
)
);
@@ -93,12 +97,12 @@ class Documentation extends Content
public function beforeSave()
{
parent::beforeSave();
- $this->data['Documentation']['object_type'] = 'docs';
+ $this->data['Doc']['object_type'] = 'doc';
return true;
}
/**
- * Inject all "finds" against the Documentation object with lead filtering criteria
+ * Inject all "finds" against the doc object with lead filtering criteria
*
* @access public
* @param array $queryData
@@ -109,61 +113,61 @@ public function beforeFind($queryData)
parent::beforeFind($queryData);
$queryData['conditions'] = !empty($queryData['conditions']) ? $queryData['conditions'] : array();
- $DocumentationFilter = array('Documentation.object_type' => 'docs');
- $queryData['conditions'] = array_merge($queryData['conditions'], $DocumentationFilter);
+ $docFilter = array('Doc.object_type' => 'doc');
+ $queryData['conditions'] = array_merge($queryData['conditions'], $docFilter);
return $queryData;
}
/**
- * Returns a given Documentation based on a given token and a with(query) array
+ * Returns a given doc based on a given token and a with(query) array
*
* @access public
* @param string $token
* @param string|array $with (default: 'public')
* @return array
*/
- public function getDocumentationWith($token, $with = 'public')
+ public function getDocWith($token, $with = 'public')
{
$theToken = array(
'conditions' => array('or' => array(
- 'Documentation.id' => $token,
- 'Documentation.slug' => $token,
- 'Documentation.short_cut' => $token
+ 'Doc.id' => $token,
+ 'Doc.slug' => $token,
+ 'Doc.short_cut' => $token
))
);
$finder = array_merge($this->dataSet[$with], $theToken);
- $documentation = $this->find('first', $finder);
+ $doc = $this->find('first', $finder);
- return $documentation;
+ return $doc;
}
/**
- * Returns a given Documentation based predefinded conditions
+ * Returns a given Doc based predefinded conditions
*
* @access public
* @param string|array $with (default: 'public')
* @return array
*/
- public function fetchDocumentationsWith($with = 'public')
+ public function fetchDocsWith($with = 'public')
{
$finder = $this->dataSet[$with];
- $documentations = $this->find('all', $finder);
- return $documentations;
+ $docs = $this->find('all', $finder);
+ return $docs;
}
/**
- * Given a parsed documentation file content and hierarchy data structure, populate the documentation table.
+ * Given a parsed doc file content and hierarchy data structure, populate the content table.
*
* @access public
* @param array $files
* @return boolean
*
- * [TODO] Make this more of a transactional process, i.e. the entire clearing of the old documentation and
- * generation of the new documentation.
+ * [TODO] Make this more of a transactional process, i.e. the entire clearing of the old doc and
+ * generation of the new doc.
*/
public function saveDocFile($files)
{
@@ -180,8 +184,8 @@ public function saveDocFile($files)
}
}
- $this->data['Documentation']['title'] = $docHierarchy . str_replace('.md', '', $tempFile['file']);
- $this->data['Documentation']['body'] = $tempFile['html'];
+ $this->data['Doc']['title'] = $docHierarchy . str_replace('.md', '', $tempFile['file']);
+ $this->data['Doc']['body'] = $tempFile['html'];
$this->save($this->data);
}
@@ -190,15 +194,15 @@ public function saveDocFile($files)
}
/**
- * Clear all current content of the type documentation (docs)
+ * Clear all current content of the type doc (docs)
*
* @access public
* @return boolean
*/
public function clearAllDocs()
{
$oppStatus = $this->deleteAll(array(
- 'Documentation.object_type' => 'docs'
+ 'Doc.object_type' => 'doc'
));
return ($oppStatus)? true: false;
@@ -20,6 +20,6 @@
</div>
<div class="twelve columns omega">
- <?php echo $doc['Documentation']['body']; ?>
+ <?php echo $doc['Doc']['body']; ?>
</div>
</div>
@@ -17,7 +17,7 @@
<?php //debug($doc_nav_index); ?>
-<a href="/docs/">Table of Contents</a>
+<a href="/doc/">Table of Contents</a>
<?php foreach($doc_nav_index as $key1 => $value1): ?>
<?php if($key1 == '_root'): ?>
Oops, something went wrong.

0 comments on commit 96b65fa

Please sign in to comment.