aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2017-10-28 15:47:06 +0200
committerChristian Weiske <cweiske@cweiske.de>2017-10-28 15:47:06 +0200
commit53cddb9c9e119561458dff43a4b1be67de73cf4f (patch)
tree9a3627b682d8a3324a0e086a208bdd7f0cbeac43
parent01fee6cee1831c88fe9522167940d2ad68657efa (diff)
downloadphorkie-53cddb9c9e119561458dff43a4b1be67de73cf4f.tar.gz
phorkie-53cddb9c9e119561458dff43a4b1be67de73cf4f.zip
Word-wrap for txt files
This means there are no line numbers for .txt anymore, but I find it more important to have word wrap. Resolves: https://github.com/cweiske/phorkie/issues/31
-rw-r--r--data/config.default.php3
-rw-r--r--src/phorkie/Renderer/Plaintext.php25
-rw-r--r--www/css/phorkie.css3
3 files changed, 30 insertions, 1 deletions
diff --git a/data/config.default.php b/data/config.default.php
index 06b53ed..fce74c1 100644
--- a/data/config.default.php
+++ b/data/config.default.php
@@ -161,7 +161,8 @@ $GLOBALS['phorkie']['languages'] = array(
'txt' => array(
'title' => 'Text (plain)',
'mime' => 'text/plain',
- 'geshi' => 'txt'
+ 'geshi' => 'txt',
+ 'renderer' => '\\phorkie\\Renderer_Plaintext'
),
'ts' => array(
'title' => 'TypoScript',
diff --git a/src/phorkie/Renderer/Plaintext.php b/src/phorkie/Renderer/Plaintext.php
new file mode 100644
index 0000000..ef448f9
--- /dev/null
+++ b/src/phorkie/Renderer/Plaintext.php
@@ -0,0 +1,25 @@
+<?php
+namespace phorkie;
+
+/**
+ * Render plain .txt files
+ */
+class Renderer_Plaintext
+{
+ /**
+ * Simply displays the file
+ *
+ * @param File $file File to render
+ *
+ * @return string HTML
+ */
+ public function toHtml(File $file)
+ {
+ $html = '<div class="code"><pre class="txt">'
+ . htmlspecialchars($file->getContent())
+ . '</pre></div>' . "\n";
+ return $html;
+ }
+}
+
+?>
diff --git a/www/css/phorkie.css b/www/css/phorkie.css
index e9bce5d..3619d54 100644
--- a/www/css/phorkie.css
+++ b/www/css/phorkie.css
@@ -110,6 +110,9 @@ h1 {
margin: 0px;
margin-bottom: 2ex;
}
+.code pre.txt {
+ white-space: pre-wrap;
+}
.code {
overflow-x: auto;
}