Enabled Domain homepage

This commit is contained in:
Deon George 2021-06-14 21:33:18 +10:00
parent a3b4214040
commit 4011b2a82d
13 changed files with 205 additions and 70 deletions

View File

@ -20,12 +20,13 @@ class DomainController extends Controller
{ {
if ($request->post()) { if ($request->post()) {
$request->validate([ $request->validate([
'name' => 'required|unique:domains|max:8', 'name' => 'required|max:8|unique:domains,name,'.$o->id,
'dnsdomain' => 'nullable|unique:domains|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i', 'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.$o->id,
'active' => 'required', 'active' => 'required',
'public' => 'required',
]); ]);
foreach (['name','dnsdomain','active','notes'] as $key) foreach (['name','dnsdomain','active','public','homepage','notes'] as $key)
$o->{$key} = $request->post($key); $o->{$key} = $request->post($key);
$o->save(); $o->save();

View File

@ -2,12 +2,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Domain;
class HomeController extends Controller class HomeController extends Controller
{ {
public function network(string $name) public function network(Domain $o)
{ {
return view('networks') return view('domain.view')
->with('content',$name) ->with('o',$o);
->with('network',$name);
} }
} }

View File

@ -10,10 +10,32 @@ class Domain extends Model
{ {
use ScopeActive; use ScopeActive;
/* SCOPES */
/**
* Only query active records
*/
public function scopePublic($query)
{
return $query->where('public',TRUE);
}
/* RELATIONS */ /* RELATIONS */
public function zones() public function zones()
{ {
return $this->hasMany(Zone::class); return $this->hasMany(Zone::class);
} }
/* CASTS */
public function getHomePageAttribute($value)
{
return $value ? gzuncompress(base64_decode($value)) : 'No available information at the moment.';
}
public function setHomePageAttribute($value)
{
$this->attributes['homepage'] = base64_encode(gzcompress($value,9));
}
} }

View File

@ -17,13 +17,5 @@ class Zone extends Model
return $this->belongsTo(Domain::class); return $this->belongsTo(Domain::class);
} }
/* SCOPES */
/**
* Only query active records
*/
public function scopePublic()
{
return $this->where('public',TRUE);
}
} }

View File

@ -10,8 +10,8 @@ trait ScopeActive
/** /**
* Only query active records * Only query active records
*/ */
public function scopeActive() public function scopeActive($query)
{ {
return $this->where($this->getTable().'.active',TRUE); return $query->where($this->getTable().'.active',TRUE);
} }
} }

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPublicToDomains extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('domains', function (Blueprint $table) {
$table->boolean('public')->default(TRUE);
$table->text('homepage')->nullable();
});
Schema::table('zones', function (Blueprint $table) {
$table->dropColumn('public');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('domains', function (Blueprint $table) {
$table->dropColumn(['public','homepage']);
});
Schema::table('zones', function (Blueprint $table) {
$table->boolean('public')->default(TRUE);
});
}
}

View File

