first commit

This commit is contained in:
Babibubebon 2020-01-19 21:24:54 +09:00
commit edf65530fc
43 changed files with 6076 additions and 0 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

19
.env.example Normal file
View file

@ -0,0 +1,19 @@
APP_NAME=lodfe
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
QUEUE_CONNECTION=sync

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
/.idea
/*.iml
/vendor
/.idea
Homestead.json
Homestead.yaml
.env
.phpunit.result.cache

6
.styleci.yml Normal file
View file

@ -0,0 +1,6 @@
php:
preset: laravel
disabled:
- unused_use
js: true
css: true

4
README.md Normal file
View file

@ -0,0 +1,4 @@
lodfe
=====
SPARQLエンドポイントを用いたLinked Open Dataフロントエンド

View file

29
app/Console/Kernel.php Normal file
View file

@ -0,0 +1,29 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
//
}
}

10
app/Events/Event.php Normal file
View file

@ -0,0 +1,10 @@
<?php
namespace App\Events;
use Illuminate\Queue\SerializesModels;
abstract class Event
{
use SerializesModels;
}

View file

@ -0,0 +1,16 @@
<?php
namespace App\Events;
class ExampleEvent extends Event
{
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}

View file

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
//
}

View file

@ -0,0 +1,69 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ResourceController extends Controller
{
protected $acceptableFileExtensions = [
'.json',
'.jsonld',
'.nt',
'.rdf',
'.ttl',
];
/**
* @param Request $request
* @return mixed
*/
protected function getCurrentDatasetConfig($request) {
$datasetName = explode('.', $request->route()[1]['as'])[1];
return config('datasets.' . $datasetName);
}
/**
* @param $request
* @param $id
* @return \EasyRdf_Graph
*/
protected function querySparql($request, $id)
{
$datasetConfig = $this->getCurrentDatasetConfig($request);
$client = new \EasyRdf_Sparql_Client($datasetConfig['endpoint']);
$resourceUri = str_replace('{id}', $id, $datasetConfig['resource_uri']);
$query = 'DESCRIBE <' . $resourceUri . '>';
return $client->query($query);
}
public function html(Request $request, $id)
{
$graph = $this->querySparql($request, $id);
$subject = key($graph->toRdfPhp());
$datasetConfig = $this->getCurrentDatasetConfig($request);
$dataUri = str_replace('{id}', $id, $datasetConfig['data_uri']);
return view('resource')->with([
'graph' => $graph,
'subject' => $subject,
'dataUri' => $dataUri,
]);
}
public function data(Request $request, $id, $ext)
{
if (!in_array($ext, $this->acceptableFileExtensions)) {
abort(400);
}
$graph = $this->querySparql($request, $id);
try {
$data = $graph->serialise(substr($ext, 1));
} catch (\EasyRdf_Exception $e) {
abort(400);
}
return $data;
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;
class Authenticate
{
/**
* The authentication guard factory instance.
*
* @var \Illuminate\Contracts\Auth\Factory
*/
protected $auth;
/**
* Create a new middleware instance.
*
* @param \Illuminate\Contracts\Auth\Factory $auth
* @return void
*/
public function __construct(Auth $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if ($this->auth->guard($guard)->guest()) {
return response('Unauthorized.', 401);
}
return $next($request);
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace App\Http\Middleware;
use Closure;
class ContentNegotiatorMiddleware
{
public $defaultType = 'text/html';
public $acceptableTypes = [
'text/html' => 'html',
'application/xhtml+xml' => 'html',
'text/n3' => 'data',
'text/turtle' => 'data',
'application/n-triples' => 'data',
'application/rdf+xml' => 'data',
];
public $fileExtensions = [
'text/html' => '.html',
'application/xhtml+xml' => '.html',
'text/turtle' => '.ttl',
'application/n-triples' => '.nt',
'application/rdf+xml' => '.rdf',
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$datasetName = explode('.', $request->route()[1]['as'])[1];
// parse HTTP "Accept" header
$accepts = [];
foreach (explode(',', $request->header('accept')) as $accept) {
$accept = explode(';', $accept);
if (count($accept) === 2 && preg_match('/q=([\d\.]+)/', $accept[1], $m)) {
$accepts[trim($accept[0])] = (float)$m[1];
} elseif (count($accept) !== 2) {
$accepts[trim($accept[0])] = 1.0;
}
}
arsort($accepts);
// 303 redirect
$id = $request->route('id');
$negotiatedType = $this->defaultType;
foreach ($accepts as $mime => $q) {
if (array_key_exists($mime, $this->acceptableTypes)) {
$negotiatedType = $mime;
}
}
$redirectTo = $this->acceptableTypes[$negotiatedType] . '.' . $datasetName;
$params = ['id' => $id];
if (substr($redirectTo, 0, 4) === 'data') {
$params['ext'] = $this->fileExtensions[$negotiatedType];
}
return redirect()->route($redirectTo, $params, 303);
}
}

26
app/Jobs/ExampleJob.php Normal file
View file

@ -0,0 +1,26 @@
<?php
namespace App\Jobs;
class ExampleJob extends Job
{
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
}
}

24
app/Jobs/Job.php Normal file
View file

@ -0,0 +1,24 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
abstract class Job implements ShouldQueue
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use InteractsWithQueue, Queueable, SerializesModels;
}

View file

@ -0,0 +1,31 @@
<?php
namespace App\Listeners;
use App\Events\ExampleEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class ExampleListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param \App\Events\ExampleEvent $event
* @return void
*/
public function handle(ExampleEvent $event)
{
//
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View file

@ -0,0 +1,39 @@
<?php
namespace App\Providers;
use App\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
\App\Events\ExampleEvent::class => [
\App\Listeners\ExampleListener::class,
],
];
}

