-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.R
135 lines (112 loc) · 4.3 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
library(shiny)
library(rmarkdown)
shslines <- c("Increased student return rates by 50%",
"Reached out to troubled populations",
"Stepped in to ensure student well-being")
dblmtlines <- c("Employee of the month - March 2002",
"Promoted to grill after one day",
"Closed with 100% drawer accuracy")
watcherslines <- c("Died twice",
"Earned inaugural Class Protector award",
"Saved the world. A lot.")
skills <- c("Microsoft Office",
"Research",
"Mentoring",
"Bullying prevention")
ui <- fluidPage(
titlePanel("Shiny Resume Builder"),
sidebarLayout(
sidebarPanel(
checkboxInput("incl_address", "Include contact info", value = TRUE),
checkboxGroupInput("employers", "Choose employers to include:",
choices = c("Doublemeat Palace", "Sunnydale High School", "Watchers Council"),
selected = c("Doublemeat Palace", "Sunnydale High School", "Watchers Council")),
uiOutput("choose_emp3"),
uiOutput("choose_emp"),
uiOutput("choose_emp2"),
selectizeInput("skills", "Choose skills:", choices = skills,
multiple = TRUE, options = list(plugins = list('drag_drop'))),
checkboxInput("incl_orgs", "Include organizations", value = TRUE),
radioButtons("format", "Output format:",
choices = c("HTML" = "html_document",
"PDF" = "pdf_document",
"Word" = "word_document")),
actionButton("goknit", "I am the plan")
),
mainPanel(
uiOutput("buttonappear"),
tableOutput("preview"),
tableOutput("skills")
)
)
)
server <- function(input, output) {
reportdone <- eventReactive(input$goknit, {
render("bsummers_resume.Rmd",
output_format = isolate(input$format),
params = list(
shs_strings = isolate(input$shs),
dblmt_strings = isolate(input$dblmt),
watcher_strings = isolate(input$wc),
incl_address = isolate(input$incl_address),
incl_orgs = isolate(input$incl_orgs),
skills = isolate(input$skills)))
})
output$buttonappear <- renderUI({
reportdone()
downloadButton("knitdoc", "It's ready!")
})
output$knitdoc <- downloadHandler(
filename = function(){
ext <- switch(isolate(input$format),
"html_document" = ".html",
"pdf_document" = ".pdf",
"word_document" = ".docx")
paste0("bsummers_resume", ext)
},
content = function(file){
file.copy(reportdone(), file, overwrite = TRUE)
}
)
output$preview <- renderTable({
if (length(input$employers) > 0){
rlist <- NULL
if (!(is.null(input$wc))){
rlist <- c(rlist, c("WATCHERS COUNCIL", input$wc))
}
if (!(is.null(input$shs))){
rlist <- c(rlist, c("SUNNYDALE HIGH", input$shs))
}
if (!(is.null(input$dblmt))){
rlist <- c(rlist, c("DOUBLEMEAT PALACE", input$dblmt))
}
data.frame("Employers" = rlist)
}
})
output$skills <- renderTable({
data.frame("Skills" = input$skills)
})
output$choose_emp <- renderUI({
if ("Sunnydale High School" %in% input$employers){
selectizeInput("shs", "Choose accomplishments for Sunnydale High School:", choices = shslines,
multiple = TRUE, options = list(plugins = list('drag_drop')))
}
})
output$choose_emp2 <- renderUI({
if ("Doublemeat Palace" %in% input$employers){
selectizeInput("dblmt", "Choose accomplishments for Doublemeat Palace:", choices = dblmtlines,
multiple = TRUE, options = list(plugins = list('drag_drop')))
}
})
output$choose_emp3 <- renderUI({
if ("Watchers Council" %in% input$employers){
selectizeInput("wc", "Choose accomplishments for Watchers Council:", choices = watcherslines,
multiple = TRUE, options = list(plugins = list('drag_drop')))
}
})
output$test <- renderText(
input$format
)
}
# Run the application
shinyApp(ui = ui, server = server)