Skip to content

Commit b4169b5

Browse files
committed
Add _embed page for embedding, clean up style to match. Reviewed in http://codereview.appspot.com/5668045/
1 parent acf517f commit b4169b5

File tree

3 files changed

+139
-9
lines changed

3 files changed

+139
-9
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title> Google API Client for Python Documentation </title>
5+
<style type="text/css">
6+
body
7+
{
8+
margin: 0;
9+
padding: 0;
10+
border: 0;
11+
}
12+
body table th,
13+
body table td
14+
{
15+
color: #333;
16+
font-family: Arial, sans-serif;
17+
font-size: 13px;
18+
font-style: normal;
19+
font-weight: normal;
20+
line-height: 21px;
21+
}
22+
body table th
23+
{
24+
font-weight: bold;
25+
background: #6199DF;
26+
color: white;
27+
}
28+
table
29+
{
30+
display: table;
31+
border: 1px solid #BBB;
32+
border-spacing: 0;
33+
border-collapse: collapse;
34+
margin: 0;
35+
padding: 0;
36+
}
37+
tr
38+
{
39+
display: table-row;
40+
border: 0;
41+
margin: 0;
42+
padding: 0;
43+
}
44+
td, th
45+
{
46+
display: table-cell;
47+
border: 1px solid #BBB;
48+
margin: 0;
49+
padding: 6px 10px;
50+
text-align: left;
51+
vertical-align: top;
52+
}
53+
.icon {
54+
width: 16px;
55+
height: 16px;
56+
}
57+
</style>
58+
<body>
59+
<table>
60+
<tr>
61+
<th>API</th>
62+
<th>Documentation</th>
63+
<th>PyDoc</th>
64+
<th>Name</th>
65+
<th>Version</th>
66+
</tr>
67+
{% for item in directory %}
68+
<tr>
69+
<td><img class=icon src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
70+
<td><a target=_top href="{{ item.documentationLink }}">Documentation</a></td>
71+
<td><a target=_top href="/{{ item.name }}/{{ item.version }}">PyDoc</a></td>
72+
<td>{{ item.name }}</td>
73+
<td>{{ item.version}}</td>
74+
</tr>
75+
{% endfor %}
76+
</table>
77+
</body>
78+
</html>

samples/api-python-client-doc/index.html

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,53 @@
33
<head>
44
<title> Google API Client for Python Documentation </title>
55
<style>
6-
table {
6+
body
7+
{
8+
color: #333;
9+
font-family: Arial, sans-serif;
10+
}
11+
body table th,
12+
body table td
13+
{
14+
color: #333;
15+
font-family: Arial, sans-serif;
16+
font-size: 13px;
17+
font-style: normal;
18+
font-weight: normal;
19+
line-height: 21px;
20+
}
21+
body table th
22+
{
23+
font-weight: bold;
24+
background: #6199DF;
25+
color: white;
26+
}
27+
table
28+
{
29+
display: table;
30+
border: 1px solid #BBB;
31+
border-spacing: 0;
732
border-collapse: collapse;
33+
margin: 0;
34+
padding: 0;
35+
}
36+
tr
37+
{
38+
display: table-row;
39+
border: 0;
40+
margin: 0;
41+
padding: 0;
842
}
9-
td, th {
10-
padding: 0.3em;
43+
td, th
44+
{
45+
display: table-cell;
46+
border: 1px solid #BBB;
1147
margin: 0;
12-
border: solid black 1px;
48+
padding: 6px 10px;
49+
text-align: left;
50+
vertical-align: top;
1351
}
14-
img {
52+
.icon {
1553
width: 16px;
1654
height: 16px;
1755
}
@@ -29,7 +67,7 @@ <h1> Google API Client for Python Documentation </h1>
2967
</tr>
3068
{% for item in directory %}
3169
<tr>
32-
<td><img src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
70+
<td><img class=icon src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
3371
<td><a href="{{ item.documentationLink }}">Documentation</a></td>
3472
<td><a href="/{{ item.name }}/{{ item.version }}">PyDoc</a></td>
3573
<td>{{ item.name }}</td>

samples/api-python-client-doc/main.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
import pydoc
3131
import re
3232

33-
from apiclient.anyjson import simplejson
3433
from apiclient import discovery
3534
from apiclient.errors import HttpError
3635
from google.appengine.api import memcache
3736
from google.appengine.ext import webapp
3837
from google.appengine.ext.webapp import template
3938
from google.appengine.ext.webapp import util
39+
from oauth2client.anyjson import simplejson
4040

4141

4242
DISCOVERY_URI = 'https://www.googleapis.com/discovery/v1/apis?preferred=true'
@@ -69,8 +69,7 @@ def get(self):
6969

7070

7171
class GadgetHandler(webapp.RequestHandler):
72-
"""Handles serving the Google Gadget.
73-
"""
72+
"""Handles serving the Google Gadget."""
7473

7574
def get(self):
7675
directory = get_directory_doc()
@@ -84,6 +83,20 @@ def get(self):
8483
self.response.headers.add_header('Content-Type', 'application/xml')
8584

8685

86+
class EmbedHandler(webapp.RequestHandler):
87+
"""Handles serving a front page suitable for embedding."""
88+
89+
def get(self):
90+
directory = get_directory_doc()
91+
for item in directory:
92+
item['title'] = item.get('title', item.get('description', ''))
93+
path = os.path.join(os.path.dirname(__file__), 'embed.html')
94+
self.response.out.write(
95+
template.render(
96+
path, {'directory': directory,
97+
}))
98+
99+
87100
def _render(resource):
88101
"""Use pydoc helpers on an instance to generate the help documentation.
89102
"""
@@ -140,6 +153,7 @@ def main():
140153
[
141154
(r'/', MainHandler),
142155
(r'/_gadget/', GadgetHandler),
156+
(r'/_embed/', EmbedHandler),
143157
(r'/([^\/]*)/([^\/]*)(?:/(.*))?', ResourceHandler),
144158
],
145159
debug=False)

0 commit comments

Comments
 (0)