Skip to content

Commit

Permalink
version 0.7.9
Browse files Browse the repository at this point in the history
  • Loading branch information
oss-linux-etc authored and cran-robot committed Jan 20, 2022
1 parent 7adfba7 commit 626c103
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 59 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Imports: jsonlite, stringr, crayon, RCurl, readr, rstudioapi,
pkgsearch, tibble, dplyr
Title: Various Useful Web Tools (Including Full CRAN Dataset Search and
Fetch)
Version: 0.7.8
Version: 0.7.9
Author: LS Malenica
Maintainer: LS Malenica <lsmalenica@gmail.com>
Description: A set of useful web tools to improve your productivity. Including:
Expand All @@ -15,6 +15,6 @@ Encoding: UTF-8
License: CC0
RoxygenNote: 7.1.2
NeedsCompilation: no
Packaged: 2022-01-12 13:44:20 UTC; louis
Packaged: 2022-01-20 19:23:08 UTC; louis
Repository: CRAN
Date/Publication: 2022-01-12 21:10:02 UTC
Date/Publication: 2022-01-20 19:40:02 UTC
14 changes: 7 additions & 7 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
82061f438e0981323051c3d5c31480a7 *DESCRIPTION
69931079c34052460a670036598d5f56 *DESCRIPTION
17966ffcb2fdca73318c5a1368055a76 *NAMESPACE
d66652ce84171db2855a233be5994372 *R/ddg.R
378bbe09b3791dc8e665d6f326ae645e *R/dsearch.R
57d2433d0f04d7a1ab2447ccdae08061 *R/ddg.R
ac1fe5868f4436f3cf6653473c0bbd1f *R/dsearch.R
81e93b9bdd2bc388695cc0616c707de1 *R/guid.R
5f19326113d8717b9a9aa1021191b7e5 *R/sharebin.R
0f5347545d26d746b6ed0043531db34f *R/zzz.R
eb816271216086a6568b4f5dfc798744 *man/ddg.Rd
a34ca38351bc7ae4b3b84354a748e2a6 *man/ddg.Rd
1d6dd095f8a8efb1e6befbe6a6afa360 *man/dexout.Rd
1706e27d5d0ef07a669b06ee2fdcbaf6 *man/dfetch.Rd
92fbcf6e51ba334b5ae6c419f50ced18 *man/dinfo.Rd
fec965808bf707a1b8c96717e6ce791f *man/dfetch.Rd
9953efa2cadb2a55bb1237400f1e3575 *man/dinfo.Rd
b6c925df3b7d777e164c34912169a5f8 *man/do_info_search.Rd
f3cab49b31c434df7e7b1f705dbc0ce6 *man/dsearch.Rd
7af014919829e37498c18baac69e3243 *man/dsearch.Rd
f3d25589d2cc41eceab295074e7afec1 *man/elec_load.Rd
5e62f78fe5e5c1bcb6a7f67c8283cbd9 *man/guid.Rd
01e2c4b6306fa9872077b0ce4e095aee *man/sexout.Rd
Expand Down
27 changes: 14 additions & 13 deletions R/ddg.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#' Duckduckgo Instant-search
#' @description Perform a DDG Instant search on a query term.
#' @param x The search string
#' @param q The search string
#' @param max_rel (optional) Max. number of related results (default 3), or the
#' number of results returned, which ever is smaller
#' @usage ddg(x, max_rel)
#' @param get_result (optional) Return the first result (either the `Instant
#' Result`` or, if none, the first related result)
#' @usage ddg(q, max_rel, get_result)
#' @examples ddg('ngrams')
#' @examples ddg('ngrams', 2)
#' @return The search URL used
#' @examples ddg('ngrams', get_result=TRUE)
#' @return A "safe" search URL, or the first result if get_result=TRUE passed
#' @export
ddg <- function(x, max_rel=3) {
ddg <- function(q, max_rel=3, get_result=FALSE) {

q <- paste0(x) # String it
q <- paste0(q) # String it
url <- paste0('https://api.duckduckgo.com/?format=json&q=', q)
url_safe <- paste0('https://api.duckduckgo.com/?q=', q)
mydata <- jsonlite::fromJSON(url)
inst_txt <- mydata$AbstractText
header <- paste0(crayon::bgYellow('\nDDG >>'), ' Instant Result:\n')
writeLines(header)

qry.out <- crayon::blue$bold(q)

if(inst_txt == '') {
writeLines(paste0(qry.out, ' - (No *Instant Result* !)'))
} else {
result <- paste0(qry.out, ' - ', inst_txt)
writeLines(result)
}
result <- ifelse(inst_txt=='', '(No *Instant Result* !)', inst_txt)
writeLines(paste0(qry.out, ' - ', result))

writeLines(paste0(crayon::bgYellow('\n>>'), ' Related topics:\n'))

Expand All @@ -39,8 +38,10 @@ ddg <- function(x, max_rel=3) {

if(i == 1) {
writeLines('(No *Related Topics* !)\n')
} else if(inst_txt=='') {
result <- mydata$RelatedTopics[['Text']][[1]]
}

return(url)
return(ifelse(get_result==TRUE, result, url_safe))

}
39 changes: 19 additions & 20 deletions R/dsearch.R

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions man/ddg.Rd

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

6 changes: 4 additions & 2 deletions man/dfetch.Rd

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

10 changes: 4 additions & 6 deletions man/dinfo.Rd

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

8 changes: 3 additions & 5 deletions man/dsearch.Rd

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

0 comments on commit 626c103

Please sign in to comment.