Skip to content

Commit

Permalink
first cut
Browse files Browse the repository at this point in the history
  • Loading branch information
mhausenblas committed Jun 11, 2011
1 parent e7627a2 commit fc74edf
Show file tree
Hide file tree
Showing 194 changed files with 38,243 additions and 0 deletions.
13 changes: 13 additions & 0 deletions a404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
omnidator
</title>
</head>
<body>
<div style="margin: 5em; text-align: center; font-size: 30pt">Uuuups, that a 404</div>
<div style="margin: 5em; text-align: center; font-size: 18pt">... sorry, seems we don't have what you're looking for ...</div>
</body>
</html>
10 changes: 10 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
application: omnidator
version: 1
runtime: python
api_version: 1

handlers:
- url: /examples
static_dir: examples
- url: /.*
script: main.py
4 changes: 4 additions & 0 deletions examples/solar-system.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Thing,Mass,URL
Earth,"5.9721986x10^24 kg",http://dbpedia.org/resource/Earth
Mars,"6.4191x10^23 kg",http://dbpedia.org/resource/Mars
Sun,"1.988435x10^30 kg",http://dbpedia.org/resource/Sun
53 changes: 53 additions & 0 deletions handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
The handler script.
@author: Michael Hausenblas, http://sw-app.org/mic.xhtml#i
@since: 2011-06-11
@status: inital version
"""
import sys
sys.path.insert(0, 'lib')
import logging
import cgi
import os
import platform
import urllib
import urllib2
import StringIO
import csv

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

import rdflib

from rdflib import Graph
from rdflib import Namespace
from rdflib import plugin
from rdflib.serializer import Serializer

import schema_org_processor


class MainHandler(webapp.RequestHandler):
def get(self):
self.response.out.write(template.render('index.html', None))

class NotFoundHandler(webapp.RequestHandler):
def get(self):
self.error(404)
self.response.out.write(template.render('a404.html', None))

class SchemaOrgHandler(webapp.RequestHandler):
def get(self, doc_url):
logging.info('Trying to translate document at [%s]' %(urllib.unquote(doc_url)))

try:
sop = schema_org_processor.SchemaOrgProcessor()
sop.parse(urllib.unquote(doc_url))
self.response.headers.add_header("Access-Control-Allow-Origin", "*") # CORS-enabled
self.response.headers['Content-Type'] = 'application/rdf+xml'
self.response.out.write(str(sop.dump_data()))
except Exception, e:
self.error(404)
self.response.out.write(e)#template.render('a404.html', None))
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
omnidator
</title>
</head>
<body>
<h1>API</h1>
<div>http://omnidator.appspot.com/2/{URL} ... from Schema.org data (microdata, CSV, etc.) to RDF</div>
</body>
</html>
17 changes: 17 additions & 0 deletions lib/html5lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
HTML parsing library based on the WHATWG "HTML5"
specification. The parser is designed to be compatible with existing
HTML found in the wild and implements well-defined error recovery that
is largely compatible with modern desktop web browsers.
Example usage:
import html5lib
f = open("my_document.html")
tree = html5lib.parse(f)
"""
__version__ = "0.95-dev"
from html5parser import HTMLParser, parse, parseFragment
from treebuilders import getTreeBuilder
from treewalkers import getTreeWalker
from serializer import serialize
Binary file added lib/html5lib/__init__.pyc
Binary file not shown.
Loading

0 comments on commit fc74edf

Please sign in to comment.