Skip to content

Commit

Permalink
Updated reddit url check (#19)
Browse files Browse the repository at this point in the history
* Moved rtweet to suggests and added package check
* Updated reddit url check regex
* Update README.md
* Minor update to pkgdown css
  • Loading branch information
bryn-g authored Jan 27, 2020
1 parent 0d83325 commit b2ee090
Show file tree
Hide file tree
Showing 61 changed files with 246 additions and 184 deletions.
23 changes: 18 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
Package: VOSONDash
Version: 0.5.1
Version: 0.5.2
Title: User Interface for Collecting and Analysing Social Networks
Description: A 'Shiny' application for the interactive visualisation and
analysis of networks that also provides a web interface for collecting
social media data using 'vosonSML'.
Type: Package
Imports: shiny (>= 1.3.2), magrittr, igraph (>= 1.2.2), rtweet (>= 0.6.8),
vosonSML (>= 0.27.0), RColorBrewer, tm, wordcloud, syuzhet, httr, utils,
graphics, lattice, httpuv
Imports:
graphics,
httpuv,
httr,
igraph (>= 1.2.2),
lattice,
magrittr,
RColorBrewer,
shiny (>= 1.3.2),
syuzhet,
tm,
utils,
vosonSML (>= 0.27.0),
wordcloud
Suggests:
rtweet (>= 0.6.8)
Depends: R (>= 3.2.0)
Encoding: UTF-8
Author: Bryan Gertzel, Robert Ackland
Maintainer: Bryan Gertzel <bryan.gertzel@anu.edu.au>
License: GPL (>= 3)
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
NeedsCompilation: no
URL: https://github.com/vosonlab/VOSONDash
BugReports: https://github.com/vosonlab/VOSONDash/issues
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ importFrom(igraph,vertex_attr_names)
importFrom(lattice,barchart)
importFrom(magrittr,'%<>%')
importFrom(magrittr,'%>%')
importFrom(rtweet,create_token)
importFrom(syuzhet,get_nrc_sentiment)
importFrom(tm,DocumentTermMatrix)
importFrom(tm,removeSparseTerms)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# VOSONDash 0.5.2

## Minor Changes:
- Moved `rtweet` from package imports to suggests.

## Bug Fixes:
- Fixed `reddit` URL formatting to support retrieving additional threads.

# VOSONDash 0.5.1

## Minor Changes:
Expand Down
15 changes: 7 additions & 8 deletions R/VOSONDash-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
#' @docType package
#' @author Bryan Gertzel and Robert Ackland.
#'
#' @import shiny
#' @importFrom graphics plot text title par barplot
#' @import httpuv
#' @importFrom tm DocumentTermMatrix removeSparseTerms
#' @importFrom httr parse_url
#' @importFrom igraph vertex_attr as_edgelist gsize delete_vertices components simplify vcount
#' betweenness closeness set_graph_attr V 'V<-' E 'E<-' degree edge_attr_names vertex_attr_names
#' reciprocity transitivity mean_distance graph.density is.directed ecount count_components
#' centr_degree centr_betw centr_clo
#' @importFrom rtweet create_token
#' @importFrom lattice barchart
#' @importFrom magrittr '%>%' '%<>%'
#' @importFrom RColorBrewer brewer.pal
#' @import shiny
#' @importFrom syuzhet get_nrc_sentiment
#' @importFrom wordcloud wordcloud
#' @importFrom httr parse_url
#' @importFrom vosonSML Authenticate Collect Create
#' @importFrom tm DocumentTermMatrix removeSparseTerms
#' @importFrom utils packageVersion
#' @importFrom graphics plot text title par barplot
#' @importFrom lattice barchart
#' @importFrom vosonSML Authenticate Collect Create
#' @importFrom wordcloud wordcloud
NULL
18 changes: 8 additions & 10 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,20 @@ systemTimeFilename <- function(name_suffix, name_ext, clean = FALSE) {
#' @keywords internal
#' @export
createRedditRequestUrl <- function(url) {
url <- tolower(url)
# url <- tolower(url)

# base_url <- "https://reddit.com/r/"
# base_url_oauth <- "https://oauth.reddit.com/r/"

if(!grepl("^https://(www\\.)?reddit.com/r/(.*?)/comments/([0-9A-Za-z]{6})?/.*$",
if(!grepl("^https://(www\\.)?reddit.com/r/(.*?)/comments/([0-9A-Za-z]{6})?/.*?/$",
url, ignore.case = TRUE, perl = TRUE)) {
return(NULL)
}

# "https://oauth.reddit.com/r/"
url <- gsub("^https://(www\\.)?reddit.com/r/", "r/",
url, ignore.case = TRUE, perl = TRUE)
url <- gsub("^https://(www\\.)?reddit.com/r/", "r/", url, ignore.case = TRUE, perl = TRUE)

# url <- gsub("^(.*)?/comments/([0-9A-Za-z]{6})?/.*?(/)?$", "\\1/comments/\\2/",
# url, ignore.case = TRUE, perl = TRUE)

url <- gsub("^(.*)?/comments/([0-9A-Za-z]{6})?/.*?(/)?$", "\\1/comments/\\2/",
url, ignore.case = TRUE, perl = TRUE)
# url <- gsub("^(.*)?/comments/([0-9A-Za-z]{6})?/(.*)?/$", "\\1/comments/\\2/\\3/",
# url, ignore.case = TRUE, perl = TRUE)
}

#' @title Get a reddit thread id from url
Expand Down
15 changes: 7 additions & 8 deletions R/vosonSML.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ isVosonSML0290 <- function() {
#' @keywords internal
#' @export
createTwitterDevToken <- function(app_name, keys) {
check_keys <- sapply(keys, isNullOrEmpty)
if (!requireNamespace("rtweet", quietly = TRUE)) { return(NULL) }

if (any(check_keys == TRUE)) {
return(NULL)
}
check_keys <- sapply(keys, isNullOrEmpty)
if (any(check_keys == TRUE)) { return(NULL) }

cred <- vosonSML::Authenticate("twitter",
appName = app_name,
Expand Down Expand Up @@ -72,11 +71,10 @@ createTwitterDevToken <- function(app_name, keys) {
#' @keywords internal
#' @export
createTwitterWebToken <- function(app_name, keys) {
check_keys <- sapply(keys, isNullOrEmpty)
if (!requireNamespace("rtweet", quietly = TRUE)) { return(NULL) }

if (any(check_keys == TRUE)) {
return(NULL)
}
check_keys <- sapply(keys, isNullOrEmpty)
if (any(check_keys == TRUE)) { return(NULL) }

cred <- list(socialmedia = "twitter", auth = NULL)
class(cred) <- append(class(cred), c("credential", "twitter"))
Expand Down Expand Up @@ -130,6 +128,7 @@ collectTwitterData <- function(cred, search_term, search_type, tweet_count,
include_retweets, retry_on_rate_limit,
language, date_until, since_id, max_id) {

# if (!requireNamespace("rtweet", quietly = TRUE)) { return(NULL) }
if (is.null(cred) || isNullOrEmpty(search_term)) { return(NULL) }

collect_params <- list()
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
![Downloads](https://cranlogs.r-pkg.org/badges/VOSONDash)
![Total](https://cranlogs.r-pkg.org/badges/grand-total/VOSONDash)
![Github Release](https://img.shields.io/github/release-pre/vosonlab/VOSONDash.svg?logo=github&colorB=8065ac)
![Dev](https://img.shields.io/static/v1?label=dev&message=v0.5.1&color=orange&logo=github)
![Last Commit](https://img.shields.io/github/last-commit/vosonlab/VOSONDash.svg?logo=github)
![Dev](https://img.shields.io/static/v1?label=dev&message=v0.5.2&color=659DBD&logo=github)
![Last Commit](https://img.shields.io/github/last-commit/vosonlab/VOSONDash.svg?color=659DBD&logo=github)

`VOSONDash` is an interactive [R Shiny](https://shiny.rstudio.com/) web application for the visualisation and analysis of social network data. The app has a dashboard layout with sections for visualising and manipulating network graphs, performing text analysis, displaying network metrics and the collection of network data using the [vosonSML](https://github.com/vosonlab/vosonSML) R package.

Expand All @@ -23,7 +23,7 @@ install.packages("https://github.com/vosonlab/VOSONDash/releases/download/v0.5.1
repo = NULL, type = "source")
```

Install the latest development version (v0.5.1):
Install the latest development version (v0.5.2):
```R
# library(devtools)
devtools::install_github("vosonlab/VOSONDash")
Expand Down Expand Up @@ -53,14 +53,11 @@ Checking packages...
Error: Required packages missing.
- visNetwork
- syuzhet
```

The missing packages can be installed using the provided package install command.

```R
Please install required packages before using VOSONDash:
install.packages(c("visNetwork","syuzhet"))
```
The missing packages can be installed using the generated package install command.

After installing required packages and running again the `VOSONDash` Shiny app will open up in the default web browser.

Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ navbar:
href: index.html
news:
icon: fa-newspaper-o
text: "News"
text: "Changelog"
href: news/index.html
reference:
icon: fa-cubes
Expand Down
4 changes: 2 additions & 2 deletions docs/404.html

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

4 changes: 2 additions & 2 deletions docs/LICENSE-text.html

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

4 changes: 2 additions & 2 deletions docs/authors.html

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

2 changes: 1 addition & 1 deletion docs/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ h4, .h4, h5, .h5 {
}

.contents h1 {
padding-top: 60px;
padding-top: 50px;
margin-top: -20px;
}

Expand Down
19 changes: 10 additions & 9 deletions docs/index.html

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

Loading

0 comments on commit b2ee090

Please sign in to comment.