summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-06-11 18:35:35 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-06-11 19:02:16 +0200
commit39a760b1266e43175ad271da39898659df0231e4 (patch)
treee75126854efb2a65a8a92aa3dd29bcd40610f517
parent09dc1388561d3fb5021691fb318e2412d395979f (diff)
add markdown rendering support
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--data/paste.css8
-rw-r--r--system/application/models/file_mod.php18
-rw-r--r--system/application/views/file/html_header.php7
3 files changed, 26 insertions, 7 deletions
diff --git a/data/paste.css b/data/paste.css
index 013f6e6a1..f6a47fe49 100644
--- a/data/paste.css
+++ b/data/paste.css
@@ -55,6 +55,14 @@ table.content td.code {
padding-bottom: 15px;
}
+table.content td.markdownrender {
+ vertical-align: top;
+ padding-left: 20px;
+ padding-right: 20px;
+ padding-bottom: 15px;
+ width: 100%;
+}
+
pre {
margin-top:1em;
margin-bottom:2px;
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php
index 66817a7a6..0541d5d2b 100644
--- a/system/application/models/file_mod.php
+++ b/system/application/models/file_mod.php
@@ -172,13 +172,21 @@ class File_mod extends Model {
$data['title'] = $filedata['filename'];
$data['raw_link'] = site_url($id);
$data['plain_link'] = site_url($id.'/plain');
+ $data['auto_link'] = site_url($id).'/';
+ $data['rmd_link'] = site_url($id.'/rmd');
header("Content-Type: text/html\n");
echo $this->load->view('file/html_header', $data, true);
- // only rewrite if it's fast
- // count(file($file)); isn't
- echo passthru('/usr/bin/perl -ne \'print "<a href=\"#n$.\" class=\"no\" id=\"n$.\" name=\"n$.\">$.</a>\n"\' '.escapeshellarg($file));
- echo '</pre></td><td class="code"><pre>'."\n";
- echo shell_exec(FCPATH.'scripts/syntax-highlighting.sh '.escapeshellarg($filedata['filename']).'.'.escapeshellarg($mode).' < '.escapeshellarg($file));
+ if ($mode == "rmd") {
+ echo '<td class="markdownrender"><pre>'."\n";
+ passthru('/usr/bin/perl /usr/bin/perlbin/vendor/Markdown.pl '.escapeshellarg($file));
+ } else {
+ echo '<td class="numbers"><pre>';
+ // only rewrite if it's fast
+ // count(file($file)); isn't
+ passthru('/usr/bin/perl -ne \'print "<a href=\"#n$.\" class=\"no\" id=\"n$.\" name=\"n$.\">$.</a>\n"\' '.escapeshellarg($file));
+ echo '</pre></td><td class="code"><pre>'."\n";
+ echo shell_exec(FCPATH.'scripts/syntax-highlighting.sh '.escapeshellarg($filedata['filename']).'.'.escapeshellarg($mode).' < '.escapeshellarg($file));
+ }
echo $this->load->view('file/html_footer', $data, true);
} else {
if ($mode == 'plain') {
diff --git a/system/application/views/file/html_header.php b/system/application/views/file/html_header.php
index fdd46acb9..dfa08ad46 100644
--- a/system/application/views/file/html_header.php
+++ b/system/application/views/file/html_header.php
@@ -6,9 +6,12 @@
</head>
<body>
<div class="top_bar">
- <a class="raw_link no" href="<?php echo $raw_link; ?>">Raw</a>
+ <a class="raw_link no" href="<?php echo $raw_link; ?>">Raw</a> |
<a class="raw_link no" href="<?php echo $plain_link; ?>">Plain</a>
+ <div style="float:right;">
+ <a class="raw_link no" href="<?php echo $auto_link; ?>">Code</a> |
+ <a class="raw_link no" href="<?php echo $rmd_link; ?>">Render Markdown</a>
+ </div>
</div>
<table class="content">
<tr>
- <td class="numbers"><pre>