Skip to content

Commit

Permalink
Merge branch 'main' into digital-research-hub
Browse files Browse the repository at this point in the history
  • Loading branch information
somathias committed Jan 25, 2024
2 parents cd3e4e0 + b657e2b commit 8731938
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/single_page/dynamic_table.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const handleSelect = (e) => {
if (cellData == "#HIDDEN") $j(td).addClass("disabled");
};
// Changes the id header to an instance id
if (c.title == "id") c.title = instanceName + " id";
if (c.title == "id") c.title = window.instanceName + " id";
});
// Retrieve the column index of the multi-input cells (select2 items)
// if column has a multi-input cell, it adds the index to the t array (=accumulator)
Expand Down
1 change: 1 addition & 0 deletions app/views/isa_assays/_assay_design.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</p>
<% end %>
<script>
window.instanceName = "<%= Seek::Config.instance_name %>";
async function loadDynamicTableFromDefaultView(element) {
await loadItemDetails(`/assays/${id}`, { view: "default" });
}
Expand Down
1 change: 1 addition & 0 deletions app/views/isa_studies/_study_design.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<% end %>

<script>
window.instanceName = "<%= Seek::Config.instance_name %>";
async function loadDynamicTableFromDefaultView(element) {
await loadItemDetails(`/studies/${id}`, { view: "default" });
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/single_pages/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<script type="text/javascript">
var selectedItem = {type:"",id:""}, pid, uid, projectDefaultPolicy, dynamicTableDataPath
const instanceName = "<%= Seek::Config.instance_name %>";
window.instanceName = "<%= Seek::Config.instance_name %>";

$j(document).ready(function() {
$j("#content .container-fluid").removeClass("container-fluid").addClass("container-fluid-single-page")
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/renderers/renderer_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def detect_renderer(blob)

# Ordered list of Renderer classes. More generic renderers appear last.
def renderer_instances
[SlideshareRenderer, YoutubeRenderer, MarkdownRenderer, NotebookRenderer, TextRenderer, PdfRenderer, ImageRenderer, BlankRenderer]
[SlideshareRenderer, YoutubeRenderer, MarkdownRenderer, NotebookRenderer, PdfRenderer, ImageRenderer, TextRenderer, BlankRenderer]
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions test/functional/git_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def setup
assert_select 'img.git-image-preview[src=?]', workflow_git_raw_path(@workflow, version: @git_version.version, path: 'diagram.png')
end

test 'get svg file blob' do
@git_version.add_file('test.svg', open_fixture_file('transparent-fairdom-logo-square.svg'))
@git_version.save!
get :blob, params: { workflow_id: @workflow.id, version: @git_version.version, path: 'test.svg', format: 'html' } # Not sure why this is needed

assert_response :success
assert_select 'a.btn[href=?]', workflow_git_remove_file_path(@workflow, version: @git_version.version, path: 'test.svg')
assert_select 'img.git-image-preview[src=?]', workflow_git_raw_path(@workflow, version: @git_version.version, path: 'test.svg')
end

test 'get raw binary file' do
get :raw, params: { workflow_id: @workflow.id, version: @git_version.version, path: 'diagram.png' }

Expand Down
14 changes: 14 additions & 0 deletions test/unit/renderers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RenderersTest < ActiveSupport::TestCase
assert_equal Seek::Renderers::NotebookRenderer, factory.renderer(FactoryBot.create(:jupyter_notebook_content_blob)).class
assert_equal Seek::Renderers::TextRenderer, factory.renderer(FactoryBot.create(:txt_content_blob)).class
assert_equal Seek::Renderers::ImageRenderer, factory.renderer(FactoryBot.create(:image_content_blob)).class
assert_equal Seek::Renderers::ImageRenderer, factory.renderer(FactoryBot.create(:svg_content_blob)).class
assert_equal Seek::Renderers::BlankRenderer, factory.renderer(FactoryBot.create(:binary_content_blob)).class
end

Expand Down Expand Up @@ -387,9 +388,22 @@ class RenderersTest < ActiveSupport::TestCase
assert_select 'iframe', count: 0
assert_select '#navbar', count: 0
assert_select 'img.git-image-preview'

blob = FactoryBot.create(:txt_content_blob, asset: @asset)
renderer = Seek::Renderers::ImageRenderer.new(blob)
refute renderer.can_render?

@git.add_file('test.svg', open_fixture_file('transparent-fairdom-logo-square.svg'))
git_blob = @git.get_blob('test.svg')
renderer = Seek::Renderers::ImageRenderer.new(git_blob)
assert renderer.can_render?
@html = Nokogiri::HTML.parse(renderer.render)
assert_select 'img.git-image-preview'

@html = Nokogiri::HTML.parse(renderer.render_standalone)
assert_select 'iframe', count: 0
assert_select '#navbar', count: 0
assert_select 'img.git-image-preview'
end

def document_root_element
Expand Down

0 comments on commit 8731938

Please sign in to comment.