diff options
author | bryan newbold <bnewbold@snark.mit.edu> | 2009-06-15 15:28:21 -0400 |
---|---|---|
committer | bryan newbold <bnewbold@snark.mit.edu> | 2009-06-15 15:28:21 -0400 |
commit | f78236c4113d0d4e5019df316125e86a63befd07 (patch) | |
tree | 06267d37b36c2e86d659a0213e3cb010b1c294bb | |
parent | c2c48ce70e942aaea78d6a2100411803db7ff8bf (diff) | |
download | equator-f78236c4113d0d4e5019df316125e86a63befd07.tar.gz equator-f78236c4113d0d4e5019df316125e86a63befd07.zip |
more changes; BROKEN?
-rw-r--r-- | app.yaml | 6 | ||||
-rw-r--r-- | equations/models.py | 5 | ||||
-rw-r--r-- | index.yaml | 11 | ||||
-rw-r--r-- | load_export.py | 106 | ||||
-rw-r--r-- | templates/about.html | 32 | ||||
-rw-r--r-- | templates/base.html | 3 | ||||
-rw-r--r-- | templates/index.html | 40 |
7 files changed, 199 insertions, 4 deletions
@@ -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 %} +<p /> +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. +<p /> +This site runs on <a href="http://appspot.com">google app engine</a>; it uses +the python project <a href="http://djangoproject.com">django</a> and should +be using the javascript math package <a href="http://www.math.union.edu/~dpvc/jsMath/">jsMath</a>. +<p /> +The full source code is available at +<a href="http://git.bnewbold.net">git.bnewbold.net</a>. 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. + +<h2>Stuff that is out there</h2> +<ul> + <li /><a href="http://en.wikipedia.org/">wikipedia</a> + <li /><a href="http://hyperphysics.phy-astr.gsu.edu/hbase/HFrame.html">hyperphysics</a> + <li /><a href="http://planetmath.org/">Planet Math</a> + <li /><a href="http://www.sagemath.org/">Sage Math</a> + <li /><a href="http://en.wikipedia.org/wiki/Axiom_(computer_algebra_system)">AXIOM</a> + <li /><a href="http://mathworld.wolfram.com/">mathworld.wolfram.com</a> + <li /><a href="http://functions.wolfram.com/">functions.wolfram.com</a> + <li /><a href="http://www.aip.org/stixfonts/">stix fonts</a> + <li />much else... +</ul> +{% 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? <hr> <span class="footer"> <a href="/">home</a> - +<a href="/about/">about</a> - <a href="/go/">do it</a> - <a href="/equation/">equations</a> - <a href="/variable/">variables</a> - <a href="/symbol/">symbols</a> <br>Legalese? Copyright? Fuck no! -<a href="mailto:webmaster@equator.memeschemes.com" style="text-decoration: line-through;">email the webmaster!</a> 2007! +<a href="mailto:webmaster@equator.memeschemes.com" style="text-decoration: line-through;">email the webmaster!</a> 2009! </span> </div></body></html> 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 %} +<div style="width: 300px; margin-left: 176px; border: 3px solid red; +padding: 5px; background-color: orange; font-size: 30px; text-align: center;"> +<a href="/go/" style="text-decoration:none;">GO</a></div> +<br /> +<h3>View all <a href="/equation/">equations</a>, +<a href="/variable/">variables</a>, or +<a href="/symbol/">symbols</a>.</h3> +<p /> +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. +<p /> +The site runs on <a href="http://appspot.com">google app engine</a>; it uses +the python project <a href="http://djangoproject.com">django</a> and should +be using the javascript math package <a href="http://www.math.union.edu/~dpvc/jsMath/">jsMath</a>. +<p /> +The full source code is available at +<a href="http://git.bnewbold.net">git.bnewbold.net</a>. 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. + +<h2>Stuff that is out there</h2> +<ul> + <li /><a href="http://en.wikipedia.org/">wikipedia</a> + <li /><a href="http://hyperphysics.phy-astr.gsu.edu/hbase/HFrame.html">hyperphysics</a> + <li /><a href="http://planetmath.org/">Planet Math</a> + <li /><a href="http://www.sagemath.org/">Sage Math</a> + <li /><a href="http://en.wikipedia.org/wiki/Axiom_(computer_algebra_system)">AXIOM</a> + <li /><a href="http://mathworld.wolfram.com/">mathworld.wolfram.com</a> + <li /><a href="http://functions.wolfram.com/">functions.wolfram.com</a> + <li /><a href="http://www.aip.org/stixfonts/">stix fonts</a> + <li />much else... +</ul> + +{% endblock %} |