From ad10a6467f76822b9289832eeb0d0ac2038b32d1 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 30 Dec 2019 16:57:13 +0100 Subject: Strip down for simple app for Greek verb λύω --- Readme.md | 4 +- app/Form.php | 36 ++ .../Controllers/Auth/ForgotPasswordController.php | 32 -- app/Http/Controllers/Auth/LoginController.php | 39 -- app/Http/Controllers/Auth/RegisterController.php | 76 ---- .../Controllers/Auth/ResetPasswordController.php | 34 -- app/Http/Controllers/FormController.php | 51 +++ app/Http/Controllers/RandomVerbController.php | 49 --- app/Http/Controllers/RootController.php | 58 --- app/Http/Controllers/VerbController.php | 161 -------- app/Mode.php | 29 ++ app/Observers/UserObserver.php | 35 -- app/PointChange.php | 35 -- app/RandomLog.php | 4 +- app/Root.php | 37 -- app/RootKind.php | 29 -- app/RootTranslation.php | 29 -- app/Stem.php | 29 -- app/Tense.php | 4 +- app/User.php | 56 --- app/Verb.php | 71 ---- app/VerbAction.php | 41 -- composer.json | 6 +- database/factories/ModelFactory.php | 23 -- .../2016_01_04_143639_create_modes_table.php | 48 +++ .../2016_01_04_143639_create_stems_table.php | 47 --- .../2016_01_04_143647_create_tenses_table.php | 4 +- .../2016_01_04_143655_create_roots_table.php | 48 --- .../2016_01_04_143702_create_forms_table.php | 59 +++ .../2016_01_04_143702_create_verbs_table.php | 59 --- ...01_04_144049_create_root_translations_table.php | 52 --- .../2016_05_10_211558_create_random_logs_table.php | 2 +- .../2016_09_04_081740_create_users_table.php | 33 -- ...2016_09_04_081754_create_verb_actions_table.php | 38 -- ...016_09_04_081811_create_point_changes_table.php | 37 -- .../2016_09_04_081924_add_active_to_verbs.php | 31 -- .../2016_09_05_215803_create_root_kinds.php | 45 --- .../2016_09_05_230150_add_isadmin_to_users.php | 28 -- .../2016_09_25_210947_add_remember_token.php | 32 -- ...6_09_25_230620_create_password_resets_table.php | 32 -- database/seeds/BasisTableSeeder.php | 46 +-- database/seeds/DatabaseSeeder.php | 7 +- database/seeds/FormTableSeeder.php | 34 ++ database/seeds/RootTableSeeder.php | 53 --- database/seeds/VerbTableSeeder.php | 59 --- public/css/fonts/EzraSIL.ttf | Bin 155584 -> 0 bytes public/css/fonts/SBL_grk.ttf | Bin 0 -> 1123080 bytes public/css/hebrewparsetrainer.css | 77 ---- public/css/luoparsetrainer.css | 77 ++++ public/js/alerts.js | 11 - public/js/hebrewparsetrainer.js | 362 ----------------- public/js/luoparsetrainer.js | 436 +++++++++++++++++++++ public/js/moderators.js | 118 ------ resources/views/add_root.blade.php | 29 -- resources/views/auth/login.blade.php | 68 ---- resources/views/auth/passwords/email.blade.php | 47 --- resources/views/auth/passwords/reset.blade.php | 70 ---- resources/views/auth/register.blade.php | 82 ---- resources/views/contribute.blade.php | 53 --- resources/views/layouts/master.blade.php | 40 +- resources/views/mails/user/create.blade.php | 13 - resources/views/shared/already_logged_in.blade.php | 1 - resources/views/shared/messages.blade.php | 5 - resources/views/stats.blade.php | 134 ------- resources/views/suggest.blade.php | 89 ----- resources/views/suggestions.blade.php | 43 -- resources/views/trainer.blade.php | 70 ++-- resources/views/user/create.blade.php | 32 -- resources/views/user/top.blade.php | 39 -- routes/web.php | 30 +- tools/import_etcbc.py | 140 ------- 71 files changed, 834 insertions(+), 2994 deletions(-) create mode 100644 app/Form.php delete mode 100644 app/Http/Controllers/Auth/ForgotPasswordController.php delete mode 100644 app/Http/Controllers/Auth/LoginController.php delete mode 100644 app/Http/Controllers/Auth/RegisterController.php delete mode 100644 app/Http/Controllers/Auth/ResetPasswordController.php create mode 100644 app/Http/Controllers/FormController.php delete mode 100644 app/Http/Controllers/RandomVerbController.php delete mode 100644 app/Http/Controllers/RootController.php delete mode 100644 app/Http/Controllers/VerbController.php create mode 100644 app/Mode.php delete mode 100644 app/Observers/UserObserver.php delete mode 100644 app/PointChange.php delete mode 100644 app/Root.php delete mode 100644 app/RootKind.php delete mode 100644 app/RootTranslation.php delete mode 100644 app/Stem.php delete mode 100644 app/User.php delete mode 100644 app/Verb.php delete mode 100644 app/VerbAction.php delete mode 100644 database/factories/ModelFactory.php create mode 100644 database/migrations/2016_01_04_143639_create_modes_table.php delete mode 100644 database/migrations/2016_01_04_143639_create_stems_table.php delete mode 100644 database/migrations/2016_01_04_143655_create_roots_table.php create mode 100644 database/migrations/2016_01_04_143702_create_forms_table.php delete mode 100644 database/migrations/2016_01_04_143702_create_verbs_table.php delete mode 100644 database/migrations/2016_01_04_144049_create_root_translations_table.php delete mode 100644 database/migrations/2016_09_04_081740_create_users_table.php delete mode 100644 database/migrations/2016_09_04_081754_create_verb_actions_table.php delete mode 100644 database/migrations/2016_09_04_081811_create_point_changes_table.php delete mode 100644 database/migrations/2016_09_04_081924_add_active_to_verbs.php delete mode 100644 database/migrations/2016_09_05_215803_create_root_kinds.php delete mode 100644 database/migrations/2016_09_05_230150_add_isadmin_to_users.php delete mode 100644 database/migrations/2016_09_25_210947_add_remember_token.php delete mode 100644 database/migrations/2016_09_25_230620_create_password_resets_table.php create mode 100644 database/seeds/FormTableSeeder.php delete mode 100644 database/seeds/RootTableSeeder.php delete mode 100644 database/seeds/VerbTableSeeder.php delete mode 100644 public/css/fonts/EzraSIL.ttf create mode 100644 public/css/fonts/SBL_grk.ttf delete mode 100644 public/css/hebrewparsetrainer.css create mode 100644 public/css/luoparsetrainer.css delete mode 100644 public/js/alerts.js delete mode 100644 public/js/hebrewparsetrainer.js create mode 100644 public/js/luoparsetrainer.js delete mode 100644 public/js/moderators.js delete mode 100644 resources/views/add_root.blade.php delete mode 100644 resources/views/auth/login.blade.php delete mode 100644 resources/views/auth/passwords/email.blade.php delete mode 100644 resources/views/auth/passwords/reset.blade.php delete mode 100644 resources/views/auth/register.blade.php delete mode 100644 resources/views/contribute.blade.php delete mode 100644 resources/views/mails/user/create.blade.php delete mode 100644 resources/views/shared/already_logged_in.blade.php delete mode 100644 resources/views/shared/messages.blade.php delete mode 100644 resources/views/stats.blade.php delete mode 100644 resources/views/suggest.blade.php delete mode 100644 resources/views/suggestions.blade.php delete mode 100644 resources/views/user/create.blade.php delete mode 100644 resources/views/user/top.blade.php delete mode 100755 tools/import_etcbc.py diff --git a/Readme.md b/Readme.md index 0da38a5..e725a29 100644 --- a/Readme.md +++ b/Readme.md @@ -102,7 +102,7 @@ In a subdirectory, we need to enforce trailing slashes and do some special thing Copyright 2015–present Camil Staps. Licensed under GPL v3.0, see the LICENSE file. -This project uses the [EzraSIL][ezrasil] font which is licensed under the Open Font License. +This project uses the [SBL Greek][sblgrk] font which is licensed under the SBL Font User Agreement. [demo]: https://parse.hebrewtools.org/ -[ezrasil]: http://scripts.sil.org/cms/scripts/page.php?item_id=EzraSIL_Home +[ezrasil]: https://www.sbl-site.org/educational/biblicalfonts.aspx diff --git a/app/Form.php b/app/Form.php new file mode 100644 index 0000000..767c122 --- /dev/null +++ b/app/Form.php @@ -0,0 +1,36 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +namespace HebrewParseTrainer; + +use Illuminate\Database\Eloquent\Model; + +class Form extends Model { + + protected $table = 'forms'; + public $timestamps = false; + protected $fillable = ['form', 'tense', 'mode', 'voice', 'person', 'number', 'gender', 'case']; + + const ACCEPTED_VOTE_COUNT = 5; + + public function otherParsings() { + return self::where('form', $this->form)->get() + ->filter(function($v){return $v->form === $this->form;}); + } + +} diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php deleted file mode 100644 index a36a6f4..0000000 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ /dev/null @@ -1,32 +0,0 @@ -middleware('guest'); - } -} diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php deleted file mode 100644 index 4c81bea..0000000 --- a/app/Http/Controllers/Auth/LoginController.php +++ /dev/null @@ -1,39 +0,0 @@ -middleware('guest', ['except' => 'logout']); - } -} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php deleted file mode 100644 index 29ec08a..0000000 --- a/app/Http/Controllers/Auth/RegisterController.php +++ /dev/null @@ -1,76 +0,0 @@ -middleware('guest'); - } - - /** - * Get a validator for an incoming registration request. - * - * @param array $data - * @return \Illuminate\Contracts\Validation\Validator - */ - protected function validator(array $data) - { - return Validator::make($data, [ - 'name' => 'required|max:255', - 'email' => 'required|email|max:255|unique:users', - 'password' => 'required|min:6|confirmed', - ]); - } - - /** - * Create a new user instance after a valid registration. - * - * @param array $data - * @return User - */ - protected function create(array $data) - { - $user = new User([ - 'name' => $data['name'], - 'email' => $data['email'], - ]); - - $user->password = bcrypt($data['password']); - - $user->save(); - - return $user; - } -} diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php deleted file mode 100644 index 98d1131..0000000 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ /dev/null @@ -1,34 +0,0 @@ -middleware('guest'); - } -} diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php new file mode 100644 index 0000000..a860363 --- /dev/null +++ b/app/Http/Controllers/FormController.php @@ -0,0 +1,51 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +namespace App\Http\Controllers; + +use HebrewParseTrainer\Form; +use HebrewParseTrainer\RandomLog; + +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Input; +use Illuminate\Support\Facades\Validator; + +class FormController extends Controller { + + public function random() { + $forms = Form::all(); + foreach (Input::get() as $col => $val) { + if ($col == '_token') + continue; + $vals = explode(',', $val); + $forms = $forms->whereIn($col, $vals); + } + $form = $forms->random(); + + $log = new RandomLog(); + $log->request = json_encode(Input::get()); + $log->response = $form->id; + $log->ip = $_SERVER['REMOTE_ADDR']; + $log->save(); + + $obj = ['form' => $form, 'answers' => $form->otherParsings()]; + return response()->json($obj); + } + +} diff --git a/app/Http/Controllers/RandomVerbController.php b/app/Http/Controllers/RandomVerbController.php deleted file mode 100644 index ceb5ff9..0000000 --- a/app/Http/Controllers/RandomVerbController.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace App\Http\Controllers; - -use HebrewParseTrainer\Verb; -use HebrewParseTrainer\RandomLog; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Input; - -class RandomVerbController extends Controller { - - public function show() - { - $verbs = Verb::all(); - foreach (Input::get() as $col => $val) { - $val = explode(',', $val); - $verbs = $verbs->filter(function(Verb $item) use ($col, $val) { - return in_array($item->getAttribute($col), $val); - }); - } - $verb = $verbs->random(); - - $log = new RandomLog(); - $log->request = json_encode(Input::get()); - $log->response = $verb->id; - $log->ip = $_SERVER['REMOTE_ADDR']; - $log->save(); - - $obj = ['verb' => $verb, 'answers' => $verb->otherParsings()]; - return response()->json($obj); - } - -} diff --git a/app/Http/Controllers/RootController.php b/app/Http/Controllers/RootController.php deleted file mode 100644 index 5546a1d..0000000 --- a/app/Http/Controllers/RootController.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace App\Http\Controllers; - -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Validator; - -use HebrewParseTrainer\Root; -use HebrewParseTrainer\RootKind; - -class RootController extends Controller { - - public function create(Request $request) { - $_kinds = RootKind::all(); - $kinds = []; - foreach ($_kinds as $kind) - $kinds[] = $kind->id; - - $validator = Validator::make($request->input(), [ - 'root' => 'required', - 'root_kind_id' => 'in:' . implode(',', $kinds), - ]); - - if ($validator->fails()) { - return [ - 'success' => false, - 'message' => $validator->errors()->first() - ]; - } - - $root = new Root; - $root->root = $request->input('root'); - $root->root_kind_id = $request->input('root_kind_id'); - $root->save(); - - return [ - 'success' => true, - ]; - } - -} diff --git a/app/Http/Controllers/VerbController.php b/app/Http/Controllers/VerbController.php deleted file mode 100644 index 042bfe2..0000000 --- a/app/Http/Controllers/VerbController.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace App\Http\Controllers; - -use HebrewParseTrainer\PointChange; -use HebrewParseTrainer\Stem; -use HebrewParseTrainer\Tense; -use HebrewParseTrainer\Verb; -use HebrewParseTrainer\VerbAction; -use HebrewParseTrainer\RandomLog; - -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Input; -use Illuminate\Support\Facades\Validator; - -class VerbController extends Controller { - - public function random() { - $verbs = Verb::where('active', 1); - foreach (Input::get() as $col => $val) { - if ($col == '_token') - continue; - $vals = explode(',', $val); - $verbs = $verbs->whereIn($col, $vals); - } - $verb = $verbs->get()->random(); - - $log = new RandomLog(); - $log->request = json_encode(Input::get()); - $log->response = $verb->id; - $log->ip = $_SERVER['REMOTE_ADDR']; - $log->save(); - - $obj = ['verb' => $verb, 'answers' => $verb->otherParsings()]; - return response()->json($obj); - } - - public function suggest(Request $request) { - $_tenses = Tense::all(); - $tenses = []; - foreach ($_tenses as $tense) - $tenses[] = $tense->name; - - $_stems = Stem::all(); - $stems = []; - foreach ($_stems as $stem) - $stems[] = $stem->name; - - $validator = Validator::make($request->input(), [ - 'verb' => 'required', - 'root' => 'required', - 'stem' => 'in:' . implode(',', $stems), - 'tense' => 'in:' . implode(',', $tenses), - 'person' => 'in:,1,2,3', - 'gender' => 'in:,m,f', - 'number' => 'in:,s,p', - ]); - - if ($validator->fails()) { - return [ - 'success' => false, - 'message' => $validator->errors()->first() - ]; - } - - $verb = new Verb; - $verb->verb = $request->input('verb'); - $verb->root = $request->input('root'); - $verb->stem = $request->input('stem'); - $verb->tense = $request->input('tense'); - $verb->person = $request->input('person') ? $request->input('person') : null; - $verb->gender = $request->input('gender') ? $request->input('gender') : null; - $verb->number = $request->input('number') ? $request->input('number') : null; - $verb->active = 0; - $verb->save(); - - $action = new VerbAction; - $action->kind = VerbAction::KIND_SUGGEST; - $action->user_id = Auth::user()->id; - $action->verb_id = $verb->id; - $action->save(); - - $this->vote(1, $verb->id); - - return [ - 'success' => true, - 'id' => $verb->id, - 'accepted' => $verb->active != 0 - ]; - } - - protected function checkAccept($verb) { - if ($verb->voteCount() < Verb::ACCEPTED_VOTE_COUNT) - return false; - - $verb->active = 1; - $verb->save(); - - if (!is_null($user = $verb->suggestedBy())) { - $ptchange = new PointChange; - $ptchange->kind = PointChange::KIND_SUGGESTION_ACCEPTED; - $ptchange->change = PointChange::POINTS_SUGGESTION_ACCEPTED; - $ptchange->user_id = $user->id; - $ptchange->verb_id = $verb->id; - $ptchange->save(); - - $user->points += PointChange::POINTS_SUGGESTION_ACCEPTED; - $user->save(); - } - - return true; - } - - public function vote($verb_id, $choice) { - $verb = Verb::findOrFail($verb_id); - $user = Auth::user(); - - if ($verb->active) - return ['success' => false, 'message' => 'This verb has been accepted already.']; - - foreach ($verb->actions()->where('kind', VerbAction::KIND_VOTE)->get() as $vote) { - if ($vote->user->id == $user->id) { - $vote->delete(); - } - } - - $vote = new VerbAction; - $vote->user_id = $user->id; - $vote->verb_id = $verb_id; - $vote->kind = VerbAction::KIND_VOTE; - $vote->vote_weight = ($choice == 1 ? 1 : -1) * $user->voteWeight(); - $vote->save(); - - $accepted = $this->checkAccept($verb); - - return [ - 'success' => true, - 'vote_weight' => $user->voteWeight(), - 'accepted' => $accepted, - 'new_vote_count' => $verb->voteCount() - ]; - } - -} diff --git a/app/Mode.php b/app/Mode.php new file mode 100644 index 0000000..f7739fd --- /dev/null +++ b/app/Mode.php @@ -0,0 +1,29 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +namespace HebrewParseTrainer; + +use Illuminate\Database\Eloquent\Model; + +class Mode extends Model { + + protected $table = 'modes'; + public $timestamps = false; + protected $fillable = ['name', 'abbreviation']; + +} diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php deleted file mode 100644 index b5a2421..0000000 --- a/app/Observers/UserObserver.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace App\Observers; - -use Illuminate\Support\Facades\Mail; - -use HebrewParseTrainer\User; - -class UserObserver { - - public function created(User $user) { - Mail::plain('mails.user.create', ['user' => $user], function ($msg) use ($user) { - $msg->subject('Your account'); - $msg->to([$user->email]); - $msg->cc(['info@camilstaps.nl']); - }); - } - -} diff --git a/app/PointChange.php b/app/PointChange.php deleted file mode 100644 index c157b36..0000000 --- a/app/PointChange.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class PointChange extends Model { - - protected $table = 'point_changes'; - public $timestamps = false; - protected $dates = ['date']; - protected $fillable = ['kind', 'change']; - - const KIND_SUGGESTION_ACCEPTED = 1; - const KIND_MANUAL = 3; - - const POINTS_SUGGESTION_ACCEPTED = 2; - -} diff --git a/app/RandomLog.php b/app/RandomLog.php index f0fefb9..8ba2889 100644 --- a/app/RandomLog.php +++ b/app/RandomLog.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/Root.php b/app/Root.php deleted file mode 100644 index 4e5e9df..0000000 --- a/app/Root.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class Root extends Model { - - protected $table = 'roots'; - public $timestamps = false; - protected $fillable = ['root', 'root_kind_id']; - - public function kind() { - return $this->belongsTo('HebrewParseTrainer\RootKind', 'root_kind_id'); - } - - public function verbs() { - return $this->hasMany('HebrewParseTrainer\Verb', 'root', 'root'); - } - -} diff --git a/app/RootKind.php b/app/RootKind.php deleted file mode 100644 index 6c68465..0000000 --- a/app/RootKind.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class RootKind extends Model { - - protected $table = 'root_kinds'; - public $timestamps = false; - protected $fillable = ['strong', 'name']; - -} diff --git a/app/RootTranslation.php b/app/RootTranslation.php deleted file mode 100644 index 120dc5c..0000000 --- a/app/RootTranslation.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class RootTranslation extends Model { - - protected $table = 'root_translations'; - public $timestamps = false; - protected $fillable = ['root', 'translation']; - -} \ No newline at end of file diff --git a/app/Stem.php b/app/Stem.php deleted file mode 100644 index 4616b1e..0000000 --- a/app/Stem.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class Stem extends Model { - - protected $table = 'stems'; - public $timestamps = false; - protected $fillable = ['name']; - -} \ No newline at end of file diff --git a/app/Tense.php b/app/Tense.php index f30e352..b337eff 100644 --- a/app/Tense.php +++ b/app/Tense.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/User.php b/app/User.php deleted file mode 100644 index ca14b40..0000000 --- a/app/User.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Hash; -use Illuminate\Foundation\Auth\User as FoundationUser; - -class User extends FoundationUser { - - protected $table = 'users'; - public $timestamps = false; - protected $fillable = ['email', 'name', 'password', 'isadmin']; - protected $hidden = ['password', 'remember_token']; - - const VOTE_WEIGHT_BASE = 5; - - public function changePoints($kind, $change, $verb = null) { - $change = new PointChange; - $change->user = $this->id; - $change->change = $change; - $change->kind = $kind; - $change->verb = is_null($verb) ? null : $verb->id; - $change->save(); - - $this->points += $change; - $this->save(); - } - - public function voteWeight() { - if ($this->isadmin) - return Verb::ACCEPTED_VOTE_COUNT; - - if ($this->points <= 0) - return 0; - - return floor(log($this->points, self::VOTE_WEIGHT_BASE)); - } - -} diff --git a/app/Verb.php b/app/Verb.php deleted file mode 100644 index 3ff79fc..0000000 --- a/app/Verb.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class Verb extends Model { - - protected $table = 'verbs'; - public $timestamps = false; - protected $fillable = ['verb', 'root', 'stem', 'tense', 'person', 'gender', 'number']; - - const ACCEPTED_VOTE_COUNT = 5; - - public function actions() { - return $this->hasMany('HebrewParseTrainer\VerbAction'); - } - - public function otherParsings() { - return self::where('verb', $this->verb)->get() - ->filter(function($v){return $v->verb === $this->verb;}); - } - - public function voteCount() { - $votes = $this->actions()->where('kind', VerbAction::KIND_VOTE)->get(); - $total = 0; - foreach ($votes as $vote) - $total += $vote->vote_weight; - return $total; - } - - public function userVote(User $user) { - $votes = $this->actions() - ->where('kind', VerbAction::KIND_VOTE) - ->where('user_id', $user->id) - ->get(); - foreach ($votes as $vote) { - return $vote->vote_weight; - } - return 0; - } - - public function suggestedBy() { - $suggs = $this->actions() - ->where('kind', VerbAction::KIND_SUGGEST) - ->get(); - - foreach ($suggs as $sugg) { - return $sugg->user; - } - - return null; - } - -} diff --git a/app/VerbAction.php b/app/VerbAction.php deleted file mode 100644 index 79c8cd0..0000000 --- a/app/VerbAction.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -namespace HebrewParseTrainer; - -use Illuminate\Database\Eloquent\Model; - -class VerbAction extends Model { - - protected $table = 'verb_actions'; - public $timestamps = false; - protected $dates = ['date']; - protected $fillable = ['user_id', 'verb_id', 'kind', 'vote_weight', 'comment_text']; - - const KIND_SUGGEST = 1; - const KIND_VOTE = 2; - - public function verb() { - return $this->belongsTo('HebrewParseTrainer\Verb'); - } - - public function user() { - return $this->belongsTo('HebrewParseTrainer\User'); - } - -} diff --git a/composer.json b/composer.json index 7f8200c..ae6f198 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "hebrewtools/parsetrainer", - "description": "A simple app to practice Hebrew verbs", - "keywords": ["hebrew", "education", "bible"], + "name": "camilstaps/luo-parsetrainer", + "description": "A simple app to practice Ancient Greek verb forms", + "keywords": ["greek", "education"], "license": "GPLv3", "type": "project", "require": { diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php deleted file mode 100644 index e0dc869..0000000 --- a/database/factories/ModelFactory.php +++ /dev/null @@ -1,23 +0,0 @@ -define(App\User::class, function (Faker\Generator $faker) { - static $password; - - return [ - 'name' => $faker->name, - 'email' => $faker->unique()->safeEmail, - 'password' => $password ?: $password = bcrypt('secret'), - 'remember_token' => str_random(10), - ]; -}); diff --git a/database/migrations/2016_01_04_143639_create_modes_table.php b/database/migrations/2016_01_04_143639_create_modes_table.php new file mode 100644 index 0000000..5bb1061 --- /dev/null +++ b/database/migrations/2016_01_04_143639_create_modes_table.php @@ -0,0 +1,48 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateModesTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('modes', function (Blueprint $table) { + $table->increments('id'); + $table->string('name', 24)->unique(); + $table->string('abbreviation', 6)->unique(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('modes'); + } +} diff --git a/database/migrations/2016_01_04_143639_create_stems_table.php b/database/migrations/2016_01_04_143639_create_stems_table.php deleted file mode 100644 index 539aa26..0000000 --- a/database/migrations/2016_01_04_143639_create_stems_table.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class CreateStemsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('stems', function (Blueprint $table) { - $table->increments('id'); - $table->string('name', 24)->unique(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('stems'); - } -} diff --git a/database/migrations/2016_01_04_143647_create_tenses_table.php b/database/migrations/2016_01_04_143647_create_tenses_table.php index 45c361a..9499c43 100644 --- a/database/migrations/2016_01_04_143647_create_tenses_table.php +++ b/database/migrations/2016_01_04_143647_create_tenses_table.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/database/migrations/2016_01_04_143655_create_roots_table.php b/database/migrations/2016_01_04_143655_create_roots_table.php deleted file mode 100644 index 0e6d858..0000000 --- a/database/migrations/2016_01_04_143655_create_roots_table.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class CreateRootsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('roots', function (Blueprint $table) { - $table->increments('id'); - $table->string('root', 24)->collate('utf8_general_ci')->unique(); - $table->boolean('strong'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('roots'); - } -} diff --git a/database/migrations/2016_01_04_143702_create_forms_table.php b/database/migrations/2016_01_04_143702_create_forms_table.php new file mode 100644 index 0000000..4581db7 --- /dev/null +++ b/database/migrations/2016_01_04_143702_create_forms_table.php @@ -0,0 +1,59 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateFormsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('forms', function (Blueprint $table) { + $table->increments('id'); + $table->string('form', 24)->collate('utf8_general_ci'); + $table->string('tense', 24); + $table->string('mode', 24); + $table->enum('voice', ['A','M','P','MP'])->nullable(); + $table->enum('person', [1,2,3])->nullable(); + $table->enum('number', ['sg', 'pl'])->nullable(); + $table->enum('gender', ['M', 'F', 'N'])->nullable(); + $table->enum('case', ['nom', 'gen', 'dat', 'acc'])->nullable(); + + $table->unique(['form', 'tense', 'mode', 'voice', 'person', 'number', 'gender', 'case']); + + $table->foreign('tense')->references('name')->on('tenses'); + $table->foreign('mode')->references('name')->on('modes'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('forms'); + } +} diff --git a/database/migrations/2016_01_04_143702_create_verbs_table.php b/database/migrations/2016_01_04_143702_create_verbs_table.php deleted file mode 100644 index a50c365..0000000 --- a/database/migrations/2016_01_04_143702_create_verbs_table.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class CreateVerbsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('verbs', function (Blueprint $table) { - $table->increments('id'); - $table->string('verb', 24)->collate('utf8_general_ci'); - $table->string('root', 24)->collate('utf8_general_ci'); - $table->string('stem', 24); - $table->string('tense', 24); - $table->enum('person', [1,2,3])->nullable(); - $table->enum('gender', ['m', 'f'])->nullable(); - $table->enum('number', ['s', 'p'])->nullable(); - - $table->unique(['verb', 'root', 'stem', 'tense', 'person', 'gender', 'number']); - - $table->foreign('root')->references('root')->on('roots'); - $table->foreign('stem')->references('name')->on('stems'); - $table->foreign('tense')->references('name')->on('tenses'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('verbs'); - } -} diff --git a/database/migrations/2016_01_04_144049_create_root_translations_table.php b/database/migrations/2016_01_04_144049_create_root_translations_table.php deleted file mode 100644 index 7c060ca..0000000 --- a/database/migrations/2016_01_04_144049_create_root_translations_table.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class CreateRootTranslationsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('root_translations', function (Blueprint $table) { - $table->increments('id'); - $table->string('root', 24)->collate('utf8_general_ci'); - $table->string('translation', 63); - - $table->unique(['root', 'translation']); - - $table->foreign('root')->references('root')->on('roots'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('root_translations'); - } -} diff --git a/database/migrations/2016_05_10_211558_create_random_logs_table.php b/database/migrations/2016_05_10_211558_create_random_logs_table.php index 10a924e..dc7ea0d 100644 --- a/database/migrations/2016_05_10_211558_create_random_logs_table.php +++ b/database/migrations/2016_05_10_211558_create_random_logs_table.php @@ -18,7 +18,7 @@ class CreateRandomLogsTable extends Migration $table->integer('response')->unsigned(); $table->timestamp('created_at'); - $table->foreign('response')->references('id')->on('verbs'); + $table->foreign('response')->references('id')->on('forms'); }); } diff --git a/database/migrations/2016_09_04_081740_create_users_table.php b/database/migrations/2016_09_04_081740_create_users_table.php deleted file mode 100644 index c5586dc..0000000 --- a/database/migrations/2016_09_04_081740_create_users_table.php +++ /dev/null @@ -1,33 +0,0 @@ -increments('id'); - $table->string('email')->unique(); - $table->string('name')->unique(); - $table->string('password'); - $table->integer('points')->default(0); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('users'); - } -} diff --git a/database/migrations/2016_09_04_081754_create_verb_actions_table.php b/database/migrations/2016_09_04_081754_create_verb_actions_table.php deleted file mode 100644 index d7b0f29..0000000 --- a/database/migrations/2016_09_04_081754_create_verb_actions_table.php +++ /dev/null @@ -1,38 +0,0 @@ -increments('id'); - $table->integer('user_id')->unsigned(); - $table->integer('verb_id')->unsigned(); - $table->tinyInteger('kind'); - $table->tinyInteger('vote_weight')->nullable(); - $table->string('comment_text')->nullable(); - $table->timestamp('date')->default(DB::raw('CURRENT_TIMESTAMP')); - - $table->foreign('user_id')->references('id')->on('users'); - $table->foreign('verb_id')->references('id')->on('verbs'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('verb_actions'); - } -} diff --git a/database/migrations/2016_09_04_081811_create_point_changes_table.php b/database/migrations/2016_09_04_081811_create_point_changes_table.php deleted file mode 100644 index 4ade816..0000000 --- a/database/migrations/2016_09_04_081811_create_point_changes_table.php +++ /dev/null @@ -1,37 +0,0 @@ -increments('id'); - $table->integer('user_id')->unsigned(); - $table->integer('verb_id')->unsigned()->nullable(); - $table->tinyInteger('kind')->unsigned(); - $table->integer('change'); - $table->timestamp('date')->default(DB::raw('CURRENT_TIMESTAMP')); - - $table->foreign('user_id')->references('id')->on('users'); - $table->foreign('verb_id')->references('id')->on('verbs'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('point_changes'); - } -} diff --git a/database/migrations/2016_09_04_081924_add_active_to_verbs.php b/database/migrations/2016_09_04_081924_add_active_to_verbs.php deleted file mode 100644 index 79c5993..0000000 --- a/database/migrations/2016_09_04_081924_add_active_to_verbs.php +++ /dev/null @@ -1,31 +0,0 @@ -boolean('active')->default(true); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('verbs', function (Blueprint $table) { - $table->dropColumn('active'); - }); - } -} diff --git a/database/migrations/2016_09_05_215803_create_root_kinds.php b/database/migrations/2016_09_05_215803_create_root_kinds.php deleted file mode 100644 index 2ab1a42..0000000 --- a/database/migrations/2016_09_05_215803_create_root_kinds.php +++ /dev/null @@ -1,45 +0,0 @@ -increments('id'); - $table->boolean('strong'); - $table->string('name')->unique(); - }); - - Schema::table('roots', function (Blueprint $table) { - $table->dropColumn('strong'); - - $table->integer('root_kind_id')->unsigned()->nullable(); - $table->foreign('root_kind_id')->references('id')->on('root_kinds'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('roots', function (Blueprint $table) { - $table->dropForeign(['root_kind_id']); - $table->dropColumn('root_kind_id'); - - $table->boolean('strong')->default(1); - }); - - Schema::drop('root_kinds'); - } -} diff --git a/database/migrations/2016_09_05_230150_add_isadmin_to_users.php b/database/migrations/2016_09_05_230150_add_isadmin_to_users.php deleted file mode 100644 index e548420..0000000 --- a/database/migrations/2016_09_05_230150_add_isadmin_to_users.php +++ /dev/null @@ -1,28 +0,0 @@ -boolean('isadmin')->default(false); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('isadmin'); - }); - } -} diff --git a/database/migrations/2016_09_25_210947_add_remember_token.php b/database/migrations/2016_09_25_210947_add_remember_token.php deleted file mode 100644 index 83f72bd..0000000 --- a/database/migrations/2016_09_25_210947_add_remember_token.php +++ /dev/null @@ -1,32 +0,0 @@ -rememberToken(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('remember_token'); - }); - } -} diff --git a/database/migrations/2016_09_25_230620_create_password_resets_table.php b/database/migrations/2016_09_25_230620_create_password_resets_table.php deleted file mode 100644 index bda733d..0000000 --- a/database/migrations/2016_09_25_230620_create_password_resets_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('email')->index(); - $table->string('token')->index(); - $table->timestamp('created_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('password_resets'); - } -} diff --git a/database/seeds/BasisTableSeeder.php b/database/seeds/BasisTableSeeder.php index d02dfe8..3f933b0 100644 --- a/database/seeds/BasisTableSeeder.php +++ b/database/seeds/BasisTableSeeder.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ use Illuminate\Database\Seeder; use HebrewParseTrainer\RootKind; -use HebrewParseTrainer\Stem; +use HebrewParseTrainer\Mode; use HebrewParseTrainer\Tense; class BasisTableSeeder extends Seeder { @@ -32,35 +32,19 @@ class BasisTableSeeder extends Seeder { */ public function run() { - Stem::create(['name' => 'Qal']); - Stem::create(['name' => 'Niphal']); - Stem::create(['name' => 'Piel']); - Stem::create(['name' => 'Pual']); - Stem::create(['name' => 'Hiphil']); - Stem::create(['name' => 'Hophal']); - Stem::create(['name' => 'Hitpael']); + Tense::create(['name' => 'praesens', 'abbreviation' => 'pr']); + Tense::create(['name' => 'imperfectum', 'abbreviation' => 'impf']); + Tense::create(['name' => 'aoristus', 'abbreviation' => 'aor']); + Tense::create(['name' => 'futurum', 'abbreviation' => 'fut']); + Tense::create(['name' => 'perfectum', 'abbreviation' => 'pf']); + Tense::create(['name' => 'plusquamperfectum', 'abbreviation' => 'pqpf']); - Tense::create(['name' => 'perfect', 'abbreviation' => 'pf']); - Tense::create(['name' => 'imperfect', 'abbreviation' => 'ipf']); - Tense::create(['name' => 'cohortative', 'abbreviation' => 'coh']); - Tense::create(['name' => 'imperative', 'abbreviation' => 'imp']); - Tense::create(['name' => 'jussive', 'abbreviation' => 'ius']); - Tense::create(['name' => 'infinitive construct', 'abbreviation' => 'infcs']); - Tense::create(['name' => 'infinitive absolute', 'abbreviation' => 'infabs']); - Tense::create(['name' => 'participle active', 'abbreviation' => 'pta']); - Tense::create(['name' => 'participle passive', 'abbreviation' => 'ptp']); - - RootKind::create(['strong' => true, 'name' => 'Strong']); - RootKind::create(['strong' => false, 'name' => 'I-Guttural']); - RootKind::create(['strong' => false, 'name' => 'I-Aleph']); - RootKind::create(['strong' => false, 'name' => 'I-Nun']); - RootKind::create(['strong' => false, 'name' => 'I-Waw']); - RootKind::create(['strong' => false, 'name' => 'I-Yod']); - RootKind::create(['strong' => false, 'name' => 'II-Guttural']); - RootKind::create(['strong' => false, 'name' => 'III-He']); - RootKind::create(['strong' => false, 'name' => 'Biconsonantal']); - RootKind::create(['strong' => false, 'name' => 'Geminate']); - RootKind::create(['strong' => false, 'name' => 'Double weak']); + Mode::create(['name' => 'indicativus', 'abbreviation' => 'ind']); + Mode::create(['name' => 'conjunctivus', 'abbreviation' => 'conj']); + Mode::create(['name' => 'optativus', 'abbreviation' => 'opt']); + Mode::create(['name' => 'imperativus', 'abbreviation' => 'imp!']); + Mode::create(['name' => 'participium', 'abbreviation' => 'ptc']); + Mode::create(['name' => 'infinitivus', 'abbreviation' => 'inf']); } } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 7cb8402..c5b6ab0 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,8 +32,7 @@ class DatabaseSeeder extends Seeder Model::unguard(); $this->call('BasisTableSeeder'); - $this->call('RootTableSeeder'); - $this->call('VerbTableSeeder'); + $this->call('FormTableSeeder'); Model::reguard(); } diff --git a/database/seeds/FormTableSeeder.php b/database/seeds/FormTableSeeder.php new file mode 100644 index 0000000..4ddb983 --- /dev/null +++ b/database/seeds/FormTableSeeder.php @@ -0,0 +1,34 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Illuminate\Database\Seeder; +use HebrewParseTrainer\Form; + +class FormTableSeeder extends Seeder { + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Form::create(['form' => 'λύω', 'tense' => 'praesens', 'mode' => 'indicativus', + 'voice' => 'A', 'person' => '1', 'number' => 'sg']); + } +} diff --git a/database/seeds/RootTableSeeder.php b/database/seeds/RootTableSeeder.php deleted file mode 100644 index 7c3b0ea..0000000 --- a/database/seeds/RootTableSeeder.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Seeder; -use HebrewParseTrainer\Root; -use HebrewParseTrainer\RootKind; -use HebrewParseTrainer\RootTranslation; - -class RootTableSeeder extends Seeder { - - protected function add($root, $kind) { - $kind_id = null; - foreach (RootKind::where('name', $kind)->get() as $rootkind) - $kind_id = $rootkind->id; - - if (is_null($kind_id)) - die('Unknown root kind ' . $kind . "\n"); - - Root::create([ - 'root' => $root, - 'root_kind_id' => $kind_id - ]); - } - - /** - * Run the database seeds. - * - * @return void - */ - public function run() - { - $this->add('קטל', 'Strong'); - - RootTranslation::create(['root' => 'קטל', 'translation' => 'kill']); - } - -} diff --git a/database/seeds/VerbTableSeeder.php b/database/seeds/VerbTableSeeder.php deleted file mode 100644 index 89a8094..0000000 --- a/database/seeds/VerbTableSeeder.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -use Illuminate\Database\Seeder; -use HebrewParseTrainer\Verb; - -class VerbTableSeeder extends Seeder { - - /** - * Run the database seeds. - * - * @return void - */ - public function run() - { - Verb::create(['verb' => 'קָטַל', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 3, 'gender' => 'm', 'number' => 's']); - Verb::create(['verb' => 'קָֽטְלָה', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 3, 'gender' => 'f', 'number' => 's']); - Verb::create(['verb' => 'קָטַ֫לְתָּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 2, 'gender' => 'm', 'number' => 's']); - Verb::create(['verb' => 'קָטַלְתְּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 2, 'gender' => 'f', 'number' => 's']); - Verb::create(['verb' => 'קָטַ֫לְתִּי', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 1, 'gender' => 'm', 'number' => 's']); - Verb::create(['verb' => 'קָטַ֫לְתִּי', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 1, 'gender' => 'f', 'number' => 's']); - - Verb::create(['verb' => 'קָֽטְלוּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 3, 'gender' => 'm', 'number' => 'p']); - Verb::create(['verb' => 'קָֽטְלוּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 3, 'gender' => 'f', 'number' => 'p']); - Verb::create(['verb' => 'קְטַלְתֶּם', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 2, 'gender' => 'm', 'number' => 'p']); - Verb::create(['verb' => 'קְטַלְתֶּן', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 2, 'gender' => 'f', 'number' => 'p']); - Verb::create(['verb' => 'קָטַ֫לְנוּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 1, 'gender' => 'm', 'number' => 'p']); - Verb::create(['verb' => 'קָטַ֫לְנוּ', 'root' => 'קטל', 'stem' => 'Qal', - 'tense' => 'perfect', 'person' => 1, 'gender' => 'f', 'number' => 'p']); - } - -} \ No newline at end of file diff --git a/public/css/fonts/EzraSIL.ttf b/public/css/fonts/EzraSIL.ttf deleted file mode 100644 index b135760..0000000 Binary files a/public/css/fonts/EzraSIL.ttf and /dev/null differ diff --git a/public/css/fonts/SBL_grk.ttf b/public/css/fonts/SBL_grk.ttf new file mode 100644 index 0000000..90a807b Binary files /dev/null and b/public/css/fonts/SBL_grk.ttf differ diff --git a/public/css/hebrewparsetrainer.css b/public/css/hebrewparsetrainer.css deleted file mode 100644 index 03c661c..0000000 --- a/public/css/hebrewparsetrainer.css +++ /dev/null @@ -1,77 +0,0 @@ -/** - * HebrewParseTrainer - practice Hebrew verbs - * Copyright (C) 2015 Camil Staps - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -@font-face { - font-family: 'Ezra SIL'; - src: url('fonts/EzraSIL.ttf'); -} - -body { - padding-top: 20px; -} - -.large { - font-size: 150%; -} - -.header { - border-bottom: 1px solid #e5e5e5; - margin-bottom: 30px; -} - -.header h2 a { - color: inherit !important; - text-decoration: none !important; -} - -.suggestions td { - vertical-align: middle !important; -} - -.suggestions td.vote-cell { - width: 30px; -} - -#trainer { - margin-bottom: 70px; -} - -#trainer-404 { - display: none; - padding: 15px; -} - -#trainer-input-fancy { - margin-bottom: 20px; -} - -#trainer-input-help { - display: none; -} - -.hebrew { - direction: rtl; - font-family: 'Ezra SIL', David; -} - -.ltr { - direction: ltr; -} - -.hebrew-large { - font-size: 40px; -} diff --git a/public/css/luoparsetrainer.css b/public/css/luoparsetrainer.css new file mode 100644 index 0000000..e3af912 --- /dev/null +++ b/public/css/luoparsetrainer.css @@ -0,0 +1,77 @@ +/** + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +@font-face { + font-family: 'SBL Greek'; + src: url('fonts/SBL_grk.ttf'); +} + +body { + padding-top: 20px; +} + +.large { + font-size: 150%; +} + +.header { + border-bottom: 1px solid #e5e5e5; + margin-bottom: 30px; +} + +.header h2 a { + color: inherit !important; + text-decoration: none !important; +} + +.suggestions td { + vertical-align: middle !important; +} + +.suggestions td.vote-cell { + width: 30px; +} + +#trainer { + margin-bottom: 70px; +} + +#trainer-404 { + display: none; + padding: 15px; +} + +#trainer-input-fancy { + margin-bottom: 20px; +} + +#trainer-input-fancy button { + margin-bottom: 3px; + min-width: 7em; +} + +#trainer-input-help { + display: none; +} + +.greek { + font-family: 'SBL Greek', 'Palatino Linotype'; +} + +.greek-large { + font-size: 40px; +} diff --git a/public/js/alerts.js b/public/js/alerts.js deleted file mode 100644 index c1763ed..0000000 --- a/public/js/alerts.js +++ /dev/null @@ -1,11 +0,0 @@ -$.fn.addAlert = function (kind, message) { - var box = ''; - - $(this).find('.alerts').append($(box)); -} - -$.fn.clearAlerts = function () { - $(this).find('.alerts').html(''); -} diff --git a/public/js/hebrewparsetrainer.js b/public/js/hebrewparsetrainer.js deleted file mode 100644 index d875a90..0000000 --- a/public/js/hebrewparsetrainer.js +++ /dev/null @@ -1,362 +0,0 @@ -/** - * HebrewParseTrainer - practice Hebrew verbs - * Copyright (C) 2015 Camil Staps - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -$(document).ready(function(){ - // http://stackoverflow.com/a/4399433/1544337 - jQuery.fn.shake = function(intShakes, intDistance, intDuration) { - this.each(function() { - $(this).css("position","relative"); - for (var x=1; x<=intShakes; x++) { - $(this).animate({left:(intDistance*-1)}, (intDuration/intShakes)/4) - .animate({left:intDistance}, (intDuration/intShakes)/2) - .animate({left:0}, (intDuration/intShakes)/4); - } - }); - return this; - }; - - var audio_positive = new Audio('public/audio/positive.wav'); - var audio_negative = new Audio('public/audio/negative.wav'); - - var correct_answers; - var input_count = 0; - var checked = false; - - function stepFancyInput(step) { - $('#trainer-input-fancy').html(''); - var buts = {}; - switch (step) { - case 0: - buts = { 'Q ': 'Qal' - , 'Hip ': 'Hiphil' - , 'Ho ': 'Hophal' - , 'Ni ': 'Niphal' - , 'Pi ': 'Piel' - , 'Pu ': 'Pual' - , 'Hit ': 'Hitpael' - }; break; - case 1: - buts = { 'pf ': 'Pf.' - , 'ipf ': 'Ipf.' - , 'coh ': 'Coh.' - , 'imp ': 'Imp.' - , 'ius ': 'Ius.' - , 'infcs': 'Inf. cs.' - , 'infabs': 'Inf. abs.' - , 'pta ': 'Part. act.' - , 'ptp ': 'Part. pass.' - }; break; - case 2: - buts = { '1': '1', '2': '2', '3': '3', '': 'N/A' }; break; - case 3: - buts = { 'm': 'Masculine', 'f': 'Feminine', '': 'N/A' }; break; - case 4: - buts = { 's': 'Singular', 'p': 'Plural', '': 'N/A' }; break; - } - - for (k in buts) { - var but = $(''); - but.addClass('btn btn-default').attr('role', 'button'); - but.text(buts[k]).val(k); - but.click(function(){ - var ip = $('#trainer-input-'+input_count); - ip.val(ip.val() + $(this).val()).focus(); - if (step < 4) { - stepFancyInput(step + 1); - } else { - var done = checkInput(true); - if ($('#trainer-input-'+input_count).parent().hasClass('has-error')) { - var next = $(''); - next.addClass('btn btn-warning').attr('role', 'button'); - next.click(reloadVerb); - if (done) { - next.text('Next'); - } else { - next.text('Skip'); - } - $('#trainer-input-fancy').html(next); - } - } - }); - - $('#trainer-input-fancy').append(but).append(' '); - } - } - - function addInput() { - input_count++; - var html = "
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
"; - $('#trainer-input-container').append(html); - - $('#trainer-input-'+input_count).keyup(function(e){ - if (e.keyCode == 13) { - if (!checked) { - checked = checkInput(false); - } else { - reloadVerb(); - $(this) - .val('') - .css({backgroundColor:'transparent'}) - .parent().removeClass('has-error has-success'); - checked = false; - } - } else { - $(this) - .css({backgroundColor:'transparent'}) - .parent().removeClass('has-error has-success'); - checked = false; - processInput(); - } - }).focus(); - - stepFancyInput(0); - } - - function removeInputs() { - $('.trainer-input').remove(); - input_count = 0; - } - - function reloadVerb() { - $('#trainer-404').hide(); - $('#trainer-verb').css({color: 'gray'}); - $('#trainer-answer').text(''); - removeInputs(); - - var stems = $('input[name="stem"]:checked').map(function(){return this.value;}); - var tenses = $('input[name="tense"]:checked').map(function(){return this.value;}); - var roots = $('select[name="root"]').val(); - - $.ajax('verb/random/', { - method: 'POST', - data: { - _token: $('#csrf').val(), - stem: $.makeArray(stems).join(), - tense: $.makeArray(tenses).join(), - root: $.makeArray(roots).join() - }, - dataType: 'json', - error: function(jqxhr, status, error) { - $('#trainer-404').fadeIn(); - }, - success: function(data, status, jqxhr) { - $('#trainer-verb').text(data.verb.verb).css({color: 'black'}); - - correct_answers = []; - for (var i in data.answers) { - var answer = { - root: data.answers[i].root, - stem: data.answers[i].stem, - tense: data.answers[i].tense, - person: data.answers[i].person, - gender: data.answers[i].gender, - number: data.answers[i].number - }; - correct_answers.push(answer); - } - - addInput(); - } - }); - } - - var stems = []; - var tenses = []; - var tenses_abbr = []; - - function findStem(stem) { - var stems_ = stems.filter(function(s){return s.toLowerCase().indexOf(stem.toLowerCase()) == 0;}); - if (stems_.length == 1) - return stems_[0]; - } - - function findTense(tense) { - if (tenses.indexOf(tense) != -1) - return tense; - if (tenses_abbr.indexOf(tense) != -1) - return tenses[tenses_abbr.indexOf(tense)]; - } - - function parseAnswer(parsing) { - var persons = ['1', '2', '3', null]; - var genders = ['m', 'f', 'c', null]; - var numbers = ['s', 'p', null]; - - var re = /^\s*(\w+)\s+(\w+)(?:\s+(?:([123])\s*)?([mf])\s*([sp])\s*)?$/; - var match = parsing.match(re); - if (match == null) - return false; - - var stem = findStem(match[1]); - var tense = findTense(match[2]); - var person = match[3] ? match[3] : null; - var gender = match[4] ? match[4] : null; - var number = match[5] ? match[5] : null; - - if (typeof stem === 'undefined' || typeof tense === 'undefined' || $.inArray(person, persons) == -1 || - $.inArray(gender, genders) == -1 || $.inArray(number, numbers) == -1) - return false; - - if (tense.indexOf('infinitive') == 0 && (person != null || gender != null || number != null)) - return false; - if (tense.indexOf('infinitive') != 0) { - if (gender == null || number == null) - return false; - if (tense.indexOf('participle') == 0 && person != null) - return false; - if (tense.indexOf('participle') != 0 && person == null) - return false; - } - - return { - stem: stem, - tense: tense, - person: person, - gender: gender, - number: number - }; - } - - function parsingToString(parsing, extended) { - var genders = { - 'm': 'masculine', - 'f': 'feminine' - }; - var numbers = { - 's': 'singular', - 'p': 'plural' - }; - - var prs = parsing.stem + ' ' + parsing.tense + - (parsing.person ? (' ' + parsing.person) : ''); - - if (extended === true) { - prs += (parsing.gender ? (' ' + genders[parsing.gender]) : '') + - (parsing.number ? (' ' + numbers[parsing.number]) : ''); - } else { - prs += (parsing.gender ? (' ' + parsing.gender) : '') + - (parsing.number ? (' ' + parsing.number) : ''); - } - - if ('root' in parsing) - prs += ' ' + parsing.root; - - return prs; - } - - function processInput() { - var input = $('#trainer-input-' + input_count); - var answer = parseAnswer(input.val()); - if (answer === false) { - input.parent().addClass('has-error'); - $('#trainer-parsed-' + input_count).val( - input.val().length < 8 ? 'Input full parsing...' : 'Parsing error'); - } else { - input.parent().removeClass('has-error'); - $('#trainer-parsed-' + input_count).val(parsingToString(answer, true)); - } - return answer; - } - - function checkInput(reload) { - var answer = processInput(); - if (!answer && $('#trainer-input-'+input_count).val() != '') { - $('#trainer-input-'+input_count).shake(2, 12, 300); - return false; - } - - for (var i in correct_answers) { - var correct_answer = correct_answers[i]; - var root = correct_answer['root']; - delete correct_answer['root']; - var json = JSON.stringify(correct_answer); - correct_answer['root'] = root; - if (JSON.stringify(answer) == json) { - $('#trainer-input-'+input_count) - .css({backgroundColor: '#dff0d8'}) - .parent().addClass('has-success'); - if ($('#settings-audio').prop('checked')) audio_positive.play(); - - correct_answers.splice(i,1); - if (correct_answers.length > 0) { - addInput(); - return false; - } else { - if (reload === true) { - window.setTimeout(reloadVerb, 600); - } - return true; - } - } - } - - $('#trainer-input-'+input_count) - .css({backgroundColor: '#f2dede'}) - .parent().addClass('has-error'); - if ($('#settings-audio').prop('checked')) audio_negative.play(); - $('#trainer-answer').text(' - ' + correct_answers.map(parsingToString).join(', ')); - - return true; - } - - function init() { - $.ajax('stem/', { - dataType: 'json', - success: function(data, status, jqxhr) { - stems = data.map(function(d){return d.name;}); - } - }); - - $.ajax('tense/', { - dataType: 'json', - success: function(data, status, jqxhr) { - tenses = data.map(function(d){return d.name;}); - tenses_abbr = data.map(function(d){return d.abbreviation;}); - } - }); - - if (typeof reload_on_load != 'undefined' && reload_on_load) - reloadVerb(); - } - - $('#hebrewparsetrainer-settings .reload-verb').change(function(){ - reloadVerb(); - }); - - var help_shown = false; - $('#show-hide-help').click(function(){ - help_shown = !help_shown; - $('#trainer-input-help').slideToggle(); - $(this).text((help_shown ? 'Hide' : 'Show') + ' help'); - $('#trainer-input-'+input_count).focus(); - }); - - init(); -}); diff --git a/public/js/luoparsetrainer.js b/public/js/luoparsetrainer.js new file mode 100644 index 0000000..11394e4 --- /dev/null +++ b/public/js/luoparsetrainer.js @@ -0,0 +1,436 @@ +/** + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +$(document).ready(function(){ + // http://stackoverflow.com/a/4399433/1544337 + jQuery.fn.shake = function(intShakes, intDistance, intDuration) { + this.each(function() { + $(this).css("position","relative"); + for (var x=1; x<=intShakes; x++) { + $(this).animate({left:(intDistance*-1)}, (intDuration/intShakes)/4) + .animate({left:intDistance}, (intDuration/intShakes)/2) + .animate({left:0}, (intDuration/intShakes)/4); + } + }); + return this; + }; + + var audio_positive = new Audio('public/audio/positive.wav'); + var audio_negative = new Audio('public/audio/negative.wav'); + + var correct_answers; + var input_count = 0; + var checked = false; + + function stepFancyInput(step, val) { + $('#trainer-input-fancy').html(''); + var buts = {}; + switch (step) { + case 0: + buts = { 'pr ': 'Praesens' + , 'impf ': 'Imperfectum' + , 'aor ': 'Aoristus' + , 'fut ': 'Futurum' + , 'pf ': 'Perfectum' + , 'pqpf ': 'Plusquamperfectum' + }; break; + case 1: + buts = { 'ind ': 'Indicativus' + , 'conj ': 'Conjunctivus' + , 'opt ': 'Optativus' + , 'imp! ': 'Imperativus' + , 'ptc ': 'Participium' + , 'inf ': 'Infinitivus' + }; break; + case 2: + buts = { 'A ': 'Activum' + , 'M ': 'Medium' + , 'P ': 'Passivum' + , 'MP ': 'Medio-passivum' + }; break; + case 3: + if (val.match(/ inf /)) { + /* no buttons */ + } else if (val.match(/ ptc /)) { + buts = { + 'M nom ev': 'M nom ev', + 'F nom ev': 'F nom ev', + 'N nom ev': 'N nom ev', + 'M gen ev': 'M gen ev', + 'F gen ev': 'F gen ev', + 'N gen ev': 'N gen ev', + 'M dat ev': 'M dat ev', + 'F dat ev': 'F dat ev', + 'N dat ev': 'N dat ev', + 'M acc ev': 'M acc ev', + 'N acc ev': 'N acc ev', + 'F acc ev': 'F acc ev', + 'M nom mv': 'M nom mv', + 'F nom mv': 'F nom mv', + 'N nom mv': 'N nom mv', + 'M gen mv': 'M gen mv', + 'F gen mv': 'F gen mv', + 'N gen mv': 'N gen mv', + 'M dat mv': 'M dat mv', + 'F dat mv': 'F dat mv', + 'N dat mv': 'N dat mv', + 'M acc mv': 'M acc mv', + 'F acc mv': 'F acc mv', + 'N acc mv': 'N acc mv' + }; + } else { + buts = { + '1 ev': '1 ev', + '2 ev': '2 ev', + '3 ev': '3 ev', + '1 mv': '1 mv', + '2 mv': '2 mv', + '3 mv': '3 mv', + }; + } + break; + } + + var input_field = $('#trainer-input-fancy'); + + var i = 0; + for (k in buts) { + var but = $(''); + but.addClass('btn btn-default').attr('role', 'button'); + but.text(buts[k]).val(k); + but.click(function(){ + var ip = $('#trainer-input-'+input_count); + ip.val(ip.val() + $(this).val()).focus(); + if (step < 3) { + stepFancyInput(step + 1, ip.val()); + } else { + var done = checkInput(true); + if ($('#trainer-input-'+input_count).parent().hasClass('has-error')) { + var next = $(''); + next.addClass('btn btn-warning').attr('role', 'button'); + next.click(reloadVerb); + if (done) { + next.text('Next'); + } else { + next.text('Skip'); + } + $('#trainer-input-fancy').html(next); + } + } + }); + + input_field.append(but).append(' '); + + if (Object.keys(buts).length > 6 && !(++i % 3)) + input_field.append($('
')); + } + } + + function addInput() { + input_count++; + var html = "
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
"; + $('#trainer-input-container').append(html); + + $('#trainer-input-'+input_count).keyup(function(e){ + if (e.keyCode == 13) { + if (!checked) { + checked = checkInput(false); + } else { + reloadVerb(); + $(this) + .val('') + .css({backgroundColor:'transparent'}) + .parent().removeClass('has-error has-success'); + checked = false; + } + } else { + $(this) + .css({backgroundColor:'transparent'}) + .parent().removeClass('has-error has-success'); + checked = false; + processInput(); + } + }).focus(); + + stepFancyInput(0); + } + + function removeInputs() { + $('.trainer-input').remove(); + input_count = 0; + } + + function reloadVerb() { + $('#trainer-404').hide(); + $('#trainer-verb').css({color: 'gray'}); + $('#trainer-answer').text(''); + removeInputs(); + + var modes = $('input[name="mode"]:checked').map(function(){return this.value;}); + var tenses = $('input[name="tense"]:checked').map(function(){return this.value;}); + + $.ajax('form/random/', { + method: 'POST', + data: { + _token: $('#csrf').val(), + mode: $.makeArray(modes).join(), + tense: $.makeArray(tenses).join() + }, + dataType: 'json', + error: function(jqxhr, status, error) { + $('#trainer-404').fadeIn(); + }, + success: function(data, status, jqxhr) { + $('#trainer-verb').text(data.form.form).css({color: 'black'}); + + correct_answers = []; + for (var i in data.answers) { + var answer = { + tense: data.answers[i].tense, + mode: data.answers[i].mode, + voice: data.answers[i].voice, + person: data.answers[i].person, + gender: data.answers[i].gender, + number: data.answers[i].number, + case_: data.answers[i]['case'] + }; + correct_answers.push(answer); + } + + addInput(); + } + }); + } + + var modes = []; + var tenses = []; + var tenses_abbr = []; + + function findTense(tense) { + switch (tense) { + case 'pr': return 'praesens'; + case 'impf': return 'imperfectum'; + case 'aor': return 'aoristus'; + case 'fut': return 'futurum'; + case 'pf': return 'perfectum'; + case 'pqpf': return 'plusquamperfectum'; + default: return undefined; + } + } + + function findMode(mode) { + switch (mode) { + case 'ind': return 'indicativus'; + case 'conj': return 'conjunctivus'; + case 'opt': return 'optativus'; + case 'imp!': return 'imperativus'; + default: return undefined; + } + } + + function parseAnswer(parsing) { + var match = parsing.match(/^\s*(pr|impf|aor|fut|pf|pqpf)\s+(ind|conj|opt|imp!)\s+(A|M|P|MP)\s+([123])\s*([em]v)\s*$/); + if (match) { + var tense = findTense(match[1]); + var mode = findMode(match[2]); + + if (typeof tense=='undefined' || typeof mode=='undefined') + return false; + + return { + tense: tense, + mode: mode, + voice: match[3], + person: match[4], + gender: null, + number: match[5] == 'ev' ? 'sg' : 'pl', + case_: null + }; + } + + match = parsing.match(/^\s*(pr|impf|aor|fut|pf|pqpf)\s+ptc\s+(A|M|P|MP)\s+([MFN])\s+(nom|gen|dat|acc)\s+([em]v)\s*$/); + if (match) { + var tense = findTense(match[1]); + + if (typeof tense=='undefined') + return false; + + return { + tense: tense, + mode: 'participium', + voice: match[2], + person: null, + gender: match[3], + number: match[5] == 'ev' ? 'sg' : 'pl', + case_: match[4] + }; + } + + match = parsing.match(/^\s*(pr|impf|aor|fut|pf|pqpf)\s+inf\s+(A|M|P|MP)\s*$/); + if (match) { + var tense = findTense(match[1]); + + if (typeof tense=='undefined') + return false; + + return { + tense: tense, + mode: 'infinitivus', + voice: match[2], + person: null, + gender: null, + number: null, + case_: null + }; + } + + return false; + } + + function abbreviate(term) { + switch (term) { + case 'praesens': return 'pr'; + case 'imperfectum': return 'impf'; + case 'aoristus': return 'aor'; + case 'futurum': return 'fut'; + case 'perfectum': return 'pf'; + case 'plusquamperfectum': return 'pqpf'; + case 'indicativus': return 'ind'; + case 'conjunctivus': return 'conj'; + case 'optativus': return 'opt'; + case 'imperativus': return 'imp!'; + case 'participium': return 'ptc'; + case 'infinitivus': return 'inf'; + default: return term; + } + } + + function parsingToString(parsing, abbr) { + var tense = abbr === true ? abbreviate(parsing.tense) : parsing.tense; + var mode = abbr === true ? abbreviate(parsing.mode) : parsing.mode; + var number = parsing.number == 'sg' ? 'ev' : 'mv'; + var tense_mode_voice = [tense, mode, parsing.voice].join(' '); + + switch (parsing.mode) { + case 'infinitivus': + return tense_mode_voice; + case 'participium': + return [tense_mode_voice, parsing.gender, parsing.case_, number].join(' '); + default: + return [tense_mode_voice, parsing.person, number].join(' '); + } + } + + function processInput() { + var input = $('#trainer-input-' + input_count); + var answer = parseAnswer(input.val()); + if (answer === false) { + input.parent().addClass('has-error'); + $('#trainer-parsed-' + input_count).val( + input.val().length < 10 ? 'Vul een volledige parsering in...' : 'Incorrecte invoer'); + } else { + input.parent().removeClass('has-error'); + $('#trainer-parsed-' + input_count).val(parsingToString(answer, true)); + } + return answer; + } + + function checkInput(reload) { + var answer = processInput(); + if (!answer && $('#trainer-input-'+input_count).val() != '') { + $('#trainer-input-'+input_count).shake(2, 12, 300); + return false; + } + + for (var i in correct_answers) { + var correct_answer = correct_answers[i]; + var json = JSON.stringify(correct_answer); + if (JSON.stringify(answer) == json) { + $('#trainer-input-'+input_count) + .css({backgroundColor: '#dff0d8'}) + .parent().addClass('has-success'); + if ($('#settings-audio').prop('checked')) audio_positive.play(); + + correct_answers.splice(i,1); + if (correct_answers.length > 0) { + addInput(); + return false; + } else { + if (reload === true) { + window.setTimeout(reloadVerb, 600); + } + return true; + } + } + } + + $('#trainer-input-'+input_count) + .css({backgroundColor: '#f2dede'}) + .parent().addClass('has-error'); + if ($('#settings-audio').prop('checked')) audio_negative.play(); + $('#trainer-answer').text(' - ' + correct_answers.map(parsingToString).join(', ')); + + return true; + } + + function init() { + $.ajax('mode/', { + dataType: 'json', + success: function(data, status, jqxhr) { + modes = data.map(function(d){return d.name;}); + } + }); + + $.ajax('tense/', { + dataType: 'json', + success: function(data, status, jqxhr) { + tenses = data.map(function(d){return d.name;}); + tenses_abbr = data.map(function(d){return d.abbreviation;}); + } + }); + + if (typeof reload_on_load != 'undefined' && reload_on_load) + reloadVerb(); + } + + $('#luoparsetrainer-settings .reload-verb').change(function(){ + reloadVerb(); + }); + + var help_shown = false; + $('#show-hide-help').click(function(){ + help_shown = !help_shown; + $('#trainer-input-help').slideToggle(); + $(this).text((help_shown ? 'Hide' : 'Show') + ' help'); + $('#trainer-input-'+input_count).focus(); + }); + + init(); +}); diff --git a/public/js/moderators.js b/public/js/moderators.js deleted file mode 100644 index 36ec3ed..0000000 --- a/public/js/moderators.js +++ /dev/null @@ -1,118 +0,0 @@ -/** - * HebrewParseTrainer - practice Hebrew verbs - * Copyright (C) 2015 Camil Staps - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -$(document).ready(function(){ - $('.vote').click(function(){ - var vote = parseInt($(this).data('vote')); - var verbId = $(this).data('verb'); - - var container = $(this).closest('tr'); - - var fail = function(msg) { - alert('Voting failed with the message: "' + msg + '". Please try again.'); - } - - $.ajax({ - url: app_url + 'verb/' + verbId + '/vote/' + vote, - error: function(jqxhr, stat, error) { - fail(stat); - }, - success: function(data) { - if (!data.success) { - fail(data.message); - return; - } - - var btns = container.find('.vote'); - if (vote) { - $(btns[0]).removeClass('btn-danger'); - $(btns[0]).addClass('btn-default'); - $(btns[1]).addClass('btn-success'); - $(btns[1]).removeClass('btn-default'); - } else { - $(btns[0]).addClass('btn-danger'); - $(btns[0]).removeClass('btn-default'); - $(btns[1]).removeClass('btn-success'); - $(btns[1]).addClass('btn-default'); - } - - container.find('.vote-count').text(data.new_vote_count); - - if (data.accepted) { - alert('This verb has now been accepted!'); - container.remove(); - } - } - }); - - return true; - }); - - $('form#suggest').submit(function(){ - var form = $(this); - - form.clearAlerts(); - - $.ajax({ - url: app_url + 'verb/suggest', - method: 'post', - data: form.serialize(), - error: function(jqxhr, stat, error) { - form.addAlert('danger', stat); - }, - success: function(data) { - if (!data.success) { - form.addAlert('danger', data.message); - return; - } - - if (data.accepted) { - form.addAlert('success', 'The new verb has been accepted immediately.'); - } else { - form.addAlert('success', 'The new verb has been proposed for peer review.'); - } - } - }); - - return false; - }); - - $('form#add-root').submit(function(){ - var form = $(this); - - form.clearAlerts(); - - $.ajax({ - url: app_url + 'root/create', - method: 'post', - data: form.serialize(), - error: function(jqxhr, stat, error) { - form.addAlert('danger', stat); - }, - success: function(data) { - if (!data.success) { - form.addAlert('danger', data.message); - return; - } - - window.location = window.location; - } - }); - - return false; - }); -}); diff --git a/resources/views/add_root.blade.php b/resources/views/add_root.blade.php deleted file mode 100644 index 107eb16..0000000 --- a/resources/views/add_root.blade.php +++ /dev/null @@ -1,29 +0,0 @@ - -
-
-

