Began parsing process for Spee.ch URL
This commit is contained in:
parent
94f6c6eca2
commit
18c26ab330
5 changed files with 35 additions and 14 deletions
|
@ -185,7 +185,14 @@ class LBRY_Admin
|
||||||
// Check that nonce
|
// Check that nonce
|
||||||
if (! isset($_POST['_lbrynonce']) || ! wp_verify_nonce($_POST['_lbrynonce'], 'lbry_add_channel')) {
|
if (! isset($_POST['_lbrynonce']) || ! wp_verify_nonce($_POST['_lbrynonce'], 'lbry_add_channel')) {
|
||||||
LBRY()->notice->set_notice('error');
|
LBRY()->notice->set_notice('error');
|
||||||
|
} elseif (! isset($_POST['new_channel']) || ! isset($_POST['bid_amount'])) {
|
||||||
|
LBRY()->notice->set_notice('error', 'Must supply both channel name and bid amount');
|
||||||
} else {
|
} else {
|
||||||
|
$new_channel = $_POST['new_channel'];
|
||||||
|
$bid_amount = $_POST['bid_amount'];
|
||||||
|
|
||||||
|
// TODO: Wrap in a try catch
|
||||||
|
LBRY()->daemon->channel_new($new_channel, $bid_amount);
|
||||||
LBRY()->notice->set_notice('success', 'Successfully added a new channel!', true);
|
LBRY()->notice->set_notice('success', 'Successfully added a new channel!', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,9 @@ class LBRY_Daemon
|
||||||
* https://lbryio.github.io/lbry/#channel_new
|
* https://lbryio.github.io/lbry/#channel_new
|
||||||
* @return array dictionary containing result of the request
|
* @return array dictionary containing result of the request
|
||||||
*/
|
*/
|
||||||
public function channel_new()
|
public function channel_new($channel_name, $bid_amount)
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,6 +102,8 @@ class LBRY_Daemon
|
||||||
{
|
{
|
||||||
$output_filename = "lbrydaemon";
|
$output_filename = "lbrydaemon";
|
||||||
|
|
||||||
|
// HACK: Shouldn't just directly download, need to know OS, etc
|
||||||
|
// TODO: Make sure we are only installing if not there or corrupted
|
||||||
$host = "http://build.lbry.io/daemon/build-6788_commit-5099e19_branch-lbryum-refactor/mac/lbrynet";
|
$host = "http://build.lbry.io/daemon/build-6788_commit-5099e19_branch-lbryum-refactor/mac/lbrynet";
|
||||||
$fp = fopen(LBRY_URI . '/' . $output_filename, 'w+');
|
$fp = fopen(LBRY_URI . '/' . $output_filename, 'w+');
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
|
@ -10,19 +10,25 @@
|
||||||
class LBRY_Speech
|
class LBRY_Speech
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* [__construct description]
|
* HTML Parser
|
||||||
|
* @var LBRY_Speech_Parser
|
||||||
*/
|
*/
|
||||||
|
private $parser = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->parser = new LBRY_Speech_Parser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_address()
|
/**
|
||||||
|
* Checks to see if we need to rewrite URLS, does if necessary
|
||||||
|
*/
|
||||||
|
public function maybe_rewrite_urls()
|
||||||
{
|
{
|
||||||
return get_option(LBRY_SPEECH);
|
// See if we have a Spee.ch URL and if we are on the front-end
|
||||||
}
|
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
|
||||||
|
if ($speech_url != '' && !is_admin()) {
|
||||||
public function set_address($address)
|
ob_start(array($this->parser, 'rewrite'));
|
||||||
{
|
}
|
||||||
update_option(LBRY_SPEECH, $address);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
|
|
||||||
class LBRY_Speech_Parser
|
class LBRY_Speech_Parser
|
||||||
{
|
{
|
||||||
/**
|
public function rewrite($html)
|
||||||
* [__construct description]
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
{
|
||||||
|
// TODO: Completely fix this, as its super slow. Looking at cdn_enabler for ideas
|
||||||
|
$speech_url = get_option(LBRY_SETTINGS)[LBRY_SPEECH];
|
||||||
|
|
||||||
|
$html = str_replace(site_url(), $speech_url, $html);
|
||||||
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,8 @@ class LBRYPress
|
||||||
// Admin request
|
// Admin request
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
$this->admin = new LBRY_Admin();
|
$this->admin = new LBRY_Admin();
|
||||||
|
} else {
|
||||||
|
$this->speech->maybe_rewrite_urls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +165,7 @@ class LBRYPress
|
||||||
add_option(LBRY_SETTINGS, $option_defaults, false);
|
add_option(LBRY_SETTINGS, $option_defaults, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: decide if we need to check for missing or corrupt settings. May be unecessary.
|
// COMBAK: decide if we need to check for missing or corrupt settings. May be unecessary.
|
||||||
// Double check we have all settings, if not, update with default
|
// Double check we have all settings, if not, update with default
|
||||||
// $current_settings = get_option(LBRY_SETTINGS);
|
// $current_settings = get_option(LBRY_SETTINGS);
|
||||||
// $new_settings = $current_settings;
|
// $new_settings = $current_settings;
|
||||||
|
|
Loading…
Add table
Reference in a new issue