Skip to content

Commit

Permalink
Add search_rstudio_community (close #13) (#17)
Browse files Browse the repository at this point in the history
* Add search portal for RStudio Community

* Update DESCRIPTION with new portal

* Add a unit test for RSC.

* Update the README with RStudio Com add

* Update news and roll a new version
  • Loading branch information
coatless authored Jul 5, 2019
1 parent b5a7c9d commit 53700a8
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 81 deletions.
24 changes: 14 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
Package: searcher
Title: Query Search Interfaces
Version: 0.0.3.9100
Authors@R: c(person("James", "Balamuta",
email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2826-8458")))
Version: 0.0.3.9200
Authors@R: c(
person("James", "Balamuta",
email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2826-8458")
)
)
Description: Provides a search interface to look up terms
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow', 'GitHub',
and 'BitBucket'. Upon searching, a browser window will open with the
aforementioned search results.
URL: https://github.com/coatless/searcher
BugReports: https://github.com/coatless/searcher/issues
Depends: R (>= 3.0.0)
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow',
'RStudio Community', 'GitHub', and 'BitBucket'. Upon searching, a browser
window will open with the aforementioned search results.
URL: https://github.com/r-assist/searcher
BugReports: https://github.com/r-assist/searcher/issues
Depends: R (>= 3.3.0)
License: GPL (>= 2)
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export(search_gh)
export(search_github)
export(search_google)
export(search_ixquick)
export(search_rscom)
export(search_rstudio_community)
export(search_site)
export(search_so)
export(search_sp)
Expand Down
16 changes: 12 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# searcher 0.0.3.9000
# searcher 0.0.3.9200

## Features

- Added search portal:
- `search_rstudio_community()` or `search_rscom()`: Searches on [RStudio Community](https://community.rstudio.com/search).
(#13, #17)

## Changes

- Renamed search portal `search_ixquick()` to `search_startpage()` due to the
merging of ixquick into startpage. (#15)
- Renamed search portal:
- Changed `search_ixquick()` to `search_startpage()` due to the
merging of ixquick into startpage. (#15)
- Update the README overview for the project. (#16)

## Deployment
Expand All @@ -16,7 +23,8 @@

## Features

- Added search portal `search_ixquick()`: Searches with [ixquick](https://www.ixquick.com/). (#8, #6)
- Added search portal:
- `search_ixquick()`: Searches with [ixquick](https://www.ixquick.com/). (#8, #6)

## Changes

Expand Down
99 changes: 67 additions & 32 deletions R/search-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
#' Creates an appropriate query string for a search engine and then opens
#' up the resulting page in a web browser.
#'
#' @param site Name of site to search on. Supported options:
#' `"google"` (default), `"bing"`, `"duckduckgo"`, `"startpage"`,
#' `"stackoverflow"`, `"github"`, and `"bitbucket"`.
#' @param query Contents of string to search. Default is the error message.
#' @param rlang Search for results written in R. Default is `TRUE`
#' @param site Name of site to search on. Supported options:
#' `"google"` (default), `"bing"`, `"duckduckgo"`, `"startpage"`,
#' `"stackoverflow"`, `"rstudio community"`, `"github"`, and
#' `"bitbucket"`.
#' @param query Contents of string to search. Default is the error message.
#' @param rlang Search for results written in R. Default is `TRUE`
#'
#' @return The generated search URL or an empty string.
#'
#' @rdname search_site
#' @export
#' @seealso [search_google()], [search_bing()], [search_duckduckgo()],
#' [search_startpage()], [search_stackoverflow()], [search_github()],
#' [search_bitbucket()], [searcher()]
#' [search_startpage()], [search_stackoverflow()], [search_rstudio_community()],
#' [search_github()], [search_bitbucket()], and [searcher()]
#' @examples
#' # Search in a generic way
#' search_site("r-project", "google")
Expand All @@ -38,6 +39,9 @@
#' # Search all languages on StackOverflow for convolutions
#' search_stackoverflow("convolutions", rlang = FALSE)
#'
#' # Search RStudio Community
#' search_rstudio_community("RStudio IDE")
#'
#' # Search GitHub Issues for bivariate normal in the language:r
#' search_github("bivariate normal")
#'
Expand All @@ -56,16 +60,18 @@ search_site = function(query,
site = c(
"google",
"bing",
"duckduckgo",
"ddg",
"startpage",
"sp",
"stackoverflow",
"so",
"rstudio community",
"rscom",
"github",
"gh",
"duckduckgo",
"ddg",
"bitbucket",
"bb",
"startpage",
"sp"
"bb"
),
rlang = TRUE) {
site = tolower(site)
Expand All @@ -74,21 +80,19 @@ search_site = function(query,
switch(
site,
google = search_google(query, rlang),
stackoverflow = ,
# empty case carried below
so = search_stackoverflow(query, rlang),
github = ,
# empty case carried below
gh = search_github(query, rlang),
bitbucket = ,
# empty case carried below
bb = search_bitbucket(query, rlang),
bing = search_bing(query, rlang),
duckduckgo = ,
# empty case carried below
duckduckgo = , # empty case carried below
ddg = search_duckduckgo(query, rlang),
startpage = ,
sp = search_startpage(query, rlang)
startpage = , # empty case carried below
sp = search_startpage(query, rlang),
stackoverflow = , # empty case carried below
so = search_stackoverflow(query, rlang),
`rstudio community` = , # empty case carried below
rscom = search_rstudio_community(query, rlang),
github = , # empty case carried below
gh = search_github(query, rlang),
bitbucket = , # empty case carried below
bb = search_bitbucket(query, rlang)
)
}

Expand Down Expand Up @@ -122,16 +126,18 @@ search_site = function(query,
searcher = function(site = c(
"google",
"bing",
"duckduckgo",
"ddg",
"startpage",
"sp",
"so",
"gh",
"bb",
"duckduckgo",
"stackoverflow",
"so",
"rstudio community",
"rscom",
"github",
"gh",
"bitbucket",
"startpage"
"bb"
),
rlang = TRUE) {
function(query = geterrmessage(), rlang = rlang) {
Expand Down Expand Up @@ -232,7 +238,7 @@ search_sp = search_startpage
########################### End Search Engines


########################### Start Search Code Repos
########################### Start Search Development Community Websites

#' @rdname search_site
#' @export
Expand All @@ -259,6 +265,36 @@ search_stackoverflow = function(query = geterrmessage(), rlang = TRUE) {
#' @export
search_so = search_stackoverflow

#' @rdname search_site
#' @export
#' @section RStudio Community Search:
#' The `search_rstudio_community()` and `search_rscom()` functions both search
#' [RStudio Community](https://community.rstudio.com/) using:
#' \code{https://community.rstudio.com/search?q=<query>}
#'
#' For additional details regarding [RStudio Community](https://community.rstudio.com/)'s
#' search interface please see the [Discourse](https://discourse.org) API documentation:
#' \url{https://docs.discourse.org/#tag/Search}
search_rstudio_community = function(query = geterrmessage(), rlang = TRUE) {
if (!valid_query(query)) {
message("Please provide only 1 `query` term that is not empty.")
return(invisible(""))
}

# Disable using a query check
# query = append_r_suffix(query, rlang = rlang, "[r]")

browse_url("https://community.rstudio.com/search?q=", query)
}

#' @rdname search_site
#' @export
search_rscom = search_rstudio_community

########################### End Search Development Community Websites

########################### Start Search Code Repos

#' @rdname search_site
#' @export
#' @section GitHub Search:
Expand All @@ -285,7 +321,6 @@ search_github = function(query = geterrmessage(), rlang = TRUE) {
#' @export
search_gh = search_github


#' @rdname search_site
#' @export
#' @section BitBucket Search:
Expand Down
23 changes: 15 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ knitr::opts_chunk$set(
# searcher

The goal of `searcher` is to provide a search interface directly inside of _R_.
For example, within _R_, there is now the ability to look up
`rcpp example numeric vector` or `ggplot2 fix axis labels` without having to
For example, within _R_, it is possible to look up `rcpp example numeric vector`
or `ggplot2 fix axis labels` without having to
open a browser, go to a search site, and type the query. By default,
the search functions automatically search the last error on call.
the search functions automatically search the last error on call if no
query is specified.

![](https://i.imgur.com/Zq2rg6G.gif)

Expand Down Expand Up @@ -61,6 +62,7 @@ major search engines, code repositories, and help websites. The following search
platforms are supported: [Google](https://google.com), [Bing](https://www.bing.com/),
[DuckDuckGo](https://duckduckgo.com/), [Startpage](https://www.startpage.com/en/),
[StackOverflow](https://stackoverflow.com/search),
[RStudio Community](https://community.rstudio.com/search),
[GitHub](https://github.com/search), and [BitBucket](https://bitbucket.com/search).
By default, an appropriate suffix for each platform that ensures relevant
results to _R_ is appended to all queries. This behavior can be disabled by
Expand All @@ -77,6 +79,10 @@ search_startpage("R project") # or search_sp(...)
search_stackoverflow("linear regression")
search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)

# Searching RStudio Community for tips
search_rstudio_community("tips")
search_rstudio_community("tips", rlang = FALSE) # or search_rscom(...)

# Searching GitHub Issues for maps in R and other languages
search_github("maps")
search_github("maps", rlang = FALSE) # or search_gh(...)
Expand Down Expand Up @@ -120,11 +126,12 @@ the last error message as the search query on the desired search portal.
```r
search_google()
search_bing()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
search_github() # or search_gh()
search_bitbucket() # or search_bb()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
search_rstudio_community() # or search_rscom()
search_github() # or search_gh()
search_bitbucket() # or search_bb()
```


Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ coverage](https://codecov.io/gh/r-assist/searcher/branch/master/graph/badge.svg)
# searcher

The goal of `searcher` is to provide a search interface directly inside
of *R*. For example, within *R*, there is now the ability to look up
`rcpp example numeric vector` or `ggplot2 fix axis labels` without
having to open a browser, go to a search site, and type the query. By
default, the search functions automatically search the last error on
call.
of *R*. For example, within *R*, it is possible to look up `rcpp example
numeric vector` or `ggplot2 fix axis labels` without having to open a
browser, go to a search site, and type the query. By default, the search
functions automatically search the last error on call if no query is
specified.

![](https://i.imgur.com/Zq2rg6G.gif)

Expand Down Expand Up @@ -55,7 +55,8 @@ The `search_*()` functions can be used to search a query directly from
following search platforms are supported: [Google](https://google.com),
[Bing](https://www.bing.com/), [DuckDuckGo](https://duckduckgo.com/),
[Startpage](https://www.startpage.com/en/),
[StackOverflow](https://stackoverflow.com/search),
[StackOverflow](https://stackoverflow.com/search), [RStudio
Community](https://community.rstudio.com/search),
[GitHub](https://github.com/search), and
[BitBucket](https://bitbucket.com/search). By default, an appropriate
suffix for each platform that ensures relevant results to *R* is
Expand All @@ -73,6 +74,10 @@ search_startpage("R project") # or search_sp(...)
search_stackoverflow("linear regression")
search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)

# Searching RStudio Community for tips
search_rstudio_community("tips")
search_rstudio_community("tips", rlang = FALSE) # or search_rscom(...)

# Searching GitHub Issues for maps in R and other languages
search_github("maps")
search_github("maps", rlang = FALSE) # or search_gh(...)
Expand Down Expand Up @@ -117,11 +122,12 @@ search portal.
``` r
search_google()
search_bing()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
search_github() # or search_gh()
search_bitbucket() # or search_bb()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
search_rstudio_community() # or search_rscom()
search_github() # or search_gh()
search_bitbucket() # or search_bb()
```

# Motivation
Expand Down
Loading

0 comments on commit 53700a8

Please sign in to comment.