Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add ontology concepts exporters to diffrent formats (xml, ntriples, turtle) #547

Merged
merged 32 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2d2345c
add feature to display resouce content in different formats
imadbourouche Mar 20, 2024
7466092
Add download and copy buttons to the raw data section
imadbourouche Mar 20, 2024
f1326d7
Add css to highlight the content of turtle and ntriples
imadbourouche Mar 21, 2024
1836108
Add the copy functionality to the resource raw data
imadbourouche Mar 21, 2024
145702e
Remove the clipboard component and change the HTML title to Raw Data
imadbourouche Mar 26, 2024
55029d8
Add clipboard component to the resource-content
imadbourouche Mar 26, 2024
e65b165
Use Net::HTTP instead of Linked::Client::HTTP to include accept header
imadbourouche Mar 26, 2024
4d55dec
Add the content formats for instances and Properties
imadbourouche Mar 26, 2024
a6a867a
Remove copy_concept_content method in clipboard component
imadbourouche Mar 27, 2024
001d1cc
Use the highlight-js in the metadata controller and remove content_fi…
imadbourouche Mar 27, 2024
2b7da51
Remove code duplication for content formats
imadbourouche Mar 27, 2024
4d9c8f3
Remove content finder controller from index.js
imadbourouche Mar 29, 2024
fca5cd4
Small fix: remove a condition in metadata_downloader
imadbourouche Apr 2, 2024
5c7d09d
Add content_formats method to ontologies_helper and remove it from ap…
imadbourouche Apr 2, 2024
53f77ca
Use Faraday instead of Net::HTTP
imadbourouche Apr 2, 2024
c807391
Add helpers for content finder controller
imadbourouche Apr 4, 2024
feee391
change content finder route to /ontologies/:acronym/:id/serialize/:ou…
imadbourouche Apr 4, 2024
f3e0b5c
Add concept details component to schemes and collections and fix code
imadbourouche Apr 4, 2024
e3cf3a8
Merge branch 'development' into feature/concept-content-formats
syphax-bouazzouni Apr 7, 2024
5a57cda
rename the metadata downloader controller and remove the result value
syphax-bouazzouni Apr 7, 2024
850d949
update the concept formats tab UI to use icons and open in modal
syphax-bouazzouni Apr 7, 2024
55e91af
update the content finder page code to re-use concept format code
syphax-bouazzouni Apr 7, 2024
c0747e0
update the content formats icons to use the primary color of the portal
syphax-bouazzouni Apr 7, 2024
a376685
extract commun code in content finder and concept formats in a concern
syphax-bouazzouni Apr 7, 2024
52c88b8
extract rdf highlighter component from concept format and content finder
syphax-bouazzouni Apr 7, 2024
4ff797d
rename the concept formats file and action to content_serlizer
syphax-bouazzouni Apr 7, 2024
a1dd8cb
in content finder don't call the backend serializer if format is html
syphax-bouazzouni Apr 7, 2024
8e84dae
fix the content finder container width
syphax-bouazzouni Apr 7, 2024
61023e1
clean unused css code for the content finder
syphax-bouazzouni Apr 7, 2024
7bad7d4
extract link_to_format_modal function in the concept details component
syphax-bouazzouni Apr 7, 2024
dd98eb3
abstract the usage of a highlighter from the dependency highlight.js
syphax-bouazzouni Apr 7, 2024
136bf1d
update instance details page to use the concept details component
syphax-bouazzouni Apr 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/assets/images/icons/json-ld-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions app/assets/images/icons/ntriples-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions app/assets/images/icons/rdf-xml-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions app/assets/images/icons/turtle-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/concepts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ div.synonym-change-request button {
justify-content: center;
color: var(--gray-color);
margin-top: 10px;
}
}
28 changes: 1 addition & 27 deletions app/assets/stylesheets/content_finder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,17 @@
margin-bottom: 6px;
}

.content-finder-logo{
display: flex;
justify-content: center;
margin: 20px 0;
}

.content-finder-container .inputs > div{
margin:10px 0;
text-align: center;
width: 400px;
}

