Browse Source

Use pages subdirectory

Sunny 2 years ago
parent
commit
3b5fcd9108
6 changed files with 24 additions and 8 deletions
  1. 1 1
      elements/header.php
  2. 3 3
      pages/artist.php
  3. 16 0
      pages/asset.php
  4. 0 0
      pages/image.php
  5. 2 2
      pages/index.php
  6. 2 2
      pages/search.php

+ 1 - 1
elements/header.php

@@ -12,7 +12,7 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <title><?= $title ?></title>
-    <link rel="stylesheet" href="assets/style.css">
+    <link rel="stylesheet" href="asset.php?file=style.css">
   </head>
   <body>
     <header>

+ 3 - 3
artist.php → pages/artist.php

@@ -1,5 +1,5 @@
 <?php
-  require "modules/querypath/src/qp.php";
+  require "../modules/querypath/src/qp.php";
 
   /* TODO: UTF-8 titles don't seem to be decoded correctly.
            An example can be seen with "Die Tür Ist Zu" on the SWANS page. */
@@ -8,7 +8,7 @@
   $title = $document->find("#band-name-location .title")->text();
 ?>
 
-<?php include "elements/header.php" ?>
+<?php include "../elements/header.php" ?>
 
 <?php
   echo "<div class=\"results\">";
@@ -42,4 +42,4 @@
   echo "</div>";
 ?>
 
-<?php include "elements/footer.php" ?>
+<?php include "../elements/footer.php" ?>

+ 16 - 0
pages/asset.php

@@ -0,0 +1,16 @@
+<?php
+  $file = "../assets/" . basename($_GET["file"]);
+  $data = file_get_contents($file);
+
+  $mime = new finfo(FILEINFO_MIME_TYPE);
+  $mime = $mime->buffer($data);
+
+  switch (pathinfo($file, PATHINFO_EXTENSION)) {
+    case "css":
+      $mime = "text/css";
+      break;
+  };
+
+  header("Content-Type: " . $mime);
+  echo $data;
+?>

+ 0 - 0
image.php → pages/image.php


+ 2 - 2
index.php → pages/index.php

@@ -1,4 +1,4 @@
-<?php include "elements/header.php" ?>
+<?php include "../elements/header.php" ?>
 
 <h1>Tent</h1>
 <p>
@@ -35,4 +35,4 @@
   You will be able to run it using PHP and its cURL and XML extensions.
 </p>
 
-<?php include "elements/footer.php" ?>
+<?php include "../elements/footer.php" ?>

+ 2 - 2
search.php → pages/search.php

@@ -2,7 +2,7 @@
   $title = htmlspecialchars($_GET["query"]);
 ?>
 
-<?php include "elements/header.php" ?>
+<?php include "../elements/header.php" ?>
 
 <?php
   $ch = curl_init("https://bandcamp.com/api/bcsearch_public_api/1/autocomplete_elastic");
@@ -63,4 +63,4 @@
   echo "</div>";
 ?>
 
-<?php include "elements/footer.php" ?>
+<?php include "../elements/footer.php" ?>