diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/file.php | 10 | ||||
-rw-r--r-- | application/libraries/Pygments.php | 1 | ||||
-rw-r--r-- | application/views/file/fragments/asciinema-player.php | 8 | ||||
-rw-r--r-- | application/views/header.php | 2 |
4 files changed, 18 insertions, 3 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php index 1888b7c06..c26ae0420 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -229,9 +229,13 @@ class File extends MY_Controller { } } - $this->output_cache->add_function(function() use ($filedata, $lexer, $is_multipaste) { - $this->_highlight_file($filedata, $lexer, $is_multipaste); - }); + if ($lexer == "asciinema") { + $this->output_cache->add(array("filedata" => $filedata), "file/fragments/asciinema-player"); + } else { + $this->output_cache->add_function(function() use ($filedata, $lexer, $is_multipaste) { + $this->_highlight_file($filedata, $lexer, $is_multipaste); + }); + } } // TODO: move lexers json to dedicated URL diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php index 81963bc68..62229c472 100644 --- a/application/libraries/Pygments.php +++ b/application/libraries/Pygments.php @@ -165,6 +165,7 @@ class Pygments { private function filename2lexer() { $namearray = array( + 'asciinema.json' => 'asciinema', 'PKGBUILD' => 'bash', '.vimrc' => 'vim' ); diff --git a/application/views/file/fragments/asciinema-player.php b/application/views/file/fragments/asciinema-player.php new file mode 100644 index 000000000..5eb8041f7 --- /dev/null +++ b/application/views/file/fragments/asciinema-player.php @@ -0,0 +1,8 @@ +<div class="container-wide"> +<div class='panel panel-default'> + <div class='panel-heading'> + <?php echo anchor(site_url($filedata['id']), htmlspecialchars($filedata["filename"])); ?> + </div> + <div id="player-container-<?php echo $filedata['id']; ?>" class="asciinema_player" data-url="<?php echo site_url($filedata['id']); ?>"></div> +</div> +</div> diff --git a/application/views/header.php b/application/views/header.php index 0e1f174de..d4ee7a07c 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -17,6 +17,7 @@ if (is_cli_client() && !isset($force_full_html)) { <link href="<?php echo link_with_mtime("/data/css/bootstrap.min.css"); ?>" rel="stylesheet"> <link href="<?php echo link_with_mtime("/data/css/style.css"); ?>" rel="stylesheet"> <link href="<?php echo link_with_mtime("/data/css/colorbox.css"); ?>" rel="stylesheet"> + <link href="<?php echo link_with_mtime("/data/css/asciinema-player.css"); ?>" rel="stylesheet"> <?php if (file_exists(FCPATH."data/local/style.css")) { echo '<link href="'.link_with_mtime("/data/local/style.css").'" rel="stylesheet">'; @@ -26,6 +27,7 @@ if (is_cli_client() && !isset($force_full_html)) { echo '<link href="'.link_with_mtime("/data/local/favicon.png").'" rel="shortcut icon">'; } ?> + <script src="<?php echo link_with_mtime("/data/js/vendor/asciinema-player.js"); ?>"></script> <script src="<?php echo link_with_mtime("/data/js/vendor/require.js"); ?>"></script> <script type="text/javascript"> /* <![CDATA[ */ |