Skip to content

Commit

Permalink
fix tests, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Dec 6, 2024
1 parent a0b0002 commit 84e3e22
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ og_parse <- function(url) {
rvest::html_nodes("meta[property^='og:']")

# Create a named list of the metadata
og_metadata <- setNames(
og_metadata <- stats::setNames(
rvest::html_attr(meta_tags, 'content'),
rvest::html_attr(meta_tags, 'property')
)
Expand Down
112 changes: 56 additions & 56 deletions R/schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,68 @@
og_schema <- function() {
c(
# basic
'og:title', #' , # - The title of your object as it should appear within the graph, e.g., "The Rock".
'og:type', #' , # - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
'og:image', #' , # - An image URL which should represent your object within the graph.
'og:url', #' , # - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "https://www.imdb.com/title/tt0117500/".
'og:title', # - The title of your object as it should appear within the graph, e.g., "The Rock".
'og:type', # - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
'og:image', # - An image URL which should represent your object within the graph.
'og:url', # - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "https://www.imdb.com/title/tt0117500/".
# optional
'og:audio', #' , # - A URL to an audio file to accompany this object.
'og:description', #' , # - A one to two sentence description of your object.
'og:determiner', #' , # - The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
'og:locale', #' , # - The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
'og:locale:alternate', #' , # - An array of other locales this page is available in.
'og:site_name', #' , # - If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
'og:video', #' , # - A URL to a video file that complements this object.
'og:audio', # - A URL to an audio file to accompany this object.
'og:description', # - A one to two sentence description of your object.
'og:determiner', # - The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
'og:locale', # - The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
'og:locale:alternate', # - An array of other locales this page is available in.
'og:site_name', # - If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
'og:video', # - A URL to a video file that complements this object.
# structured
## image
'og:image:url', #' , # - Identical to og:image.
'og:image:secure_url', #' , # - An alternate url to use if the webpage requires HTTPS.
'og:image:type', #' , # - A MIME type for this image.
'og:image:width', #' , # - The number of pixels wide.
'og:image:height', #' , # - The number of pixels high.
'og:image:alt', #' , # - A description of what is in the image (not a caption). If the page specifies an og:image it should specify og:image:alt.
'og:image:url', # - Identical to og:image.
'og:image:secure_url', # - An alternate url to use if the webpage requires HTTPS.
'og:image:type', # - A MIME type for this image.
'og:image:width', # - The number of pixels wide.
'og:image:height', # - The number of pixels high.
'og:image:alt', # - A description of what is in the image (not a caption). If the page specifies an og:image it should specify og:image:alt.

## video
'og:video:url', #' , # - Identical to og:video.
'og:video:secure_url', #' , # - An alternate url to use if the webpage requires HTTPS.
'og:video:type', #' , # - A MIME type for this video.
'og:video:width', #' , # - The number of pixels wide.
'og:video:height', #' , # - The number of pixels high.
'og:video:alt', #' , # - A description of what is in the video (not a caption). If the page specifies an og:video it should specify og:video:alt.
'og:video:url', # - Identical to og:video.
'og:video:secure_url', # - An alternate url to use if the webpage requires HTTPS.
'og:video:type', # - A MIME type for this video.
'og:video:width', # - The number of pixels wide.
'og:video:height', # - The number of pixels high.
'og:video:alt', # - A description of what is in the video (not a caption). If the page specifies an og:video it should specify og:video:alt.

## audio
'og:audio:url', #' , # - Identical to og:audio.
'og:audio:secure_url', #' , # - An alternate url to use if the webpage requires HTTPS.
'og:audio:type', #' , # - A MIME type for this audio.
'og:audio:url', # - Identical to og:audio.
'og:audio:secure_url', # - An alternate url to use if the webpage requires HTTPS.
'og:audio:type', # - A MIME type for this audio.

# music.song
'music:duration', #' , # - integer >=1' , # - The song\'s length in seconds.
'music:album', # - music.album array' , # - The album this song is from.
'music:album:disc', # - integer >=1' , # - Which disc of the album this song is on.
'music:album:track', # - integer >=1' , # - Which track this song is.
'music:musician', # - profile array' , # - The musician that made this song.
'music:duration', # - integer >=1 - The song\'s length in seconds.
'music:album', # - music.album array - The album this song is from.
'music:album:disc', # - integer >=1 - Which disc of the album this song is on.
'music:album:track', # - integer >=1 - Which track this song is.
'music:musician', # - profile array - The musician that made this song.
'music.album',
'music:song', # - music.song' , # - The song on this album.
'music:song:disc', # - integer >=1' , # - The same as music:album:disc but in reverse.
'music:song:track', # - integer >=1' , # - The same as music:album:track but in reverse.
'music:musician', # - profile' , # - The musician that made this song.
'music:release_date', # - datetime' , # - The date the album was released.
'music:song', # - music.song - The song on this album.
'music:song:disc', # - integer >=1 - The same as music:album:disc but in reverse.
'music:song:track', # - integer >=1 - The same as music:album:track but in reverse.
'music:musician', # - profile - The musician that made this song.
'music:release_date', # - datetime - The date the album was released.
'music.playlist',
'music:song', # - Identical to the ones on music.album
'music:song:disc',
'music:song:track',
'music:creator', # - profile' , # - The creator of this playlist.
'music:creator', # - profile - The creator of this playlist.
'music.radio_station',
'music:creator', # - profile' , # - The creator of this station.
'music:creator', # - profile - The creator of this station.

'video.movie',
'video:actor', # - profile array' , # - Actors in the movie.
'video:actor:role', # - string' , # - The role they played.
'video:director', # - profile array' , # - Directors of the movie.
'video:writer', # - profile array' , # - Writers of the movie.
'video:duration', # - integer >=1' , # - The movie's length in seconds.
'video:release_date', , # - datetime' , # - The date the movie was released.
'video:tag', # - string array' , # - Tag words associated with this movie.
'video:actor', # - profile array - Actors in the movie.
'video:actor:role', # - string - The role they played.
'video:director', # - profile array - Directors of the movie.
'video:writer', # - profile array - Writers of the movie.
'video:duration', # - integer >=1 - The movie's length in seconds.
'video:release_date', # - datetime - The date the movie was released.
'video:tag', # - string array - Tag words associated with this movie.
'video.episode',
'video:actor', # - Identical to video.movie
'video:actor:role',
Expand All @@ -81,26 +81,26 @@ og_schema <- function() {
'video:duration',
'video:release_date',
'video:tag',
'video:series', # video.tv_show' , # - Which series this episode belongs to.
'video:series', # video.tv_show - Which series this episode belongs to.
'video.tv_show', # A multi-episode TV show. The metadata is identical to video.movie.

'video.other', # A video that doesn\'t belong in any other category. The metadata is identical to video.movie.

'article', # - Namespace URI: https://ogp.me/ns/article#

'article:published_time', # - datetime' , # - When the article was first published.
'article:modified_time', # - datetime' , # - When the article was last changed.
'article:expiration_time', # - datetime' , # - When the article is out of date after.
'article:author', # - profile array' , # - Writers of the article.
'article:section', # - string' , # - A high-level section name. E.g. Technology
'article:tag', # - string array' , # - Tag words associated with this article.
'article:published_time', # - datetime - When the article was first published.
'article:modified_time', # - datetime - When the article was last changed.
'article:expiration_time', # - datetime - When the article is out of date after.
'article:author', # - profile array - Writers of the article.
'article:section', # - string - A high-level section name. E.g. Technology
'article:tag', # - string array - Tag words associated with this article.

'book', # - Namespace URI: https://ogp.me/ns/book#

'book:author', # - profile array' , # - Who wrote this book.
'book:isbn', # - string' , # - The ISBN
'book:release_date', # - datetime' , # - The date the book was released.
'book:tag', # - string array' , # - Tag words associated with this book.
'book:author', # - profile array - Who wrote this book.
'book:isbn', # - string - The ISBN
'book:release_date', # - datetime - The date the book was released.
'book:tag', # - string array - Tag words associated with this book.

'profile', # - Namespace URI: https://ogp.me/ns/profile#

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-parse.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test_that('multiplication works', {
expect_true(is.list(og_parse('https://www.rstudio.com')))
test_that('og_parse works', {
expect_true(is.vector(og_parse('https://www.rstudio.com')))
})
2 changes: 1 addition & 1 deletion tests/testthat/test-property.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test_that('multiplication works', {
test_that('og_property works', {
expect_equal(og_property('https://www.rstudio.com', 'og:title'), 'Posit')
})
2 changes: 1 addition & 1 deletion tests/testthat/test-schema.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test_that('schema works', {
expect_true(is.list(og_schema()))
expect_true(length(og_schema()) == 81L)
})

0 comments on commit 84e3e22

Please sign in to comment.