From 1bcfd6786bebc164e86889591c36ef0793dff76f Mon Sep 17 00:00:00 2001 From: MontrealSergiy Date: Tue, 10 Oct 2023 17:51:23 -0400 Subject: [PATCH] html file model and viewer --- .../app/assets/stylesheets/cbrain.css.erb | 6 ++- .../userfiles/html_file/html_file.rb | 38 +++++++++++++++++ .../userfiles/html_file/views/_html.html.erb | 41 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb create mode 100644 BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb diff --git a/BrainPortal/app/assets/stylesheets/cbrain.css.erb b/BrainPortal/app/assets/stylesheets/cbrain.css.erb index 8ab644820..51e52918b 100644 --- a/BrainPortal/app/assets/stylesheets/cbrain.css.erb +++ b/BrainPortal/app/assets/stylesheets/cbrain.css.erb @@ -679,7 +679,11 @@ a { border: 1px solid #E4E4E4; } - +.bigiframe { + position: relative; + height: 100%; + width: 100%; +} /* % ######################################################### */ /* % General box layouts for account information */ diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb new file mode 100644 index 000000000..2a556bd66 --- /dev/null +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb @@ -0,0 +1,38 @@ + +# +# CBRAIN Project +# +# Copyright (C) 2008-2023 +# The Royal Institution for the Advancement of Learning +# McGill University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This model represents a single HTML file +class HtmlFile < TextFile + + Revision_info=CbrainFileRevision[__FILE__] #:nodoc: + + has_viewer :name => 'HTML', :partial => :html, :if => :is_locally_synced? + + def self.file_name_pattern #:nodoc: + /\.x?html?\z/i + end + + def self.pretty_type #:nodoc: + "HTML File" + end + +end diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb new file mode 100644 index 000000000..8a84be987 --- /dev/null +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb @@ -0,0 +1,41 @@ + +<% +# +# CBRAIN Project +# +# Copyright (C) 2008-2023 +# The Royal Institution for the Advancement of Learning +# McGill University +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +%> + + + +<%= link_to h("Open in a separate tab"), url_for(:controller => :userfiles, :id => @userfile.id, :action => :display, :viewer => :html, :content_viewer => "on", :file_name => @userfile.name), :target => "_blank" if params[:action] == "show" %> + + +HTML was sandboxed and filtered for greter safety +<%= link_to h("Show as is in a separate tab, without any safety filters"), stream_userfile_path(@userfile, :disposition => 'inline'), :target => "_blank" %> + + + +