diff --git a/R/help.R b/R/help.R new file mode 100644 index 0000000..1d569af --- /dev/null +++ b/R/help.R @@ -0,0 +1,129 @@ +# HELP TEXT + +help_warranty <- function(...) { + tags$p( + "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY." + ) +} + +help_cite <- function(...) { + pkg <- switch ( + get_app_name(), + seriate = "kairos", + source = "nexus", + ternary = "isopleuros", + NULL + ) + + list( + tags$p( + "If you use this application in your research, you must report", + "and cite it properly to ensure transparency of your results.", + "Moreover, authors and maintainers of this project are more likely", + "to continue their work if they see that it's being used and valued", + "by the research community." + ), + tags$p("To cite in your publications, please use:"), + cite_package(pkg) + ) +} + +help_license <- function(...) { + list( + h3("License"), + tags$p( + "This app is distributed as a free and open source", + tags$a("R package", href = url_tesselle("kinesis"), + target = "_blank", rel = "external", .noWS = "after"), "." + ), + tags$p( + "You can redistribute it and/or modify it under the terms", + "of the GNU General Public License as published", + "by the Free Software Foundation, either version 3 of the License,", + "or (at your option) any later version." + ) + ) +} + +help_tesselle <- function(...) { + list( + h3("What is", tags$em("tesselle", .noWS = "after"), "?"), + tags$p( + "This app is a part of the", tags$strong("tesselle"), "project,", + "a collection of packages for research and teaching in archaeology.", + "The", tags$strong("tesselle"), "packages focus on quantitative", + "analysis methods developed for archaeology. They can be used to", + "explore and analyze common data types in archaeology: count data,", + "compositional data and chronological data." + ), + tags$p( + "For more information and relevant links see:", + tags$a("tesselle.org", href = url_tesselle(), + target = "_blank", rel = "external", .noWS = "after"), "." + ) + # h3("Who is", tags$em("tesselle"), "for?") + ) +} + +help_overview <- function(...) { + switch ( + get_app_name(), + source = .help_overview_source(), + tags$p() + ) +} + +.help_overview_source <- function(...) { + list( + tags$p( + "Provenance studies rely on the identification of probable sources,", + "such that the variability between two sources is greater than", + "the internal variability of a single source", + "(the so-called", tags$em("provenance postulate", .noWS = "after"), ").", + "This assumes that a unique signature can be identified for each source", + "on the basis of several criteria." + ), + tags$p( + "This application is designed for chemical fingerprinting", + "and source tracking of ancient materials. It provides provides tools", + "for the exploration, visualization and analysis of compositional data", + "in the framework of", + cite_article(author = "Aitchison", year = "1986", after = ".") + ) + ) +} + +help_workflow <- function(...) { + def <- .help_workflow_panel() + tab <- switch ( + get_app_name(), + source = c("Data", "Composition", "Transform", "Statistics", "Plot", "Analysis"), + ternary = c("Data", "Plot"), + "Data" + ) + + txt <- def[tab] + # dl <- mapply( + # dt = names(txt), + # dd = txt, + # FUN = function(dt, dd) { list(tags$dt(dt), tags$dd(dd)) } + # ) + # tags$dl(ol) + ol <- mapply( + dt = names(txt), + dd = txt, + FUN = function(dt, dd) { list(tags$li(tags$strong(dt, .noWS = "after"), ".", dd)) } + ) + tags$ol(ol) +} + +.help_workflow_panel <- function(...) { + list( + Data = "Import your data and perform basic data cleansing and preparation steps.", + Composition = "Coerce your data to compositions and define (reference) groups.", + Transform = "Compute log-ratio transformations of compositional data.", + Statistics = "Data summary and descriptive statistics.", + Plot = "Visualize your data.", + Analysis = "Perform multivariate data analysis." + ) +} diff --git a/R/home.R b/R/home.R index ba254c8..39a2c2c 100644 --- a/R/home.R +++ b/R/home.R @@ -6,7 +6,7 @@ #' @family page modules #' @keywords internal #' @export -home_ui <- function(id, name = NULL) { +home_ui <- function(id) { # Create a namespace function using the provided id ns <- NS(id) @@ -16,68 +16,35 @@ home_ui <- function(id, name = NULL) { sidebar = sidebar( width = 400, h5("Workflow"), + help_workflow() ), # sidebar navset_card_pill( placement = "above", nav_panel( - title = "How to use", - h3("Overview"), - tags$p( - get_option("description") - ), - tags$p( - "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY." - ), + title = "Overview", + help_overview(), + help_warranty(), tags$p( class = "logo", tags$a(href = "https://www.archeosciences-bordeaux.fr", rel = "external", tags$img(src = "static/logo-archeosciences.svg")), tags$a(href = "https://www.huma-num.fr", rel = "external", tags$img(src = "static/logo-humanum.svg")) - ), - h3("Metadata"), - textInput(inputId = ns("user"), label = "User name"), - textInput(inputId = ns("project"), label = "Project ID") + ) + ), + nav_panel( + title = "How to cite", + help_cite() ), nav_panel( title = "About", - h3("How to cite"), - tags$p( - "If you use this application in your research, you must report - and cite it properly to ensure transparency of your results. - Moreover, authors and maintainers of this project are more likely to - continue their work if they see that it's being used and valued - by the research community." - ), - tags$p("To cite in your publications, please use:"), - cite_package(name), - h3("What is", tags$i("tesselle", .noWS = "after"), "?"), - tags$p( - "This app is a part of the", tags$strong("tesselle"), "project,", - "a collection of packages for research and teaching in archaeology. - The", tags$strong("tesselle"), "packages focus on quantitative - analysis methods developed for archaeology. They can be used to - explore and analyze common data types in archaeology: count data, - compositional data and chronological data." - ), - tags$p( - "For more information and relevant links see:", - tags$a("tesselle.org", href = url_tesselle(), - target = "_blank", rel = "external", .noWS = "after"), "." - ), - # h3("Who is", tags$i("tesselle"), "for?"), - h3("License"), - tags$p( - "This app is distributed as a free and open source", - tags$a("R package", href = url_tesselle("kinesis"), - target = "_blank", rel = "external", .noWS = "after"), "." - ), - tags$p( - "You can redistribute it and/or modify it under the terms of the - GNU General Public License as published by the Free Software - Foundation, either version 3 of the License, or (at your option) - any later version." - ) + help_tesselle(), + help_license() + ), + nav_panel( + title = "Metadata", + textInput(inputId = ns("user"), label = "User name"), + textInput(inputId = ns("project"), label = "Project ID") ) ) # navset_card_pill ) # layout_sidebar diff --git a/R/run.R b/R/run.R index b4687de..2287df3 100644 --- a/R/run.R +++ b/R/run.R @@ -35,6 +35,7 @@ run_app <- function(app = c("seriate", "source", "ternary"), ## Bundling the options inside the shinyApp object kinesis_options <- get_config(app) obj$appOptions$kinesis_options <- kinesis_options + obj$appOptions$app_name <- app obj } @@ -74,3 +75,7 @@ get_option <- function(name = NULL, default = NULL) { shiny::getShinyOption("kinesis_options")[[name]] %||% default } } + +get_app_name <- function(...) { + shiny::getShinyOption("app_name") +} diff --git a/inst/seriate/ui.R b/inst/seriate/ui.R index 6a02021..58e4e49 100644 --- a/inst/seriate/ui.R +++ b/inst/seriate/ui.R @@ -9,7 +9,7 @@ shiny_ui <- function(request) { lang = "en", bslib::page_navbar( title = "seriate", - kinesis::home_ui("home", name = "kairos"), + kinesis::home_ui("home"), bslib::nav_panel( title = "Data", kinesis::import_ui("import") diff --git a/inst/source/ui.R b/inst/source/ui.R index 4d7e56b..ef7064a 100644 --- a/inst/source/ui.R +++ b/inst/source/ui.R @@ -9,7 +9,7 @@ shiny_ui <- function(request) { lang = "en", bslib::page_navbar( title = "source", - kinesis::home_ui("home", name = "nexus"), + kinesis::home_ui("home"), bslib::nav_panel( title = "Data", kinesis::import_ui("import") @@ -18,21 +18,6 @@ shiny_ui <- function(request) { title = "Composition", kinesis::coda_ui("coda") ), - bslib::nav_panel( - title = "Statistics", - kinesis::coda_summary_ui("coda_summary") - ), - bslib::nav_menu( - title = "Plot", - bslib::nav_panel( - title = "Bar plot", - kinesis::coda_plot_ui("barplot") - ), - bslib::nav_panel( - title = "Ternary plot", - kinesis::ternary_ui("ternary") - ) - ), bslib::nav_menu( title = "Transform", bslib::nav_panel( @@ -56,6 +41,21 @@ shiny_ui <- function(request) { kinesis::logratio_ui("plr") ) ), + bslib::nav_panel( + title = "Statistics", + kinesis::coda_summary_ui("coda_summary") + ), + bslib::nav_menu( + title = "Plot", + bslib::nav_panel( + title = "Bar plot", + kinesis::coda_plot_ui("barplot") + ), + bslib::nav_panel( + title = "Ternary plot", + kinesis::ternary_ui("ternary") + ) + ), bslib::nav_menu( title = "Analysis", # bslib::nav_panel( diff --git a/inst/ternary/ui.R b/inst/ternary/ui.R index c690b34..e18db83 100644 --- a/inst/ternary/ui.R +++ b/inst/ternary/ui.R @@ -9,7 +9,7 @@ shiny_ui <- function(request) { lang = "en", bslib::page_navbar( title = "ternary", - kinesis::home_ui("home", name = "isopleuros"), + kinesis::home_ui("home"), bslib::nav_panel( title = "Data", kinesis::import_ui("import")