public
Description: Use portions of other web documents (such as Google Docs) in your web pages
Homepage:
Clone URL: git://github.com/canadaduane/getdoc.git
getdoc / sample.rhtml
100644 58 lines (55 sloc) 1.618 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<%
require File.join(File.dirname(__FILE__), "ruby/get_doc")
# Default document is a Google word processing document
google_doc = GetDoc.new("dcjnq5tv_4gw4qk2")
 
# Getting a document from somewhere other than google docs is possible, but it
# is a little more complicated, because we need to specify the following:
# 1. The URL of the post without the domain
# 2. The domain of the blog, and the location in the string to insert the post (%s)
# 3. A transformation proc which can extract the content from the blog using hpricot
blog_post = GetDoc.new(
"2008/07/15/lucky-to-be-a-programmer",
"http://blog.inquirylabs.com/%s") do |hpricot|
(hpricot / ".PostHead h1:first").to_html +
(hpricot / ".PostContent:first").inner_html
end
 
# Uncomment the following line to have the cache cleared for EVERY page load
# GetDoc.reset_cache
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Sample GetDoc Page</title>
<style type="text/css" media="screen">
#left {
width: 50%;
float: left;
}
#right {
width: 50%;
float: right;
}
</style>
</head>
<body>
<div id="container">
<div id="top">
<div id="header">
<div id="title">Sample GetDoc Page</div>
</div>
<div id="content">
<div id="left">
<h1>Google Doc</h1>
<%= google_doc %>
</div>
<div id="right">
<div class="sideitem">
<h1>Blog Post</h1>
<%= blog_post %>
</div>
</div>
</div>
</div>
</body>
</html>