35
artisan Normal file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(
'Illuminate\Contracts\Console\Kernel'
);
exit($kernel->handle(new ArgvInput, new ConsoleOutput));

103
bootstrap/app.php Normal file
View file

@ -0,0 +1,103 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
dirname(__DIR__)
))->bootstrap();
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Laravel\Lumen\Application(
dirname(__DIR__)
);
$app->withFacades();
// $app->withEloquent();
$app->configure('app');
$app->configure('datasets');
/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/
// $app->middleware([
// App\Http\Middleware\ExampleMiddleware::class
// ]);
$app->routeMiddleware([
'content_negotiation' => App\Http\Middleware\ContentNegotiatorMiddleware::class,
]);
/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/
// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__ . '/../routes/web.php';
});
return $app;

44
composer.json Normal file
View file

@ -0,0 +1,44 @@
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.2",
"easyrdf/easyrdf": "^0.9.1",
"laravel/lumen-framework": "^6.0",
"ml/json-ld": "^1.1"
},
"require-dev": {
"fzaninotto/faker": "^1.4",
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

4951
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

113
config/app.php Normal file
View file

@ -0,0 +1,113 @@
<?php
return [
'version' => '1.0.0',
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Lumen'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => env('APP_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
];

13
config/datasets.php Normal file
View file

@ -0,0 +1,13 @@
<?php
return [
/*
'sample_dataset' => [
'host_name' => '' // (optional) The host name of this server if differ from resource URI
'resource_uri' => 'https://example.com/resource/{id}',
'html_uri' => 'https://example.com/page/{id}',
'data_uri' => 'https://example.com/data/{id}',
'endpoint' => 'https://example.com/query', // SPARQL endpoint URI
],
*/
];

View file

@ -0,0 +1,24 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\User;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
];
});

View file

View file

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call('UsersTableSeeder');
}
}

26
phpunit.xml Normal file
View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/app.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
</php>
</phpunit>

21
public/.htaccess Normal file
View file

@ -0,0 +1,21 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

28
public/index.php Normal file
View file

@ -0,0 +1,28 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();

0
resources/views/.gitkeep Normal file
View file

View file

