Moved into module.
4
.gitignore
vendored
@ -135,5 +135,5 @@ node_modules
|
|||||||
|
|
||||||
wanikani.db
|
wanikani.db
|
||||||
config.py
|
config.py
|
||||||
/static/*.map
|
/wanikaniburned/static/*.map
|
||||||
/static/*.js
|
/wanikaniburned/static/*.js
|
||||||
|
@ -18,7 +18,7 @@ Demo API key: **demo**
|
|||||||
|
|
||||||
Unzip build archive.
|
Unzip build archive.
|
||||||
|
|
||||||
unzip build.zip
|
unzip archive.zip
|
||||||
|
|
||||||
Create a file config.py in the base directory and added configuration options (see example-config.py).
|
Create a file config.py in the base directory and added configuration options (see example-config.py).
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ Install dependencies.
|
|||||||
|
|
||||||
Start application.
|
Start application.
|
||||||
|
|
||||||
python wanikaniburned.py
|
python runserver.py
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -53,13 +53,13 @@ Install CoffeeScript (requires npm)
|
|||||||
|
|
||||||
Compile CoffeeScript.
|
Compile CoffeeScript.
|
||||||
|
|
||||||
coffee --map --compile ./static
|
coffee --map --compile ./wanikaniburned/static
|
||||||
|
|
||||||
### Optional
|
### Optional
|
||||||
|
|
||||||
Auto watch and recompile CoffeeScript file(s) on changes.
|
Auto watch and recompile CoffeeScript file(s) on changes.
|
||||||
|
|
||||||
coffee --map --watch --compile ./static
|
coffee --map --watch --compile ./wanikaniburned/static
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
5
runserver.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from wanikaniburned import db, app
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
db.create_all()
|
||||||
|
app.run(threaded=True, port=app.config['PORT'])
|
1
static/wanakana.min.js
vendored
5
tests.py
@ -1,7 +1,8 @@
|
|||||||
import gzip
|
import gzip
|
||||||
import ujson as json
|
import ujson as json
|
||||||
import unittest
|
import unittest
|
||||||
from wanikaniburned import app, db, User, datetime_format, parse_range
|
from wanikaniburned import app, db
|
||||||
|
from wanikaniburned.wanikaniburned import User, datetime_format, parse_range
|
||||||
from flask.ext.testing import TestCase
|
from flask.ext.testing import TestCase
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ class TestFormats(unittest.TestCase):
|
|||||||
def test_custom_datetime_format(self):
|
def test_custom_datetime_format(self):
|
||||||
test_time = datetime.min
|
test_time = datetime.min
|
||||||
output = datetime_format(test_time)
|
output = datetime_format(test_time)
|
||||||
self.assertEqual(output, "01 January 1 12:00AM")
|
self.assertEqual(output, test_time.strftime("%d %B %Y %I:%M%p"))
|
||||||
|
|
||||||
def test_parse_range_empty(self):
|
def test_parse_range_empty(self):
|
||||||
self.assertIsNone(parse_range(""))
|
self.assertIsNone(parse_range(""))
|
||||||
|
34
wanikaniburned/__init__.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import flask
|
||||||
|
from flask.ext.sqlalchemy import SQLAlchemy
|
||||||
|
from flask.ext.login import LoginManager
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
console_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
console_handler.setLevel(logging.DEBUG)
|
||||||
|
handler = logging.FileHandler('wkburned.log')
|
||||||
|
handler.setLevel(logging.WARN)
|
||||||
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
console_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
logger.addHandler(console_handler)
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
logger.debug("Configuring application.")
|
||||||
|
app.config.update(
|
||||||
|
PORT=5000,
|
||||||
|
JSON_AS_ASCII=False
|
||||||
|
)
|
||||||
|
app.config.from_pyfile('config.py', silent=True)
|
||||||
|
logger.debug("Setting up login manager.")
|
||||||
|
login_manager = LoginManager()
|
||||||
|
login_manager.init_app(app)
|
||||||
|
logger.debug("Setting up database.")
|
||||||
|
db = SQLAlchemy(app)
|
||||||
|
filter_regex = re.compile('\d+([,-]\d+)*')
|
||||||
|
logger.debug("Setup complete")
|
||||||
|
|
||||||
|
import wanikaniburned.wanikaniburned
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 814 B After Width: | Height: | Size: 814 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 715 B |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@ -1,44 +1,15 @@
|
|||||||
import ujson as json
|
import ujson as json
|
||||||
import re
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from flask.ext.login import LoginManager, login_user, login_required, current_user, logout_user, login_fresh, \
|
from flask.ext.login import login_user, login_required, current_user, logout_user, login_fresh, \
|
||||||
confirm_login
|
confirm_login
|
||||||
from flask.ext.sqlalchemy import SQLAlchemy
|
|
||||||
from flask.ext.wtf import Form
|
from flask.ext.wtf import Form
|
||||||
import requests
|
import requests
|
||||||
from wtforms import StringField
|
from wtforms import StringField
|
||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
from wanikaniburned import db, logger, filter_regex, login_manager, app
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
console_handler = logging.StreamHandler(sys.stdout)
|
|
||||||
console_handler.setLevel(logging.DEBUG)
|
|
||||||
handler = logging.FileHandler('wkburned.log')
|
|
||||||
handler.setLevel(logging.WARN)
|
|
||||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
console_handler.setFormatter(formatter)
|
|
||||||
logger.addHandler(handler)
|
|
||||||
logger.addHandler(console_handler)
|
|
||||||
|
|
||||||
app = flask.Flask(__name__)
|
|
||||||
logger.debug("Configuring application.")
|
|
||||||
app.config.update(
|
|
||||||
PORT=5000,
|
|
||||||
JSON_AS_ASCII=False
|
|
||||||
)
|
|
||||||
app.config.from_pyfile('config.py', silent=True)
|
|
||||||
logger.debug("Setting up login manager.")
|
|
||||||
login_manager = LoginManager()
|
|
||||||
login_manager.init_app(app)
|
|
||||||
logger.debug("Setting up database.")
|
|
||||||
db = SQLAlchemy(app)
|
|
||||||
filter_regex = re.compile('\d+([,-]\d+)*')
|
|
||||||
logger.debug("Setup complete")
|
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(Form):
|
class LoginForm(Form):
|