Skip to content

Commit

Permalink
release: 0.4.1 Catoprion
Browse files Browse the repository at this point in the history
release: 0.4.1 Catoprion
  • Loading branch information
ZsgsDesign authored Dec 9, 2020
2 parents a62dc94 + a3c3412 commit ab441b9
Show file tree
Hide file tree
Showing 496 changed files with 25,184 additions and 2,270 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ APP_ENV=local #Current Environment Name
APP_KEY=base64:6KvSj1hj/VJCNXnHECU16OVbcHk7h20O5TbsyOz5WuA= #App Key
APP_DEBUG=true #Debug Mode
APP_URL=http://ojsystem.com/
APP_LOCALE=en

BABEL_MIRROR=https://acm.njupt.edu.cn/babel #The mirror of babel marketplace

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ yarn-error.log
/public/external
/app/Http/Controllers/VirtualCrawler/CodeForces/problemset.problems
/public/static/library
/.vscode/ipch
/.vscode/ipch
/.rnd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For installation options and troubleshooting tips, see [installation](https://nj
- [X] User Search
- [X] Group Search
- [X] Contest Search
- [X] OnmiSearch Support
- [X] OmniSearch Support
- [X] Problem System
- [X] Problem List
- [X] Problem Tag
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/Controllers/ContestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Admin\Controllers;

use App\Models\ContestModel;
use App\Models\Eloquent\ContestModel as EloquentContestModel;
use App\Models\Eloquent\Contest as EloquentContestModel;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
Expand Down
6 changes: 3 additions & 3 deletions app/Admin/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public static function general()
$status = [
['name' => 'NOJ Version', 'value' => version()],
['name' => 'Lastest Version', 'value' => is_null($version)?'Failed to fetch latest version':$version["name"]],
['name' => 'Problems', 'value' => \App\Models\Eloquent\ProblemModel::count()],
['name' => 'Problems', 'value' => \App\Models\Eloquent\Problem::count()],
['name' => 'Solutions', 'value' => \App\Models\Eloquent\ProblemSolutionModel::count()],
['name' => 'Submissions', 'value' => \App\Models\Eloquent\SubmissionModel::count()],
['name' => 'Contests', 'value' => \App\Models\Eloquent\ContestModel::count()],
['name' => 'Submissions', 'value' => \App\Models\Eloquent\Submission::count()],
['name' => 'Contests', 'value' => \App\Models\Eloquent\Contest::count()],
['name' => 'Users', 'value' => \App\Models\Eloquent\UserModel::count()],
['name' => 'Groups', 'value' => \App\Models\Eloquent\Group::count()],
];
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/Controllers/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Admin\Controllers;

use App\Models\Eloquent\ProblemModel as EloquentProblemModel;
use App\Models\Eloquent\Problem as EloquentProblemModel;
use App\Http\Controllers\Controller;
use App\Admin\Forms\ImportPOEM;
use Encore\Admin\Controllers\HasResourceActions;
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/Controllers/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Admin\Controllers;

use App\Models\Eloquent\SubmissionModel as EloquentSubmissionModel;
use App\Models\Eloquent\Submission as EloquentSubmissionModel;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/Forms/ImportPOEM.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Admin\Forms;

use App\Models\Eloquent\ProblemModel;
use App\Models\Eloquent\Problem;
use Encore\Admin\Widgets\Form;
use Illuminate\Support\MessageBag;
use Illuminate\Http\Request;
Expand Down
12 changes: 0 additions & 12 deletions app/Admin/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,6 @@
"updated_at": "2019-04-12 09:30:12",
"roles": []
},
{
"id": 19,
"parent_id": 0,
"order": 19,
"title": "Api tester",
"icon": "MDI tune",
"uri": "api-tester",
"permission": null,
"created_at": "2019-04-11 13:04:49",
"updated_at": "2019-04-12 09:30:12",
"roles": []
},
{
"id": 20,
"parent_id": 0,
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\RankModel;
use App\Models\SiteMapModel;
use App\Models\ContestModel;
use App\Models\Eloquent\ContestModel as EloquentContestModel;
use App\Models\Eloquent\Contest as EloquentContestModel;
use App\Models\GroupModel;
use App\Models\OJModel;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
Expand Down
12 changes: 12 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public function report(Exception $exception)
*/
public function render($request, Exception $exception)
{
if(!env("APP_DEBUG") && $request->is('api/*')) {
return response(json_encode([
'success' => false,
'message' => 'Server Error',
'ret' => [],
'err' => [
'code' => 500,
'msg' => 'Server Error',
'data'=>[]
]
]),500)->header('Content-Type','application/json');
};
return parent::render($request, $exception);
}
}
18 changes: 12 additions & 6 deletions app/Helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ function formatHumanReadableTime($date)
$unix_date=strtotime($date);

if (empty($unix_date)) {
return "Bad date";
return __("helper.time.malformatter");
}

