Skip to content

Commit

Permalink
Add search_twitter() (#30)
Browse files Browse the repository at this point in the history
* Add search_twitter()

* - Reformat unit tests
- Add unit tests for twitter

* Update site references...

* Roll out a new release note.

* Ensure we mention it on the readme page.

* Clarify search heading

* Update CRAN comments
  • Loading branch information
coatless authored Dec 31, 2019
1 parent 9b3b928 commit ff84ac9
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 88 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Authors@R: c(
)
)
Description: Provides a search interface to look up terms
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow',
on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'Twitter', '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
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export(search_so)
export(search_sp)
export(search_stackoverflow)
export(search_startpage)
export(search_twitter)
export(searcher)
18 changes: 11 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Features

- Allow RStudio's Viewer pane to display search results.
- Note: This feature requires a patch per [rstudio/rstudio#2252](https://github.com/rstudio/rstudio/issues/2252).
([#21](https://github.com/r-assist/searcher/issues/21),
[#22](https://github.com/r-assist/searcher/pull/22))
- Added search portal:
- `search_twitter()`: Searches on [Twitter](https://twitter.com/search).
([#19](https://github.com/r-assist/searcher/issues/19),
[#30](https://github.com/r-assist/searcher/pull/30))
- Added ability to set default package actions.
([#7](https://github.com/r-assist/searcher/issues/7),
[#20](https://github.com/r-assist/searcher/pull/20))
Expand All @@ -16,11 +16,15 @@
[sandbox issue](https://github.com/rstudio/rstudio/issues/2252) is resolved.
- `searcher.default_keyword`: Suffix keyword to focus search results
between either `"base"` or `"tidyverse"`. Default is `"base"`.
- Added option to launch RStudio's Viewer pane to display search results.
- Note: This feature requires a patch per [rstudio/rstudio#2252](https://github.com/rstudio/rstudio/issues/2252).
([#21](https://github.com/r-assist/searcher/issues/21),
[#22](https://github.com/r-assist/searcher/pull/22))

## Changes
## Breaking Changes

- Function factory or a closure approach is now used to create
search portal functions through `searcher()`.
- Function factory or a closure approach-based approach is now used to create
search portal functions `search_*()` through `searcher()`.
- `searcher()` function has lost the ability to specify `rlang` to address
an unevaluated promise issue.

Expand Down
5 changes: 5 additions & 0 deletions R/index-sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ site_index =
"https://bitbucket.com/search?q=",
"bb",
keyword_entry("lang:r")
),
site_entry(
"twitter",
"https://twitter.com/search?q=",
keywords = keyword_entry("%23rstats", "%23rstats %23tidyverse") # %23 is #
)
)

Expand Down
73 changes: 46 additions & 27 deletions R/search-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#'
#' @param site Name of site to search on. Supported options:
#' `"google"` (default), `"bing"`, `"duckduckgo"`, `"startpage"`,
#' `"stackoverflow"`, `"rstudio community"`, `"github"`, and
#' `"bitbucket"`.
#' `"rstudio community"`, `"twitter"`,`"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`
#'
Expand All @@ -15,8 +15,9 @@
#' @rdname search_site
#' @export
#' @seealso [search_google()], [search_bing()], [search_duckduckgo()],
#' [search_startpage()], [search_stackoverflow()], [search_rstudio_community()],
#' [search_github()], [search_bitbucket()], and [searcher()]
#' [search_startpage()], [search_twitter()], [search_rstudio_community()],
#' [search_stackoverflow()], [search_github()], [search_bitbucket()],
#' and [searcher()]
#' @examples
#' # Search in a generic way
#' search_site("r-project", "google")
Expand All @@ -31,17 +32,20 @@
#' search_duckduckgo("R language")
#'
#' # Search startpage
#' search_startpage("RStudio IDE")
#' search_startpage("VS Code")
#'
#' # Search RStudio Community
#' search_rstudio_community("RStudio IDE")
#'
#' # Search Twitter
#' search_twitter("searcher")
#'
#' # Search StackOverflow for Convolutions in the r tag
#' search_stackoverflow("convolutions")
#'
#' # 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 @@ -64,10 +68,11 @@ search_site = function(query,
"ddg",
"startpage",
"sp",
"stackoverflow",
"so",
"rstudio community",
"rscom",
"twitter",
"stackoverflow",
"so",
"github",
"gh",
"bitbucket",
Expand All @@ -85,10 +90,11 @@ search_site = function(query,
ddg = search_duckduckgo(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),
twitter = search_twitter(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
Expand Down Expand Up @@ -199,21 +205,6 @@ search_sp = search_startpage

########################### Start Search Development Community Websites

#' @rdname search_site
#' @export
#' @section StackOverflow Search:
#' The `search_stackoverflow()` and `search_so()` functions both search
#' [StackOverflow](https://stackoverflow.com) using:
#' \code{https://stackoverflow.com/search?q=\%5Br\%5D+<query>}
#'
#' For additional details regarding [StackOverflow](https://stackoverflow.com)'s
#' search interface please see:
#' \url{https://stackoverflow.com/help/advanced-search-parameters-jobs}
search_stackoverflow = searcher("so")

#' @rdname search_site
#' @export
search_so = search_stackoverflow

#' @rdname search_site
#' @export
Expand All @@ -231,6 +222,34 @@ search_rstudio_community = searcher("rscom")
#' @export
search_rscom = search_rstudio_community

#' @rdname search_site
#' @export
#' @section Twitter Search:
#' The `search_twitter()` functions search
#' [Twitter](https://twitter.com/) using:
#' \code{https://twitter.com/search?q=<query>}
#'
#' For additional details regarding [Twitter](https://twitter.com/)'s
#' search interface please see:
#' \url{https://help.twitter.com/en/using-twitter/twitter-advanced-search}
search_twitter = searcher("twitter")

#' @rdname search_site
#' @export
#' @section StackOverflow Search:
#' The `search_stackoverflow()` and `search_so()` functions both search
#' [StackOverflow](https://stackoverflow.com) using:
#' \code{https://stackoverflow.com/search?q=\%5Br\%5D+<query>}
#'
#' For additional details regarding [StackOverflow](https://stackoverflow.com)'s
#' search interface please see:
#' \url{https://stackoverflow.com/help/advanced-search-parameters-jobs}
search_stackoverflow = searcher("so")

#' @rdname search_site
#' @export
search_so = search_stackoverflow

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

########################### Start Search Code Repos
Expand Down
7 changes: 6 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The `search_*()` functions can be used to search a query directly from _R_ on
major search engines, programming help websites, and code repositories. 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),
[Twitter](https://twitter.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
Expand All @@ -78,6 +78,10 @@ search_bing("R project")
search_duckduckgo("R project") # or search_ddg(...)
search_startpage("R project") # or search_sp(...)

# Searching Twitter to find out about machine learning for R and in general
search_twitter("machine learning")
search_twitter("machine learning", rlang = FALSE)

# Searching for linear regression questions for R and in general
search_stackoverflow("linear regression")
search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)
Expand Down Expand Up @@ -129,6 +133,7 @@ the last error message as the search query on the desired search portal.
```r
search_google()
search_bing()
search_twitter()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ repositories. 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/),
[Twitter](https://twitter.com/search),
[StackOverflow](https://stackoverflow.com/search), [RStudio
Community](https://community.rstudio.com/search),
[GitHub](https://github.com/search), and
Expand All @@ -75,6 +76,10 @@ search_bing("R project")
search_duckduckgo("R project") # or search_ddg(...)
search_startpage("R project") # or search_sp(...)

# Searching Twitter to find out about machine learning for R and in general
search_twitter("machine learning")
search_twitter("machine learning", rlang = FALSE)

# Searching for linear regression questions for R and in general
search_stackoverflow("linear regression")
search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)
Expand Down Expand Up @@ -127,6 +132,7 @@ search portal.
``` r
search_google()
search_bing()
search_twitter()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Test environments

- local OS X install, R 3.6.0
- ubuntu 14.04 (on travis-ci), R 3.6.0
- local OS X install, R 3.6.2
- ubuntu 16.04 (with GitHub Actions), R 3.6.2
- win-builder (devel and release)

## R CMD check results
Expand Down
73 changes: 46 additions & 27 deletions man/search_site.Rd

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

Loading

0 comments on commit ff84ac9

Please sign in to comment.