R/home-module.R

Defines functions homeUI home

Documented in homeUI

#' Homepage
#' @param id Namespace id
homeUI <- function(id){

  ns <- NS(id)

  tagList(
    br(),
    br(),
    div(
      class = "container",
      style = "min-height:90vh;",
      br(),
      br(),
      img(
        width = "70%",
        src = "https://auritus.io/logo.png",
        alt = "auritus"
      ),
      br(),
      br(),
      h2("Free, Open-Source News Monitoring Platform."),
      br(),
      br(),
      fluidRow(
        column(
          4,
          tags$a(
            class = "btn btn-default",
            href = "https://github.com/JohnCoene/auritus",
            target = "_blank",
            icon("github"),
            "Github"
          ),
          tags$a(
            class = "btn btn-danger",
            href = "https://auritus.io/",
            target = "_blank",
            icon("desktop"),
            "Website"
          )
        ),
        column(
          8,
          h4("Latest article was published on",
             textillate::textillateOutput(ns("recent")),
             class = "pull-right")
        )
      )
    )
  )

}

home <- function(input, output, session, pool){

  output$recent <- textillate::renderTextillate({

    latest <- dbGetQuery(pool, "SELECT MAX(published) FROM articles;") %>%
      unlist() %>%
      unname()
    
    if(inherits(latest, "numeric"))
      latest <- as.POSIXct(latest, origin = "1970-01-01 12:00")
    
    latest <- as.Date(latest)

    textillate::textillate(
      format(latest, "%d %B %Y"),
      min.display.time = 5000
    ) %>% 
      textillate::textillateIn(
        effect = "rollIn",
        shuffle = TRUE
      )
  })

}
news-r/auritus documentation built on March 14, 2020, 12:50 p.m.