gadenbuie / metathis

@@ -213,7 +213,7 @@
Loading
213 213
  htmltools::htmlDependency(
214 214
    paste0("metathis", "-", random_id()),
215 215
    version = metathis_version,
216 -
    src = system.file(package = "metathis"),
216 +
    src = c(href = "http://example.com"),
217 217
    all_files = FALSE,
218 218
    head = .meta %>% paste()
219 219
  )

@@ -0,0 +1,162 @@
Loading
1 +
#' Add Google Scholar Metadata
2 +
#'
3 +
#' Add biobliographic metadata to pages in the format expected by Google
4 +
#' Scholar. Please reference the
5 +
#' [Google Scholar Inclusion](https://scholar.google.com/intl/en/scholar/inclusion.html#indexing)
6 +
#' page for the most up-to-date information and instructions. Note that this
7 +
#' function adds the `citation_` prefix to all of its arguments; the `title`
8 +
#' argument becomes the `citation_title` `<meta>` tag.
9 +
#'
10 +
#' @examples
11 +
#' meta_google_scholar(
12 +
#'   title = c(
13 +
#'     "The testis isoform of the phosphorylase kinase catalytic subunit (PhK-T)",
14 +
#'     "plays a critical role in regulation of glycogen mobilization in developing lung"
15 +
#'   ),
16 +
#'   author = c(
17 +
#'     "Liu, Li",
18 +
#'     "Rannels, Stephen R.",
19 +
#'     "Falconieri, Mary",
20 +
#'     "Phillips, Karen S.",
21 +
#'     "Wolpert, Ellen B.",
22 +
#'     "Weaver, Timothy E."
23 +
#'   ),
24 +
#'   publication_date = "1996/05/17",
25 +
#'   journal_title = "Journal of Biological Chemistry",
26 +
#'   volume = 271,
27 +
#'   issue = 20,
28 +
#'   firstpage = 11761,
29 +
#'   lastpage = 11766,
30 +
#'   pdf_url = "http://www.example.com/content/271/20/11761.full.pdf"
31 +
#' )
32 +
#'
33 +
#' @template describe-meta
34 +
#' @param title The title of the paper.
35 +
#'
36 +
#'   The title tag must contain the title of the paper. Don't use it for the
37 +
#'   title of the journal or a book in which the paper was published, or for the
38 +
#'   name of your repository. This tag is required for inclusion in Google
39 +
#'   Scholar.
40 +
#' @param author A vector of author names.
41 +
#'
42 +
#'   The `author` tag, must contain the authors (and only the actual authors) of
43 +
#'   the paper. Don't use it for the author of the website or for contributors
44 +
#'   other than authors, e.g., thesis advisors. Author names can be listed
45 +
#'   either as "Smith, John" or as "John Smith". Put each author name in a
46 +
#'   separate tag and omit all affiliations, degrees, certifications, etc., from
47 +
#'   this field. At least one author tag is required for inclusion in Google
48 +
#'   Scholar.
49 +
#' @param publication_date,online_date The date the paper was published in the
50 +
#'   journal (`publication_date`) or published online (`online_date`).
51 +
#'
52 +
#'   The `publication_date` tag must contain the date of publication, i.e., the
53 +
#'   date that would normally be cited in references to this paper from other
54 +
#'   papers. Don't use it for the date of entry into the repository - that
55 +
#'   should go into `online_date` instead. Provide full dates in the "2010/5/12"
56 +
#'   format if available; or a year alone otherwise. This tag is required for
57 +
#'   inclusion in Google Scholar.
58 +
#'
59 +
#' @param journal_title,conference_title,issn,isbn,volume,issue,firstpage,lastpage
60 +
#'   For journal and conference papers, provide the remaining bibliographic
61 +
#'   citation data in the following tags: `journal_title` or `conference_title`,
62 +
#'   `issn`, `isbn`, `volume`, `issue`, `firstpage`, and `lastpage.` These
63 +
#'   fields must contain sufficient information to identify a reference to this
64 +
#'   paper from another document, which is normally all of: (a) journal or
65 +
#'   conference name, (b) volume and issue numbers, if applicable, and (c) the
66 +
#'   number of the first page of the paper in the volume (or issue) in question.
67 +
#'
68 +
#' @param dissertation_institution,technical_report_institution,technical_report_number
69 +
#'   For theses, dissertations, and technical reports, provide the remaining
70 +
#'   bibliographic citation data in the following tags:
71 +
#'   `dissertation_institution`, `technical_report_institution` for the name of
72 +
#'   the institution and `technical_report_number` for the number of the
73 +
#'   technical report. As with journal and conference papers, you need to
74 +
#'   provide sufficient information to recognize a formal citation to this
75 +
#'   document from another article.
76 +
#'
77 +
#' @param pdf_url The `<meta>` tags normally apply only to the exact page on
78 +
#'   which they're provided. If this page shows only the abstract of the paper
79 +
#'   and you have the full text in a separate file, e.g., in the PDF format,
80 +
#'   please specify the locations of all full text versions using `pdf_url`. The
81 +
#'   content of the tag is the absolute URL of the PDF file; for security
82 +
#'   reasons, it must refer to a file in the same subdirectory as the HTML
83 +
#'   abstract.
84 +
#'
85 +
#' @template describe-meta-return
86 +
#'
87 +
#' @references <https://scholar.google.com/intl/en/scholar/inclusion.html#indexing>
88 +
#' @export
89 +
meta_google_scholar <- function(
90 +
  .meta = meta(),
91 +
  title,
92 +
  author,
93 +
  publication_date,
94 +
  online_date = NULL,
95 +
  journal_title = NULL,
96 +
  conference_title = NULL,
97 +
  volume = NULL,
98 +
  issue = NULL,
99 +
  firstpage = NULL,
100 +
  lastpage = NULL,
101 +
  pdf_url = NULL,
102 +
  issn = NULL,
103 +
  isbn = NULL,
104 +
  dissertation_institution = NULL,
105 +
  technical_report_institution = NULL,
106 +
  technical_report_number = NULL
107 +
) {
108 +
  assert_is_meta(.meta)
109 +
110 +
  assert_valid_google_scholar_date(publication_date)
111 +
  assert_valid_google_scholar_date(online_date)
112 +
113 +
  scholar <- list(
114 +
    title            = title,
115 +
    publication_date = publication_date,
116 +
    online_date      = online_date,
117 +
    journal_title    = journal_title,
118 +
    conference_title = conference_title,
119 +
    volume           = volume,
120 +
    issue            = issue,
121 +
    firstpage        = firstpage,
122 +
    lastpage         = lastpage,
123 +
    pdf_url          = pdf_url,
124 +
    issn             = issn,
125 +
    isbn             = isbn,
126 +
    dissertation_institution     = dissertation_institution,
127 +
    technical_report_institution = technical_report_institution,
128 +
    technical_report_number      = technical_report_number
129 +
  )
130 +
  names(scholar) <- paste0("citation_", names(scholar))
131 +
132 +
  for (aut in rev(author)) {
133 +
    scholar <- purrr::prepend(scholar, list(citation_author = aut))
134 +
  }
135 +
  idx_title <- which(names(scholar) == "citation_title")
136 +
  scholar <- c(scholar[idx_title], scholar[-idx_title])
137 +
138 +
  meta_scholar <-
139 +
    scholar %>%
140 +
    purrr::compact() %>%
141 +
    collapse_single_string() %>%
142 +
    purrr::imap(~ tag_meta(name = .y, content = .x)) %>%
143 +
    unname()
144 +
145 +
  append_to_meta(.meta, meta_scholar)
146 +
}
147 +
148 +
assert_valid_google_scholar_date <- function(x) {
149 +
  if (is.null(x)) return()
150 +
  x_name <- deparse(substitute(x))
151 +
  x <- as.character(x)
152 +
153 +
  if (length(x) > 1) {
154 +
    stop("`", x_name, "` must be a single value.", call. = FALSE)
155 +
  }
156 +
157 +
  valid_date_fmt <- "^\\d{4}(/\\d{1,2}/\\d{1,2})?$"
158 +
159 +
  if (!grepl(valid_date_fmt, x)) {
160 +
    stop("`", x_name, "` must be in YYYY or YYYY/MM/DD format.", call. = FALSE)
161 +
  }
162 +
}
Files Coverage
R 100.00%
Project Totals (9 files) 100.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading