R/mod_share_ui.R

Defines functions mod_share_server mod_share_ui

# WARNING - Generated by {fusen} from /dev/dev_golem_module.Rmd: do not edit by hand

#' categories UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd 
#'
#' @importFrom shiny NS tagList 
#' @importFrom shinydashboard box 
mod_share_ui <- function(id){
  ns <- NS(id)

  tagList( 
     # actionButton(inputId="publish",
     #     label="Share your story (not working yet)",
     #     icon("share-from-square"))  ,
     # Combine text with url variable
      # Use the onclick parameter to open a new window to the twitter url
     
     # HTML("<div style='float:right'>
     #         <a href='https://twitter.com/share' 
     #         class='twitter-share-button' 
     #         align='middle' 
     #         data-url='https://rstudio.unhcr.org/Data_Literacy/' 
     #         data-text='Insert text here!' 
     #         data-size='large'>Tweet
     #         </a>
     #         <script>!function(d,s,id){
     #         var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
     #         if(!d.getElementById(id)){
     #         js=d.createElement(s);
     #         js.id=id;
     #         js.src=p+'://platform.twitter.com/widgets.js';
     #         fjs.parentNode.insertBefore(js,fjs);
     #         }
     #         }(document, 'script', 'twitter-wjs');
     #         </script>
     #         </div>")
     
     # actionButton("twitter_share",
     #               label = "Share your story!",
     #               icon = icon("twitter"),
     #               onclick = sprintf("window.open('%s')", output$url)) 
     
     
     )
}
    
#' categories Server Functions
#'
#' @noRd 
mod_share_server <- function(id, tweetplot){
  moduleServer( id, function(input, output, session){
    ns <- session$ns
  #   output$url <- renderText({ 
  #      
  #   ### Build and save the twitter card 
  #   
  #   ## Get the plot and save it as an image   on the disk  
  #  # tweechart <-   ""
  #   ## extract tweet message aka the plot tile
  # #  tweetmessage <- ""
  #   ## Now build the html tweetcard file to reference the image
  #  # tweetcard <- 
  #   # <meta name="twitter:card" content="summary_large_image">
  #   # <meta name="twitter:site" content="@Refugees">
  #   # <meta name="twitter:creator" content="@edouard_lgp">
  #   # <meta name="twitter:title" content="">
  #   # <meta name="twitter:description" content="Data Literacy on Forced Displacement">
  #   # <meta name="twitter:image" content="https://rstudio.unhcr.org/Data_Literacy/image.jpg">
  #   # <meta name="twitter:url" content="https://rstudio.unhcr.org/Data_Literacy/" />
  #   
  #   ### Save the twitter card on the disk 
  #   
  #   
  #   ## Create the URL and append it to the twitter intend.. 
  #    #  url <- paste0("https://twitter.com/intent/tweet?text=",
  #    #                tweetmessage,
  #    #               "&url=https://rstudio.unhcr.org/Data_Literacy/",
  #    #               tweetchart,"\"")
  #    # 
  #    # ## Give back that URL 
  #    # return(url)
  #  ## For FB 'https://www.facebook.com/sharer/sharer.php?u='  
  #     })
  })
}
    
## To be copied in the UI
# mod_share_ui("categories_1")
    
## To be copied in the server
# mod_share_server("categories_1")
Edouard-Legoupil/unhcrdatapackage documentation built on Nov. 6, 2023, 6:10 p.m.