1
0
Prechádzať zdrojové kódy

Bootstrap album page

Sunny 2 rokov pred
rodič
commit
ffde50bb13
3 zmenil súbory, kde vykonal 22 pridanie a 3 odobranie
  1. 16 0
      pages/album.php
  2. 2 1
      pages/index.php
  3. 4 2
      utilities/link.php

+ 16 - 0
pages/album.php

@@ -0,0 +1,16 @@
+<?php
+  require "../modules/querypath/src/qp.php";
+
+  $document = htmlqp(file_get_contents("https://" . urlencode($_GET["artist"]) . ".bandcamp.com/album/" . urlencode($_GET["name"])));
+
+  $title = $document->find("h2")->text();
+?>
+
+<?php include "../elements/header.php" ?>
+<?php include "../utilities/link.php" ?>
+
+<?php
+  // ...
+?>
+
+<?php include "../elements/footer.php" ?>

+ 2 - 1
pages/index.php

@@ -32,8 +32,9 @@
 <ul>
   <?php
     $rules = [
-      "https://bandcamp.com/search?q=$1",
       "https://$1.bandcamp.com/",
+      "https://$1.bandcamp.com/album/$2",
+      "https://bandcamp.com/search?q=$1",
       "https://f4.bcbits.com/img/$1"
     ];
 

+ 4 - 2
utilities/link.php

@@ -8,13 +8,15 @@ function convert_link($link) {
   $base = $scheme . "://" . $host . preg_replace("/\/.*.php/", "/", strtok($uri, "?"));
 
   $host = parse_url($link, PHP_URL_HOST);
-  $path = parse_url($link, PHP_URL_PATH);
+  $path = ltrim(parse_url($link, PHP_URL_PATH), "/");
   parse_str(parse_url($link, PHP_URL_QUERY), $query);
 
-  if ($host === "bandcamp.com" && $path === "/search") {
+  if ($host === "bandcamp.com" && $path === "search") {
     return $base . "search.php?query=" . $query["q"];
   } elseif (str_ends_with($host, ".bandcamp.com") && !$path) {
     return $base . "artist.php?name=" . explode(".", $host)[0];
+  } elseif (str_ends_with($host, ".bandcamp.com") && explode("/", $path)[0] === "album") {
+    return $base . "album.php?artist=" . explode(".", $host)[0] . "&name=" . explode("/", $path)[1];
   } elseif ($host === "f4.bcbits.com") {
     return $base . "image.php?file=" . basename($link);
   } else {