.content-finder-result{
margin-top: 20px;
margin-bottom: 30px;
text-align: left;
max-width: 95%;
width: 95%;
margin-left: auto;
margin-right: auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
border: 1px solid #a1a1a1;
}

.content-finder-html-result{
Expand All @@ -45,24 +33,10 @@
color: #770088;
}


.content-finder-logo svg {
width: 100px;
height: 100px;
}
.content-finder-logo svg path{
fill: var(--primary-color)
}

.hljs-subject{
color: green;
}

.hljs-predicate{
color: #770088;
}

.parse_button{
display: flex;
justify-content: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class extends Controller {
this.#copied()
})
}

#copied () {
if (this.timeout) {
clearTimeout(this.timeout)
Expand Down
10 changes: 9 additions & 1 deletion app/components/concept_details_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

class ConceptDetailsComponent < ViewComponent::Base
include ApplicationHelper
include OntologiesHelper
include MultiLanguagesHelper

renders_one :header, TableComponent
renders_many :sections, TableRowComponent

attr_reader :concept_properties

def initialize(id:, acronym:, properties:, top_keys:, bottom_keys:, exclude_keys:)
def initialize(id:, acronym:, concept_id: nil , properties: nil, top_keys: [], bottom_keys: [], exclude_keys: [])
@acronym = acronym
@properties = properties
@top_keys = top_keys
@bottom_keys = bottom_keys
@exclude_keys = exclude_keys
@id = id
@concept_id=concept_id

@concept_properties = concept_properties2hash(@properties) if @properties
end
Expand Down Expand Up @@ -77,6 +79,12 @@ def filter_properties(top_keys, bottom_keys, exclude_keys, concept_properties)

private

def link_to_format_modal(format, icon)
link_to_modal(nil, "/ontologies/#{@acronym}/#{escape(@concept_id)}/serialize/#{format}", data: {show_modal_title_value: @concept_id, show_modal_size_value: 'modal-xl'}) do
inline_svg("icons/#{icon}.svg", width: '50px', height: '50px')
end
end

def concept_properties2hash(properties)
# NOTE: example properties
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
= header
%div.my-3
%div.raw-table
- if @bottom_keys.present?
= render DropdownContainerComponent.new(title: 'Raw data', id: "accordion-#{@id}") do
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, prefix_properties(@concept_properties))
- leftover_set = convert_dates(leftover_set)
= render TableComponent.new(stripped: true) do |t|

= render DropdownContainerComponent.new(title: 'Raw data', id: "accordion-#{@id}") do
= render TableComponent.new(stripped: true) do |t|
- if @bottom_keys.present?
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, prefix_properties(@concept_properties))
- leftover_set = convert_dates(leftover_set)
- row_hash_properties(top_set, @acronym).each do |row|
- t.add_row(*row)

Expand All @@ -23,3 +22,11 @@

- row_hash_properties(bottom_set, @acronym).each do |row|
- t.add_row(*row)

- if @concept_id
- t.row do |r|
- r.td(colspan: 2) do
%div.d-flex.justify-content-center.p-2
- [["json","json-ld-file"], ["xml","rdf-xml-file"] , ["ntriples","ntriples-file"], ["turtle","turtle-file"]].each do |format, icon|
%div.mx-4{data: {controller: "tooltip"}, title: "Export in #{format.upcase}"}
= link_to_format_modal(format, icon)
9 changes: 9 additions & 0 deletions app/components/display/rdf_highlighter_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Display::RdfHighlighterComponent < ViewComponent::Base

def initialize(format: , text: )
@format = format
@content = text
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.clipboard-component-resource-content{style: 'position: absolute; right: 2%; top: 5px;'}
= render ClipboardComponent.new(message: @content, show_content: false)
.content-finder-result{data: {controller: 'rdf-highlighter', 'rdf-highlighter-format-value': @format }}
%pre.mb-0
%code.d-block{style: 'text-wrap: pretty; word-break: break-all', data: {'rdf-highlighter-target': 'content'}}
#{@content}
Loading
Loading