if ($now>$unix_date) {
$difference=$now-$unix_date;
$tense="ago";
$tense=__("helper.time.after");
} else {
$difference=$unix_date-$now;
$tense="from now";
$tense=__("helper.time.before");
}

for ($j=0; $difference>=$lengths[$j] && $j<count($lengths)-1; $j++) {
Expand All @@ -181,10 +181,16 @@ function formatHumanReadableTime($date)
$difference=round($difference);

if ($difference!=1) {
$periods[$j].="s";
$periods[$j]=__("helper.time.plural.$periods[$j]");
} else {
$periods[$j]=__("helper.time.singular.$periods[$j]");
}

return "$difference $periods[$j] {$tense}";
return __("helper.time.formatter",[
"time" => $difference,
"unit" => $periods[$j],
"tense" => $tense,
]);
}
}

Expand Down Expand Up @@ -219,4 +225,4 @@ function latex2Image($content)
$content = preg_replace_callback('/\\\\\\[(.*?)\\\\\\]/', $callback, $content);
return $content;
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/ContestAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Ajax;

use App\Models\ContestModel;
use App\Models\Eloquent\ContestModel as EloquentContestModel;
use App\Models\Eloquent\Contest as EloquentContestModel;
use App\Models\GroupModel;
use App\Models\ResponseModel;
use App\Models\AccountModel;
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Ajax/ContestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Ajax;

use App\Models\ContestModel;
use App\Models\Eloquent\ContestModel as EloquentContestModel;
use App\Models\Eloquent\Contest as EloquentContestModel;
use App\Models\GroupModel;
use App\Models\ResponseModel;
use App\Http\Controllers\Controller;
Expand All @@ -18,7 +18,6 @@ public function fetchClarification(Request $request)
$request->validate([
'cid' => 'required|integer',
]);

$all_data=$request->all();

$contestModel=new ContestModel();
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Ajax/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function joinGroup(Request $request)
sendMessage([
'sender' => 1,
'receiver' => $leader->id,
'title' => "Some users agreed to join your group {$group->name}.",
'title' => __('group.message.agreeJoin.title', ['name' => $group->name]),
'type' => 2,
'data' => [
'group' => [
Expand Down Expand Up @@ -82,7 +82,7 @@ public function joinGroup(Request $request)
sendMessage([
'sender' => 1,
'receiver' => $leader->id,
'title' => 'Someone applied to join your group.',
'title' => __('group.message.agreeJoin.title', ['name' => $group->name]),
'type' => 1,
'data' => [
'group' => [
Expand All @@ -106,7 +106,7 @@ public function joinGroup(Request $request)
sendMessage([
'sender' => 1,
'receiver' => $leader->id,
'title' => "Some users agreed to join your group {$group->name}.",
'title' => __('group.message.agreeJoin.title', ['name' => $group->name]),
'type' => 2,
'data' => [
'group' => [
Expand Down Expand Up @@ -134,7 +134,7 @@ public function joinGroup(Request $request)
sendMessage([
'sender' => 1,
'receiver' => $leader->id,
'title' => "Some users applied to join your group {$group->name}.",
'title' => __('group.message.appliedJoin.title', ['name' => $group->name]),
'type' => 1,
'data' => [
'group' => [
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Ajax/GroupManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public function inviteMember(Request $request)
sendMessage([
'receiver' => $receiverInfo["id"],
'sender' => Auth::user()->id,
'title' => "{$sender_name} invites you to group {$basic['name']}",
'content' => "Hi, Dear **{$receiverInfo['name']}**,\n\n **{$sender_name}** has just invited you to join the group **[{$basic['name']}]({$url})**. Take a look and meet other fascinating people right now!\n\nSincerely, NOJ"
'title' => __('group.message.inviteJoin.title', ['sender_name' => $sender_name, 'group_name' => $basic['name']]),
'content' => __('group.message.inviteJoin.content', ['reciver_name' => $receiverInfo['name'], 'group_name' => $basic['name'], 'group_url' => $url]),
]);
return ResponseModel::success(200);
}
Expand Down
47 changes: 47 additions & 0 deletions app/Http/Controllers/Api/AccountController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AccountController extends Controller
{
public function login(Request $request) {
$credentials = [
'email' => $request->email,
'password' => $request->password
];

if(auth()->attempt($credentials)) {
$user = auth()->user();
if(!empty($user->tokens)){
foreach($user->tokens as $token){
$token->delete();
}
}
$token = $user->createToken('NOJ Password Grant Client')->accessToken;
return response()->json([
'success' => true,
'message' => 'Successfully Login',
'ret' => [
"token" => $token,
"user" => $user,
],
'err' => []
]);
} else {
return response()->json([
'success' => false,
'message' => 'Email/Password Wrong',
'ret' => [],
'err' => [
'code' => 1100,
'msg' => 'Email/Password Wrong',
'data'=>[]
]
]);
}

}
}
Loading

0 comments on commit ab441b9

Please sign in to comment.