@ -41,6 +41,9 @@ textarea {
a:link { a:link {
text-decoration:none text-decoration:none
} }
a.disabled {
pointer-events: none;
}
.cap { .cap {
text-transform:uppercase text-transform:uppercase
@ -261,6 +264,11 @@ ul#navlist-desktop {
text-shadow: 2px 2px 0 #555; text-shadow: 2px 2px 0 #555;
border-bottom: 2px solid #aaa; border-bottom: 2px solid #aaa;
} }
#content h1>small {
font-size: 35%;
color: #403f3f;
text-shadow: none;
}
#content h2 { #content h2 {
color:#fff; color:#fff;
background-color:#a00; background-color:#a00;
@ -298,10 +306,7 @@ ul#navlist-desktop {
color:#c60; color:#c60;
} }
#content>div.row:first-child { #content>div.row:not(:first-child) {
padding-top: 0px;
}
#content>div.row {
padding-top: 20px; padding-top: 20px;
} }
@ -412,6 +417,9 @@ form div.row {
.greyframe>form>div.row:last-child { .greyframe>form>div.row:last-child {
padding-bottom: 15px; padding-bottom: 15px;
} }
.greyframe div.row div[class^="col-"]:not(:first-child) {
padding-left: 20px;
}
label.form-label { label.form-label {
font-size: 75%; font-size: 75%;
@ -458,6 +466,23 @@ div p:last-child {
margin: auto; margin: auto;
} }
pre,
pre code {
font-family:ibmbios2y,monospace;
font-size:14px;
color: #ccc;
margin:0;
padding: 0 0 20px 0;
font-weight:400;
text-align:left;
white-space:pre-wrap;
white-space:-moz-pre-wrap;
white-space:-pre-wrap;
white-space:-o-pre-wrap;
word-wrap:break-word;
text-indent:initial
}
.row { .row {
text-align: left; text-align: left;
} }
@ -549,6 +574,9 @@ tbody {
border-bottom:1px solid #666 border-bottom:1px solid #666
} }
.push-right {
float:right;
}
.text-center { .text-center {
text-align:center; text-align:center;
} }

View File

@ -1,4 +1,7 @@
@extends('layouts.app') @extends('layouts.app')
@section('htmlheader_title')
About
@endsection
@section('content') @section('content')
<h2>About the FTN Clearing House</h2> <h2>About the FTN Clearing House</h2>

View File

@ -5,16 +5,16 @@
@endsection @endsection
@section('content') @section('content')
<div class="row"> <form class="row g-0 needs-validation" method="post" novalidate>
<div class="col-6 m-auto"> @csrf
<div class="greyframe titledbox shadow0xb0 text-center">
<h2 class="cap">@if($o->exists) Update @else Add @endif Domain</h2>
<form class="row g-0 needs-validation" method="post" novalidate> <div class="row">
@csrf <div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">@if($o->exists) Update @else Add @endif Domain</h2>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-4">
<label for="name" class="form-label">Name</label> <label for="name" class="form-label">Name</label>
<div class="input-group has-validation"> <div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span> <span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
@ -30,25 +30,8 @@
@enderror @enderror
</div> </div>
</div> </div>
</div>
<div class="row"> <div class="col-4">
<div class="col-12">
<label for="name" class="form-label">DNS Domain</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('dnsdomain') is-invalid @enderror" id="dnsdomain" placeholder="DNS Domain (if applicable)" name="dnsdomain" value="{{ old('dnsdomain',$o->dnsdomain) }}">
@error('dnsdomain')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<label for="active" class="form-label">Active</label> <label for="active" class="form-label">Active</label>
<div class="input-group has-validation"> <div class="input-group has-validation">
<div class="btn-group" role="group"> <div class="btn-group" role="group">
@ -63,20 +46,77 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-4">
<label for="notes" class="form-label">Notes</label> <label for="name" class="form-label">DNS Domain</label>
<textarea class="form-control" rows=3 cols=68 name="notes" placeholder="Notes...">{{ old('notes',$o->notes) }}</textarea> <div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('dnsdomain') is-invalid @enderror" id="dnsdomain" placeholder="DNS Domain (if applicable)" name="dnsdomain" value="{{ old('dnsdomain',$o->dnsdomain) }}">
@error('dnsdomain')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@enderror
</div>
</div>
<div class="col-4">
<label for="public" class="form-label">Public</label>
<div class="input-group has-validation">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="public" id="public_yes" value="1" required @if($o->public)checked @endif>
<label class="btn btn-outline-success" for="public_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="public" id="public_no" value="0" required @if(! $o->public)checked @endif>
<label class="btn btn-outline-danger" for="public_no">No</label>
</div>
</div>
</div>
<div class="col-4">
more text
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<a href="{{ url('ftn/domain') }}" class="btn btn-danger">Cancel</a> <label for="notes" class="form-label">Notes</label>
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button> <textarea class="form-control" rows=3 cols=68 name="notes" placeholder="Notes...">{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>
</form> </div>
</div> </div>
</div> </div>
</div>
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">Home Page</h2>
<div class="row">
<div class="col-12" >
<label for="homepage" class="form-label">Home Page Text</label>
<div style="background-color: #fff;color: #000;">
<textarea class="form-control" rows=5 cols=68 id="homepage" name="homepage" placeholder="Home Page...">{{ old('homepage',$o->homepage) }}</textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('ftn/domain') }}" class="btn btn-danger">Cancel</a>
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button>
</div>
</div>
</div>
</div>
</form>
@endsection @endsection
@section('page-scripts')
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<script>
var simplemde = new SimpleMDE({ element: $("#homepage")[0] });
</script>
@append

View File

@ -1,4 +1,7 @@
@extends('layouts.app') @extends('layouts.app')
@section('htmlheader_title')
FTN Domains
@endsection
@section('content') @section('content')
<div class="row"> <div class="row">
@ -32,7 +35,7 @@
<tr> <tr>
<td colspan="5"><a href="{{ url('ftn/domain/addedit') }}">Add New Domain</a></td> <td colspan="5"><a href="{{ url('ftn/domain/addedit') }}">Add New Domain</a></td>
</tr> </tr>
@foreach (\App\Models\Domain::cursor() as $oo) @foreach (\App\Models\Domain::orderBy('name')->cursor() as $oo)
<tr> <tr>
<td><a href="{{ url('ftn/domain/addedit',[$oo->id]) }}">{{ $oo->id }}</a></td> <td><a href="{{ url('ftn/domain/addedit',[$oo->id]) }}">{{ $oo->id }}</a></td>
<td>{{ $oo->active ? 'YES' : 'NO' }}</td> <td>{{ $oo->active ? 'YES' : 'NO' }}</td>

