Skip to content

Commit

Permalink
Implement layouts, fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Dec 4, 2019
1 parent 1d145fc commit 18e3e67
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 37 deletions.
10 changes: 7 additions & 3 deletions bin/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ class Files extends \Tatter\Files\Config\Files
// Whether to continue instead of throwing exceptions
public $silent = true;

// The session variable to check for a logged-in user ID
// Session variable to check for a logged-in user ID
public $userSource = 'logged_in';

// Directory to store files (with trailing slash)
public $storagePath = ROOTPATH . 'writable/files/';

// Layouts to use for general access and for administration
public $layouts = [
'public' => 'Tatter\Files\Views\layout',
'manage' => 'Tatter\Files\Views\layout',
];

// Views to display for each function
public $views = [
'header' => 'Tatter\Files\Views\templates\header',
'footer' => 'Tatter\Files\Views\templates\footer',
'dropzone' => 'Tatter\Files\Views\dropzone\config',
];

Expand Down
16 changes: 10 additions & 6 deletions src/Config/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ class Files extends BaseConfig
{
// Whether to continue instead of throwing exceptions
public $silent = true;

// Session variable to check for a logged-in user ID
public $userSource = 'logged_in';

// Directory to store files (with trailing slash)
public $storagePath = ROOTPATH . 'writable/files/';


// Layouts to use for general access and for administration
public $layouts = [
'public' => 'Tatter\Files\Views\layout',
'manage' => 'Tatter\Files\Views\layout',
];

// Views to display for each function
public $views = [
'header' => 'Tatter\Files\Views\templates\header',
'footer' => 'Tatter\Files\Views\templates\footer',
'dropzone' => 'Tatter\Files\Views\dropzone\config',
];

// Default display format; built in are 'cards', 'list', 'select'
public $defaultFormat = 'cards';
}
2 changes: 1 addition & 1 deletion src/Controllers/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function rename($fileId = null)

// Display only the form for AJAX
if ($this->request->isAJAX())
return view('Tatter\Files\Views\renameForm', $data);
return view('Tatter\Files\Views\forms\rename', $data);

// Display the form
return view('Tatter\Files\Views\rename', $data);
Expand Down
5 changes: 3 additions & 2 deletions src/Views/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?= view($config->views['header']) ?>
<?= $this->extend($config->layouts['public']) ?>
<?= $this->section('main') ?>

<div class="row">
<div class="col">
Expand Down Expand Up @@ -57,4 +58,4 @@

<?= view($config->views['dropzone']) ?>

<?= view($config->views['footer'], ['config' => $config]) ?>
<?= $this->endSection() ?>
14 changes: 12 additions & 2 deletions src/Views/templates/header.php → src/Views/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<!-- FontAwesome Free -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">

<?= service('alerts')->css() ?>
</head>
<body>
Expand All @@ -43,3 +43,13 @@
<?= service('alerts')->display() ?>

<main role="main" class="container my-5">

<?= $this->renderSection('main') ?>

</main><!-- /.container -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

</body>
</html>
5 changes: 3 additions & 2 deletions src/Views/messages.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?= view($config->views['header']) ?>
<?= $this->extend($config->layouts['public']) ?>
<?= $this->section('main') ?>

<h2>Information</h2>

Expand Down Expand Up @@ -34,4 +35,4 @@
endif;
?>

<?= view($config->views['footer']) ?>
<?= $this->endSection() ?>
5 changes: 3 additions & 2 deletions src/Views/rename.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?= view($config->views['header']) ?>
<?= $this->extend($config->layouts['public']) ?>
<?= $this->section('main') ?>

<div class="row">
<div class="col">
Expand All @@ -7,4 +8,4 @@
</div>
</div>

<?= view($config->views['footer'], ['config' => $config]) ?>
<?= $this->endSection() ?>
8 changes: 0 additions & 8 deletions src/Views/templates/footer.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Views/upload.php

This file was deleted.

0 comments on commit 18e3e67

Please sign in to comment.