From 651b390f4c22b86a8d01ac11a2350c79e15d6b10 Mon Sep 17 00:00:00 2001 From: MontrealSergiy Date: Mon, 9 Oct 2023 21:11:06 -0400 Subject: [PATCH 1/2] add hmtl file type plugin --- .../app/assets/stylesheets/cbrain.css.erb | 6 ++- .../userfiles/html_file/html_file.rb | 48 +++++++++++++++++++ .../userfiles/html_file/views/_html.html.erb | 37 ++++++++++++++ 3 files changed, 90 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 8a0a5029b..547151395 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..1b0d0e452 --- /dev/null +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb @@ -0,0 +1,48 @@ + +# +# 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 + + # def is_viewable? #:nodoc: + # # check for unsafe elements (js?forms?) + # if ! self.is_locally_synced? + # return [ "hdf image file not yet synchronized" ] + # else + # true + # end + # 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..0afa8dee7 --- /dev/null +++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb @@ -0,0 +1,37 @@ + +<% +# +# 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" %> + + + +<%= link_to h("Show as is a separate tab, without any safety filters"), url_for(:controller => :userfiles, :id => @userfile.id, :action => :display, :viewer => :html, :content_viewer => "off", :file_name => @userfile.name), :target => "_blank" if params[:action] == "show" %> + + + + From acfda9dd94e302cc612f3011170f9fb75f0bd88d Mon Sep 17 00:00:00 2001 From: Serge Date: Tue, 10 Oct 2023 08:47:13 -0400 Subject: [PATCH 2/2] remove commented out code html_file.rb --- .../userfiles/html_file/html_file.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) 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 index 1b0d0e452..2a556bd66 100644 --- 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 @@ -34,15 +34,5 @@ def self.file_name_pattern #:nodoc: def self.pretty_type #:nodoc: "HTML File" end - - # def is_viewable? #:nodoc: - # # check for unsafe elements (js?forms?) - # if ! self.is_locally_synced? - # return [ "hdf image file not yet synchronized" ] - # else - # true - # end - # end - + end -