From 3aeb166d555eae1dca09ab40c02790534ab06268 Mon Sep 17 00:00:00 2001 From: "Gun.io Whitespace Robot" Date: Fri, 21 Oct 2011 03:00:35 -0400 Subject: [PATCH] Remove whitespace [Gun.io WhitespaceBot] --- index-sample.php | 4 +- markdown-wiki.php | 112 +++++++++--------- markdown.php | 230 ++++++++++++++++++------------------- pages/markdown.markdown | 6 +- tests/MarkdownTest.php | 2 +- tests/MarkdownWikiTest.php | 22 ++-- 6 files changed, 188 insertions(+), 188 deletions(-) diff --git a/index-sample.php b/index-sample.php index 7f57394..e7e54c9 100644 --- a/index-sample.php +++ b/index-sample.php @@ -1,4 +1,4 @@ - $appRoot . 'pages/', - + # Default page name 'defaultPage' => 'index' diff --git a/markdown-wiki.php b/markdown-wiki.php index b201003..fcf8bae 100644 --- a/markdown-wiki.php +++ b/markdown-wiki.php @@ -8,18 +8,18 @@ class MarkdownWiki { 'newPageText' => 'Start editing your new page', 'markdownExt' => 'markdown' ); - + // An instance of the Markdown parser protected $parser; protected $baseUrl; - + public function __construct($config=false) { $this->initWiki(); if ($config) { $this->setConfig($config); } } - + protected function initWiki() { $baseDir = dirname(__FILE__) . '/'; @@ -27,13 +27,13 @@ protected function initWiki() { //echo "BaseDir: {$baseDir}\n"; require_once $baseDir . 'markdown.php'; } - + public function wikiLink($link) { global $docIndex; - + $isNew = false; $wikiUrl = $link; - + if (preg_match('/^\/?([a-z0-9-]+(\/[a-z0-9-]+)*)$/i', $link, $matches)) { $wikiUrl = "{$this->baseUrl}{$matches[1]}"; $isNew = !$this->isMarkdownFile($link); @@ -41,7 +41,7 @@ public function wikiLink($link) { $wikiUrl = "{$this->baseUrl}{$this->config['defaultPage']}"; $isNew = !$this->isMarkdownFile($this->config['defaultPage']); } - + return array($isNew, $wikiUrl); } @@ -57,11 +57,11 @@ public function setConfig($config) { public function handleRequest($request=false, $server=false) { $action = $this->parseRequest($request, $server); $action->model = $this->getModelData($action); - + // If this is a new file, switch to edit mode if ($action->model->updated==0 && $action->action=='display') { $action->action = 'edit'; - } + } $action->response = $this->doAction($action); $output = $this->renderResponse($action->response); @@ -72,9 +72,9 @@ public function handleRequest($request=false, $server=false) { ## ## Methods handling each action ## - + public function doAction($action) { - + switch($action->action) { case 'UNKNOWN': # Default to display case 'display': @@ -93,7 +93,7 @@ public function doAction($action) { case 'admin': case 'browse': default: - $response = array( + $response = array( 'messages' => array( "Action {$action->action} not implemented." ) @@ -104,7 +104,7 @@ public function doAction($action) { return $response; } - + protected function doDisplay($action) { $response = array( 'title' => "Displaying: {$action->page}", @@ -115,10 +115,10 @@ protected function doDisplay($action) { ), 'related' => '' ); - + return $response; } - + protected function doEdit($action) { $response = array( 'title' => "Editing: {$action->page}", @@ -129,10 +129,10 @@ protected function doEdit($action) { ), 'related' => '' ); - + return $response; } - + protected function doPreview($action) { $response = array( 'title' => "Editing: {$action->page}", @@ -143,7 +143,7 @@ protected function doPreview($action) { ), 'related' => '' ); - + return $response; } @@ -159,7 +159,7 @@ protected function doSave($action) { } else { echo "WARN: Editing conflict!\n"; } - + return $this->doDisplay($action); } @@ -169,18 +169,18 @@ protected function doSave($action) { protected function getModelData($action) { $data = (object) NULL; - + $data->file = $this->getFilename($action->page); $data->content = $this->getContent($data->file); $data->updated = $this->getLastUpdated($data->file); - + return $data; } - + protected function setModelData($model) { $directory = dirname($model->file); if (!file_exists($directory)) { - mkdir($directory, 0777, true); + mkdir($directory, 0777, true); } elseif (!is_dir($directory)) { echo "ERROR: Cannot create {$model->file}\n"; } @@ -191,16 +191,16 @@ protected function setModelData($model) { ## ## Methods for parsing the incoming request ## - + public function parseRequest($request=false, $server=false) { $action = (object) NULL; if (!$request) { $request = $_REQUEST; } if (!$server) { $server = $_SERVER; } - + //echo "Request: "; print_r($request); //echo "Server : "; print_r($server); - + $action->method = $this->getMethod($request, $server); $action->page = $this->getPage($request, $server); $action->action = $this->getAction($request, $server); @@ -209,50 +209,50 @@ public function parseRequest($request=false, $server=false) { if ($action->method=='POST') { $action->post = $this->getPostDetails($request, $server); } - + // Take a copy of the action base for the wikiLink function $this->baseUrl = $action->base; return $action; } - + protected function getFilename($page) { return "{$this->config['docDir']}{$page}.{$this->config['markdownExt']}"; } - + protected function getContent($filename) { if (file_exists($filename)) { return file_get_contents($filename); } return $this->config['newPageText']; } - + protected function getLastUpdated($filename) { if (file_exists($filename)) { return filectime($filename); } return 0; } - + protected function getMethod($request, $server) { if (!empty($server['REQUEST_METHOD'])) { return $server['REQUEST_METHOD']; } return 'UNKNOWN'; } - + protected function getPage($request, $server) { $page = ''; - + // Determine the page name if (!empty($server['PATH_INFO'])) { //echo "Path info detected\n"; // If we are using PATH_INFO then that's the page name $page = substr($server['PATH_INFO'], 1); - + } elseif (!empty($request['id'])) { $page = $request['id']; - + } else { // TODO: Keep checking //echo "WARN: Could not find a pagename\n"; @@ -262,10 +262,10 @@ protected function getPage($request, $server) { if ($page=='' || preg_match('/\/$/', $page)) { $page .= $this->config['defaultPage']; } - + return $page; } - + protected function getAction($request, $server) { if ($server['REQUEST_METHOD']=='POST') { if (!empty($request['preview'])) { @@ -278,12 +278,12 @@ protected function getAction($request, $server) { } elseif (!empty($server['PATH_INFO'])) { return 'display'; } - + // TODO: handle version history etc. - + return 'UNKNOWN'; } - + protected function getBaseUrl($request, $server) { if (!empty($this->config['baseUrl'])) { return $this->config['baseUrl']; @@ -294,7 +294,7 @@ protected function getBaseUrl($request, $server) { [DOCUMENT_ROOT] => /home/user/sites/default/htdocs [SCRIPT_FILENAME] => /home/user/sites/default/htdocs/index-sample.php [REQUEST_METHOD] => GET - [QUERY_STRING] => + [QUERY_STRING] => [REQUEST_URI] => /index-sample.php [SCRIPT_NAME] => /index-sample.php [PHP_SELF] => /index-sample.php @@ -303,7 +303,7 @@ protected function getBaseUrl($request, $server) { $scriptName = $server['SCRIPT_NAME']; $requestUrl = $server['REQUEST_URI']; $phpSelf = $server['PHP_SELF']; - + if ($requestUrl==$scriptName) { // PATH_INFO based } elseif(strpos($requestUrl, $scriptName)===0) { @@ -312,10 +312,10 @@ protected function getBaseUrl($request, $server) { // Maybe mod_rewrite based? // Perhaps we need a config entry here } - + return '/index-sample.php/'; // PATH-INFO base } - + protected function getPostDetails($request, $server) { $post = (object) NULL; $post->text = stripslashes($request['text']); @@ -324,9 +324,9 @@ protected function getPostDetails($request, $server) { } /********* - - RESPONSE RENDERERS - + + RESPONSE RENDERERS + *********/ public function renderResponse($response) { @@ -334,7 +334,7 @@ public function renderResponse($response) { // TODO: Use a custom template } else { $footer = array(); - + if (!empty($response['options'])) { $footer[] = '