Add _embed page for embedding, clean up style to match. Reviewed in http://codereview.appspot.com/5668045/
diff --git a/samples/api-python-client-doc/embed.html b/samples/api-python-client-doc/embed.html
new file mode 100644
index 0000000..96b2ba4
--- /dev/null
+++ b/samples/api-python-client-doc/embed.html
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title> Google API Client for Python Documentation </title>
+ <style type="text/css">
+ body
+ {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ }
+ body table th,
+ body table td
+ {
+ color: #333;
+ font-family: Arial, sans-serif;
+ font-size: 13px;
+ font-style: normal;
+ font-weight: normal;
+ line-height: 21px;
+ }
+ body table th
+ {
+ font-weight: bold;
+ background: #6199DF;
+ color: white;
+ }
+ table
+ {
+ display: table;
+ border: 1px solid #BBB;
+ border-spacing: 0;
+ border-collapse: collapse;
+ margin: 0;
+ padding: 0;
+ }
+ tr
+ {
+ display: table-row;
+ border: 0;
+ margin: 0;
+ padding: 0;
+ }
+ td, th
+ {
+ display: table-cell;
+ border: 1px solid #BBB;
+ margin: 0;
+ padding: 6px 10px;
+ text-align: left;
+ vertical-align: top;
+ }
+ .icon {
+ width: 16px;
+ height: 16px;
+ }
+ </style>
+ <body>
+ <table>
+ <tr>
+ <th>API</th>
+ <th>Documentation</th>
+ <th>PyDoc</th>
+ <th>Name</th>
+ <th>Version</th>
+ </tr>
+ {% for item in directory %}
+ <tr>
+ <td><img class=icon src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
+ <td><a target=_top href="{{ item.documentationLink }}">Documentation</a></td>
+ <td><a target=_top href="/{{ item.name }}/{{ item.version }}">PyDoc</a></td>
+ <td>{{ item.name }}</td>
+ <td>{{ item.version}}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ </body>
+</html>
diff --git a/samples/api-python-client-doc/index.html b/samples/api-python-client-doc/index.html
index 79144b6..af9afbe 100644
--- a/samples/api-python-client-doc/index.html
+++ b/samples/api-python-client-doc/index.html
@@ -3,15 +3,53 @@
<head>
<title> Google API Client for Python Documentation </title>
<style>
- table {
+ body
+ {
+ color: #333;
+ font-family: Arial, sans-serif;
+ }
+ body table th,
+ body table td
+ {
+ color: #333;
+ font-family: Arial, sans-serif;
+ font-size: 13px;
+ font-style: normal;
+ font-weight: normal;
+ line-height: 21px;
+ }
+ body table th
+ {
+ font-weight: bold;
+ background: #6199DF;
+ color: white;
+ }
+ table
+ {
+ display: table;
+ border: 1px solid #BBB;
+ border-spacing: 0;
border-collapse: collapse;
- }
- td, th {
- padding: 0.3em;
margin: 0;
- border: solid black 1px;
+ padding: 0;
}
- img {
+ tr
+ {
+ display: table-row;
+ border: 0;
+ margin: 0;
+ padding: 0;
+ }
+ td, th
+ {
+ display: table-cell;
+ border: 1px solid #BBB;
+ margin: 0;
+ padding: 6px 10px;
+ text-align: left;
+ vertical-align: top;
+ }
+ .icon {
width: 16px;
height: 16px;
}
@@ -29,7 +67,7 @@
</tr>
{% for item in directory %}
<tr>
- <td><img src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
+ <td><img class=icon src="{{ item.icons.x16 }}"/> {{ item.title }}</td>
<td><a href="{{ item.documentationLink }}">Documentation</a></td>
<td><a href="/{{ item.name }}/{{ item.version }}">PyDoc</a></td>
<td>{{ item.name }}</td>
diff --git a/samples/api-python-client-doc/main.py b/samples/api-python-client-doc/main.py
index 888c32e..40c3ffc 100755
--- a/samples/api-python-client-doc/main.py
+++ b/samples/api-python-client-doc/main.py
@@ -30,13 +30,13 @@
import pydoc
import re
-from apiclient.anyjson import simplejson
from apiclient import discovery
from apiclient.errors import HttpError
from google.appengine.api import memcache
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp import util
+from oauth2client.anyjson import simplejson
DISCOVERY_URI = 'https://www.googleapis.com/discovery/v1/apis?preferred=true'
@@ -69,8 +69,7 @@
class GadgetHandler(webapp.RequestHandler):
- """Handles serving the Google Gadget.
- """
+ """Handles serving the Google Gadget."""
def get(self):
directory = get_directory_doc()
@@ -84,6 +83,20 @@
self.response.headers.add_header('Content-Type', 'application/xml')
+class EmbedHandler(webapp.RequestHandler):
+ """Handles serving a front page suitable for embedding."""
+
+ def get(self):
+ directory = get_directory_doc()
+ for item in directory:
+ item['title'] = item.get('title', item.get('description', ''))
+ path = os.path.join(os.path.dirname(__file__), 'embed.html')
+ self.response.out.write(
+ template.render(
+ path, {'directory': directory,
+ }))
+
+
def _render(resource):
"""Use pydoc helpers on an instance to generate the help documentation.
"""
@@ -140,6 +153,7 @@
[
(r'/', MainHandler),
(r'/_gadget/', GadgetHandler),
+ (r'/_embed/', EmbedHandler),
(r'/([^\/]*)/([^\/]*)(?:/(.*))?', ResourceHandler),
],
debug=False)