Commit 06b6dc28 authored by Yannick Chudy's avatar Yannick Chudy

relative path to static

parent 2a89dbd1
...@@ -28,8 +28,9 @@ PATH = "./static/images" # images storage ...@@ -28,8 +28,9 @@ PATH = "./static/images" # images storage
KEY = codecs.open("secret/key.txt", 'r', encoding='utf8').read().strip() KEY = codecs.open("secret/key.txt", 'r', encoding='utf8').read().strip()
# padagraph host t o connect # padagraph host t o connect
HOST = "http://padagraph.io" STATIC_HOST = os.environ.get('STATIC_HOST', "http://padagraph.io")
HOST = os.environ.get('PDG_HOST', "http://localhost:5000") ENGINES_HOST = os.environ.get('ENGINES_HOST', "http://padagraph.io")
KEY = codecs.open("../me.local", 'r', encoding='utf8').read().strip() KEY = codecs.open("../me.local", 'r', encoding='utf8').read().strip()
# delete before import # delete before import
...@@ -39,7 +40,7 @@ DELETE = os.environ.get('BOTAPAD_DELETE', "True").lower() == "true" ...@@ -39,7 +40,7 @@ DELETE = os.environ.get('BOTAPAD_DELETE', "True").lower() == "true"
# app # app
print( "== Botapad %s %s ==" % ("DEBUG" if DEBUG else "", "DELETE" if DELETE else "") ) print( "== Botapad %s %s ==" % ("DEBUG" if DEBUG else "", "DELETE" if DELETE else "") )
print( "== %s ==" % HOST) print( "== engines:%s static:%s ==" % (ENGINES_HOST, STATIC_HOST) )
app = Flask(__name__) app = Flask(__name__)
app.config['DEBUG'] = DEBUG app.config['DEBUG'] = DEBUG
...@@ -104,13 +105,13 @@ def snapshot(gid, **kwargs): ...@@ -104,13 +105,13 @@ def snapshot(gid, **kwargs):
""" """
path = '%s/%s.png' % ( PATH, gid ) path = '%s/%s.png' % ( PATH, gid )
#driver, HOST, gid, path, width, height, {iframe params} #driver, HOST, gid, path, width, height, {iframe params}
getScreenShot(driver, HOST, gid, path, 400,400, **kwargs) getScreenShot(driver, ENGINES_HOST, gid, path, 400,400, **kwargs)
def img_url(gid): def img_url(gid):
return '%s/%s.png' % ( PATH, gid ) return '%s/%s.png' % ( PATH, gid )
def graph_url(gid): def graph_url(gid):
return '%s/graph/%s' % ( HOST, gid ) return '%s/graph/%s' % ( ENGINES_HOST, gid )
# === app routes === # === app routes ===
...@@ -213,7 +214,7 @@ def home(): ...@@ -213,7 +214,7 @@ def home():
def pad2pdg(gid, url): def pad2pdg(gid, url):
description = "imported from %s" % url description = "imported from %s" % url
bot = Botagraph(HOST, KEY) bot = Botagraph(ENGINES_HOST, KEY)
botapad = Botapad(bot, gid, description, delete=DELETE) botapad = Botapad(bot, gid, description, delete=DELETE)
return bot.parse(url, separator='auto', debug=app.config['DEBUG']) return bot.parse(url, separator='auto', debug=app.config['DEBUG'])
...@@ -247,7 +248,7 @@ def botimport(repo, content_type="html"): ...@@ -247,7 +248,7 @@ def botimport(repo, content_type="html"):
#raise ValueError(request) #raise ValueError(request)
action = "%s?%s" % (repo, request.query_string) action = "%s?%s" % (repo, request.query_string)
print "action " , action print "action " , action
routes = "%s/engines" % HOST routes = "%s/engines" % ENGINES_HOST
graph = None graph = None
data = None data = None
...@@ -293,7 +294,7 @@ def botimport(repo, content_type="html"): ...@@ -293,7 +294,7 @@ def botimport(repo, content_type="html"):
try : try :
if repo == "padagraph": if repo == "padagraph":
pad2pdg(gid, url) pad2pdg(gid, url)
data = "%s/xplor/%s.json" % (HOST, gid) data = "%s/xplor/%s.json" % (ENGINES_HOST, gid)
complete = True complete = True
if content_type == "json": if content_type == "json":
...@@ -348,7 +349,7 @@ def botimport(repo, content_type="html"): ...@@ -348,7 +349,7 @@ def botimport(repo, content_type="html"):
#snapshot(gid, **params)D #snapshot(gid, **params)D
return render_template('homepage.html', return render_template('homepage.html',
static_host=HOST, action=action, content_type=content_type, color=color, static_host=STATIC_HOST, action=action, content_type=content_type, color=color,
repo=repo, complete=complete, error=error, repo=repo, complete=complete, error=error,
routes=routes, data=data, options=json.dumps(options), routes=routes, data=data, options=json.dumps(options),
padurl=url, graphurl=graph_url(gid) , img=img_url(gid), padurl=url, graphurl=graph_url(gid) , img=img_url(gid),
......
...@@ -337,12 +337,17 @@ ...@@ -337,12 +337,17 @@
<a class="active item" href="{{padurl}}">Imported from {{padurl}}</a> <a class="active item" href="{{padurl}}">Imported from {{padurl}}</a>
</div> </div>
<script src="{{static_host}}/static/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- require JS--> <script src="{{static_host}}/static/webcomponents-lite.js"></script>
<script data-main="{{static_host}}/static/main" src="{{static_host}}/static/bower_components/requirejs/require.js"></script>
<script data-main="{{static_host}}/static/main" src="{{static_host}}/static/require.js"></script>
<link rel="import" href="{{static_host}}/static/padagraph-gviz-min.html"/>
<!--
<link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-collection.html"/> <link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-collection.html"/>
<link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-controls.html"/> <link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-controls.html"/>
<link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-gviz.html"/> <link rel="import" href="{{static_host}}/static/padagraph_webcomponents/padagraph-gviz.html"/>
-->
<div id="gviz"> <div id="gviz">
<padagraph-gviz-json routes="{{routes}}" data="{{data}}" > <padagraph-gviz-json routes="{{routes}}" data="{{data}}" >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment