Class: Jekyll::Ett::ToolTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Ett::ToolTag
- Defined in:
- lib/elixir-toolkit-theme-plugins/tool_tag.rb
Instance Method Summary collapse
- #create_tag(url, icon, label) ⇒ Object
- #create_tags(tool) ⇒ Object
- #find_tool(tool_id) ⇒ Object
-
#initialize(tagName, content, tokens) ⇒ ToolTag
constructor
A new instance of ToolTag.
- #load_tools ⇒ Object
- #render(context) ⇒ Object
Constructor Details
#initialize(tagName, content, tokens) ⇒ ToolTag
Returns a new instance of ToolTag.
7 8 9 10 11 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 7 def initialize(tagName, content, tokens) super @content = content load_tools end |
Instance Method Details
#create_tag(url, icon, label) ⇒ Object
71 72 73 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 71 def create_tag(url, icon, label) "<a href='#{url}' target='_blank' rel='noopener' class='mt-2 me-2'><span class='badge bg-dark text-white hover-primary'><i class='fa-solid #{icon} me-2'></i>#{label}</span></a>" end |
#create_tags(tool) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 41 def (tool) = "" << create_tag("#{tool["url"]}", "fa-link", "Website") if tool["registry"] registry = tool["registry"] if registry["biotools"] << create_tag("https://bio.tools/#{registry["biotools"]}", "fa-info", "Tool info") end if registry["fairsharing"] << create_tag("https://fairsharing.org/FAIRsharing.#{registry["fairsharing"]}", "fa-database", "Standards/Databases") end if registry["fairsharing-coll"] << create_tag("https://fairsharing.org/#{registry["fairsharing-coll"]}", "fa-database", "Standards/Databases") end if registry["tess"] << create_tag("https://tess.elixir-europe.org/search?q=#{registry["tess"]}", "fa-graduation-cap", "Training") end if registry["europmc"] << create_tag("https://europepmc.org/article/MED/#{registry["europmc"]}", "fa-book", "Publication") end end end |
#find_tool(tool_id) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 34 def find_tool(tool_id) tool = @tools.find { |t| t["id"] == tool_id.strip } return tool if tool raise Exception.new "Undefined tool ID: #{tool_id}" end |
#load_tools ⇒ Object
13 14 15 16 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 13 def load_tools tools_path = File.join(Dir.pwd, "_data", "tool_and_resource_list.yml") @tools = YAML.load(File.read(tools_path)) end |
#render(context) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/elixir-toolkit-theme-plugins/tool_tag.rb', line 18 def render(context) tool = find_tool(context[@content.strip]) = (tool) %Q{<a tabindex="0" class="tool" aria-description="#{tool["description"]}" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-trigger="focus" data-bs-content="<h5>#{tool["name"]}</h5><div class='mb-2'>#{tool["description"]}</div>#{}" data-bs-template="<div class='popover popover-tool' role='tooltip'><div class='popover-arrow'></div><h3 class='popover-header'></h3><div class='popover-body'></div></div>" data-bs-html="true" ><i class="fa-solid fa-wrench me-2"></i>#{ tool["name"] }</a>} end |