Skip to content

Commit

Permalink
update vignettes have them as many
Browse files Browse the repository at this point in the history
  • Loading branch information
favstats committed Oct 11, 2023
1 parent 106632e commit b0431b9
Show file tree
Hide file tree
Showing 48 changed files with 1,119 additions and 1,642 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
args: 'c("--no-vignettes", "--no-build-vignettes", "--ignore-vignettes")'
build_args: 'c("--no-build-vignettes")'
4 changes: 2 additions & 2 deletions R/feed.r
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ get_feeds_created_by <- function(actor,
if (parse) {
cli::cli_progress_step("Parsing {length(res)} results.")

out <- res %>%
map_dfr(~{
out <- res |>
purrr::map_dfr(~{
l <- .x |>
purrr::list_flatten() |>
purrr::list_flatten() |>
Expand Down
77 changes: 74 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ output: github_document
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = FALSE,
warning = FALSE,
fig.path = "man/figures/README-",
out.width = "100%"
)
knitr::knit_hooks$set(document = function(x, options)
gsub("(figures/", "(vignettes/figures/", x, fixed = TRUE))
library(dplyr)
library(purrr)
```

# atr <img src="man/figures/logo.png" align="right" height="120">
Expand All @@ -23,28 +28,94 @@ knitr::knit_hooks$set(document = function(x, options)
[![Codecov test coverage](https://codecov.io/gh/JBGruber/atr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/JBGruber/atr?branch=main)
<!-- badges: end -->

The goal of atr is to wrap the AT Protocol (Authenticated Transfer Protocol) behind Bluesky.
And we have actually already fulfilled this goal!
The goal of atr is to wrap the AT Protocol (Authenticated Transfer Protocol) behind Bluesky. *And we have actually already fulfilled this goal!*

The entire protocol is open and documented in so-called [lexicons](https://atproto.com/guides/lexicon), from which we autogenerated `R` functions.

These are not exported, however, since dealing with them is a bit advanced.
Rather we have some nice human-generated functions with documentation and examples.

## Installation

You can install the development version of atr like so (`pak` works similar to `remotes` here, but it's what the cool kids use now :grin:):
You can install the development version of `atr` like so (`pak` works similar to `remotes` here, but it's what the cool kids use now :grin:):

``` r
# install.packages("pak")
pak::pak("JBGruber/atr")
```

## Load the package

```{r setup}
library(atr)
```


## Authentication

The first time you make a request, you will be prompted automatically to enter your user handle and an app password to authenticate `atr` to communicate with BlueSky for you.

![RStudio Popup](figures/password_popup.png)

The page to generate app passwords is also automatically opened for you.

![page to create new app passwords](figures/app_password.png)

However, you can also trigger this process manually:

```{r eval=FALSE}
auth("jbgruber.bsky.social")
```

This can be useful if you want to replace an old token as it is permanently stored encrypted on disk.



## Retrieve Skeets (`get_skeets_authored_by`)

To fetch all the skeets by a specific user, use the `get_skeets_authored_by` function. *Note this also includes quote skeets and reskeets.* You can also opt not to parse the result by setting `parse = FALSE`, however it is recommended to use the default parse option which results in a (more) tidy tibble.

```{r}
get_skeets_authored_by(actor = "benguinaudeau.bsky.social", parse = TRUE) |>
dplyr::glimpse()
```




## Analyzing Feeds on Blue Sky

On Blue Sky users have the ability to create custom feeds based on specific keywords. These feeds aggregate content, for instance, a user might curate a feed around the hashtag `#rstats` to gather all relevant content about. Let's delve into the dynamics of such feeds.


Our starting point is to extract the posts from the `#rstats` feed created by "andrew.heiss.phd".


```{r}
# Fetching the feed posts
feeds <- get_feeds_created_by(actor = "andrew.heiss.phd")
# Filtering for a specific keyword, for example "#rstats"
rstat_feed <- feeds |>
filter(displayName == "#rstats")
# Extracting posts from this curated feed
rstat_posts <- get_feed(rstat_feed$uri, limit = 200) |>
# Extracting user handle from the author
mutate(handle = author |> map_chr(~{.x$handle})) |>
dplyr::glimpse()
```

## Learn More?

Start with the [Basic Usage](https://jbgruber.github.io/atr/articles/Basic_Usage.html) vignette to learn more.

# Want to help?

You can help by creating an [issue](https://github.com/JBGruber/atr/issues/new/choose) requesting new features or reporting bugs.

If you are a developer, we are happy to accept pull requests.

It should be fairly straightforward, as all endpoints are already covered by automatically generated function.

But please open an issue first, so we don't do duplicated work.
115 changes: 109 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,126 @@ coverage](https://codecov.io/gh/JBGruber/atr/branch/main/graph/badge.svg)](https
<!-- badges: end -->

The goal of atr is to wrap the AT Protocol (Authenticated Transfer
Protocol) behind Bluesky. And we have actually already fulfilled this
goal! The entire protocol is open and documented in so-called
Protocol) behind Bluesky. *And we have actually already fulfilled this
goal!*

The entire protocol is open and documented in so-called
[lexicons](https://atproto.com/guides/lexicon), from which we
autogenerated `R` functions. These are not exported, however, since
dealing with them is a bit advanced. Rather we have some nice
human-generated functions with documentation and examples.
autogenerated `R` functions.

These are not exported, however, since dealing with them is a bit
advanced. Rather we have some nice human-generated functions with
documentation and examples.

## Installation

You can install the development version of atr like so (`pak` works
You can install the development version of `atr` like so (`pak` works
similar to `remotes` here, but it’s what the cool kids use now :grin:):

``` r
# install.packages("pak")
pak::pak("JBGruber/atr")
```

## Load the package

``` r
library(atr)
```

## Authentication

The first time you make a request, you will be prompted automatically to
enter your user handle and an app password to authenticate `atr` to
communicate with BlueSky for you.

<figure>
<img src="vignettes/figures/password_popup.png" alt="RStudio Popup" />
<figcaption aria-hidden="true">RStudio Popup</figcaption>
</figure>

The page to generate app passwords is also automatically opened for you.

<figure>
<img src="vignettes/figures/app_password.png"
alt="page to create new app passwords" />
<figcaption aria-hidden="true">page to create new app
passwords</figcaption>
</figure>

However, you can also trigger this process manually:

``` r
auth("jbgruber.bsky.social")
```

This can be useful if you want to replace an old token as it is
permanently stored encrypted on disk.

## Retrieve Skeets (`get_skeets_authored_by`)

To fetch all the skeets by a specific user, use the
`get_skeets_authored_by` function. *Note this also includes quote skeets
and reskeets.* You can also opt not to parse the result by setting
`parse = FALSE`, however it is recommended to use the default parse
option which results in a (more) tidy tibble.

``` r
get_skeets_authored_by(actor = "benguinaudeau.bsky.social", parse = TRUE) |>
dplyr::glimpse()
#> Rows: 24
#> Columns: 11
#> $ uri <chr> "at://did:plc:l6z5l7dtmoalsxl6v6a57mjk/app.bsky.feed.post…
#> $ cid <chr> "bafyreihfmnxonlhlukswv6flaf4xzporosdbwo57ii3lo3fgzebggho…
#> $ author <list> ["did:plc:l6z5l7dtmoalsxl6v6a57mjk", "elisadeisshelbig.b…
#> $ text <chr> "I am very much looking forward to the CPPE talks put tog…
#> $ record <list> ["I am very much looking forward to the CPPE talks put t…
#> $ reply_count <int> 0, 3, 0, 2, 0, 2, 0, 0, 1, 0, 1, 1, 0, 1, 1, 2, 1, 0, 1, …
#> $ repost_count <int> 2, 45, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3…
#> $ like_count <int> 8, 38, 2, 36, 1, 5, 4, 1, 0, 4, 4, 3, 0, 1, 0, 5, 0, 3, 3…
#> $ indexed_at <dttm> 2023-10-05 15:53:49, 2023-10-04 13:15:35, 2023-10-02 01:…
#> $ reply <list> <NULL>, <NULL>, [["app.bsky.feed.defs#postView", "at://d…
#> $ is_reskeet <lgl> TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALS…
```

## Analyzing Feeds on Blue Sky

On Blue Sky users have the ability to create custom feeds based on
specific keywords. These feeds aggregate content, for instance, a user
might curate a feed around the hashtag `#rstats` to gather all relevant
content about. Let’s delve into the dynamics of such feeds.

Our starting point is to extract the posts from the `#rstats` feed
created by “andrew.heiss.phd”.

``` r
# Fetching the feed posts
feeds <- get_feeds_created_by(actor = "andrew.heiss.phd")

# Filtering for a specific keyword, for example "#rstats"
rstat_feed <- feeds |>
filter(displayName == "#rstats")

# Extracting posts from this curated feed
rstat_posts <- get_feed(rstat_feed$uri, limit = 200) |>
# Extracting user handle from the author
mutate(handle = author |> map_chr(~{.x$handle})) |>
dplyr::glimpse()
#> Rows: 89
#> Columns: 11
#> $ uri <chr> "at://did:plc:bpwmgq35v7snpvi6xxjhgucy/app.bsky.feed.post…
#> $ cid <chr> "bafyreic7iiamtnin5oluodqsrq4ivuh5kgiapnsvug2c6lm5kyyule5…
#> $ author <list> ["did:plc:bpwmgq35v7snpvi6xxjhgucy", "fdechterenko.bsky.…
#> $ text <chr> "Hi Bluesky! I finally made it to the other site. Hope th…
#> $ record <list> ["Hi Bluesky! I finally made it to the other site. Hope …
#> $ reply_count <int> 0, 1, 1, 0, 0, 1, 1, 0, 3, 3, 0, 0, 1, 2, 0, 0, 0, 4, 0, …
#> $ repost_count <int> 1, 1, 1, 2, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 4, 0, 0, …
#> $ like_count <int> 8, 6, 8, 5, 1, 1, 5, 0, 9, 1, 1, 3, 6, 4, 5, 4, 11, 6, 1,…
#> $ indexed_at <dttm> 2023-10-11 06:18:40, 2023-10-11 00:53:13, 2023-10-10 21:…
#> $ reply <list> <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, …
#> $ handle <chr> "fdechterenko.bsky.social", "ceenell.bsky.social", "gabsp…
```

## Learn More?

Start with the [Basic
Expand Down
44 changes: 27 additions & 17 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b0431b9

Please sign in to comment.