diff --git a/build/index.php b/build/index.php index f407e62..1299bb4 100644 --- a/build/index.php +++ b/build/index.php @@ -2789,6 +2789,16 @@ register_module([ } /// ETag handling end /// + /* Disabled until we work out what to do about caching previews * + $previewFilename = "$filepath.preview.$outputFormat"; + if($target_size === $settings->default_preview_size) + { + // The request is for the default preview size + // Check to see if we have a preview pre-rendered + + } + */ + $preview = new Imagick(); switch(substr($mime_type, 0, strpos($mime_type, "/"))) { @@ -2808,6 +2818,14 @@ register_module([ case "video": case "audio": + if($settings->data_storage_dir == ".") + { + // The data storage directory is the current directory + // Redirect to the file isntead + http_response_code(307); + header("location: " . $pageindex->{$env->page}->uploadedfilepath); + exit(); + } // TODO: Add support for ranges here. // Get the file size $filesize = filesize($filepath); @@ -2837,8 +2855,14 @@ register_module([ // Send the completed preview image to the user header("content-type: $output_mime"); header("x-generation-time: " . (microtime(true) - $start_time) . "s"); - $preview->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1)); + $outputFormat = substr($output_mime, strpos($output_mime, "/") + 1); + $preview->setImageFormat($outputFormat); echo($preview->getImageBlob()); + /* Disabled while we work out what to do about caching previews * + // Save a preview file if there isn't one alreaddy + if(!file_exists($previewFilename)) + file_put_contents($previewFilename, $preview->getImageBlob()); + */ }); /* diff --git a/module_index.json b/module_index.json index f06c1ee..8c314a9 100644 --- a/module_index.json +++ b/module_index.json @@ -68,7 +68,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.", "id": "feature-upload", - "lastupdate": 1460282792, + "lastupdate": 1460283999, "optional": false }, { diff --git a/modules/feature-upload.php b/modules/feature-upload.php index 44f76eb..d632fd8 100644 --- a/modules/feature-upload.php +++ b/modules/feature-upload.php @@ -243,6 +243,16 @@ register_module([ } /// ETag handling end /// + /* Disabled until we work out what to do about caching previews * + $previewFilename = "$filepath.preview.$outputFormat"; + if($target_size === $settings->default_preview_size) + { + // The request is for the default preview size + // Check to see if we have a preview pre-rendered + + } + */ + $preview = new Imagick(); switch(substr($mime_type, 0, strpos($mime_type, "/"))) { @@ -262,6 +272,14 @@ register_module([ case "video": case "audio": + if($settings->data_storage_dir == ".") + { + // The data storage directory is the current directory + // Redirect to the file isntead + http_response_code(307); + header("location: " . $pageindex->{$env->page}->uploadedfilepath); + exit(); + } // TODO: Add support for ranges here. // Get the file size $filesize = filesize($filepath); @@ -291,8 +309,14 @@ register_module([ // Send the completed preview image to the user header("content-type: $output_mime"); header("x-generation-time: " . (microtime(true) - $start_time) . "s"); - $preview->setImageFormat(substr($output_mime, strpos($output_mime, "/") + 1)); + $outputFormat = substr($output_mime, strpos($output_mime, "/") + 1); + $preview->setImageFormat($outputFormat); echo($preview->getImageBlob()); + /* Disabled while we work out what to do about caching previews * + // Save a preview file if there isn't one alreaddy + if(!file_exists($previewFilename)) + file_put_contents($previewFilename, $preview->getImageBlob()); + */ }); /*