This repository has been archived by the owner on Mar 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
114 lines (90 loc) · 4.61 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#########################################################################################
#########################################################################################
################### #######################
################### SCIENCE PULSE - SCRIPT APP #######################
################### #######################
#########################################################################################
### PACKAGES
suppressMessages(library(shiny))
suppressMessages(library(DBI))
suppressMessages(library(odbc))
suppressMessages(library(RPostgreSQL))
suppressMessages(library(pool))
suppressMessages(library(rtweet))
suppressMessages(library(tidyverse))
suppressMessages(library(dbplyr))
suppressMessages(library(rsconnect))
suppressMessages(library(lubridate))
suppressMessages(library(scales))
suppressMessages(library(DT))
suppressMessages(library(shinycssloaders))
suppressMessages(library(stringi))
suppressMessages(library(tidytext))
suppressMessages(library(ggthemes))
suppressMessages(library(sysfonts))
suppressMessages(library(pracma))
### FUNCTIONS
source("science_pulse_functions.R")
# Sanitize error messages
options(shiny.sanitize.errors = TRUE)
#########################################################################################
### UI
ui <- fluidPage(
tags$head(includeHTML("google-analytics.html")),
img(src = "header-pulse.svg", height = "", width = "100%"),
navbarPage(
title = tags$div(tags$h1(tags$a(img(src = "logo-rosa.png", height = "", width = "130px"),
href="https://sciencepulse.org/eng/", target="_blank")),
tags$small("(Beta Version 0.9.1)"),
style = "width: 150px !important"),
theme = "custom.css",
navbarMenu(tags$div(icon("twitter-square", class = "icons"), " Twitter Data"),
tabPanel(tags$div(icon("fire"), " Trends"),
mod_trends_ui("trends")),
tabPanel(tags$div(icon("search-plus"), " Explore"),
mod_explore_ui("explore")),
tabPanel(tags$div(icon("fire-alt"), " Popularity"),
mod_popularity_ui("popularity")),
tabPanel(tags$div(icon("user"), " Profiles"),
mod_profile_ui("profiles")),
tabPanel(tags$div(icon("search"), " Tweets Search"),
mod_tweets_ui("tweets")),
tabPanel(tags$div(icon("virus"), " Covid-19 Special"),
mod_covid_ui("covid"))
),
tabPanel(tags$a(tags$div(class = "calltoaction",
icon("envelope", class = "calltoaction"), "newsletters",
style = "background-color:#333333;color:#fff !important;padding:5px 9px;margin-top: -17px !important;margin-left:5px;border-radius:5px"),
href="https://nucleo.jor.br/newsletters/despachos/", target="_blank")),
tabPanel(tags$div(class = "calltoaction",
icon("bullhorn", class = "calltoaction"),
includeHTML("important_notes.html"),
style = "background-color:#ababab;color:#fff !important;padding:5px 9px;margin-top: -12px !important;margin-left:5px;border-radius:5px")),
tabPanel(tags$a(tags$div(class = "calltoaction",
" Português",
style = "background-color:#cbcbcb;color:#000 !important;padding:5px 9px;margin-top: -17px !important;margin-left:5px;border-radius:5px"),
href="https://nucleo.jor.br/sciencepulse/", target="_blank"))
)
# includeHTML("footer.html")
)
#########################################################################################
### SERVER
server <- function(input, output, session){
##################################
# CONNECT TO DATABASE
monitor_db <- dbPool(drv = "PostgreSQL", dbname = "monitordb",
host = "monitordb.c34gb8x0kzzf.us-east-1.rds.amazonaws.com",
port = 5432, user = "appcontest", password = "shinyrules")
onStop(function() {
poolClose(monitor_db)
})
##################################
mod_trends_server("trends", monitor_db)
mod_explore_server("explore", monitor_db)
mod_popularity_server("popularity", monitor_db)
mod_profile_server("profiles", monitor_db)
mod_tweets_server("tweets", monitor_db)
mod_covid_server("covid", monitor_db)
}
#########################################################################################
shinyApp(ui = ui, server = server)