diff --git a/app/Http/Controllers/Oai/RequestController.php b/app/Http/Controllers/Oai/RequestController.php index 25e545b..6892ab8 100644 --- a/app/Http/Controllers/Oai/RequestController.php +++ b/app/Http/Controllers/Oai/RequestController.php @@ -121,8 +121,10 @@ class RequestController extends Controller $this->proc->setParameter('', 'unixTimestamp', $unixTimestamp); // set OAI base url + $frontend = config('tethys.frontend'); $uri = explode('?', $_SERVER['REQUEST_URI'], 2); - $this->proc->setParameter('', 'baseURL', url('/') . $uri[0]); + // $this->proc->setParameter('', 'baseURL', url('/') . $uri[0]); + $this->proc->setParameter('', 'baseURL', $frontend. '/oai');// . $uri[0]); $this->proc->setParameter('', 'repURL', url('/')); $this->proc->setParameter('', 'downloadLink', url('/') . '/file/download/'); $this->proc->setParameter('', 'doiLink', 'https://doi.org/'); @@ -437,7 +439,9 @@ class RequestController extends Controller if (array_key_exists('from', $oaiRequest) && array_key_exists('until', $oaiRequest)) { $from = $oaiRequest['from']; + $fromDate = \Illuminate\Support\Carbon::parse($from); $until = $oaiRequest['until']; + $untilDate = \Illuminate\Support\Carbon::parse($until); if (strlen($from) != strlen($until)) { throw new OaiModelException( @@ -445,9 +449,10 @@ class RequestController extends Controller OaiModelError::BADARGUMENT ); } - } - - if (array_key_exists('until', $oaiRequest)) { + $finder->whereDate('server_date_published', '>=', $fromDate) + ->whereDate('server_date_published', '<=', $untilDate); + $test = $finder->toSql(); + } else if (array_key_exists('until', $oaiRequest) && !array_key_exists('from', $oaiRequest)) { $until = $oaiRequest['until']; try { $untilDate = \Illuminate\Support\Carbon::parse($until); @@ -473,9 +478,7 @@ class RequestController extends Controller OaiModelError::BADARGUMENT ); } - } - - if (array_key_exists('from', $oaiRequest)) { + } else if (array_key_exists('from', $oaiRequest) && !array_key_exists('until', $oaiRequest)) { $from = $oaiRequest['from']; try { $fromDate = \Illuminate\Support\Carbon::parse($from); @@ -550,7 +553,8 @@ class RequestController extends Controller */ private function setParamResumption($res, $cursor, $totalIds) { - $tomorrow = str_replace('+00:00', 'Z', Carbon::now()->addHour(1)->setTimeZone('UTC')); + // $tomorrow = str_replace('+00:00', 'Z', Carbon::now()->addHour(1)->setTimeZone('UTC')); + $tomorrow = Carbon::now()->addDay(1)->toIso8601ZuluString(); $this->proc->setParameter('', 'dateDelete', $tomorrow); $this->proc->setParameter('', 'res', $res); $this->proc->setParameter('', 'cursor', $cursor); diff --git a/config/oai.php b/config/oai.php index ee1ec9a..a81890a 100644 --- a/config/oai.php +++ b/config/oai.php @@ -16,7 +16,7 @@ return [ 'workspacePath' => public_path() . DIRECTORY_SEPARATOR . "workspace", 'max' => [ - 'listidentifiers' => 15, - 'listrecords' => 15 + 'listidentifiers' => 100, + 'listrecords' => 100 ], ]; diff --git a/config/tethys.php b/config/tethys.php index eb27945..64ca87c 100644 --- a/config/tethys.php +++ b/config/tethys.php @@ -18,5 +18,6 @@ return [ 'datacite_test_service_url' => env('DATACITE_TEST_SERVICE_URL'), 'base_domain' => env('BASE_DOMAIN', 'https://tethys.at'), - 'test_base_domain' => env('TEST_BASE_DOMAIN') + 'test_base_domain' => env('TEST_BASE_DOMAIN'), + 'frontend' => env('FRONTEND', 'https://tethys.at') ]; diff --git a/public/.user.ini b/public/.user.ini index 667c823..8c3237d 100644 --- a/public/.user.ini +++ b/public/.user.ini @@ -1,4 +1,4 @@ ; Override value of upload_max_filesize -upload_max_filesize = 100M -post_max_size = 100M -memory_limit = 128M \ No newline at end of file +upload_max_filesize = 200M +post_max_size = 200M +memory_limit = 200M \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index f038928..e9a251f 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -79,7 +79,7 @@ {{-- --}} -
@@ -87,7 +87,7 @@
  • Home + href="{{route('frontend.home.index')}}">Home
  • diff --git a/routes/api.php b/routes/api.php index 15cf0b7..674fdcb 100644 --- a/routes/api.php +++ b/routes/api.php @@ -3,6 +3,8 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use App\Models\Person; +use App\Models\Dataset; +use Illuminate\Support\Facades\DB; /* |-------------------------------------------------------------------------- @@ -36,6 +38,70 @@ $appRoutes = function () { }); Route::get('/oai', 'Oai\RequestController@identify'); + + Route::get('/api/years', function () { + //return["2019", "2020", "2021"]; + $serverState = 'published'; + $select = DB::table('documents') + ->where('server_state', 'LIKE', "%" . $serverState . "%"); + + $select + ->select(DB::raw('EXTRACT(YEAR FROM server_date_published) as published_date')) + // ->select(DB::raw("DATE_PART('year', server_date_published) as published_date")) + // ->select(DB::raw("YEAR(server_date_published) AS published_date")) + ->distinct(true); + $years = $select->pluck('published_date')->toArray(); + return response() + ->json($years) + ->header('Access-Control-Allow-Origin', '*') + ->header('Access-Control-Allow-Methods', 'GET'); + }); + + Route::get('api/sitelinks/{year}', function($year) { + //$select = DB::table('documents') + //->where('server_state','LIKE', "%".$serverState."%"); + $serverState = 'published'; + $select = Dataset::with('titles', 'authors') + ->where('server_state', 'LIKE', "%" . $serverState . "%"); + + $from = (int) $year; + $until = $year + 1; + $select + ->whereYear('server_date_published', '>=', $from) + ->whereYear('server_date_published', '<', $until); + + $documents = $select->orderBy('publish_id', 'asc') + ->get(); + return response() + ->json($documents) + ->header('Access-Control-Allow-Origin', '*') + ->header('Access-Control-Allow-Methods', 'GET'); + }); + + Route::get('/api/dataset/{id}', function($id) { + $dataset = Dataset::where('publish_id', '=', $id) + ->with([ + 'titles', + 'abstracts', + 'user', + 'authors', + 'contributors', + 'subjects', + 'coverage', + 'licenses', + 'project', + 'files', + 'identifier' + ]) + ->firstOrFail(); + // $dataset->load('titles'); + // $dataset->load('abstracts'); + + return response() + ->json($dataset) + ->header('Access-Control-Allow-Origin', '*') + ->header('Access-Control-Allow-Methods', 'GET'); + }); Route::get('/api/persons', function () { $request = request();