View File

@ -4,7 +4,7 @@
<ul id="navlist-desktop"> <ul id="navlist-desktop">
<li><a href="{{ url('/') }}" class="@if(preg_match('#^/#',request()->path()))thispage @endif"><span>Home</span></a></li> <li><a href="{{ url('/') }}" class="@if(preg_match('#^/#',request()->path()))thispage @endif"><span>Home</span></a></li>
<li><a href="{{ url('about') }}" class="@if(preg_match('#^about#',request()->path()))thispage @endif"><span>About</span></a></li> <li><a href="{{ url('about') }}" class="@if(preg_match('#^about#',request()->path()))thispage @endif"><span>About</span></a></li>
<li><a href="{{ url('help') }}" class="@if(preg_match('#^help#',request()->path()))thispage @endif"><span>Help</span></a></li> <li><a href="{{ url('help') }}" class="@if(preg_match('#^help#',request()->path()))thispage @endif disabled"><span>Help</span></a></li>
@can('admin') @can('admin')
<li><a href="{{ url('setup') }}" class="@if(preg_match('#^setup#',request()->path()))thispage @endif"><span>Setup</span></a></li> <li><a href="{{ url('setup') }}" class="@if(preg_match('#^setup#',request()->path()))thispage @endif"><span>Setup</span></a></li>
@endcan @endcan
@ -13,8 +13,9 @@
@endif @endif
</ul> </ul>
<ul style="float: right;"> <ul class="push-right">
@auth @auth
<li><a href="{{ url('settings') }}"><span>{{ Auth::user()->name }}</span></a></li>
<li><a href="{{ url('logout') }}"><span>Logout</span></a></li> <li><a href="{{ url('logout') }}"><span>Logout</span></a></li>
@endauth @endauth
@guest @guest
@ -69,30 +70,29 @@
<div id="sidebar"> <div id="sidebar">
<div id="sidebar-scroller"> <div id="sidebar-scroller">
FTN Networks
@auth @auth
Jump to section:
<dl> <dl>
<dt><a href="#" >FTN Networks</a></dt> <dt><a href="#" >Network Admin</a></dt>
<dd><a href="{{ url('ftn/domain') }}">Domains</a></dd> <dd><a href="{{ url('ftn/domain') }}">Domains</a></dd>
<dd><a href="{{ url('ftn/zones') }}" >Zones</a></dd> <dd><a href="{{ url('ftn/zone') }}" >Zones</a></dd>
<dd><a href="{{ url('ftn/nodes') }}" >Nodes</a></dd> <dd><a href="{{ url('ftn/node') }}" >Nodes</a></dd>
</dl> </dl>
@can('admin')
<dl> <dl>
<dt><a href="#" >Users</a></dt> <dt><a href="#" >Users</a></dt>
<dd><a href="{{ url('user/add') }}" >Create</a></dd> <dd><a href="{{ url('user/add') }}" >Create</a></dd>
<dd><a href="{{ url('user/list') }}">List</a></dd> <dd><a href="{{ url('user/list') }}">List</a></dd>
</dl> </dl>
@endcan
@endauth @endauth
@guest <dl>
Explore: <dt><a href="#" >Expore Networks</a></dt>
<dl> @foreach (\App\Models\Domain::active()->public()->get() as $o)
<dt><a href="#" >FTN Networks</a></dt> <dd><a href="{{ url('network',['id'=>$o->id]) }}" title="{{ $o->description }}">{{ $o->name }}</a></dd>
@foreach (\App\Models\Zone::active()->public()->get() as $o) @endforeach
<dd><a href="{{ url('network',['id'=>$o->name]) }}" title="{{ $o->description }}">{{ $o->name }}</a></dd> </dl>
@endforeach
</dl>
@endguest
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,7 @@
@extends('layouts.app') @extends('layouts.app')
@section('htmlheader_title')
FTN Zones
@endsection
@section('main-content') @section('main-content')
<div class="row"> <div class="row">

View File

@ -45,3 +45,5 @@ Route::middleware(['verified'])->group(function () {
Route::get('ftn/network/{name}',[HomeController::class,'network']); Route::get('ftn/network/{name}',[HomeController::class,'network']);
}); });
Route::get('network/{o}',[HomeController::class,'network']);