Browse Source

Get things out of /frontend, closes #28

Bojidar Marinov 9 years ago
parent
commit
1a58a48ced
12 changed files with 23 additions and 12 deletions
  1. 1 1
      .gitignore
  2. 2 1
      .htaccess
  3. 2 0
      data/.htaccess
  4. 0 3
      frontend/index.php
  5. 4 0
      index.php
  6. 2 0
      logs/.htaccess
  7. 0 1
      logs/README.md
  8. 2 0
      src/.htaccess
  9. 3 3
      src/middleware.php
  10. 4 2
      src/routes/auth.php
  11. 2 0
      templates/.htaccess
  12. 1 1
      templates/_header.phtml

+ 1 - 1
.gitignore

@@ -1,5 +1,5 @@
 vendor/**
-logs/**
+logs/**/*.log
 src/settings-local.php
 
 **/bower_components/**

+ 2 - 1
frontend/.htaccess → .htaccess

@@ -4,7 +4,8 @@ RewriteEngine On
 # If you need to use the `RewriteBase` directive, it should be the
 # absolute physical path to the directory that contains this htaccess file.
 #
-RewriteBase /asset-library/frontend
+
+RewriteBase /asset-library
 
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [QSA,L]

+ 2 - 0
data/.htaccess

@@ -0,0 +1,2 @@
+Order allow,deny
+Deny from all

+ 0 - 3
frontend/index.php

@@ -1,3 +0,0 @@
-<?php
-$frontend = true;
-include(__DIR__ . '/../api/index.php');

+ 4 - 0
index.php

@@ -0,0 +1,4 @@
+<?php
+$frontend = true;
+include(__DIR__ . '/api/index.php');
+

+ 2 - 0
logs/.htaccess

@@ -0,0 +1,2 @@
+Order allow,deny
+Deny from all

+ 0 - 1
logs/README.md

@@ -1 +0,0 @@
-Your Slim Framework application's log files will be written to this directory.

+ 2 - 0
src/.htaccess

@@ -0,0 +1,2 @@
+Order allow,deny
+Deny from all

+ 3 - 3
src/middleware.php

@@ -48,7 +48,7 @@ if(isset($frontend) && $frontend) {
 
     if(isset($result['url'])) {
       $response = new \Slim\Http\Response(303);
-      $response = $response->withHeader('Location', dirname($request->getUri()->getBasePath()) . '/frontend/' . $result['url']);
+      $response = $response->withHeader('Location', $request->getUri()->getBasePath() . '/' . $result['url']);
     } else {
       $template_names = [
         //'/configure' => 'configure',
@@ -77,8 +77,8 @@ if(isset($frontend) && $frontend) {
         $errorResponse = new \Slim\Http\Response();
         $params = [
           'data' => $result,
-          'basepath' => dirname($request->getUri()->getBasePath()) . '/frontend',
-          'bowerpath' => dirname($request->getUri()->getBasePath()) . '/bower_components',
+          'basepath' => $request->getUri()->getBasePath(). '',
+          'bowerpath' => $request->getUri()->getBasePath() . '/bower_components',
           'path' => $path,
           'params' => $request->getQueryParams(),
           'categories' => [], // Filled later

+ 4 - 2
src/routes/auth.php

@@ -3,7 +3,7 @@
 
 
 // Initializes the connection by sending all categories available
-$app->get('/configure', function ($request, $response, $args) {
+$app->get('/configure', function ($request, $response, $args) { global $frontend;
   $params = $request->getQueryParams();
 
   $category_type = $this->constants['category_type']['addon'];
@@ -28,7 +28,9 @@ $app->get('/configure', function ($request, $response, $args) {
     return $response->withJson([
       'categories' => $query->fetchAll(),
       'token' => $token,
-      'login_url' => $_SERVER['HTTP_HOST'] . dirname($request->getUri()->getBasePath()) . 'frontend/login#' . urlencode($token),
+      'login_url' => $_SERVER['HTTP_HOST'] .
+        (isset($frontend) && $frontend ? dirname($request->getUri()->getBasePath()) : $request->getUri()->getBasePath()) .
+        '/login#' . urlencode($token),
       // ^ TODO: Make those routes actually work
     ], 200);
 

+ 2 - 0
templates/.htaccess

@@ -0,0 +1,2 @@
+Order allow,deny
+Deny from all

+ 1 - 1
templates/_header.phtml

@@ -31,7 +31,7 @@
           <span class="icon-bar"></span>
           <span class="icon-bar"></span>
         </button>
-        <a class="navbar-brand" href="/asset-library/frontend">Godot Asset Library</a>
+        <a class="navbar-brand" href="<?php echo $basepath ?>">Godot Asset Library</a>
       </div>
 
       <?php global $gPaths; $gPaths = [$basepath, $path]; function make_nav_link($name, $link='#') { global $gPaths; ?>