Skip to content

Commit

Permalink
Merge pull request #15 from datacamp/jh/update
Browse files Browse the repository at this point in the history
Enable using browser history and update server dependencies
  • Loading branch information
hermansje authored Nov 9, 2018
2 parents c7f7ef2 + 56dcde5 commit f5a3124
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
9 changes: 7 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
app = Flask(__name__)
app.config.from_object('config')

app.wsgi_app = WhiteNoise(app.wsgi_app, root='app/static/', prefix='static/')
app.wsgi_app = WhiteNoise(app.wsgi_app, root='app/static/', prefix='/', index_file=True)

# Helper funcs ----------------------------------------------------------------
from antlr_plsql import plsql_grammar, ast as plsql_ast
Expand Down Expand Up @@ -47,7 +47,7 @@ def get_ast(code, start, parser_name):
return None

# Views -----------------------------------------------------------------------
from flask import Flask, request, url_for, redirect, jsonify, make_response
from flask import Flask, request, url_for, redirect, jsonify, make_response, send_file
import yaml


Expand Down Expand Up @@ -104,3 +104,8 @@ def ast_from_config():
out[k] = [{'code': code, 'ast': json_ast} for code, json_ast in zipped]
print(out)
return jsonify(out)


@app.errorhandler(404)
def page_not_found(error):
return send_file('./static/index.html')
1 change: 1 addition & 0 deletions app/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const routes = [
]

const router = new VueRouter({
mode: 'history',
routes
})

Expand Down
17 changes: 10 additions & 7 deletions app/static/src/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
<pre id="editor1"></pre>
<div class="scrollmargin"></div>

parser:
parser:
<select type="text" v-model="grammarName" v-on:change="resetStartPoint">
<option v-for="grammar in grammars" :key="grammar.name" :value="grammar.name">
{{grammar.name}}
</option>
</select>

start: <input type="text" v-model="parserStart">
<br>
<button v-on:click="parseCode">Submit Code</button>
<button v-on:click="routeToCode">Save</button>
<button v-on:click="submit">Submit Code</button>

<!-- NODE GRAPH -->

Expand All @@ -35,7 +33,7 @@ var graphs = require('./graphs.js')
var request = require('superagent')
var grammars = [
{
{
name: 'plsql',
start: 'sql_script',
show_parse: true
Expand Down Expand Up @@ -95,8 +93,8 @@ export default {
crntGrammar () { return this.grammars.filter(({name}) => name == this.grammarName)[0]},
},
watch: {
codeData () {
this.getAst()
codeData () {
this.getAst()
},
},
methods: {
Expand Down Expand Up @@ -143,6 +141,11 @@ export default {
this.parserStart = this.crntGrammar.start
},
submit () {
this.parseCode()
this.routeToCode()
},
setupEditor(editor) {
editor.setTheme("ace/theme/tomorrow_night_eighties");
editor.session.setMode("ace/mode/sql");
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gunicorn==19.7.1
gevent==1.2.1
Flask==0.12.1
whitenoise==3.3.1
Flask==1.0.2
whitenoise==4.1
PyYAML==3.12

antlr4-python3-runtime==4.7.1
Expand Down

0 comments on commit f5a3124

Please sign in to comment.