เปิดแอปมันเงาโดยคลิกลิงก์ในแอปมันเงาอื่นใช่ไหม

แค่สงสัยว่าสิ่งนี้เป็นไปได้หรือไม่ ฉันมีแอปที่แสดงลิงก์ไปยังไฟล์บางไฟล์ และต้องการเปิดแอปมันวาวแยกต่างหากเมื่อผู้ใช้คลิกลิงก์ใดลิงก์หนึ่ง


person Joe Bringley    schedule 20.02.2017    source แหล่งที่มา
comment
คุณหมายถึงลิงก์ไปยังแอปอื่นๆ ที่โฮสต์บนเซิร์ฟเวอร์/บัญชีของคุณ หรือไซต์ภายนอกใช่หรือไม่   -  person Carl Boneri    schedule 20.02.2017


คำตอบ (2)


หากต้องการเปิดลิงก์ภายนอก คุณสามารถแทรก:

tag("a", list(href = "http://www.myapps.com/otherapp", "Other App"))

แท็ก "a" ใน HTML (ภาษา) ใช้เพื่อแสดงถึงลิงก์ที่พูดโดยทั่วไป และแอตทริบิวต์ href คือตำแหน่งที่แทรกเส้นทาง ด้านล่างนี้ฉันได้รวบรวมตัวอย่างสั้นๆ โดยใช้แกลเลอรี Shiny App และลิงก์ช่วยเหลือทั้งหมด

ui <- bootstrapPage(
  tag('ul',
lapply(read_html("http://shiny.rstudio.com/gallery/") %>%
xml_find_all('//a'), function(i){
li <- url_absolute(xml_attr(i, 'href'), xml_url(i))
data.frame(li = li, 
          txt = stri_trans_totitle(
                trimws(gsub("\\-|\\.html"," ",basename(li)))),
          stringsAsFactors = FALSE)
  }) %>% rbind.pages() %>% 
dplyr::filter(!duplicated(txt)) %>% apply(., 1, function(x){
    tag("li",list(tag("a", list(href = x[[1]],x[[2]]))))
  }))
)

server <- function(session, input, output){

}

shinyApp(ui, server)

สำหรับลิงก์ใด ๆ ไปยังแอปภายนอกคุณสามารถใช้:

ext.link <- function(label = NULL, link = NULL){
   tag("a", list(href = link,
       ifelse(!is.null(label), label, basename(link))))
}

ซึ่งจะสร้าง html ในแอปของคุณ:

> ext.link(label = "New app", link = "http://mypage.com/new_app")
  <a href="http://mypage.com/new_app">New app</a>
person Carl Boneri    schedule 20.02.2017

ขอบคุณ Carl ฉันมีปัญหาที่คล้ายกัน โดยจำเป็นต้องสร้างลิงก์ไดนามิกเพิ่มเติมที่เปลี่ยนแปลงตามการกระทำของผู้ใช้ ฉันแก้ไขด้วยวิธีนี้ (ฉันอ่านรหัสของคุณแล้ว Shiny.rstudio.com/gallery)

extract_info <- function(html_line) {
    li <- url_absolute(xml_attr(html_line, 'href'), xml_url(html_line))
    data.frame(li = li, 
               txt = stri_trans_totitle(trimws(gsub("\\-|\\.html", " ", basename(li)))),
               stringsAsFactors = FALSE)
}

mydata.df <- lapply(read_html("http://shiny.rstudio.com/gallery/") %>%
                       xml_find_all('//a'), 
                    function(line) extract_info(line)) %>%
    rbind_pages() %>% 
    dplyr::filter(!duplicated(txt))

ui <- fluidPage(        
    titlePanel("Select shiny apps"),
    sidebarLayout(
        sidebarPanel(
            numericInput(inputId = "myline", label = "Select one line", 
                         value = 1, min = 1, max = NA, step = 1),
            uiOutput("wantedlink")
        ),
        mainPanel(DT::dataTableOutput("mytable"))
    )
)

server <- function(session, input, output) {
    output$mytable <- DT::renderDataTable({ DT::datatable( mydata.df ) })

    mylink <- reactive({ 
        mydata.df$li[input$myline] })
    mytext <- reactive({ 
        mydata.df$txt[input$myline] })

    output$wantedlink <- renderUI({
       HTML(sprintf('<a href = %s target = "_blank">%s</a>', as.character(mylink()), mytext()))
    })
}

shinyApp(ui, server)
person ecarosati    schedule 04.07.2019