Skip to content

Commit 53700a8

Browse files
authored
Add search_rstudio_community (close #13) (#17)
* 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
1 parent b5a7c9d commit 53700a8

File tree

10 files changed

+184
-81
lines changed

10 files changed

+184
-81
lines changed

DESCRIPTION

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
Package: searcher
22
Title: Query Search Interfaces
3-
Version: 0.0.3.9100
4-
Authors@R: c(person("James", "Balamuta",
5-
email = "[email protected]", role = c("aut", "cre"),
6-
comment = c(ORCID = "0000-0003-2826-8458")))
3+
Version: 0.0.3.9200
4+
Authors@R: c(
5+
person("James", "Balamuta",
6+
email = "[email protected]",
7+
role = c("aut", "cre"),
8+
comment = c(ORCID = "0000-0003-2826-8458")
9+
)
10+
)
711
Description: Provides a search interface to look up terms
8-
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow', 'GitHub',
9-
and 'BitBucket'. Upon searching, a browser window will open with the
10-
aforementioned search results.
11-
URL: https://github.com/coatless/searcher
12-
BugReports: https://github.com/coatless/searcher/issues
13-
Depends: R (>= 3.0.0)
12+
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow',
13+
'RStudio Community', 'GitHub', and 'BitBucket'. Upon searching, a browser
14+
window will open with the aforementioned search results.
15+
URL: https://github.com/r-assist/searcher
16+
BugReports: https://github.com/r-assist/searcher/issues
17+
Depends: R (>= 3.3.0)
1418
License: GPL (>= 2)
1519
Encoding: UTF-8
1620
LazyData: true

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export(search_gh)
99
export(search_github)
1010
export(search_google)
1111
export(search_ixquick)
12+
export(search_rscom)
13+
export(search_rstudio_community)
1214
export(search_site)
1315
export(search_so)
1416
export(search_sp)

NEWS.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
# searcher 0.0.3.9000
1+
# searcher 0.0.3.9200
2+
3+
## Features
4+
5+
- Added search portal:
6+
- `search_rstudio_community()` or `search_rscom()`: Searches on [RStudio Community](https://community.rstudio.com/search).
7+
(#13, #17)
28

39
## Changes
410

5-
- Renamed search portal `search_ixquick()` to `search_startpage()` due to the
6-
merging of ixquick into startpage. (#15)
11+
- Renamed search portal:
12+
- Changed `search_ixquick()` to `search_startpage()` due to the
13+
merging of ixquick into startpage. (#15)
714
- Update the README overview for the project. (#16)
815

916
## Deployment
@@ -16,7 +23,8 @@
1623

1724
## Features
1825

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

2129
## Changes
2230

R/search-functions.R

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
#' Creates an appropriate query string for a search engine and then opens
44
#' up the resulting page in a web browser.
55
#'
6-
#' @param site Name of site to search on. Supported options:
7-
#' `"google"` (default), `"bing"`, `"duckduckgo"`, `"startpage"`,
8-
#' `"stackoverflow"`, `"github"`, and `"bitbucket"`.
9-
#' @param query Contents of string to search. Default is the error message.
10-
#' @param rlang Search for results written in R. Default is `TRUE`
6+
#' @param site Name of site to search on. Supported options:
7+
#' `"google"` (default), `"bing"`, `"duckduckgo"`, `"startpage"`,
8+
#' `"stackoverflow"`, `"rstudio community"`, `"github"`, and
9+
#' `"bitbucket"`.
10+
#' @param query Contents of string to search. Default is the error message.
11+
#' @param rlang Search for results written in R. Default is `TRUE`
1112
#'
1213
#' @return The generated search URL or an empty string.
1314
#'
1415
#' @rdname search_site
1516
#' @export
1617
#' @seealso [search_google()], [search_bing()], [search_duckduckgo()],
17-
#' [search_startpage()], [search_stackoverflow()], [search_github()],
18-
#' [search_bitbucket()], [searcher()]
18+
#' [search_startpage()], [search_stackoverflow()], [search_rstudio_community()],
19+
#' [search_github()], [search_bitbucket()], and [searcher()]
1920
#' @examples
2021
#' # Search in a generic way
2122
#' search_site("r-project", "google")
@@ -38,6 +39,9 @@
3839
#' # Search all languages on StackOverflow for convolutions
3940
#' search_stackoverflow("convolutions", rlang = FALSE)
4041
#'
42+
#' # Search RStudio Community
43+
#' search_rstudio_community("RStudio IDE")
44+
#'
4145
#' # Search GitHub Issues for bivariate normal in the language:r
4246
#' search_github("bivariate normal")
4347
#'
@@ -56,16 +60,18 @@ search_site = function(query,
5660
site = c(
5761
"google",
5862
"bing",
63+
"duckduckgo",
64+
"ddg",
65+
"startpage",
66+
"sp",
5967
"stackoverflow",
6068
"so",
69+
"rstudio community",
70+
"rscom",
6171
"github",
6272
"gh",
63-
"duckduckgo",
64-
"ddg",
6573
"bitbucket",
66-
"bb",
67-
"startpage",
68-
"sp"
74+
"bb"
6975
),
7076
rlang = TRUE) {
7177
site = tolower(site)
@@ -74,21 +80,19 @@ search_site = function(query,
7480
switch(
7581
site,
7682
google = search_google(query, rlang),
77-
stackoverflow = ,
78-
# empty case carried below
79-
so = search_stackoverflow(query, rlang),
80-
github = ,
81-
# empty case carried below
82-
gh = search_github(query, rlang),
83-
bitbucket = ,
84-
# empty case carried below
85-
bb = search_bitbucket(query, rlang),
8683
bing = search_bing(query, rlang),
87-
duckduckgo = ,
88-
# empty case carried below
84+
duckduckgo = , # empty case carried below
8985
ddg = search_duckduckgo(query, rlang),
90-
startpage = ,
91-
sp = search_startpage(query, rlang)
86+
startpage = , # empty case carried below
87+
sp = search_startpage(query, rlang),
88+
stackoverflow = , # empty case carried below
89+
so = search_stackoverflow(query, rlang),
90+
`rstudio community` = , # empty case carried below
91+
rscom = search_rstudio_community(query, rlang),
92+
github = , # empty case carried below
93+
gh = search_github(query, rlang),
94+
bitbucket = , # empty case carried below
95+
bb = search_bitbucket(query, rlang)
9296
)
9397
}
9498

@@ -122,16 +126,18 @@ search_site = function(query,
122126
searcher = function(site = c(
123127
"google",
124128
"bing",
129+
"duckduckgo",
125130
"ddg",
131+
"startpage",
126132
"sp",
127-
"so",
128-
"gh",
129-
"bb",
130-
"duckduckgo",
131133
"stackoverflow",
134+
"so",
135+
"rstudio community",
136+
"rscom",
132137
"github",
138+
"gh",
133139
"bitbucket",
134-
"startpage"
140+
"bb"
135141
),
136142
rlang = TRUE) {
137143
function(query = geterrmessage(), rlang = rlang) {
@@ -232,7 +238,7 @@ search_sp = search_startpage
232238
########################### End Search Engines
233239

234240

235-
########################### Start Search Code Repos
241+
########################### Start Search Development Community Websites
236242

237243
#' @rdname search_site
238244
#' @export
@@ -259,6 +265,36 @@ search_stackoverflow = function(query = geterrmessage(), rlang = TRUE) {
259265
#' @export
260266
search_so = search_stackoverflow
261267

268+
#' @rdname search_site
269+
#' @export
270+
#' @section RStudio Community Search:
271+
#' The `search_rstudio_community()` and `search_rscom()` functions both search
272+
#' [RStudio Community](https://community.rstudio.com/) using:
273+
#' \code{https://community.rstudio.com/search?q=<query>}
274+
#'
275+
#' For additional details regarding [RStudio Community](https://community.rstudio.com/)'s
276+
#' search interface please see the [Discourse](https://discourse.org) API documentation:
277+
#' \url{https://docs.discourse.org/#tag/Search}
278+
search_rstudio_community = function(query = geterrmessage(), rlang = TRUE) {
279+
if (!valid_query(query)) {
280+
message("Please provide only 1 `query` term that is not empty.")
281+
return(invisible(""))
282+
}
283+
284+
# Disable using a query check
285+
# query = append_r_suffix(query, rlang = rlang, "[r]")
286+
287+
browse_url("https://community.rstudio.com/search?q=", query)
288+
}
289+
290+
#' @rdname search_site
291+
#' @export
292+
search_rscom = search_rstudio_community
293+
294+
########################### End Search Development Community Websites
295+
296+
########################### Start Search Code Repos
297+
262298
#' @rdname search_site
263299
#' @export
264300
#' @section GitHub Search:
@@ -285,7 +321,6 @@ search_github = function(query = geterrmessage(), rlang = TRUE) {
285321
#' @export
286322
search_gh = search_github
287323

288-
289324
#' @rdname search_site
290325
#' @export
291326
#' @section BitBucket Search:

README.Rmd

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ knitr::opts_chunk$set(
2222
# searcher
2323

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

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

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

82+
# Searching RStudio Community for tips
83+
search_rstudio_community("tips")
84+
search_rstudio_community("tips", rlang = FALSE) # or search_rscom(...)
85+
8086
# Searching GitHub Issues for maps in R and other languages
8187
search_github("maps")
8288
search_github("maps", rlang = FALSE) # or search_gh(...)
@@ -120,11 +126,12 @@ the last error message as the search query on the desired search portal.
120126
```r
121127
search_google()
122128
search_bing()
123-
search_duckduckgo() # or search_ddg()
124-
search_startpage() # or search_sp()
125-
search_stackoverflow() # or search_so()
126-
search_github() # or search_gh()
127-
search_bitbucket() # or search_bb()
129+
search_duckduckgo() # or search_ddg()
130+
search_startpage() # or search_sp()
131+
search_stackoverflow() # or search_so()
132+
search_rstudio_community() # or search_rscom()
133+
search_github() # or search_gh()
134+
search_bitbucket() # or search_bb()
128135
```
129136

130137

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ coverage](https://codecov.io/gh/r-assist/searcher/branch/master/graph/badge.svg)
1515
# searcher
1616

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

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

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

77+
# Searching RStudio Community for tips
78+
search_rstudio_community("tips")
79+
search_rstudio_community("tips", rlang = FALSE) # or search_rscom(...)
80+
7681
# Searching GitHub Issues for maps in R and other languages
7782
search_github("maps")
7883
search_github("maps", rlang = FALSE) # or search_gh(...)
@@ -117,11 +122,12 @@ search portal.
117122
``` r
118123
search_google()
119124
search_bing()
120-
search_duckduckgo() # or search_ddg()
121-
search_startpage() # or search_sp()
122-
search_stackoverflow() # or search_so()
123-
search_github() # or search_gh()
124-
search_bitbucket() # or search_bb()
125+
search_duckduckgo() # or search_ddg()
126+
search_startpage() # or search_sp()
127+
search_stackoverflow() # or search_so()
128+
search_rstudio_community() # or search_rscom()
129+
search_github() # or search_gh()
130+
search_bitbucket() # or search_bb()
125131
```
126132

127133
# Motivation

0 commit comments

Comments
 (0)