From 4650df72898250c027976a4335faef0bc33a4a16 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 7 Jun 2016 16:48:16 +0200 Subject: Add asciinema support This bypasses require.js for asciinema because apparently require.js can't deal with the embedded React library. The result is that React is not loaded properly and the asciinema player is unable to find it. Just load it like upstream tells you to. Signed-off-by: Florian Pritz --- application/controllers/file.php | 10 +- application/libraries/Pygments.php | 1 + .../views/file/fragments/asciinema-player.php | 8 + application/views/header.php | 2 + public_html/data/css/asciinema-player.css | 2595 ++++++++++++++++++++ public_html/data/js/application.js | 10 +- public_html/data/js/vendor/asciinema-player.js | 909 +++++++ 7 files changed, 3531 insertions(+), 4 deletions(-) create mode 100644 application/views/file/fragments/asciinema-player.php create mode 100644 public_html/data/css/asciinema-player.css create mode 100644 public_html/data/js/vendor/asciinema-player.js 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 @@ +
+
+
+ +
+
+
+
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)) { " rel="stylesheet"> " rel="stylesheet"> " rel="stylesheet"> + " rel="stylesheet"> '; @@ -26,6 +27,7 @@ if (is_cli_client() && !isset($force_full_html)) { echo ''; } ?> +