Add a new root

-
-
-
- -
-
- - -
-
- - -
-
- -
-
-
-
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php deleted file mode 100644 index 2070f2b..0000000 --- a/resources/views/auth/login.blade.php +++ /dev/null @@ -1,68 +0,0 @@ -@extends('layouts.master') - -@section('master-content') -
-
-
-
-
Login
-
-
- {{ csrf_field() }} - -
- - -
- - - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('password')) - - {{ $errors->first('password') }} - - @endif -
-
- -
-
-
- -
-
-
- -
-
- - - - Forgot Your Password? - -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php deleted file mode 100644 index 62e0120..0000000 --- a/resources/views/auth/passwords/email.blade.php +++ /dev/null @@ -1,47 +0,0 @@ -@extends('layouts.master') - - -@section('master-content') -
-
-
-
-
Reset Password
-
- @if (session('status')) -
- {{ session('status') }} -
- @endif - -
- {{ csrf_field() }} - -
- - -
- - - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
-
- -
-
- -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php deleted file mode 100644 index deb4d56..0000000 --- a/resources/views/auth/passwords/reset.blade.php +++ /dev/null @@ -1,70 +0,0 @@ -@extends('layouts.master') - -@section('master-content') -
-
-
-
-
Reset Password
- -
-
- {{ csrf_field() }} - - - -
- - -
- - - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('password')) - - {{ $errors->first('password') }} - - @endif -
-
- -
- -
- - - @if ($errors->has('password_confirmation')) - - {{ $errors->first('password_confirmation') }} - - @endif -
-
- -
-
- -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php deleted file mode 100644 index c4f9009..0000000 --- a/resources/views/auth/register.blade.php +++ /dev/null @@ -1,82 +0,0 @@ -@extends('layouts.master') - -@section('master-content') -
-
-
-
-
Register
-
-
- {{ csrf_field() }} - -
- - -
- - - @if ($errors->has('name')) - - {{ $errors->first('name') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('password')) - - {{ $errors->first('password') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('password_confirmation')) - - {{ $errors->first('password_confirmation') }} - - @endif -
-
- -
-
- -
-
-
-
-
-
-
-
-@endsection diff --git a/resources/views/contribute.blade.php b/resources/views/contribute.blade.php deleted file mode 100644 index 86473de..0000000 --- a/resources/views/contribute.blade.php +++ /dev/null @@ -1,53 +0,0 @@ - -@extends('layouts.master') - -@section('master-content') -

- Thank you for wanting to help out! To expand our database, we are looking for volunteers to enter more verbs. -

- -@if(!Auth::check()) - Login - Sign up -@endif - -

Here's how it works:

- -
    -
  • Any user can suggest new verbs.
  • -
  • These have to be peer-reviewed by other contributors.
  • -
  • It has to get {{ Verb::ACCEPTED_VOTE_COUNT }} votes to be accepted.
  • -
  • Contributors earn points for all accepted verbs they suggested.
  • -
  • The vote weight is dependent on the number of points a user has.
  • -
- -

- If you have any questions, please write me at info@camilstaps.nl. -

- -@if(Auth::check()) -
-
-
- @include('suggestions') -
-
- @include('suggest') -
-
- @include('add_root') -
-
- -
- -
-
- @include('user.top') -
-
-@endif - -@endsection diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php index 6a472e3..faf8aa2 100644 --- a/resources/views/layouts/master.blade.php +++ b/resources/views/layouts/master.blade.php @@ -1,7 +1,7 @@ - ['/', ''], -]; - -if (Auth::check()) { - $menu['Contribute'] = ['contribute', 'contribute']; - $menu['Statistics'] = ['stats', 'stats']; -} -?> @@ -38,7 +24,7 @@ if (Auth::check()) { ParseTrainer - + - - - @if(Auth::check()) - - - - @endif + diff --git a/resources/views/mails/user/create.blade.php b/resources/views/mails/user/create.blade.php deleted file mode 100644 index 4094dfd..0000000 --- a/resources/views/mails/user/create.blade.php +++ /dev/null @@ -1,13 +0,0 @@ -Dear {{ $user->name }}, - -Thank you for creating an account at the Hebrew Parse Trainer. - -You can now login at {{ URL::to('/contribute?login=yes') }}, using your email address and password. - -If you need any help, you can reach us at {{ env('MAIL_FROM_ADDRESS') }}. - -Thank you for your help! - -Best, - -{{ env('MAIL_FROM_NAME') }} diff --git a/resources/views/shared/already_logged_in.blade.php b/resources/views/shared/already_logged_in.blade.php deleted file mode 100644 index 37725fa..0000000 --- a/resources/views/shared/already_logged_in.blade.php +++ /dev/null @@ -1 +0,0 @@ -You are already logged in. diff --git a/resources/views/shared/messages.blade.php b/resources/views/shared/messages.blade.php deleted file mode 100644 index 67feae5..0000000 --- a/resources/views/shared/messages.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@if(isset($messages)) -@foreach($messages as $message) - -@endforeach -@endif diff --git a/resources/views/stats.blade.php b/resources/views/stats.blade.php deleted file mode 100644 index eb4205f..0000000 --- a/resources/views/stats.blade.php +++ /dev/null @@ -1,134 +0,0 @@ -groupBy(DB::raw('DATE(created_at)')) - ->orderBy('created_at') - ->get(); - -$stats['requests'] = []; -$last_date = null; -foreach ($db_stats as $stat) { - $date = strtotime($stat->created_at); - while ($last_date != null && $last_date + 86400 < $date) { - $last_date += 86400; - $stats['requests'][] = "[Date.UTC" . date("(Y,n-1,j)", $last_date) . ",0]"; - } - $stats['requests'][] = "[Date.UTC" . date("(Y,n-1,j)", $date) . "," . $stat->count . "]"; - $last_date = $date; -} -$stats['requests'] = "[" . implode(",", $stats['requests']) . "]"; - -$db_stats = RandomLog - ::select( - DB::raw('COUNT(DISTINCT `ip`) as count'), - DB::raw('DATE(created_at) as created_at')) - ->groupBy(DB::raw('DATE(created_at)')) - ->orderBy('created_at') - ->get(); - -$stats['unique-ips'] = []; -$last_date = null; -foreach ($db_stats as $stat) { - $date = strtotime($stat->created_at); - while ($last_date != null && $last_date + 86400 < $date) { - $last_date += 86400; - $stats['unique-ips'][] = "[Date.UTC" . date("(Y,n-1,j)", $last_date) . ",0]"; - } - $stats['unique-ips'][] = "[Date.UTC" . date("(Y,n-1,j)", $date) . "," . $stat->count . "]"; - $last_date = $date; -} -$stats['unique-ips'] = "[" . implode(",", $stats['unique-ips']) . "]"; -?> - -@extends('layouts.master') - -@section('master-content') -
-
-
-
-

Random verb requests

-
-
-
-
-
-
-
- - - - - - - -@endsection diff --git a/resources/views/suggest.blade.php b/resources/views/suggest.blade.php deleted file mode 100644 index 1e5c424..0000000 --- a/resources/views/suggest.blade.php +++ /dev/null @@ -1,89 +0,0 @@ - -
-
-

Suggest a new verb

-
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
diff --git a/resources/views/suggestions.blade.php b/resources/views/suggestions.blade.php deleted file mode 100644 index 68ad049..0000000 --- a/resources/views/suggestions.blade.php +++ /dev/null @@ -1,43 +0,0 @@ -orderBy('root') - ->orderBy('stem', 'desc') - ->orderBy('tense', 'desc') - ->orderBy('number') - ->orderBy('person', 'desc') - ->orderBy('gender') - ->get(); -?> -
-
-

Current suggestions

-
-
- - - - - - - - - - - @forelse($suggestions as $verb) - - - - - - - - - @empty - - @endforelse - -
VerbRootParsingVotes
{{ $verb->verb }}{{ $verb->root }}{{ $verb->stem }} {{ $verb->tense }} {{ $verb->person }}{{ $verb->gender }}{{ $verb->number }}{{ $verb->voteCount() }}
There are no active suggestions. Why not add a verb yourself?
-
-
diff --git a/resources/views/trainer.blade.php b/resources/views/trainer.blade.php index ea0c141..c73dcd3 100644 --- a/resources/views/trainer.blade.php +++ b/resources/views/trainer.blade.php @@ -1,26 +1,17 @@ @extends('layouts.with_sidebar') @section('sidebar') -
+
-

Stems

- @foreach (Stem::all() as $stem) -
- -
- @endforeach -
- -
-

Tenses

+

Tempora

@foreach (Tense::all() as $tense)
@@ -29,14 +20,12 @@ use HebrewParseTrainer\Tense;
-

Roots

- {{{ $mode->name }}} +
@endforeach -
@@ -52,39 +41,30 @@ use HebrewParseTrainer\Tense;

There are no verbs matching the criteria in our database.

-

+

-

Parse the verb and enter the answer as described below. Press return. If your answer was correct and there are multiple possible parsings, an extra input field will appear. After the first incorrect answer or after entering all possible answers, you can continue to the next verb by pressing return once more.

- Stems: either use the full name or a significant beginning (i.e. Q for Qal but Pi for Piel rather than P).
- Tenses: use the abbreviations pf, ipf, coh, imp, jus, infcs, infabs, pta and ptp.
- Person: 1, 2, 3 or none (infinitives and participles).
- Gender: m, f or none (infinitives).
- Number: s, p or none (infinitives). + Parseer de werkwoordsvorm en vul het antwoord in, gevolgd door Enter. + Als het antwoord correct is en er meerdere mogelijke antwoorden zijn, verschijnt er een extra invoerveld. + Na het eerste incorrecte antwoord, of als alle mogelijkheden zijn gegeven, kun je door naar de volgende vorm met Enter.

-

Examples: Q pf 3ms, ni pta fp, pi infabs.

-

You can also use the buttons to enter your answer. This is an experimental feature.

-
- -
-
- -
- -
-
-
-
-

About

-
-
-

© 2015–{!! date('y') !!} Camil Staps. Licensed under GPL 3.0. Source is on GitHub.

-

Please report any mistakes to info@camilstaps.nl.

-
+

+ Tempora (tijden): gebruik de afkortingen pr(aesens), imp(er)f(ectum), aor(istus), fut(urum), p(er)f(ectum) en p(lus)q(uam)p(er)f(ectum).
+ Modi (wijzen): ind(icativus), conj(unctivus), opt(ativus), imp!(erativus), p(ar)t(i)c(ipium), inf(initivus).
+ Genera: A(ctivum), M(edium), P(assivum), M(edio-)P(assivum).
+ Persoon (indien van toepassing): 1, 2 of 3.
+ Geslacht (indien van toepassing): M(asculinum), F(eminimum), N(eutrum).
+ Naamval (indien van toepassing): nom(inativus), gen(itivus), dat(ivus), acc(usativus).
+ Getal (indien van toepassing): e(nkel)v(oud) of m(eer)v(oud). +

+

Voorbeelden: pr ind A 1 ev, fut inf M, pqpf ptc P M nom ev.

+

Je kunt ook de knoppen gebruiken om een vorm te parseren.

+

© 2015–{!! date('y') !!} Camil Staps. Gelicenseerd onder GPL 3.0. De broncode staat op git.camilstaps.nl/luo-parsetrainer.git.

+
diff --git a/resources/views/user/create.blade.php b/resources/views/user/create.blade.php deleted file mode 100644 index b823451..0000000 --- a/resources/views/user/create.blade.php +++ /dev/null @@ -1,32 +0,0 @@ -@extends('layouts.master') - -@section('master-content') - -@if(Auth::check()) - @include('shared.already_logged_in') -@else - @include('shared.messages') - - -
- - - You will not receive any automated email from us, but we like to have some way of contacting you available. Your email address will not be shared with third parties, and will not be visible to users of the website. -
-
- - - Your name as shown on the site. -
-
- - -
-
- -
- - -@endif - -@endsection diff --git a/resources/views/user/top.blade.php b/resources/views/user/top.blade.php deleted file mode 100644 index eeeafde..0000000 --- a/resources/views/user/top.blade.php +++ /dev/null @@ -1,39 +0,0 @@ -orderBy('points', 'desc') - ->take(3) - ->get(); -?> -@if(count($users) > 0) -
-
-

Top contributors

-
-
- - - - - - - - - - @foreach($users as $user) - - - - - - @endforeach - -
NamePoints
{{{ $user->name }}}{{{ $user->points }}}
- - @if(Auth::check()) -

You have {{ Auth::user()->points }} points.

- @endif -
-
-@endif diff --git a/routes/web.php b/routes/web.php index a4d1007..58e592f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,7 @@ + * Luo Parse Trainer - practice Ancient Greek verb forms + * Copyright (C) 2015-present Camil Staps * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,35 +28,15 @@ Route::group( }); Route::get('/stem', function () { - return \HebrewParseTrainer\Stem::all(); + return \HebrewParseTrainer\Mode::all(); }); Route::get('/tense', function () { return \HebrewParseTrainer\Tense::all(); }); - Route::post('/verb/random', - '\App\Http\Controllers\VerbController@random'); - - Route::get('/contribute', function () { - return view('contribute'); - }); - - Route::group(['middleware' => 'auth'], function () { - Route::get('/stats', function () { - return view('stats'); - }); - - Route::get('/verb/{id}/vote/{choice}', - '\App\Http\Controllers\VerbController@vote'); - - Route::post('/verb/suggest', - '\App\Http\Controllers\VerbController@suggest'); - - Route::post('/root/create', - '\App\Http\Controllers\RootController@create'); - - }); + Route::post('/form/random', + '\App\Http\Controllers\FormController@random'); }); diff --git a/tools/import_etcbc.py b/tools/import_etcbc.py deleted file mode 100755 index 4d752e7..0000000 --- a/tools/import_etcbc.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python3 - -from tf.fabric import Fabric -import csv -import re - -VERB_STARTID=13 -ROOT_STARTID=2 - -STEMS = { - 'qal': 'Qal', - 'hif': 'Hiphil', - 'piel': 'Piel', - 'nif': 'Niphal', - 'hit': 'Hitpael', - 'pual': 'Pual', - 'hof': 'Hophal' - } - -TENSES = { - 'perf': 'perfect', - 'impf': 'imperfect', - #'wayq': 'wayyiqtol', - 'ptca': 'participle active', - 'infc': 'infinitive construct', - 'impv': 'imperative', - 'ptcp': 'participle passive', - 'infa': 'infinitive absolute' - } - -PERSONS = {'p1': 1, 'p2': 2, 'p3': 3, 'unknown': None} -GENDERS = {'m': 'm', 'f': 'f', 'unkown': None} -NUMBERS = {'sg': 's', 'pl': 'p', 'unknown': None} - -class Root: - def __init__(self, n): - self.lex = F.lex_utf8.v(n) - - def __eq__(self, other): - return self.lex == other.lex - - def __hash__(self): - return hash(self.lex) - -class Verb: - def __init__(self, n): - self.n = n - verb = F.g_word_utf8.v(n) - if verb is None or '\u05c3' in verb or '\u05be' in verb: - raise ValueError('no text, sof pasuq or maqaf') - # strip accents - self.verb = re.sub(r'[^\u05b0-\u05bc\u05c1\u05c2\u05c7-\u05ea]', '', verb) - self.root = F.lex_utf8.v(n) - self.stem = STEMS[F.vs.v(n)] - self.tense = TENSES[F.vt.v(n)] - self.person = PERSONS[F.ps.v(n)] - self.gender = GENDERS[F.gn.v(n)] - self.number = NUMBERS[F.nu.v(n)] - self.loc = T.sectionFromNode(n) - - def unpointed_word(self): - return re.sub(r'[^\u05d0-\u05ea]', '', self.verb) - - def __eq__(self, other): - return self.unpointed_word() == other.unpointed_word() and \ - self.root == other.root and \ - self.stem == other.stem and \ - self.tense == other.tense and \ - self.person == other.person and \ - self.gender == other.gender and \ - self.number == other.number - - def __hash__(self): - return hash((self.unpointed_word(), self.root, self.stem, self.tense, - self.person, self.gender, self.number)) - -class Databank: - def __init__(self): - self.verbs = set() - self.roots = set() - - def add_root(self, root): - self.roots.add(root) - - def add_verb(self, verb): - self.verbs.add(verb) - -def handle(n, data): - if F.language.v(n) != 'hbo': # Ancient Hebrew - return - data.add_verb(Verb(n)) - data.add_root(Root(n)) - -def main(): - TF = Fabric( - modules=['hebrew/etcbc4c'], - locations='~/VersionControl/etcbc-data', - silent=True) - api = TF.load('language g_word_utf8 lex_utf8 vs vt gn nu ps', silent=True) - api.makeAvailableIn(globals()) - - data = Databank() - - for n in N(): - try: - handle(n, data) - except (KeyError, ValueError): - pass - - print(len(data.verbs), len(data.roots)) - - with open('etcbc-verbs.csv', 'w') as csvverbs: - verbwr = csv.writer(csvverbs, quoting=csv.QUOTE_MINIMAL) - #verbwr.writerow(['id', 'verb','root','stem','tense','person','gender','number','active']) - i = VERB_STARTID - for verb in data.verbs: - verbwr.writerow([ - i, - verb.verb, - verb.root, - verb.stem, - verb.tense, - verb.person if verb.person is not None else 'NULL', - verb.gender if verb.gender is not None else 'NULL', - verb.number if verb.number is not None else 'NULL', - 1 - ]) - i += 1 - - with open('etcbc-roots.csv', 'w') as csvroots: - rootwr = csv.writer(csvroots, quoting=csv.QUOTE_MINIMAL) - #rootwr.writerow(['id', 'root', 'root_kind_id']) - i = ROOT_STARTID - for root in data.roots: - rootwr.writerow([i, root.lex, 1]) - i += 1 - - -if __name__ == '__main__': - main() -- cgit v1.2.3