From 5b464f03022643875063cf13ed4de2d725bbde91 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Tue, 31 May 2016 03:53:29 +0100 Subject: [PATCH] Moved into module. --- .gitignore | 4 +-- README.md | 8 ++--- runserver.py | 5 +++ static/wanakana.min.js | 1 - tests.py | 5 +-- wanikaniburned/__init__.py | 34 ++++++++++++++++++ .../example-config.py | 0 {static => wanikaniburned/static}/burned.png | Bin .../favicon/android-chrome-144x144.png | Bin .../favicon/android-chrome-192x192.png | Bin .../static}/favicon/android-chrome-36x36.png | Bin .../static}/favicon/android-chrome-48x48.png | Bin .../static}/favicon/android-chrome-72x72.png | Bin .../static}/favicon/android-chrome-96x96.png | Bin .../favicon/apple-touch-icon-114x114.png | Bin .../favicon/apple-touch-icon-120x120.png | Bin .../favicon/apple-touch-icon-144x144.png | Bin .../favicon/apple-touch-icon-152x152.png | Bin .../favicon/apple-touch-icon-180x180.png | Bin .../favicon/apple-touch-icon-57x57.png | Bin .../favicon/apple-touch-icon-60x60.png | Bin .../favicon/apple-touch-icon-72x72.png | Bin .../favicon/apple-touch-icon-76x76.png | Bin .../favicon/apple-touch-icon-precomposed.png | Bin .../static}/favicon/apple-touch-icon.png | Bin .../static}/favicon/browserconfig.xml | 0 .../static}/favicon/favicon-16x16.png | Bin .../static}/favicon/favicon-32x32.png | Bin .../static}/favicon/favicon-96x96.png | Bin .../static}/favicon/favicon.ico | Bin .../static}/favicon/manifest.json | 0 .../static}/favicon/mstile-144x144.png | Bin .../static}/favicon/mstile-150x150.png | Bin .../static}/favicon/mstile-310x150.png | Bin .../static}/favicon/mstile-310x310.png | Bin .../static}/favicon/mstile-70x70.png | Bin .../static}/quiz_item.coffee | 0 {static => wanikaniburned/static}/style.css | 0 .../static}/wanikani.png | Bin .../templates}/layout.html | 0 .../templates}/quiz.html | 0 .../templates}/welcome.html | 0 .../wanikaniburned.py | 33 ++--------------- 43 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 runserver.py delete mode 100644 static/wanakana.min.js create mode 100644 wanikaniburned/__init__.py rename example-config.py => wanikaniburned/example-config.py (100%) rename {static => wanikaniburned/static}/burned.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-144x144.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-192x192.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-36x36.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-48x48.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-72x72.png (100%) rename {static => wanikaniburned/static}/favicon/android-chrome-96x96.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-114x114.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-120x120.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-144x144.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-152x152.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-180x180.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-57x57.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-60x60.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-72x72.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-76x76.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon-precomposed.png (100%) rename {static => wanikaniburned/static}/favicon/apple-touch-icon.png (100%) rename {static => wanikaniburned/static}/favicon/browserconfig.xml (100%) rename {static => wanikaniburned/static}/favicon/favicon-16x16.png (100%) rename {static => wanikaniburned/static}/favicon/favicon-32x32.png (100%) rename {static => wanikaniburned/static}/favicon/favicon-96x96.png (100%) rename {static => wanikaniburned/static}/favicon/favicon.ico (100%) rename {static => wanikaniburned/static}/favicon/manifest.json (100%) rename {static => wanikaniburned/static}/favicon/mstile-144x144.png (100%) rename {static => wanikaniburned/static}/favicon/mstile-150x150.png (100%) rename {static => wanikaniburned/static}/favicon/mstile-310x150.png (100%) rename {static => wanikaniburned/static}/favicon/mstile-310x310.png (100%) rename {static => wanikaniburned/static}/favicon/mstile-70x70.png (100%) rename {static => wanikaniburned/static}/quiz_item.coffee (100%) rename {static => wanikaniburned/static}/style.css (100%) rename {static => wanikaniburned/static}/wanikani.png (100%) rename {templates => wanikaniburned/templates}/layout.html (100%) rename {templates => wanikaniburned/templates}/quiz.html (100%) rename {templates => wanikaniburned/templates}/welcome.html (100%) rename wanikaniburned.py => wanikaniburned/wanikaniburned.py (90%) diff --git a/.gitignore b/.gitignore index 90e4664..09f6911 100644 --- a/.gitignore +++ b/.gitignore @@ -135,5 +135,5 @@ node_modules wanikani.db config.py -/static/*.map -/static/*.js +/wanikaniburned/static/*.map +/wanikaniburned/static/*.js diff --git a/README.md b/README.md index 7f5ba72..d985f14 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Demo API key: **demo** 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). @@ -35,7 +35,7 @@ Install dependencies. Start application. - python wanikaniburned.py + python runserver.py ## Installation @@ -53,13 +53,13 @@ Install CoffeeScript (requires npm) Compile CoffeeScript. - coffee --map --compile ./static + coffee --map --compile ./wanikaniburned/static ### Optional Auto watch and recompile CoffeeScript file(s) on changes. - coffee --map --watch --compile ./static + coffee --map --watch --compile ./wanikaniburned/static ## Testing diff --git a/runserver.py b/runserver.py new file mode 100644 index 0000000..5d5b505 --- /dev/null +++ b/runserver.py @@ -0,0 +1,5 @@ +from wanikaniburned import db, app + +if __name__ == "__main__": + db.create_all() + app.run(threaded=True, port=app.config['PORT']) diff --git a/static/wanakana.min.js b/static/wanakana.min.js deleted file mode 100644 index 72916fc..0000000 --- a/static/wanakana.min.js +++ /dev/null @@ -1 +0,0 @@ -var wanakana,__indexOf=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};wanakana=wanakana||{},wanakana.version="1.3.7","function"==typeof define&&define.amd&&define("wanakana",[],function(){return wanakana}),wanakana.LOWERCASE_START=97,wanakana.LOWERCASE_END=122,wanakana.UPPERCASE_START=65,wanakana.UPPERCASE_END=90,wanakana.HIRAGANA_START=12353,wanakana.HIRAGANA_END=12438,wanakana.KATAKANA_START=12449,wanakana.KATAKANA_END=12538,wanakana.LOWERCASE_FULLWIDTH_START=65345,wanakana.LOWERCASE_FULLWIDTH_END=65370,wanakana.UPPERCASE_FULLWIDTH_START=65313,wanakana.UPPERCASE_FULLWIDTH_END=65338,wanakana.defaultOptions={useObseleteKana:!1,IMEMode:!1},wanakana.bind=function(a){return a.addEventListener("input",wanakana._onInput)},wanakana.unbind=function(a){return a.removeEventListener("input",wanakana._onInput)},wanakana._onInput=function(a){var b,c,d,e,f,g;if(b=a.target,f=b.selectionStart,g=b.value.length,d=wanakana._convertFullwidthCharsToASCII(b.value),c=wanakana.toKana(d,{IMEMode:!0}),d!==c){if(b.value=c,"number"==typeof b.selectionStart)return b.selectionStart=b.selectionEnd=b.value.length;if("undefined"!=typeof b.createTextRange)return b.focus(),e=b.createTextRange(),e.collapse(!1),e.select()}},wanakana._extend=function(a,b){var c;if(null==a)return b;for(c in b)null==a[c]&&null!=b[c]&&(a[c]=b[c]);return a},wanakana._isCharInRange=function(a,b,c){var d;return d=a.charCodeAt(0),d>=b&&c>=d},wanakana._isCharVowel=function(a,b){var c;return null==b&&(b=!0),c=b?/[aeiouy]/:/[aeiou]/,-1!==a.toLowerCase().charAt(0).search(c)},wanakana._isCharConsonant=function(a,b){var c;return null==b&&(b=!0),c=b?/[bcdfghjklmnpqrstvwxyz]/:/[bcdfghjklmnpqrstvwxz]/,-1!==a.toLowerCase().charAt(0).search(c)},wanakana._isCharKatakana=function(a){return wanakana._isCharInRange(a,wanakana.KATAKANA_START,wanakana.KATAKANA_END)},wanakana._isCharHiragana=function(a){return wanakana._isCharInRange(a,wanakana.HIRAGANA_START,wanakana.HIRAGANA_END)},wanakana._isCharKana=function(a){return wanakana._isCharHiragana(a)||wanakana._isCharKatakana(a)},wanakana._isCharNotKana=function(a){return!wanakana._isCharHiragana(a)&&!wanakana._isCharKatakana(a)},wanakana._convertFullwidthCharsToASCII=function(a){var b,c,d,e,f,g;for(c=a.split(""),e=f=0,g=c.length;g>f;e=++f)b=c[e],d=b.charCodeAt(0),wanakana._isCharInRange(b,wanakana.LOWERCASE_FULLWIDTH_START,wanakana.LOWERCASE_FULLWIDTH_END)&&(c[e]=String.fromCharCode(d-wanakana.LOWERCASE_FULLWIDTH_START+wanakana.LOWERCASE_START)),wanakana._isCharInRange(b,wanakana.UPPERCASE_FULLWIDTH_START,wanakana.UPPERCASE_FULLWIDTH_END)&&c[e](String.fromCharCode(d-wanakana.UPPERCASE_FULLWIDTH_START+wanakana.UPPERCASE_START));return c.join("")},wanakana._katakanaToHiragana=function(a){var b,c,d,e,f,g,h;for(c=[],h=a.split(""),f=0,g=h.length;g>f;f++)e=h[f],wanakana._isCharKatakana(e)?(b=e.charCodeAt(0),b+=wanakana.HIRAGANA_START-wanakana.KATAKANA_START,d=String.fromCharCode(b),c.push(d)):c.push(e);return c.join("")},wanakana._hiraganaToKatakana=function(a){var b,c,d,e,f,g,h;for(d=[],h=a.split(""),f=0,g=h.length;g>f;f++)c=h[f],wanakana._isCharHiragana(c)?(b=c.charCodeAt(0),b+=wanakana.KATAKANA_START-wanakana.HIRAGANA_START,e=String.fromCharCode(b),d.push(e)):d.push(c);return d.join("")},wanakana._hiraganaToRomaji=function(a,b){var c,d,e,f,g,h,i,j,k,l;for(b=wanakana._extend(b,wanakana.defaultOptions),g=a.length,k=[],e=0,d=0,h=2,f=function(){return a.substr(e,d)},j=function(){return d=Math.min(h,g-e)};g>e;){for(j();d>0;){if(c=f(),wanakana.isKatakana(c)&&(c=wanakana._katakanaToHiragana(c)),"っ"===c.charAt(0)&&1===d&&g-1>e){i=!0,l="";break}if(l=wanakana.J_to_R[c],null!=l&&i&&(l=l.charAt(0).concat(l),i=!1),null!=l)break;d--}null==l&&(l=c),k.push(l),e+=d||1}return k.join("")},wanakana._romajiToHiragana=function(a,b){return wanakana._romajiToKana(a,b,!0)},wanakana._romajiToKana=function(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(null==c&&(c=!1),b=wanakana._extend(b,wanakana.defaultOptions),l=a.length,j=[],g=0,m=3,h=function(){return a.substr(g,f)},i=function(a){return wanakana._isCharInRange(a,wanakana.UPPERCASE_START,wanakana.UPPERCASE_END)};l>g;){for(f=Math.min(m,l-g);f>0;){if(d=h(),e=d.toLowerCase(),__indexOf.call(wanakana.FOUR_CHARACTER_EDGE_CASES,e)>=0&&l-g>=4)f++,d=h(),e=d.toLowerCase();else{if("n"===e.charAt(0)){if(b.IMEMode&&"'"===e.charAt(1)&&2===f){k="ん";break}wanakana._isCharConsonant(e.charAt(1),!1)&&wanakana._isCharVowel(e.charAt(2))&&(f=1,d=h(),e=d.toLowerCase())}"n"!==e.charAt(0)&&wanakana._isCharConsonant(e.charAt(0))&&d.charAt(0)===d.charAt(1)&&(f=1,e=d=wanakana._isCharInRange(d.charAt(0),wanakana.UPPERCASE_START,wanakana.UPPERCASE_END)?"ッ":"っ")}if(k=wanakana.R_to_J[e],null!=k)break;4===f?f-=2:f--}null==k&&(d=wanakana._convertPunctuation(d),k=d),(null!=b?b.useObseleteKana:void 0)&&("wi"===e&&(k="ゐ"),"we"===e&&(k="ゑ")),b.IMEMode&&"n"===e.charAt(0)&&("y"===a.charAt(g+1).toLowerCase()&&wanakana._isCharVowel(a.charAt(g+2))===!1||g===l-1||wanakana.isKana(a.charAt(g+1)))&&(k=d.charAt(0)),c||i(d.charAt(0))&&(k=wanakana._hiraganaToKatakana(k)),j.push(k),g+=f||1}return j.join("")},wanakana._convertPunctuation=function(a){return" "===a?" ":"-"===a?"ー":a},wanakana.isHiragana=function(a){var b;return b=a.split(""),b.every(wanakana._isCharHiragana)},wanakana.isKatakana=function(a){var b;return b=a.split(""),b.every(wanakana._isCharKatakana)},wanakana.isKana=function(a){var b;return b=a.split(""),b.every(function(a){return wanakana.isHiragana(a)||wanakana.isKatakana(a)})},wanakana.isRomaji=function(a){var b;return b=a.split(""),b.every(function(a){return!wanakana.isHiragana(a)&&!wanakana.isKatakana(a)})},wanakana.toHiragana=function(a,b){return wanakana.isRomaji(a)?a=wanakana._romajiToHiragana(a,b):wanakana.isKatakana(a)?a=wanakana._katakanaToHiragana(a,b):a},wanakana.toKatakana=function(a,b){return wanakana.isHiragana(a)?a=wanakana._hiraganaToKatakana(a,b):wanakana.isRomaji(a)?(a=wanakana._romajiToHiragana(a,b),a=wanakana._hiraganaToKatakana(a,b)):a},wanakana.toKana=function(a,b){return a=wanakana._romajiToKana(a,b)},wanakana.toRomaji=function(a){return a=wanakana._hiraganaToRomaji(a)},wanakana.R_to_J={a:"あ",i:"い",u:"う",e:"え",o:"お",yi:"い",wu:"う",whu:"う",xa:"ぁ",xi:"ぃ",xu:"ぅ",xe:"ぇ",xo:"ぉ",xyi:"ぃ",xye:"ぇ",ye:"いぇ",wha:"うぁ",whi:"うぃ",whe:"うぇ",who:"うぉ",wi:"うぃ",we:"うぇ",va:"ゔぁ",vi:"ゔぃ",vu:"ゔ",ve:"ゔぇ",vo:"ゔぉ",vya:"ゔゃ",vyi:"ゔぃ",vyu:"ゔゅ",vye:"ゔぇ",vyo:"ゔょ",ka:"か",ki:"き",ku:"く",ke:"け",ko:"こ",lka:"ヵ",lke:"ヶ",xka:"ヵ",xke:"ヶ",kya:"きゃ",kyi:"きぃ",kyu:"きゅ",kye:"きぇ",kyo:"きょ",ca:"か",ci:"き",cu:"く",ce:"け",co:"こ",lca:"ヵ",lce:"ヶ",xca:"ヵ",xce:"ヶ",qya:"くゃ",qyu:"くゅ",qyo:"くょ",qwa:"くぁ",qwi:"くぃ",qwu:"くぅ",qwe:"くぇ",qwo:"くぉ",qa:"くぁ",qi:"くぃ",qe:"くぇ",qo:"くぉ",kwa:"くぁ",qyi:"くぃ",qye:"くぇ",ga:"が",gi:"ぎ",gu:"ぐ",ge:"げ",go:"ご",gya:"ぎゃ",gyi:"ぎぃ",gyu:"ぎゅ",gye:"ぎぇ",gyo:"ぎょ",gwa:"ぐぁ",gwi:"ぐぃ",gwu:"ぐぅ",gwe:"ぐぇ",gwo:"ぐぉ",sa:"さ",si:"し",shi:"し",su:"す",se:"せ",so:"そ",za:"ざ",zi:"じ",zu:"ず",ze:"ぜ",zo:"ぞ",ji:"じ",sya:"しゃ",syi:"しぃ",syu:"しゅ",sye:"しぇ",syo:"しょ",sha:"しゃ",shu:"しゅ",she:"しぇ",sho:"しょ",shya:"しゃ",shyu:"しゅ",shye:"しぇ",shyo:"しょ",swa:"すぁ",swi:"すぃ",swu:"すぅ",swe:"すぇ",swo:"すぉ",zya:"じゃ",zyi:"じぃ",zyu:"じゅ",zye:"じぇ",zyo:"じょ",ja:"じゃ",ju:"じゅ",je:"じぇ",jo:"じょ",jya:"じゃ",jyi:"じぃ",jyu:"じゅ",jye:"じぇ",jyo:"じょ",ta:"た",ti:"ち",tu:"つ",te:"て",to:"と",chi:"ち",tsu:"つ",ltu:"っ",xtu:"っ",tya:"ちゃ",tyi:"ちぃ",tyu:"ちゅ",tye:"ちぇ",tyo:"ちょ",cha:"ちゃ",chu:"ちゅ",che:"ちぇ",cho:"ちょ",cya:"ちゃ",cyi:"ちぃ",cyu:"ちゅ",cye:"ちぇ",cyo:"ちょ",chya:"ちゃ",chyu:"ちゅ",chye:"ちぇ",chyo:"ちょ",tsa:"つぁ",tsi:"つぃ",tse:"つぇ",tso:"つぉ",tha:"てゃ",thi:"てぃ",thu:"てゅ",the:"てぇ",tho:"てょ",twa:"とぁ",twi:"とぃ",twu:"とぅ",twe:"とぇ",two:"とぉ",da:"だ",di:"ぢ",du:"づ",de:"で","do":"ど",dya:"ぢゃ",dyi:"ぢぃ",dyu:"ぢゅ",dye:"ぢぇ",dyo:"ぢょ",dha:"でゃ",dhi:"でぃ",dhu:"でゅ",dhe:"でぇ",dho:"でょ",dwa:"どぁ",dwi:"どぃ",dwu:"どぅ",dwe:"どぇ",dwo:"どぉ",na:"な",ni:"に",nu:"ぬ",ne:"ね",no:"の",nya:"にゃ",nyi:"にぃ",nyu:"にゅ",nye:"にぇ",nyo:"にょ",ha:"は",hi:"ひ",hu:"ふ",he:"へ",ho:"ほ",fu:"ふ",hya:"ひゃ",hyi:"ひぃ",hyu:"ひゅ",hye:"ひぇ",hyo:"ひょ",fya:"ふゃ",fyu:"ふゅ",fyo:"ふょ",fwa:"ふぁ",fwi:"ふぃ",fwu:"ふぅ",fwe:"ふぇ",fwo:"ふぉ",fa:"ふぁ",fi:"ふぃ",fe:"ふぇ",fo:"ふぉ",fyi:"ふぃ",fye:"ふぇ",ba:"ば",bi:"び",bu:"ぶ",be:"べ",bo:"ぼ",bya:"びゃ",byi:"びぃ",byu:"びゅ",bye:"びぇ",byo:"びょ",pa:"ぱ",pi:"ぴ",pu:"ぷ",pe:"ぺ",po:"ぽ",pya:"ぴゃ",pyi:"ぴぃ",pyu:"ぴゅ",pye:"ぴぇ",pyo:"ぴょ",ma:"ま",mi:"み",mu:"む",me:"め",mo:"も",mya:"みゃ",myi:"みぃ",myu:"みゅ",mye:"みぇ",myo:"みょ",ya:"や",yu:"ゆ",yo:"よ",xya:"ゃ",xyu:"ゅ",xyo:"ょ",ra:"ら",ri:"り",ru:"る",re:"れ",ro:"ろ",rya:"りゃ",ryi:"りぃ",ryu:"りゅ",rye:"りぇ",ryo:"りょ",la:"ら",li:"り",lu:"る",le:"れ",lo:"ろ",lya:"りゃ",lyi:"りぃ",lyu:"りゅ",lye:"りぇ",lyo:"りょ",wa:"わ",wo:"を",lwe:"ゎ",xwa:"ゎ",n:"ん",nn:"ん","n ":"ん",xn:"ん",ltsu:"っ"},wanakana.FOUR_CHARACTER_EDGE_CASES=["lts","chy","shy"],wanakana.J_to_R={"あ":"a","い":"i","う":"u","え":"e","お":"o","ゔぁ":"va","ゔぃ":"vi","ゔ":"vu","ゔぇ":"ve","ゔぉ":"vo","か":"ka","き":"ki","きゃ":"kya","きぃ":"kyi","きゅ":"kyu","く":"ku","け":"ke","こ":"ko","が":"ga","ぎ":"gi","ぐ":"gu","げ":"ge","ご":"go","ぎゃ":"gya","ぎぃ":"gyi","ぎゅ":"gyu","ぎぇ":"gye","ぎょ":"gyo","さ":"sa","す":"su","せ":"se","そ":"so","ざ":"za","ず":"zu","ぜ":"ze","ぞ":"zo","し":"shi","しゃ":"sha","しゅ":"shu","しょ":"sho","じ":"ji","じゃ":"ja","じゅ":"ju","じょ":"jo","た":"ta","ち":"chi","ちゃ":"cha","ちゅ":"chu","ちょ":"cho","つ":"tsu","て":"te","と":"to","だ":"da","ぢ":"di","づ":"du","で":"de","ど":"do","な":"na","に":"ni","にゃ":"nya","にゅ":"nyu","にょ":"nyo","ぬ":"nu","ね":"ne","の":"no","は":"ha","ひ":"hi","ふ":"fu","へ":"he","ほ":"ho","ひゃ":"hya","ひゅ":"hyu","ひょ":"hyo","ふぁ":"fa","ふぃ":"fi","ふぇ":"fe","ふぉ":"fo","ば":"ba","び":"bi","ぶ":"bu","べ":"be","ぼ":"bo","びゃ":"bya","びゅ":"byu","びょ":"byo","ぱ":"pa","ぴ":"pi","ぷ":"pu","ぺ":"pe","ぽ":"po","ぴゃ":"pya","ぴゅ":"pyu","ぴょ":"pyo","ま":"ma","み":"mi","む":"mu","め":"me","も":"mo","みゃ":"mya","みゅ":"myu","みょ":"myo","や":"ya","ゆ":"yu","よ":"yo","ら":"ra","り":"ri","る":"ru","れ":"re","ろ":"ro","りゃ":"rya","りゅ":"ryu","りょ":"ryo","わ":"wa","を":"wo","ん":"n","ゐ":"wi","ゑ":"we","きぇ":"kye","きょ":"kyo","じぃ":"jyi","じぇ":"jye","ちぃ":"cyi","ちぇ":"che","ひぃ":"hyi","ひぇ":"hye","びぃ":"byi","びぇ":"bye","ぴぃ":"pyi","ぴぇ":"pye","みぇ":"mye","みぃ":"myi","りぃ":"ryi","りぇ":"rye","にぃ":"nyi","にぇ":"nye","しぃ":"syi","しぇ":"she","いぇ":"ye","うぁ":"wha","うぉ":"who","うぃ":"wi","うぇ":"we","ゔゃ":"vya","ゔゅ":"vyu","ゔょ":"vyo","すぁ":"swa","すぃ":"swi","すぅ":"swu","すぇ":"swe","すぉ":"swo","くゃ":"qya","くゅ":"qyu","くょ":"qyo","くぁ":"qwa","くぃ":"qwi","くぅ":"qwu","くぇ":"qwe","くぉ":"qwo","ぐぁ":"gwa","ぐぃ":"gwi","ぐぅ":"gwu","ぐぇ":"gwe","ぐぉ":"gwo","つぁ":"tsa","つぃ":"tsi","つぇ":"tse","つぉ":"tso","てゃ":"tha","てぃ":"thi","てゅ":"thu","てぇ":"the","てょ":"tho","とぁ":"twa","とぃ":"twi","とぅ":"twu","とぇ":"twe","とぉ":"two","ぢゃ":"dya","ぢぃ":"dyi","ぢゅ":"dyu","ぢぇ":"dye","ぢょ":"dyo","でゃ":"dha","でぃ":"dhi","でゅ":"dhu","でぇ":"dhe","でょ":"dho","どぁ":"dwa","どぃ":"dwi","どぅ":"dwu","どぇ":"dwe","どぉ":"dwo","ふぅ":"fwu","ふゃ":"fya","ふゅ":"fyu","ふょ":"fyo","ぁ":"a","ぃ":"i","ぇ":"e","ぅ":"u","ぉ":"o","ゃ":"ya","ゅ":"yu","ょ":"yo","っ":"","ゕ":"ka","ゖ":"ka","ゎ":"wa"," ":" ","んあ":"n'a","んい":"n'i","んう":"n'u","んえ":"n'e","んお":"n'o","んや":"n'ya","んゆ":"n'yu","んよ":"n'yo"}; \ No newline at end of file diff --git a/tests.py b/tests.py index fdc9f45..1da87cb 100644 --- a/tests.py +++ b/tests.py @@ -1,7 +1,8 @@ import gzip import ujson as json 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 datetime import datetime @@ -93,7 +94,7 @@ class TestFormats(unittest.TestCase): def test_custom_datetime_format(self): test_time = datetime.min 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): self.assertIsNone(parse_range("")) diff --git a/wanikaniburned/__init__.py b/wanikaniburned/__init__.py new file mode 100644 index 0000000..abfa25b --- /dev/null +++ b/wanikaniburned/__init__.py @@ -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 diff --git a/example-config.py b/wanikaniburned/example-config.py similarity index 100% rename from example-config.py rename to wanikaniburned/example-config.py diff --git a/static/burned.png b/wanikaniburned/static/burned.png similarity index 100% rename from static/burned.png rename to wanikaniburned/static/burned.png diff --git a/static/favicon/android-chrome-144x144.png b/wanikaniburned/static/favicon/android-chrome-144x144.png similarity index 100% rename from static/favicon/android-chrome-144x144.png rename to wanikaniburned/static/favicon/android-chrome-144x144.png diff --git a/static/favicon/android-chrome-192x192.png b/wanikaniburned/static/favicon/android-chrome-192x192.png similarity index 100% rename from static/favicon/android-chrome-192x192.png rename to wanikaniburned/static/favicon/android-chrome-192x192.png diff --git a/static/favicon/android-chrome-36x36.png b/wanikaniburned/static/favicon/android-chrome-36x36.png similarity index 100% rename from static/favicon/android-chrome-36x36.png rename to wanikaniburned/static/favicon/android-chrome-36x36.png diff --git a/static/favicon/android-chrome-48x48.png b/wanikaniburned/static/favicon/android-chrome-48x48.png similarity index 100% rename from static/favicon/android-chrome-48x48.png rename to wanikaniburned/static/favicon/android-chrome-48x48.png diff --git a/static/favicon/android-chrome-72x72.png b/wanikaniburned/static/favicon/android-chrome-72x72.png similarity index 100% rename from static/favicon/android-chrome-72x72.png rename to wanikaniburned/static/favicon/android-chrome-72x72.png diff --git a/static/favicon/android-chrome-96x96.png b/wanikaniburned/static/favicon/android-chrome-96x96.png similarity index 100% rename from static/favicon/android-chrome-96x96.png rename to wanikaniburned/static/favicon/android-chrome-96x96.png diff --git a/static/favicon/apple-touch-icon-114x114.png b/wanikaniburned/static/favicon/apple-touch-icon-114x114.png similarity index 100% rename from static/favicon/apple-touch-icon-114x114.png rename to wanikaniburned/static/favicon/apple-touch-icon-114x114.png diff --git a/static/favicon/apple-touch-icon-120x120.png b/wanikaniburned/static/favicon/apple-touch-icon-120x120.png similarity index 100% rename from static/favicon/apple-touch-icon-120x120.png rename to wanikaniburned/static/favicon/apple-touch-icon-120x120.png diff --git a/static/favicon/apple-touch-icon-144x144.png b/wanikaniburned/static/favicon/apple-touch-icon-144x144.png similarity index 100% rename from static/favicon/apple-touch-icon-144x144.png rename to wanikaniburned/static/favicon/apple-touch-icon-144x144.png diff --git a/static/favicon/apple-touch-icon-152x152.png b/wanikaniburned/static/favicon/apple-touch-icon-152x152.png similarity index 100% rename from static/favicon/apple-touch-icon-152x152.png rename to wanikaniburned/static/favicon/apple-touch-icon-152x152.png diff --git a/static/favicon/apple-touch-icon-180x180.png b/wanikaniburned/static/favicon/apple-touch-icon-180x180.png similarity index 100% rename from static/favicon/apple-touch-icon-180x180.png rename to wanikaniburned/static/favicon/apple-touch-icon-180x180.png diff --git a/static/favicon/apple-touch-icon-57x57.png b/wanikaniburned/static/favicon/apple-touch-icon-57x57.png similarity index 100% rename from static/favicon/apple-touch-icon-57x57.png rename to wanikaniburned/static/favicon/apple-touch-icon-57x57.png diff --git a/static/favicon/apple-touch-icon-60x60.png b/wanikaniburned/static/favicon/apple-touch-icon-60x60.png similarity index 100% rename from static/favicon/apple-touch-icon-60x60.png rename to wanikaniburned/static/favicon/apple-touch-icon-60x60.png diff --git a/static/favicon/apple-touch-icon-72x72.png b/wanikaniburned/static/favicon/apple-touch-icon-72x72.png similarity index 100% rename from static/favicon/apple-touch-icon-72x72.png rename to wanikaniburned/static/favicon/apple-touch-icon-72x72.png diff --git a/static/favicon/apple-touch-icon-76x76.png b/wanikaniburned/static/favicon/apple-touch-icon-76x76.png similarity index 100% rename from static/favicon/apple-touch-icon-76x76.png rename to wanikaniburned/static/favicon/apple-touch-icon-76x76.png diff --git a/static/favicon/apple-touch-icon-precomposed.png b/wanikaniburned/static/favicon/apple-touch-icon-precomposed.png similarity index 100% rename from static/favicon/apple-touch-icon-precomposed.png rename to wanikaniburned/static/favicon/apple-touch-icon-precomposed.png diff --git a/static/favicon/apple-touch-icon.png b/wanikaniburned/static/favicon/apple-touch-icon.png similarity index 100% rename from static/favicon/apple-touch-icon.png rename to wanikaniburned/static/favicon/apple-touch-icon.png diff --git a/static/favicon/browserconfig.xml b/wanikaniburned/static/favicon/browserconfig.xml similarity index 100% rename from static/favicon/browserconfig.xml rename to wanikaniburned/static/favicon/browserconfig.xml diff --git a/static/favicon/favicon-16x16.png b/wanikaniburned/static/favicon/favicon-16x16.png similarity index 100% rename from static/favicon/favicon-16x16.png rename to wanikaniburned/static/favicon/favicon-16x16.png diff --git a/static/favicon/favicon-32x32.png b/wanikaniburned/static/favicon/favicon-32x32.png similarity index 100% rename from static/favicon/favicon-32x32.png rename to wanikaniburned/static/favicon/favicon-32x32.png diff --git a/static/favicon/favicon-96x96.png b/wanikaniburned/static/favicon/favicon-96x96.png similarity index 100% rename from static/favicon/favicon-96x96.png rename to wanikaniburned/static/favicon/favicon-96x96.png diff --git a/static/favicon/favicon.ico b/wanikaniburned/static/favicon/favicon.ico similarity index 100% rename from static/favicon/favicon.ico rename to wanikaniburned/static/favicon/favicon.ico diff --git a/static/favicon/manifest.json b/wanikaniburned/static/favicon/manifest.json similarity index 100% rename from static/favicon/manifest.json rename to wanikaniburned/static/favicon/manifest.json diff --git a/static/favicon/mstile-144x144.png b/wanikaniburned/static/favicon/mstile-144x144.png similarity index 100% rename from static/favicon/mstile-144x144.png rename to wanikaniburned/static/favicon/mstile-144x144.png diff --git a/static/favicon/mstile-150x150.png b/wanikaniburned/static/favicon/mstile-150x150.png similarity index 100% rename from static/favicon/mstile-150x150.png rename to wanikaniburned/static/favicon/mstile-150x150.png diff --git a/static/favicon/mstile-310x150.png b/wanikaniburned/static/favicon/mstile-310x150.png similarity index 100% rename from static/favicon/mstile-310x150.png rename to wanikaniburned/static/favicon/mstile-310x150.png diff --git a/static/favicon/mstile-310x310.png b/wanikaniburned/static/favicon/mstile-310x310.png similarity index 100% rename from static/favicon/mstile-310x310.png rename to wanikaniburned/static/favicon/mstile-310x310.png diff --git a/static/favicon/mstile-70x70.png b/wanikaniburned/static/favicon/mstile-70x70.png similarity index 100% rename from static/favicon/mstile-70x70.png rename to wanikaniburned/static/favicon/mstile-70x70.png diff --git a/static/quiz_item.coffee b/wanikaniburned/static/quiz_item.coffee similarity index 100% rename from static/quiz_item.coffee rename to wanikaniburned/static/quiz_item.coffee diff --git a/static/style.css b/wanikaniburned/static/style.css similarity index 100% rename from static/style.css rename to wanikaniburned/static/style.css diff --git a/static/wanikani.png b/wanikaniburned/static/wanikani.png similarity index 100% rename from static/wanikani.png rename to wanikaniburned/static/wanikani.png diff --git a/templates/layout.html b/wanikaniburned/templates/layout.html similarity index 100% rename from templates/layout.html rename to wanikaniburned/templates/layout.html diff --git a/templates/quiz.html b/wanikaniburned/templates/quiz.html similarity index 100% rename from templates/quiz.html rename to wanikaniburned/templates/quiz.html diff --git a/templates/welcome.html b/wanikaniburned/templates/welcome.html similarity index 100% rename from templates/welcome.html rename to wanikaniburned/templates/welcome.html diff --git a/wanikaniburned.py b/wanikaniburned/wanikaniburned.py similarity index 90% rename from wanikaniburned.py rename to wanikaniburned/wanikaniburned.py index 7249748..a8d6980 100644 --- a/wanikaniburned.py +++ b/wanikaniburned/wanikaniburned.py @@ -1,44 +1,15 @@ import ujson as json -import re from datetime import datetime, timedelta -import logging -import sys 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 -from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.wtf import Form import requests from wtforms import StringField from wtforms.validators import DataRequired -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") +from wanikaniburned import db, logger, filter_regex, login_manager, app class LoginForm(Form):