@ -0,0 +1,28 @@
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="generator" content="{{ config('app.name') }} {{ config('app.version') }}">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>@yield('title')</title>
</head>
<body>
<div class="container">
@yield('content')
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,68 @@
@extends('base')
@section('title')
About: {{ $graph->label($subject) ?? $graph->getLiteral($subject, 'schema:name') }}
@endsection
@section('content')
<section>
<h1>@yield('title')</h1>
<code class="h5">{{ $subject }}</code>
<div class="float-right">
<div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Export
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="{{ $dataUri }}.nt">N-Triples</a>
<a class="dropdown-item" href="{{ $dataUri }}.ttl">Turtle</a>
<a class="dropdown-item" href="{{ $dataUri }}.json">JSON</a>
<a class="dropdown-item" href="{{ $dataUri }}.jsonld">JSON-LD</a>
<a class="dropdown-item" href="{{ $dataUri }}.rdf">RDF/XML</a>
</div>
</div>
</div>
</section>
<table class="table table-sm mt-3">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
@foreach($graph->toRdfPhp() as $subject => $predicateObjects)
@foreach($predicateObjects as $predicate => $objects)
<tbody>
<tr>
<td>
<a href="{{ $predicate }}">{{ \EasyRdf_Namespace::shorten($predicate) ?? $predicate }}</a>
</td>
<td>
<ul>
@foreach($objects as $object)
<li>
@if($object['type'] === 'uri')
<a href="{{ $object['value'] }}">{{ $object['value'] }}</a>
@elseif($object['type'] === 'literal')
{{ $object['value'] }}
@if(isset($object['lang']))
<small>{{ '@'.$object['lang'] }}</small>
@endif
@if(isset($object['datatype']))
<small>^^{{ \EasyRdf_Namespace::shorten($object['datatype']) ?? $object['datatype'] }}</small>
@endif
@endif
</li>
@endforeach
</ul>
</td>
</tr>
</tbody>
@endforeach
@endforeach
</table>
@endsection

53
routes/web.php Normal file
View file

@ -0,0 +1,53 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
function joinHostPort($components)
{
return $components['host'] . (isset($components['port']) ? ':' . $components['port'] : '');
}
/** @var Laravel\Lumen\Routing\Router $router */
foreach (config('datasets') as $name => $dataset) {
// route for resource URI
$urlComponents = parse_url($dataset['resource_uri']);
$hostPort = $dataset['host_name'] ?: joinHostPort($urlComponents);
if ($hostPort === $_SERVER['HTTP_HOST']) {
$router->addRoute('GET', $urlComponents['path'], [
'uses' => 'ResourceController@resource',
'as' => 'resource.' . $name,
'middleware' => 'content_negotiation'
]);
}
// route for html URI
$urlComponents = parse_url($dataset['html_uri']);
$hostPort = $dataset['host_name'] ?: joinHostPort($urlComponents);
if ($hostPort === $_SERVER['HTTP_HOST']) {
$router->addRoute('GET', $urlComponents['path'], [
'uses' => 'ResourceController@html',
'as' => 'html.' . $name,
]);
}
// route for data URI
$urlComponents = parse_url($dataset['data_uri']);
$hostPort = $dataset['host_name'] ?: joinHostPort($urlComponents);
if ($hostPort === $_SERVER['HTTP_HOST']) {
$router->addRoute('GET', $urlComponents['path'].'{ext:\.[A-Za-z]+}', [
'uses' => 'ResourceController@data',
'as' => 'data.' . $name,
]);
}
}

2
storage/app/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

3
storage/framework/cache/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*
!data/
!.gitignore

View file

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/views/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/logs/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

21
tests/ExampleTest.php Normal file
View file

@ -0,0 +1,21 @@
<?php
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->get('/');
$this->assertEquals(
$this->app->version(), $this->response->getContent()
);
}
}

16
tests/TestCase.php Normal file
View file

@ -0,0 +1,16 @@
<?php
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
{
return require __DIR__.'/../bootstrap/app.php';
}
}