From 762ab9c0c9bcc0c7a31ba12e1964cebb9feff60c Mon Sep 17 00:00:00 2001 From: DaveParr Date: Mon, 29 Jun 2020 17:23:23 +0100 Subject: [PATCH] update README with workflow and other notes --- README.Rmd | 89 +++++++++++++++++++++++++++++++++++++++++++---- README.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 175 insertions(+), 14 deletions(-) diff --git a/README.Rmd b/README.Rmd index 1ea22a7..1e7b70d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,38 +17,113 @@ knitr::opts_chunk$set( to.ol -[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) +[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) The goal of `dev.to.ol` is to help R users publish to dev.to ## Installation -You can install the unreleased version of dev.to from [github](www.github.com) with: +You can install the dev.to.ol from [github](www.github.com) with `remotes`: ``` r remotes::install.github("DaveParr/dev.to.ol") ``` -## Example +## Workflow -This is a basic example which shows you how to solve a common problem: +### Create your article + +The `create_new_article` function will give you the front mattter boilerplate for an article `.Rmd` file. Optionally supplying a file name will create a new file with the front matter at the start. + +```r +create_new_article(title = "my title") +``` + +### Write your article! + +This is the fun bit. Mark your great ideas down in an `.Rmd`! + +### Post your article + +Once the `.Rmd` is written, you can post it to dev.to with `post_new_article` ```r -library(dev.to.ol) +post_new_article("./my-great-article.Rmd") +``` -post_new_article("./articles/my_article.Rmd") +### Check your articles + +There are two functions to check the posted articles on dev.to, published and unpublished. Both will return a 'tidy' data set by default. + +```r +get_users_articles() + +Using DEVTO in .Renviron +The API returned the expected success: 200 +# A tibble: 27 x 20 + type_of id title description published published_at slug path url + + 1 article 370013 Nati… "I made an… TRUE 2020-06-26T… nati… /dav… http… + 2 article 367598 Inve… "Is the de… TRUE 2020-06-26T… inve… /dav… http… + 3 article 367500 Why … "Motivatio… TRUE 2020-06-25T… why-… /dav… http… + 4 article 345011 Buil… "I'm worki… TRUE 2020-06-25T… buil… /dav… http… + 5 article 357514 3 mi… "I’ve made… TRUE 2020-06-17T… 3-mi… /dav… http… + 6 article 357411 Is '… "The langu… TRUE 2020-06-17T… is-r… /dav… http… + 7 article 357002 Webs… "library(t… TRUE 2020-06-16T… webs… /dav… http… + 8 article 356940 Is i… "I seem to… TRUE 2020-06-16T… is-i… /dav… http… + 9 article 354878 Reco… "I am writ… TRUE 2020-06-13T… reco… /dav… http… +10 article 354676 A re… "So I have… TRUE 2020-06-13T… a-re… /dav… http… +# … with 17 more rows, and 11 more variables: comments_count , +# public_reactions_count , page_views_count , +# published_timestamp , body_markdown , +# positive_reactions_count , tag_list , canonical_url , +# user , flare_tag , cover_image +``` + +### Update your article + +If you notice you've made a mistake, you can get the article id from `get_users_articles()`, and use that to send the new version of the `.Rmd` to dev.to + +```r +update_article(id = 151471, "./my-great-article.Rmd") ``` ## Authentication `dev.to.ol` will check for an `.Renviron` file it can access that has a line like this: -``` sh +```sh DEVTO="my_api_key" ``` +If you use `Rproj` projects (and you should!), this is easily placed in the root directory. Alternatively it can be set at user level for the system. + You can set up a key on dev.to [here](https://dev.to/settings/account) +The easiest way to check if this has worked is to run the function to check your users details + +```r +get_my_user() +Using DEVTO in .Renviron +The API returned the expected success: 200 +# A tibble: 11 x 2 + key value + + 1 type_of user + 2 id 150692 + 3 username daveparr + 4 name Dave Parr + 5 summary Data-scientist who loves to use #datascienceforgood, espec… + 6 twitter_usern… DaveParr + 7 github_userna… DaveParr + 8 website_url https://www.daveparr.info + 9 location Cardiff, Wales +10 joined_at Mar 29, 2019 +11 profile_image https://res.cloudinary.com/practicaldev/image/fetch/s--842… +``` + +## Code of Conduct + Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. diff --git a/README.md b/README.md index cc017fd..b302094 100644 --- a/README.md +++ b/README.md @@ -11,28 +11,85 @@ -[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) +[![Lifecycle: +maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) The goal of `dev.to.ol` is to help R users publish to dev.to ## Installation -You can install the unreleased version of dev.to from -[github](www.github.com) with: +You can install the dev.to.ol from [github](www.github.com) with +`remotes`: ``` r remotes::install.github("DaveParr/dev.to.ol") ``` -## Example +## Workflow -This is a basic example which shows you how to solve a common problem: +### Create your article + +The `create_new_article` function will give you the front mattter +boilerplate for an article `.Rmd` file. Optionally supplying a file name +will create a new file with the front matter at the start. + +``` r +create_new_article(title = "my title") +``` + +### Write your article\! + +This is the fun bit. Mark your great ideas down in an `.Rmd`\! + +### Post your article + +Once the `.Rmd` is written, you can post it to dev.to with +`post_new_article` ``` r -library(dev.to.ol) +post_new_article("./my-great-article.Rmd") +``` -post_new_article("./articles/my_article.Rmd") +### Check your articles + +There are two functions to check the posted articles on dev.to, +published and unpublished. Both will return a ‘tidy’ data set by +default. + +``` r +get_users_articles() + +Using DEVTO in .Renviron +The API returned the expected success: 200 +# A tibble: 27 x 20 + type_of id title description published published_at slug path url + + 1 article 370013 Nati… "I made an… TRUE 2020-06-26T… nati… /dav… http… + 2 article 367598 Inve… "Is the de… TRUE 2020-06-26T… inve… /dav… http… + 3 article 367500 Why … "Motivatio… TRUE 2020-06-25T… why-… /dav… http… + 4 article 345011 Buil… "I'm worki… TRUE 2020-06-25T… buil… /dav… http… + 5 article 357514 3 mi… "I’ve made… TRUE 2020-06-17T… 3-mi… /dav… http… + 6 article 357411 Is '… "The langu… TRUE 2020-06-17T… is-r… /dav… http… + 7 article 357002 Webs… "library(t… TRUE 2020-06-16T… webs… /dav… http… + 8 article 356940 Is i… "I seem to… TRUE 2020-06-16T… is-i… /dav… http… + 9 article 354878 Reco… "I am writ… TRUE 2020-06-13T… reco… /dav… http… +10 article 354676 A re… "So I have… TRUE 2020-06-13T… a-re… /dav… http… +# … with 17 more rows, and 11 more variables: comments_count , +# public_reactions_count , page_views_count , +# published_timestamp , body_markdown , +# positive_reactions_count , tag_list , canonical_url , +# user , flare_tag , cover_image +``` + +### Update your article + +If you notice you’ve made a mistake, you can get the article id from +`get_users_articles()`, and use that to send the new version of the +`.Rmd` to dev.to + +``` r +update_article(id = 151471, "./my-great-article.Rmd") ``` ## Authentication @@ -44,8 +101,37 @@ line like this: DEVTO="my_api_key" ``` +If you use `Rproj` projects (and you should\!), this is easily placed in +the root directory. Alternatively it can be set at user level for the +system. + You can set up a key on dev.to [here](https://dev.to/settings/account) +The easiest way to check if this has worked is to run the function to +check your users details + +``` r +get_my_user() +Using DEVTO in .Renviron +The API returned the expected success: 200 +# A tibble: 11 x 2 + key value + + 1 type_of user + 2 id 150692 + 3 username daveparr + 4 name Dave Parr + 5 summary Data-scientist who loves to use #datascienceforgood, espec… + 6 twitter_usern… DaveParr + 7 github_userna… DaveParr + 8 website_url https://www.daveparr.info + 9 location Cardiff, Wales +10 joined_at Mar 29, 2019 +11 profile_image https://res.cloudinary.com/practicaldev/image/fetch/s--842… +``` + +## Code of Conduct + Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.