Browse Source

adding

master
Björn 3 years ago
commit
df0f8546c8
17 changed files with 2222 additions and 0 deletions
  1. +15
    -0
      .gitignore
  2. +28
    -0
      app/Flight/FlightAbstract.php
  3. +42
    -0
      app/Flight/Functions.php
  4. +0
    -0
      app/Http/Api/Bucket.php
  5. +27
    -0
      app/Http/Bucket.php
  6. +31
    -0
      app/Http/Index.php
  7. +26
    -0
      app/Models/Bucket.php
  8. +46
    -0
      app/Models/ModelAbstract.php
  9. +17
    -0
      app/Models/Tag.php
  10. +17
    -0
      app/Models/User.php
  11. +31
    -0
      app/bootstrap.php
  12. +16
    -0
      composer.json
  13. +1832
    -0
      composer.lock
  14. +15
    -0
      public/index.php
  15. +24
    -0
      resources/views/home.blade.php
  16. +55
    -0
      resources/views/layout.blade.php
  17. +0
    -0
      storage/.gitkeep

+ 15
- 0
.gitignore View File

@ -0,0 +1,15 @@
composer.phar
/vendor/
node_modules
.env
*.log
rysnc_exclude
storage/csv/*
!storage/csv/.gitkeep
storage/database/*
!storage/database/.gitkeep
storage/cache/*
!storage/cache/.gitkeep

+ 28
- 0
app/Flight/FlightAbstract.php View File

@ -0,0 +1,28 @@
<?php
namespace App\Flight;
use Flight;
/**
* abstract FlightAbstract get instance of flight engine
*
*
* @author Björn Hase
* @license http://opensource.org/licenses/MIT The MIT License
*
*/
abstract class FlightAbstract
{
/** object of flight */
protected $app;
/**
* getting object of flight
*
*/
public function __construct()
{
$this->app = Flight::app();
}
}

+ 42
- 0
app/Flight/Functions.php View File

@ -0,0 +1,42 @@
<?php
/**
* fake function for blade @inject
*
* @param string $class
* @return object
*/
function app($class)
{
return new $class();
}
/**
* function similar to blade asset
*
* @param $path
* @return string
*
*/
function asset($path, $prefix = '/public')
{
// get flight
$app = Flight::app();
// getting basePath
$basePath = $app->get('basePath');
// path to mix-manifest
$file = $app->get('basePath').'mix-manifest.json';
if (file_exists($file)) {
$manifest = file_get_contents($file);
$files = json_decode($manifest, true);
if (isset($files[$prefix.$path])) {
$path = str_replace($prefix, '', $files[$prefix.$path]);
}
}
return $path;
}

+ 0
- 0
app/Http/Api/Bucket.php View File


+ 27
- 0
app/Http/Bucket.php View File

@ -0,0 +1,27 @@
<?php
namespace App\Http;
use Rakit\Validation\Validator;
use App\Flight\FlightAbstract;
use App\Models\Bucket;
use Carbon\Carbon;
/**
*
*
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*
*/
class Bucket extends FlightAbstract
{
public function indexAction()
{
}
}

+ 31
- 0
app/Http/Index.php View File

@ -0,0 +1,31 @@
<?php
namespace App\Http;
use Rakit\Validation\Validator;
use App\Flight\FlightAbstract;
use App\Models\Bucket;
use Carbon\Carbon;
/**
*
*
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*
*/
class Home extends FlightAbstract
{
public function indexAction()
{
$this->app->render('index', [
]);
}
}

+ 26
- 0
app/Models/Bucket.php View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
/**
* Store for Courses
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*/
class Bucket extends ModelAbstract
{
// name of store
protected $name = 'buckets';
public function findByVisiblity($visiblity)
{
return $this->store->findBy(
[ 'visiblity' => $visiblity ],
[ 'created_at' => 'ASC' ],
100
);
}
}

+ 46
- 0
app/Models/ModelAbstract.php View File

@ -0,0 +1,46 @@
<?php
namespace App\Models;
use SleekDB\Store;
use SleekDB\Query;
/**
* Abstract Class for Stores
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*/
class ModelAbstract
{
// store of model
public $store;
// name of store
protected $name;
// configuration of store
protected $configuration = [
'auto_cache' => true,
'cache_lifetime' => null,
'timeout' => 120,
'primary_key' => '_id',
'search' => [
'min_length' => 2,
'mode' => 'or',
'score_key' => 'scoreKey',
'algorithm' => Query::SEARCH_ALGORITHM['hits']
]
];
/**
*
*
*/
public function __construct()
{
$this->store = new Store($this->name, __DIR__.'/../../storage/database', $this->configuration);
}
}

