diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/phorkie/File.php | 20 | ||||
| -rw-r--r-- | src/phorkie/Renderer/Geshi.php | 8 | ||||
| -rw-r--r-- | src/phorkie/Repository.php | 3 |
3 files changed, 24 insertions, 7 deletions
diff --git a/src/phorkie/File.php b/src/phorkie/File.php index 2aa1d19..9eb7fa7 100644 --- a/src/phorkie/File.php +++ b/src/phorkie/File.php @@ -96,27 +96,37 @@ class File * Get a link to the file * * @param string $type Link type. Supported are: + * - "display" * - "raw" * - "tool" * @param string $option Additional option, e.g. tool name + * @param boolean $full Return full URL or normal relative * * @return string */ - public function getLink($type, $option = null) + public function getLink($type, $option = null, $full = false) { if ($type == 'raw') { if ($this->repo->hash === null) { - return $this->repo->id . '/raw/' . $this->getFilename(); + $link = $this->repo->id . '/raw/' . $this->getFilename(); } else { - return $this->repo->id . '/rev-raw/' . $this->repo->hash + $link = $this->repo->id . '/rev-raw/' . $this->repo->hash . '/' . $this->getFilename(); } } else if ($type == 'tool') { - return $this->repo->id + $link = $this->repo->id . '/tool/' . $option . '/' . $this->getFilename(); + } else if ($type == 'display') { + $link = $this->repo->id . '#' . $this->getFilename(); + } else { + throw new Exception('Unknown type'); } - throw new Exception('Unknown type'); + + if ($full) { + $link = Tools::fullUrl($link); + } + return $link; } /** diff --git a/src/phorkie/Renderer/Geshi.php b/src/phorkie/Renderer/Geshi.php index 0c545ed..2b3854a 100644 --- a/src/phorkie/Renderer/Geshi.php +++ b/src/phorkie/Renderer/Geshi.php @@ -22,14 +22,18 @@ class Renderer_Geshi } $geshi = new \geshi($file->getContent(), $this->getType($file)); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); - $geshi->set_header_type(GESHI_HEADER_DIV); + $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); + $geshi->enable_classes(); + $geshi->set_line_style('color: #DDD;'); if ($res !== null) { $geshi->highlight_lines_extra(array_keys($res->annotations)); $geshi->set_highlight_lines_extra_style('background-color: #F2DEDE'); } - return '<div class="code">' + return '<style type="text/css">' + . $geshi->get_stylesheet() . '</style>' + . '<div class="code">' . str_replace(' ', ' ', $geshi->parse_code()) . '</div>'; } diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 467456b..f9b248d 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -310,6 +310,7 @@ class Repository * - "delete" * - "delete-confirm" * - "display" + * - "embed" * - "fork" * - "revision" * @param string $option Additional link option, e.g. revision number @@ -334,6 +335,8 @@ class Repository $link = $this->id . '/delete'; } else if ($type == 'delete-confirm') { $link = $this->id . '/delete/confirm'; + } else if ($type == 'embed') { + $link = $this->id . '/embed'; } else if ($type == 'remotefork') { return 'web+fork:' . $this->getLink('display', null, true); } else if ($type == 'revision') { |
