• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_describe / 7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

20 Mar 2024 12:42PM UTC coverage: 30.068% (-66.2%) from 96.266%
7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

Pull #1701

circleci

leefaisonr
makes it so that links open in new window
Pull Request #1701: Update language on submission form

1019 of 3389 relevant lines covered (30.07%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/app/helpers/application_helper.rb
1
# frozen_string_literal: true
2
module ApplicationHelper
1✔
3
  ##
4
  # Attributes to add to the <html> tag (e.g. lang and dir)
5
  # @return [Hash]
6
  def html_tag_attributes
1✔
7
    { lang: I18n.locale }
×
8
  end
9

10
  def pre_curation_uploads_file_name(file:)
1✔
11
    value = file.filename.to_s
×
12
    return if value.blank?
×
13

14
    value[0..79]
×
15
  end
16
  alias post_curation_uploads_file_name pre_curation_uploads_file_name
1✔
17

18
  def ark_url(ark_value)
1✔
19
    return nil if ark_value.blank?
×
20
    # This was originally in Work#ark_url as: "https://ezid.cdlib.org/id/#{ark}"
21
    "http://arks.princeton.edu/#{ark_value}"
×
22
  end
23

24
  def doi_url(doi_value)
1✔
25
    return nil if doi_value.blank?
×
26
    "https://doi.org/#{doi_value}"
×
27
  end
28

29
  # Renders citation information APA-ish and BibTeX.
30
  # Notice that the only the APA style is visible, the BibTeX citataion is enabled via JavaScript.
31
  def render_cite_as(work)
1✔
32
    creators = work.resource.creators.map { |creator| "#{creator.family_name}, #{creator.given_name}" }
×
33
    citation = DatasetCitation.new(creators, [work.resource.publication_year], work.resource.titles.first.title, work.resource.resource_type, work.resource.publisher, work.resource.doi)
×
34
    return if citation.apa.nil?
×
35
    citation_html(work, citation)
×
36
  end
37

38
  def citation_html(work, citation)
1✔
39
    apa = citation.apa
×
40
    bibtex = citation.bibtex
×
41
    bibtex_html = html_escape(bibtex).gsub("\r\n", "<br/>").gsub("\t", "  ").gsub("  ", "&nbsp;&nbsp;")
×
42
    bibtex_text = html_escape(bibtex).gsub("\t", "  ")
×
43

44
    html = apa_section(apa) + "\n" + bibtex_section(work, bibtex_html, bibtex_text)
×
45
    # rubocop:disable Rails/OutputSafety
46
    html.html_safe
×
47
    # rubocop:enable Rails/OutputSafety
48
  end
49

50
  def bibtex_section(work, bibtex_html, bibtex_text)
1✔
51
    <<-HTML
×
52
    <div class="citation-bibtex-container hidden-element">
53
      <div class="bibtex-citation">#{bibtex_html}</div>
54
      <button id="copy-bibtext-citation-button" class="copy-citation-button btn btn-sm" data-style="BibTeX" data-text="#{bibtex_text}" title="Copy BibTeX citation to the clipboard">
55
        <i class="bi bi-clipboard" title="Copy BibTeX citation to the clipboard"></i>
56
        <span class="copy-citation-label-normal">COPY</span>
57
      </button>
58
      <button id="download-bibtex" class="btn btn-sm" data-url="#{work_bibtex_url(id: work.id)}" title="Download BibTeX citation to a file">
59
        <i class="bi bi-file-arrow-down" title="Download BibTeX citation to a file"></i>
60
        <span class="copy-citation-label-normal">DOWNLOAD</span>
61
      </button>
62
    </div>
63
  HTML
64
  end
65

66
  def apa_section(apa)
1✔
67
    <<-HTML
×
68
    <div class="citation-apa-container">
69
      <div class="apa-citation">#{html_escape(apa)}</div>
70
      <button id="copy-apa-citation-button" class="copy-citation-button btn btn-sm" data-style="APA" data-text="#{html_escape(apa)}" title="Copy citation to the clipboard">
71
        <i class="bi bi-clipboard" title="Copy citation to the clipboard"></i>
72
        <span class="copy-citation-label-normal">COPY</span>
73
      </button>
74
    </div>
75
    HTML
76
  end
77
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc