ready for publish!

This commit is contained in:
Jeremy Kauffman 2017-03-29 19:49:26 -04:00
parent 0ceacf6390
commit e8ba08b030
4 changed files with 36 additions and 14 deletions

View file

@ -37,7 +37,7 @@ class LBRY
$freePublicClaims = array_filter($claims['claims'], function($claim) { $freePublicClaims = array_filter($claims['claims'], function($claim) {
$metadata = json_decode($claim['value'], true); $metadata = json_decode($claim['value'], true);
return return
//TODO: Expand these checks //TODO: Expand these checks AND verify it is an image claim!
($metadata['license'] == "Public Domain" || stripos($metadata['license'], 'Creative Commons') !== false) && ($metadata['license'] == "Public Domain" || stripos($metadata['license'], 'Creative Commons') !== false) &&
!isset($metadata['fee']); !isset($metadata['fee']);
}); });

View file

@ -4,10 +4,6 @@ if (!defined('ROOT_PAGE')) { die('not allowed'); }
$claim = LBRY::findTopPublicFreeClaim($name); $claim = LBRY::findTopPublicFreeClaim($name);
//echo '<pre>';
//print_r($claim);
//die('over');
if ($claim) if ($claim)
{ {
$getResult = LBRY::api('get', ['name' => $name, 'claim_id' => $claim['claim_id']]); $getResult = LBRY::api('get', ['name' => $name, 'claim_id' => $claim['claim_id']]);
@ -15,6 +11,8 @@ if ($claim)
if (isset($getResult['completed']) && $getResult['completed'] && isset($getResult['download_path'])) if (isset($getResult['completed']) && $getResult['completed'] && isset($getResult['download_path']))
{ {
$path = $getResult['download_path']; $path = $getResult['download_path'];
//TODO, verify it is an image
//TODO: serve the correct content type!
header('Content-type: image/jpeg'); header('Content-type: image/jpeg');
header('Content-length: ' . filesize($path)); header('Content-length: ' . filesize($path));
readfile($getResult['download_path']); readfile($getResult['download_path']);

View file

@ -1,24 +1,33 @@
<?php <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('ROOT_PAGE', 1); define('ROOT_PAGE', 1);
require_once './LBRY.class.php'; require_once './LBRY.class.php';
$name = ltrim(urldecode($_SERVER['REQUEST_URI']), '/'); $name = ltrim(urldecode($_SERVER['REQUEST_URI']), '/');
if ($name == 'publish')
if ($name) {
include './publish.php';
exit(0);
}
elseif ($name)
{ {
error_reporting(E_ALL);
ini_set('display_errors', 1);
include './image.php'; include './image.php';
exit(0); exit(0);
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<h1>spee.ch</h1> <h1>spee.ch</h1>
<p>OMG we are live, it is actually happening. It is still happening.</p> <p>spee.ch is a single-serving site that reads (and will soon publish) images to and from the LBRY blockchain.</p>
<p>In just a few hours, this site will morph from this utterly bare 6 lines of HTML into a decentralized, censorship-resistant, truly free image sharing site powered by <a href="https://lbry.io">LBRY</a>. <p>You can watch live right now as it is being built!</p>
<p>You can watch it happen in real time, starting at 6pm EST tonight (March 29th):</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/C9LCapt_OYw" frameborder="0" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/C9LCapt_OYw" frameborder="0" allowfullscreen></iframe>
<p><a href="https://github.com/lbryio/spee.ch">GitHub repo</a></p> <p>Here are some sample images:</p>
<ul>
<?php foreach(['thailand', 'doitlive', 'coconuts', 'cow-air-balloon'] as $name): ?>
<li><a href="/<?php echo $name ?>">spee.ch/<?php echo $name ?></a></li>
<?php endforeach ?>
</ul>
<p>Publishing coming in just a few minutes!</p>

15
publish.php Normal file
View file

@ -0,0 +1,15 @@
<?php
if (isset($_POST['file']))
{
print_r($_POST['file']);
}
?>
<!DOCTYPE html>
<h1>Publish</h1>
<form method="POST" action="/publish" enctype="multipart/form-data">
<div>
<input type="file" name="file" />
</div>
<input type="submit" name="key" value="Go" />
</form>