+ 17
- 0
app/Models/Tag.php View File

@ -0,0 +1,17 @@
<?php
namespace App\Models;
/**
* Store for Tags
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*/
class Tag extends ModelAbstract
{
// name of store
protected $name = 'tags';
}

+ 17
- 0
app/Models/User.php View File

@ -0,0 +1,17 @@
<?php
namespace App\Models;
/**
* Store for Users
*
*
* @author Björn Hase
* @link https://gitea.tentakelfabrik.de/mITSM/feedback GitHub Repository
*
*/
class User extends ModelAbstract
{
// name of store
protected $name = 'users';
}

+ 31
- 0
app/bootstrap.php View File

@ -0,0 +1,31 @@
<?php
// adding functions
require_once(__DIR__.'/Flight/Functions.php');
// adding env
$env = Dotenv\Dotenv::createImmutable(__DIR__.'/..');
$env->load();
// display all errors if debug is true
if (getenv('DEBUG') === true) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
}
// create app
$app = Flight::app();
// setting view path
$app->set('flight.views.path', __DIR__.'/../resources/views');
// adding blade for templates
Flight::register('view', 'Jenssegers\Blade\Blade', [ $app->get('flight.views.path'), __DIR__.'/../storage/cache']);
Flight::map('render', function($view, $data) {
echo Flight::view()->make($view, $data);
});
// setting path
$app->set('basePath', __DIR__.'/../');
$app->set('publicPath', __DIR__.'/../public');
$app->set('storagePath', __DIR__.'/../storage');

+ 16
- 0
composer.json View File

@ -0,0 +1,16 @@
{
"require": {
"mikecao/flight": "^1.3",
"rakibtg/sleekdb": "^2.11",
"vlucas/phpdotenv": "^5.3",
"jenssegers/blade": "^1.4",
"rakit/validation": "^1.4",
"nesbot/carbon": "^2.49",
"microweber/screen": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}

+ 1832
- 0
composer.lock
File diff suppressed because it is too large
View File


+ 15
- 0
public/index.php View File

@ -0,0 +1,15 @@
<?php
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../app/bootstrap.php';
$app->route('GET /', array(new App\Controllers\Index, 'indexAction'));
$app->route('GET /api/bucket', array(new App\Controllers\Bucket, 'indexAction'));
$app->route('POST /api/bucket', array(new App\Controllers\Bucket, 'createAction'));
$app->route('POST /api/bucket/[:id]', array(new App\Controllers\Bucket, 'updateAction'));
$app->route('DELETE /api/bucket/[:id]', array(new App\Controllers\Bucket, 'destroyAction'));
$app->route('GET /api/note/:bucket_id', array(new App\Controllers\Note, 'indexAction'));
$app->start();

+ 24
- 0
resources/views/home.blade.php View File

@ -0,0 +1,24 @@
@extends('layout')
@section('main')
<div class="container">
<h2>
Buckets
<button class="button">
Create
</button>
</h2>
<h3>
</h3>
<app-buckets></app-buckets>
</div>
@push('scripts')
<script type="text/javascript" src="js/buckets.js"></script>
<script type="text/javascript" defer>
riot.mount('buckets', {!! json_encode([ 'buckets' => $buckets ]) !!});
</script>
@endpush
@endsection

+ 55
- 0
resources/views/layout.blade.php View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Nano Buckets</title>
@yield('head')
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<header class="app-header">
<div class="container is-fluid pt-2 pb-2">
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img class="app-header__logo" src="/logo.svg" alt="Urban Filehub" />
<span class="app-header__title ml-2">
Filehub<strong>.Freifunk Minden</strong>
</span>
</a>
</div>
<div class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">
Dashboard
</a>
</div>
</div>
</nav>
</div>
</header>
<section class="section">
<div class="container is-fluid mt-3 mb-4">
<urban-accordion>
<div title="Send me a Link">
<urban-login-email></urban-login-email>
</div>
<div title="Login with Password">
<urban-login-password></urban-login-password>
</div>
</urban-accordion>
</div>
</section>
<main>
@yield('main')
</main>
<script type="text/javascript" src="js/app.js"></script>
@stack('scripts')
</body>
</html>

+ 0
- 0
storage/.gitkeep View File


Loading…
Cancel
Save