# Deployment and Customization

# Introduction

Running ruminate is simple and straight forward using the ruminate function:

    library(ruminate)
    ruminate()

This is the default and presents all of the modules in the standard format. However you may wish deploy ruminate on an internal server or customize it.

# Deployment

To deploy ruminate you can create a copy of the app based on a template in the package:

    file.copy(from = system.file(package="ruminate","templates", "ruminate.R"),
              to   = "App.R")

Certain features of the app behave differently depending on whether it is running locally or deployed on a server. To tell the App it is deployed you need to create an empty file named `DEPLOYED` in the same directory as the deployed app file.

    file.create("DEPLOYED")

Those two files (`App.R` and `DEPLOYED`) placed in the same direcory on a shiny server with ruminate installed should be enough to deploy the basic app.

# Customization

You can open the `App.R` file and run the app locally from there as well. You can also edit this file to customize the app. This includes the default text that is presented, any graphics you might want, and also the color scheme. Beyond that the individual modules are also customizable.

## App Layout

The app is built around modules and the overall look and introductory text is controlled by this file. The default app uses the `{shinydashboard}` package. You can look through the documentation for that package to alter tabs, the default skin color, module icons, etc. The default package contains all of the modules, but you can simply remove the tabs for any modules you do not want.

## Individual Modules

At the top of the `App.R` file the locations of module configuration files are defined:

    formods.yaml  = system.file(package="formods",  "templates",  "formods.yaml")
    ASM.yaml      = system.file(package="formods",  "templates",  "ASM.yaml")
    UD.yaml       = system.file(package="formods",  "templates",  "UD.yaml")
    DW.yaml       = system.file(package="formods",  "templates",  "DW.yaml")
    FG.yaml       = system.file(package="formods",  "templates",  "FG.yaml")
    NCA.yaml      = system.file(package="ruminate", "templates",  "NCA.yaml")
    MB.yaml       = system.file(package="ruminate", "templates",  "MB.yaml")
    CTS.yaml      = system.file(package="ruminate", "templates",  "CTS.yaml")

Each of these controls different aspects of the module including the text displayed, icons used, certain behaviors of the app, default values, etc. These options and are described in the comments of the configuration files. To use these you need to first make a copy of the specific configuration file. For example, to customize the NCA module you would make a copy of the `NCA.yaml` file:

    file.copy(from = system.file(package="ruminate", "templates",  "NCA.yaml"),
              to   = "myNCA.yaml")

Then you can make any changes you want in the `myNCA.yaml` file. Then you need specify in the `App.R` file that you want to use the new configuration file.

    NCA.yaml      = "myNCA.yaml"

You can do the same thing for the other modules as well.

## Reporting Templates

To use your own organizational templates you need to create `onbrand` Word and PowerPoint templates using the methods described here:

- Creating onbrand templates
- formods reporting templates

Place the Word (`report.docx`), PowerPoint (`report.pptx`), and YAML (`report.yaml`) files in a `templates` directory. Then you need to create a copy of the `formods` YAML file in the deployment folder.

    file.copy(from = system.file(package="formods", "templates",  "formods.yaml"),
              to   = "myformods.yaml")

Next you need to edit the `myformods.yaml` file to ensure those new files are used by editing the `include` section to update the sources for each file. See below:

    FM:
      include:
        files:
        - file:
            source: 'file.path(".", "templates", "report.docx")'
            dest:   'file.path("config","report.docx")'
        - file:
            source: 'file.path(".", "templates", "report.pptx")'
            dest:   'file.path("config","report.pptx")'
        - file:
            source: 'file.path(".", "templates", "report.yaml")'
            dest:   'file.path("config","report.yaml")'

Then change the `App.R` file to point to the new `myformods.yaml` file.