Rails读取和呈现单独的html文档,需要<;基地>;仅应用于已读入的html
我正在使用Rails和jQuery mobile编写一个移动web应用程序。我在运行时使用HTTParty从AmazonAWSS3读取所有数据 我需要呈现的其中一个屏幕就是纯html,它可以而且通常确实有嵌入到S3上相同文件夹中的图像。这就是我的问题所在。我可以轻松地使用HTTParty拉入html,并使用html_safe选项来渲染它,但是图像不会渲染,因为它们是相对路径名。所以我一直在想办法解决这个问题 我尝试了多种方法,但我主要是研究如何使用html标记将图像指向正确的位置。问题是我不能指定一个基本标记,然后在页面上有其他链接,因为它们使用相同的基本标记,并且链接没有指向正确的位置。因此,我查看了框架集和框架,并将基本标记仅指向框架,我相信我使用的是正确的,但没有任何效果。我试过用,但没有用 因此,基本上我正在寻找一种方法,可以在我从S3读取的html字符串中设置相对路径名的基础,如果不清楚的话。我愿意接受任何建议!提前感谢您阅读并尝试解决这个非常具体的问题 哦,还有一件事,当我用Firebug查看页面时,标题中的第一行是一个基本标记,href设置为当前页面。我不知道它是从哪里来的,但我猜rails会把它扔进去吗?我不知道这是否重要,因为我在它下面放了另一个带有yield的base标签:intro_base?或者这是我的问题之一,因为那里有冲突 然后是代码: 我的“介绍”方法:Rails读取和呈现单独的html文档,需要<;基地>;仅应用于已读入的html,html,ruby-on-rails,jquery-mobile,head,base-tag,Html,Ruby On Rails,Jquery Mobile,Head,Base Tag,我正在使用Rails和jQuery mobile编写一个移动web应用程序。我在运行时使用HTTParty从AmazonAWSS3读取所有数据 我需要呈现的其中一个屏幕就是纯html,它可以而且通常确实有嵌入到S3上相同文件夹中的图像。这就是我的问题所在。我可以轻松地使用HTTParty拉入html,并使用html_safe选项来渲染它,但是图像不会渲染,因为它们是相对路径名。所以我一直在想办法解决这个问题 我尝试了多种方法,但我主要是研究如何使用html标记将图像指向正确的位置。问题是我不能指
def intro
@intros = []
@app_config.intro_screens.each do |intro_screen|
intro_screen_response =
ApplicationController.get("#{@diandr_url}/#{intro_screen['filename']}.html")
@intros << intro_screen_response.body
end
@intros.reverse!
@intros_length = @intros.length
respond_to do |format|
format.html
end
end
def简介
@简介=[]
@app_config.intro_screens.each do|intro_screens|
介绍屏幕响应=
ApplicationController.get(“#{@diandr_url}/#{intro_screen['filename']}.html”)
@介绍
*这里有一些jQuery移动分页和标题的东西,这不重要*
<% page_num = params[:id].to_i %>
<% content_for :intro_base do %>
<base href="https://s3.amazonaws.com/our_bucket_name<%=@dir_url%>/" target="intro" />
<% end %>
<% content_for :mobile_header do %>
*some jQuery mobile paging and header stuff is in here, shouldn't matter*
<% end %>
<% content_for :mobile_content do %>
<!-- <iframe src=<%= @intros[page_num] %> height="100%" width="100%"> -->
<!-- <p> This browser does not support iframes </p> -->
<!-- </iframe> -->
<frameset cols="100%">
<frame name="intro" <%= @intros[page_num].html_safe %>
</frameset>
<% end %>
<head>
<title> our Mobile App </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- These are the jQuery Mobile scripts -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js">
</script>
<%= yield :intro_base %>
<%= stylesheet_link_tag "master" %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>