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

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 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 flash_notice
1✔
11
    value = flash[:notice]
×
12
    # rubocop:disable Rails/OutputSafety
13
    value.html_safe
×
14
    # rubocop:enable Rails/OutputSafety
15
  end
16

17
  def pre_curation_uploads_file_name(file:)
1✔
18
    value = file.filename.to_s
×
19
    return if value.blank?
×
20

21
    value[0..79]
×
22
  end
23
  alias post_curation_uploads_file_name pre_curation_uploads_file_name
1✔
24

25
  def ark_url(ark_value)
1✔
26
    return nil if ark_value.blank?
×
27
    # This was originally in Work#ark_url as: "https://ezid.cdlib.org/id/#{ark}"
28
    "http://arks.princeton.edu/#{ark_value}"
×
29
  end
30

31
  def doi_url(doi_value)
1✔
32
    return nil if doi_value.blank?
×
33
    "https://doi.org/#{doi_value}"
×
34
  end
35

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

45
  def citation_html(work, citation)
1✔
46
    apa = citation.apa
×
47
    bibtex = citation.bibtex
×
48
    bibtex_html = html_escape(bibtex).gsub("\r\n", "<br/>").gsub("\t", "  ").gsub("  ", "&nbsp;&nbsp;")
×
49
    bibtex_text = html_escape(bibtex).gsub("\t", "  ")
×
50

51
    html = apa_section(apa) + "\n" + bibtex_section(work, bibtex_html, bibtex_text)
×
52
    # rubocop:disable Rails/OutputSafety
53
    html.html_safe
×
54
    # rubocop:enable Rails/OutputSafety
55
  end
56

57
  def bibtex_section(work, bibtex_html, bibtex_text)
1✔
58
    <<-HTML
×
59
    <div class="citation-bibtex-container hidden-element">
60
      <div class="bibtex-citation">#{bibtex_html}</div>
61
      <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">
62
        <i class="bi bi-clipboard" title="Copy BibTeX citation to the clipboard"></i>
63
        <span class="copy-citation-label-normal">COPY</span>
64
      </button>
65
      <button id="download-bibtex" class="btn btn-sm" data-url="#{work_bibtex_url(id: work.id)}" title="Download BibTeX citation to a file">
66
        <i class="bi bi-file-arrow-down" title="Download BibTeX citation to a file"></i>
67
        <span class="copy-citation-label-normal">DOWNLOAD</span>
68
      </button>
69
    </div>
70
  HTML
71
  end
72

73
  def apa_section(apa)
1✔
74
    <<-HTML
×
75
    <div class="citation-apa-container">
76
      <div class="apa-citation">#{html_escape(apa)}</div>
77
      <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">
78
        <i class="bi bi-clipboard" title="Copy citation to the clipboard"></i>
79
        <span class="copy-citation-label-normal">COPY</span>
80
      </button>
81
    </div>
82
    HTML
83
  end
84
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