From f78236c4113d0d4e5019df316125e86a63befd07 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Mon, 15 Jun 2009 15:28:21 -0400 Subject: more changes; BROKEN? --- app.yaml | 6 ++- equations/models.py | 5 ++- index.yaml | 11 ++++++ load_export.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ templates/about.html | 32 ++++++++++++++++ templates/base.html | 3 +- templates/index.html | 40 +++++++++++++++++++ 7 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 index.yaml create mode 100644 load_export.py create mode 100644 templates/about.html create mode 100644 templates/index.html diff --git a/app.yaml b/app.yaml index d9a5770..90885eb 100644 --- a/app.yaml +++ b/app.yaml @@ -1,5 +1,5 @@ application: yetanotherequator -version: 1 +version: 2 runtime: python api_version: 1 @@ -7,5 +7,9 @@ handlers: - url: /static static_dir: static +- url: /remote_api + script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py + login: admin + - url: /.* script: main.py diff --git a/equations/models.py b/equations/models.py index 9b8a38d..f4be69e 100644 --- a/equations/models.py +++ b/equations/models.py @@ -36,7 +36,7 @@ class Variable(BaseModel): latex = db.TextProperty(_("Raw LaTeX")) unicode = db.TextProperty(_("Unicode Representation")) description = db.TextProperty(_("Description")) - reference = db.TextProperty(_("Reference URL")) + references = db.ListProperty(db.LinkProperty(_("Reference URL"))) symbol = db.ReferenceProperty(Symbol) isgeneric = db.BooleanProperty(_("Is Generic?"), default=False) @@ -64,7 +64,8 @@ class Equation(BaseModel): #owner = models.ForeignKey(auth.User, verbose_name=_("Owner")) variables = db.ListProperty(db.Key, verbose_name="Variables") - reference = db.TextProperty(_("Reference URL")) + references = db.ListProperty(db.LinkProperty(_("Reference URL"))) + userurl = db.db.LinkProperty(_("Last User URL")) class Meta: get_latest_by = 'created' diff --git a/index.yaml b/index.yaml new file mode 100644 index 0000000..a3b9e05 --- /dev/null +++ b/index.yaml @@ -0,0 +1,11 @@ +indexes: + +# AUTOGENERATED + +# This index.yaml is automatically updated whenever the dev_appserver +# detects that a new type of query is run. If you want to manage the +# index.yaml file manually, remove the above marker line (the line +# saying "# AUTOGENERATED"). If you want to manage some indexes +# manually, move them above the marker line. The index.yaml file is +# automatically uploaded to the admin console when you next deploy +# your application using appcfg.py. diff --git a/load_export.py b/load_export.py new file mode 100644 index 0000000..ab05b55 --- /dev/null +++ b/load_export.py @@ -0,0 +1,106 @@ +import datetime +from google.appengine.ext import db +from google.appengine.tools import bulkloader +from google.appengine.api import datastore_types +from equations.models import * + +dstr = '%m/%d/%Y' + +class SymbolLoader(bulkloader.Loader): + def __init__(self): + bulkloader.Loader.__init__(self, 'Symbol', + [('name', str), + ('latex', str), + ('unicode', str), + ]) + +class SymbolExporter(bulkloader.Exporter): + def __init__(self): + bulkloader.Exporter.__init__(self, 'Symbol', + [('name', str, None), + ('latex', str, None), + ('unicode', str, None), + ]) + +class VariableLoader(bulkloader.Loader): + def __init__(self): + bulkloader.Loader.__init__(self, 'Variable', + [('name', str), + ('latex', str), + ('unicode', str), + ('description', str), + ('symbol', str), + ('references', str.split), + ('isgeneric', boolean), + ]) + + def HandleEntity(self, entity): + f = Symbol.all().filter("name =", entity['symbol']).get() + entity['symbol'] = f.key() + + reflist = [] + refstr = eval(entity['references'][0]) + for ref in refstr: + r = datastore_types.Link(ref) + reflist.append(r) + entity['references'] = reflist + +class VariableExporter(bulkloader.Exporter): + def __init__(self): + bulkloader.Exporter.__init__(self, 'Variable', + [('name', str, None), + ('latex', str, None), + ('unicode', str, None), + ('description', str, None), + ('symbol', str, None), + ('references', str, None), + ('isgeneric', str, None), + ]) + +class EquationLoader(bulkloader.Loader): + def __init__(self): + bulkloader.Loader.__init__(self, 'Equation', + [('name', str), + ('latex', str), + ('unicode', str), + ('description', str), + ('created', + lambda x: datetime.datetime.strptime(x, dstr).date()), + ('updated', + lambda x: datetime.datetime.strptime(x, dstr).date()), + ('variables', str.split), + ('references', str.split), + ('userurl', datastore_types.Link), + ]) + + def HandleEntity(self, entity): + vlist = [] + vstr = eval(entity['variables'][0]) + for var in vstr: + v = Variable.all().filter("name =", var).get() + vlist.append(v.key()) + entity['variables'] = vlist + + reflist = [] + refstr = eval(entity['references'][0]) + for ref in refstr: + r = datastore_types.Link(ref) + reflist.append(r) + entity['references'] = reflist + +class EquationExporter(bulkloader.Exporter): + def __init__(self): + bulkloader.Exporter.__init__(self, 'Equation', + [('name', str, None), + ('latex', str, None), + ('unicode', str, None), + ('description', str, None), + ('created', str, None), + ('updated', str, None), + ('variables', str, None), + ('references', str, None), + ('userurl', str, None), + ]) + +loaders = [SymbolLoader, VariableLoader, EquationLoader] +exporters= [SymbolExporter, VariableExporter, EquationExporter] diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000..3f59846 --- /dev/null +++ b/templates/about.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block title %}Equwha?{% endblock %} +{% block content %} +

+This site is a junky hack of a tool to quickly explore equations of all kinds; +the main interface is designed to quickly look up physical equations and +formulae based on their constituant variables. +

+This site runs on google app engine; it uses +the python project django and should +be using the javascript math package jsMath. +

+The full source code is available at +git.bnewbold.net. You can get all the +symbols and variables as json (poke around and you'll find it); i'd like to +offer full export in a bunch of formats as well as feeds for new/special +equations. + +

Stuff that is out there

+ +{% endblock %} diff --git a/templates/base.html b/templates/base.html index 82579c5..9d9c89c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,11 +18,12 @@ no content?
home - +about - do it - equations - variables - symbols
Legalese? Copyright? Fuck no! -email the webmaster! 2007! +email the webmaster! 2009!
diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..0ff29f8 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} + +{% block title %}The Equator is Primed{% endblock %} +{% block content %} +
+GO
+
+

View all equations, +variables, or +symbols.

+

+This site is a junky hack of a tool to quickly explore equations of all kinds; +the main interface is designed to quickly look up physical equations and +formulae based on their constituant variables. Click "GO" above to start. +

+The site runs on google app engine; it uses +the python project django and should +be using the javascript math package jsMath. +

+The full source code is available at +git.bnewbold.net. You can get all the +symbols and variables as json (poke around and you'll find it); i'd like to +offer full export in a bunch of formats as well as feeds for new/special +equations. + +

Stuff that is out there

+ + +{% endblock %} -- cgit v1.2.3