Title: | Collaborative Editing of Rmd (or Quarto / Rnw) Documents in Google Drive |
---|---|
Description: | Collaborative writing and editing of R Markdown (or Quarto / Sweave) documents. The local .Rmd (or Quarto / .Rnw) is uploaded as a plain-text file to Google Drive. By taking advantage of the easily readable Markdown (or LaTeX) syntax and the well-known online interface offered by Google Docs, collaborators can easily contribute to the writing and editing process. After integrating all authors’ contributions, the final document can be downloaded and rendered locally. |
Authors: | Emily Kothe [aut] , Claudio Zandonella Callegher [aut, cre] , Filippo Gambarota [aut] , Janosch Linkersdörfer [aut] , Mathew Ling [aut] |
Maintainer: | Claudio Zandonella Callegher <[email protected]> |
License: | GPL-3 |
Version: | 1.5.1 |
Built: | 2025-01-19 04:31:49 UTC |
Source: | https://github.com/claudiozandonella/trackdown |
Download edited version of a file from Google Drive updating the local
version with the new changes.
Use with caution as local version of the file will be
overwritten!
To know more about trackdown
workflow and features see
trackdown-package()
help page.
download_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, rm_gcomments = FALSE, force = FALSE )
download_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, rm_gcomments = FALSE, force = FALSE )
TRUE
if file from Google Drive was saved, FALSE
otherwise.
Render file from Google Drive if there have been edits
To know more about trackdown
workflow and features see
trackdown-package()
help page.
render_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, force = FALSE, rm_gcomments = FALSE )
render_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, force = FALSE, rm_gcomments = FALSE )
TRUE
if file from Google Drive was saved and rendered, FALSE
otherwise.
Authorize trackdown to view and manage your trackdown files. This function is a
wrapper around gargle::token_fetch()
.
By default, you are directed to a web browser, asked to sign in to your Google account, and to grant trackdown permission to operate on your behalf with trackdown. By default, with your permission, these user credentials are cached in a folder below your home directory, from where they can be automatically refreshed, as necessary. Storage at the user level means the same token can be used across multiple projects and tokens are less likely to be synced to the cloud by accident.
If you are interacting with R within a browser (applies to RStudio Server,
Posit Workbench, and Posit Cloud), you need a variant of this flow,
known as out-of-band auth ("oob"). If this does not happen
automatically, you can request it yourself with use_oob = TRUE
or,
more persistently, by setting an option via
options(gargle_oob_default = TRUE)
.
trackdown_auth( email = gargle::gargle_oauth_email(), path = NULL, scopes = "https://www.googleapis.com/auth/drive", cache = gargle::gargle_oauth_cache(), use_oob = gargle::gargle_oob_default(), token = NULL )
trackdown_auth( email = gargle::gargle_oauth_email(), path = NULL, scopes = "https://www.googleapis.com/auth/drive", cache = gargle::gargle_oauth_cache(), use_oob = gargle::gargle_oob_default(), token = NULL )
email |
Optional. Allows user to target a specific Google identity. If
specified, this is used for token lookup, i.e. to determine if a suitable
token is already available in the cache. If no such token is found, |
path |
JSON identifying the service account, in one of the forms
supported for the |
scopes |
A character vector of scopes to request. Pick from those listed at https://developers.google.com/identity/protocols/oauth2/scopes. For certain token flows, the
|
cache |
Specifies the OAuth token cache. Defaults to the option named
|
use_oob |
Whether to prefer out-of-band authentication. Defaults to the
value returned by |
token |
A token with class Token2.0 or an object of
httr's class |
Most users, most of the time, do not need to call trackdown_auth()
explicitly – it is triggered by the first action that requires
authorization. Even when called, the default arguments often suffice.
However, when necessary, this function allows the user to explicitly:
Declare which Google identity to use, via an email address. If there
are multiple cached tokens, this can clarify which one to use. It can
also force trackdown to switch from one identity to another. If
there's no cached token for the email, this triggers a return to the
browser to choose the identity and give consent. You can specify just
the domain by using a glob pattern. This means that a script
containing email = "*@example.com"
can be run without further
tweaks on the machine of either [email protected]
or
[email protected]
.
Use a service account token or workload identity federation.
Bring their own Token2.0.
Specify non-default behavior re: token caching and out-of-bound authentication.
Customize scopes.
For details on the many ways to find a token, see
gargle::token_fetch()
. For deeper control over auth, use
trackdown_auth_configure()
to bring your own OAuth client or API key.
Read more about gargle options, see gargle::gargle_options.
Other auth functions:
trackdown_auth_configure()
,
trackdown_deauth()
## Not run: # load/refresh existing credentials, if available # otherwise, go to browser for authentication and authorization trackdown_auth() # see user associated with current token trackdown_user() # force use of a token associated with a specific email trackdown_auth(email = "[email protected]") trackdown_user() # force a menu where you can choose from existing tokens or # choose to get a new one trackdown_auth(email = NA) # use a 'read only' scope, so it's impossible to edit or delete files # NOTE thaat this will allow only to download files from the drive trackdown_auth( scopes = "https://www.googleapis.com/auth/drive.readonly" ) # use a service account token trackdown_auth(path = "foofy-83ee9e7c9c48.json") ## End(Not run)
## Not run: # load/refresh existing credentials, if available # otherwise, go to browser for authentication and authorization trackdown_auth() # see user associated with current token trackdown_user() # force use of a token associated with a specific email trackdown_auth(email = "[email protected]") trackdown_user() # force a menu where you can choose from existing tokens or # choose to get a new one trackdown_auth(email = NA) # use a 'read only' scope, so it's impossible to edit or delete files # NOTE thaat this will allow only to download files from the drive trackdown_auth( scopes = "https://www.googleapis.com/auth/drive.readonly" ) # use a service account token trackdown_auth(path = "foofy-83ee9e7c9c48.json") ## End(Not run)
These functions give more control over and visibility into the auth
configuration than trackdown_auth()
does. trackdown_auth_configure()
lets the user specify their own:
OAuth client, which is used when obtaining a user token.
See the vignette("get-api-credentials", package = "gargle")
for more.
If the user does not configure these settings, internal defaults
are used.
trackdown_oauth_client()
retrieves the currently configured OAuth client.
trackdown_auth_configure(client, path, app = deprecated()) trackdown_oauth_client()
trackdown_auth_configure(client, path, app = deprecated()) trackdown_oauth_client()
client |
A Google OAuth client, presumably constructed via
|
path |
JSON downloaded from Google Cloud Console, containing a client id and
secret, in one of the forms supported for the |
app |
trackdown_auth_configure()
: An object of R6 class
gargle::AuthState, invisibly.
trackdown_oauth_client()
: the current user-configured OAuth client.
Other auth functions:
trackdown_auth()
,
trackdown_deauth()
# see the current user-configured OAuth client (probaby `NULL`) trackdown_oauth_client() if (require(httr)) { # store current state, so we can restore original_client <- trackdown_oauth_client() # bring your own client via client id (aka key) and secret google_client <- gargle::gargle_oauth_client( id = "123456789.apps.googleusercontent.com", secret = "abcdefghijklmnopqrstuvwxyz", name = "my-awesome-google-api-wrapping-package", ) trackdown_auth_configure(client = google_client) # confirm current client trackdown_oauth_client() # restore original state trackdown_auth_configure(client = original_client) trackdown_oauth_client() } ## Not run: # bring your own client via JSON downloaded from Google Developers Console trackdown_auth_configure( path = "/path/to/the/JSON/you/downloaded/from/google/dev/console.json" ) ## End(Not run)
# see the current user-configured OAuth client (probaby `NULL`) trackdown_oauth_client() if (require(httr)) { # store current state, so we can restore original_client <- trackdown_oauth_client() # bring your own client via client id (aka key) and secret google_client <- gargle::gargle_oauth_client( id = "123456789.apps.googleusercontent.com", secret = "abcdefghijklmnopqrstuvwxyz", name = "my-awesome-google-api-wrapping-package", ) trackdown_auth_configure(client = google_client) # confirm current client trackdown_oauth_client() # restore original state trackdown_auth_configure(client = original_client) trackdown_oauth_client() } ## Not run: # bring your own client via JSON downloaded from Google Developers Console trackdown_auth_configure( path = "/path/to/the/JSON/you/downloaded/from/google/dev/console.json" ) ## End(Not run)
Clears any currently stored token. The next time trackdown needs a token, the
token acquisition process starts over, with a fresh call to
trackdown_auth()
and, therefore, internally, a call to
gargle::token_fetch()
. Unlike some other packages that use gargle,
trackdown is not usable in a de-authorized state. Therefore, calling
trackdown_deauth()
only clears the token, i.e. it does NOT imply that
subsequent requests are made with an API key in lieu of a token.
trackdown_deauth()
trackdown_deauth()
Other auth functions:
trackdown_auth_configure()
,
trackdown_auth()
## Not run: trackdown_deauth() trackdown_user() ## End(Not run)
## Not run: trackdown_deauth() trackdown_user() ## End(Not run)
Reports whether trackdown has stored a token, ready for use in downstream requests.
trackdown_has_token()
trackdown_has_token()
Logical.
Other low-level API functions:
trackdown_token()
trackdown_has_token()
trackdown_has_token()
For internal use or for those programming around the trackdown API.
Returns a token pre-processed with httr::config()
. Most users
do not need to handle tokens "by hand" or, even if they need some
control, trackdown_auth()
is what they need. If there is no current
token, trackdown_auth()
is called to either load from cache or
initiate OAuth2.0 flow.
If auth has been deactivated via trackdown_deauth()
, trackdown_token()
returns NULL
.
trackdown_token()
trackdown_token()
A request
object (an S3 class provided by httr).
Other low-level API functions:
trackdown_has_token()
## Not run: trackdown_token() ## End(Not run)
## Not run: trackdown_token() ## End(Not run)
Reveals the email address of the user associated with the current token. If no token has been loaded yet, this function does not initiate auth.
trackdown_user()
trackdown_user()
An email address or, if no token has been loaded, NULL
.
gargle::token_userinfo()
, gargle::token_email()
,
gargle::token_tokeninfo()
## Not run: trackdown_user() ## End(Not run)
## Not run: trackdown_user() ## End(Not run)
Replaces the content of an existing file in Google Drive with the contents of
a local file. It is also possible to update (or upload if not already
present) the output (pdf or html) of the file specifying the
path_output
argument. In case of html files, if pagedown
package and Chrome are available, users can decide to upload a pdf version of
the html file.
Use with caution as tracked changes in the Google Drive file will be
lost!
To know more about trackdown
workflow and features see
trackdown-package()
help page.
update_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, hide_code = FALSE, path_output = NULL, rich_text = TRUE, rich_text_par = NULL, force = FALSE, open = rlang::is_interactive() )
update_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, hide_code = FALSE, path_output = NULL, rich_text = TRUE, rich_text_par = NULL, force = FALSE, open = rlang::is_interactive() )
The rich_text
option (default is TRUE
) allows to upload a rich
document to Google Docs. Important text that should not be changed is
highlighted. This includes, added instructions at the top of the document,
placeholders hiding the code, header of the document (YAML header or LaTeX
preamble), code chunks, and in-line code.
Default colour is opaque yellow. You can customize the colour specifying the
rgb_color
option in the rich_text_par
argument. The
rgb_color
has to be a list with elements red
, green
, and blue
.
Each element has to be a numeric value between 0 and 1. See example below.
a dribble of the uploaded file (and output if specified).
## Not run: # Change default color to opaque light-blue update_file(file = "path-to/my-file", rich_text = TRUE, rich_text_par = list(rgb_color = list(red = 102/255, green = 204/255, blue = 255/255))) ## End(Not run)
## Not run: # Change default color to opaque light-blue update_file(file = "path-to/my-file", rich_text = TRUE, rich_text_par = list(rgb_color = list(red = 102/255, green = 204/255, blue = 255/255))) ## End(Not run)
Uploads a local file to Google Drive as a plain text document. Will only
upload the file if it doesn't already exist in the chosen location. By
default files are uploaded in the folder "trackdown", if is not available on
Google Drive, permission to create it is required to the user. To update an
already existing file see update_file()
. It is also possible to
upload the output (pdf or html) of the file specifying the path_output
argument. In case of html files, if pagedown
package and Chrome are
available, users can decide to upload a pdf version of the html file.
To know more about trackdown
workflow and features see
trackdown-package()
help page.
upload_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, hide_code = FALSE, path_output = NULL, rich_text = TRUE, rich_text_par = NULL, force = FALSE, open = rlang::is_interactive() )
upload_file( file, gfile = NULL, gpath = "trackdown", shared_drive = NULL, hide_code = FALSE, path_output = NULL, rich_text = TRUE, rich_text_par = NULL, force = FALSE, open = rlang::is_interactive() )
The rich_text
option (default is TRUE
) allows to upload a rich
document to Google Docs. Important text that should not be changed is
highlighted. This includes, added instructions at the top of the document,
placeholders hiding the code, header of the document (YAML header or LaTeX
preamble), code chunks, and in-line code.
Default colour is opaque yellow. You can customize the colour specifying the
rgb_color
option in the rich_text_par
argument. The
rgb_color
has to be a list with elements red
, green
, and blue
.
Each element has to be a numeric value between 0 and 1. See example below.
a dribble of the uploaded file (and output if specified).
## Not run: # Change default color to opaque light-blue upload_file(file = "path-to/my-file", rich_text = TRUE, rich_text_par = list(rgb_color = list(red = 102/255, green = 204/255, blue = 255/255))) ## End(Not run)
## Not run: # Change default color to opaque light-blue upload_file(file = "path-to/my-file", rich_text = TRUE, rich_text_par = list(rgb_color = list(red = 102/255, green = 204/255, blue = 255/255))) ## End(Not run)