From c428b438a0d2ef16733738cfe69f69fbe0610310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 28 Oct 2014 14:18:56 +0100 Subject: [PATCH] Adds a button on each page, which links to file into the repository --- docs/config.json | 1 + libs/daux.php | 3 +++ libs/daux_directory.php | 3 +++ libs/daux_page.php | 8 ++++++++ templates/default/default.tpl | 6 +++++- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/config.json b/docs/config.json index 47bbdbf..249a461 100644 --- a/docs/config.json +++ b/docs/config.json @@ -13,6 +13,7 @@ "float": true, "file_editor": false, "repo": "justinwalsh/daux.io", + "repo_to_fix": "https://github.com/justinwalsh/daux.io/blob/master/", "ignore": { "files": ["Work_In_Progress.md"], "folders": ["99_Not_Ready"] diff --git a/libs/daux.php b/libs/daux.php index f07fe8b..ec71c9a 100644 --- a/libs/daux.php +++ b/libs/daux.php @@ -101,6 +101,7 @@ return; } $this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $global_config['docs_directory']; + $this->relative_path = $global_config['docs_directory']; if (!is_dir($this->docs_path)) { $this->generate_error_page('Docs Directory not found', 'The Docs directory does not exist. Check the path again : ' . $this->docs_path, ErrorPage::FATAL_ERROR_TYPE); @@ -192,6 +193,8 @@ private function get_page_params($mode = '') { $params = array(); $params['local_base'] = $this->local_base; + $params['relative_path'] = $this->relative_path; + $params['repo_to_fix'] = $this->options['repo_to_fix']; if ($mode === '') $mode = $this->mode; $params['mode'] = $mode; diff --git a/libs/daux_directory.php b/libs/daux_directory.php index b39a2ef..acbeca6 100644 --- a/libs/daux_directory.php +++ b/libs/daux_directory.php @@ -10,6 +10,7 @@ public $index_page; public $first_page; public $value; + public $extension; public $uri; public $local_path; public $last_modified; @@ -31,6 +32,8 @@ } else { $this->type = Directory_Entry::FILE_TYPE; $this->value = $this->uri; + $pathinfo = DauxHelper::pathinfo($path); + $this->extension = $pathinfo['extension']; } } diff --git a/libs/daux_page.php b/libs/daux_page.php index 2b9dfbc..a276ea9 100644 --- a/libs/daux_page.php +++ b/libs/daux_page.php @@ -112,9 +112,16 @@ $this->title = $file->title; $this->filename = $file->name; $this->path = $file->local_path; + $this->repo_path = $params['repo_to_fix']; + $this->extension = $file->extension; $this->mtime = $file->last_modified; $this->params = $params; + $this->folderPaths = ''; + foreach ($file->parents as $parent) { + $this->folderPaths .= DIRECTORY_SEPARATOR . $parent->name; + } + if ($this->title === 'index') { $this->homepage = ($this->filename === '_index'); $minimum_parent_dir_size = ($params['multilanguage']) ? 2 : 1; @@ -184,6 +191,7 @@ } $page['language'] = $this->language; $page['path'] = $this->path; + $page['url_for_fix'] = $this->repo_path . $this->folderPaths . DIRECTORY_SEPARATOR . $this->filename . '.' . $this->extension; $page['request'] = utf8_encode($params['request']); $page['theme'] = $params['theme']; $page['modified_time'] = filemtime($this->path); diff --git a/templates/default/default.tpl b/templates/default/default.tpl index cdfb282..f7b63a4 100644 --- a/templates/default/default.tpl +++ b/templates/default/default.tpl @@ -225,6 +225,7 @@ else echo $page['title']; ?> Edit this page'; ?> + Fix this page'; ?> @@ -239,7 +240,9 @@ if ($page['breadcrumbs']) echo $this->get_breadcrumb_title($page, $base_page); else echo $page['title']; ?> - Edit this page'; ?> + Edit this page'; ?> + Fix this page'; ?> + @@ -256,6 +259,7 @@
+