...
 
Commits (4)
@task('pull')
git -C "storage/app/ffs-proposals" pull origin master
@endtask
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Project;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
......@@ -36,36 +37,66 @@ class ProcessProposals extends Command
*/
public function handle()
{
$amounts = [];
$projects = Project::whereNull('filename');
$details = [];
$files = Storage::files('ffs-proposals');
foreach ($files as $file) {
if (strpos($file,'.md')) {
$amount['name'] = $file;
$amount['amount'] = $this->getAmountFromText($file);
$amounts[] = $amount;
$detail['name'] = $file;
$detail['values'] = $this->getAmountFromText($file);
$details[] = $detail['values']['title'];
$project = $projects->where('title', $detail['values']['title'])->first();
if ($project) {
$project->filename = $file;
$project->target_amount = $detail['values']['amount'];
$project->save();
}
}
}
dd($amounts);
foreach ($details as $det) {
$this->line($det);
}
}
/**
* Gets the ffs amount requested from a file
* Gets the ffs variables out the top of the file
*
* @param string $filename
* @return int
* @return array
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getAmountFromText($filename = 'additional-gui-dev.md')
{
$input = Storage::get($filename);
$lines = preg_split('/\r\n|\r|\n/', $input);
$values = [];
$flag = false;
$isPayoutLine = false;
foreach($lines as $line) {
$line = str_replace(' ','', $line);
if ($line === '---') {
if ($flag === true) {
break;
}
$flag = true;
continue;
}
$details = explode(':', $line);
if ($details[0] === 'amount') {
return $details[1];
if (count($details) < 2) {
continue;
}
if ($details[0] === 'payouts') {
$isPayoutLine = true;
continue;
}
if ($isPayoutLine) {
$name = trim(str_replace('-','', $details[0]));
$values['payouts'][][$name] = ltrim($details[1]);
continue;
}
$values[$details[0]] = ltrim($details[1]);
}
return 0;
return $values;
}
}
......@@ -38,16 +38,21 @@ class UpdateSiteProposals extends Command
*/
public function handle()
{
$ffs = json_decode(\Storage::get('_data_ffs.json'));
$ffs[0]->proposals = array_merge($ffs[0]->proposals, $this->getNewProposals());
$yaml = json_encode($ffs, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
\Storage::put('new.json', $yaml);
$response = [
$this->ideaProposals(),
$this->fundingRequiredProposals(),
$this->workInProgressProposals(),
];
$json = json_encode($response, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
\Storage::put('new.json', $json);
}
public function getNewProposals()
public function ideaProposals()
{
$group = new stdClass();
$group->stage = 'Ideas';
$responseProposals = [];
$proposals = Project::where('gitlab_state', 'opened')->get();
$proposals = Project::where('gitlab_state', 'opened')->where('state', 'IDEA')->get();
foreach ($proposals as $proposal) {
$prop = new stdClass();
$prop->name = $proposal->title;
......@@ -56,6 +61,56 @@ class UpdateSiteProposals extends Command
$prop->date = $proposal->gitlab_created_at->format('F j, Y');
$responseProposals[] = $prop;
}
return $responseProposals;
$group->proposals = $responseProposals;
return $group;
}
public function fundingRequiredProposals()
{
$group = new stdClass();
$group->stage = 'Funding Required';
$responseProposals = [];
$proposals = Project::where('gitlab_state', 'merged')->where('state', 'FUNDING-REQUIRED')->get();
foreach ($proposals as $proposal) {
$prop = new stdClass();
$prop->name = $proposal->title;
$prop->{'gitlab-url'} = $proposal->gitlab_url;
$prop->{'local-url'} = '#';
$prop->{'donate-url'} = '#';
$prop->percentage = 0;
$prop->amount = $proposal->target_amount;
$prop->{'amount-funded'} = $proposal->target_amount;
$prop->author = $proposal->gitlab_username;
$prop->date = $proposal->gitlab_created_at->format('F j, Y');
$responseProposals[] = $prop;
}
$group->proposals = $responseProposals;
return $group;
}
public function workInProgressProposals()
{
$group = new stdClass();
$group->stage = 'Work in Progress';
$responseProposals = [];
$proposals = Project::where('gitlab_state', 'merged')->where('state', 'WORK-IN-PROGRESS')->get();
foreach ($proposals as $proposal) {
$prop = new stdClass();
$prop->name = $proposal->title;
$prop->{'gitlab-url'} = $proposal->gitlab_url;
$prop->{'local-url'} = '#';
$prop->milestones = 4;
$prop->{'milestones-completed'} = 4;
$prop->{'milestones-percentage'} = 100;
$prop->percentage = 0;
$prop->amount = $proposal->target_amount;
$prop->{'amount-funded'} = $proposal->target_amount;
$prop->author = $proposal->gitlab_username;
$prop->date = $proposal->gitlab_created_at->format('F j, Y');
$responseProposals[] = $prop;
}
$group->proposals = $responseProposals;
return $group;
}
}
......@@ -46,4 +46,17 @@ class FundingController extends Controller
return view('projects.show')
->with('project', $project);
}
public function donate(Request $request, $paymentId)
{
$project = Project::where('payment_id', $paymentId)->firstOrFail();
if ($request->wantsJson())
{
return new ProjectResource($project);
}
return view('projects.donate')
->with('project', $project);
}
}
......@@ -20,6 +20,7 @@ class CreateProjectsTable extends Migration
$table->string('address')->nullable();
$table->string('target_amount')->nullable();
$table->string('state')->default('OPENED');
$table->string('filename')->nullable();
$table->unsignedInteger('merge_request_id')->unique();
$table->string('gitlab_username');
$table->string('gitlab_url');
......
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FFS</title>
<link rel="apple-touch-icon" sizes="180x180" href="/meta/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/meta/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/meta/favicon-16x16.png">
<link rel="manifest" href="/meta/manifest.json">
<link rel="mask-icon" href="/meta/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#ffffff">
<link href="/css/custom.css" rel="stylesheet">
<meta name="msapplication-config" content="/ietemplates/ieconfig.xml">
</head>
<body>
<div class="page-wrapper">
<div class="mob-nav">
<input class="burger-check" id="mobile-burger" type="checkbox"><label for="mobile-burger" class="burger"></label>
<div class="slide-in-nav">
<div class="container slide-in">
<div class="row">
<div class="col-xs-12">
<div class="text-center nav-item mob">
<a href="/forum-funding-system/ideas/" class="top-link">Ideas</a>
</div>
<div class="text-center nav-item mob">
<a href="/forum-funding-system/funding-required/">Funding Required</a>
</div>
<div class="text-center nav-item mob">
<a href="/forum-funding-system/work-in-progress/">Work in Progress</a>
</div>
<div class="text-center nav-item mob">
<a href="/forum-funding-system/completed-proposals/">Completed Tasks</a>
</div>
<div class="text-center nav-item mob">
<a href="/forum-funding-system/completed-proposals/">Back to Getmonero.org</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="desktop-nav">
<nav class="container">
<div class="row middle-xs">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<a href="/forum-funding-system/"><img src="/img/monero-logo.png" alt="Monero Logo" class="monero-logo"></a>
</div>
<div class="col-lg-8 col-md-8 col-sm-8 items end-xs">
<div class="row end-xs middle-xs">
<div class="col-md-12">
<a href="/forum-funding-system/ideas/" class="top-link">Ideas</a>
<a href="/forum-funding-system/funding-required/">Funding Required</a>
<a href="/forum-funding-system/work-in-progress/">Work in Progress</a>
<a href="/forum-funding-system/completed-proposals/">Completed Tasks</a>
<a href="/forum-funding-system/completed-proposals/">Getmonero.org</a>
</div>
</div>
</div>
</div>
</nav>
</div>
<div class="mob bot-nav white-nav">
<div class="row middle-xs">
<div class="col-xs-6">
<a href="/
"><img src="/img/monero-logo.png" alt="Monero Logo" class="monero-logo"></a>
</div>
</div>
</div>
<div class="site-wrap ffs-proposal ffs-con">
<div class="container ffs-breadcrumbs">
<div class="row">
<div class="col-xs-12">
<p><a href="/forum-funding-system/">Forum Funding System</a></p>
<p><a href="/forum-funding-system/funding-required/">Funding Required</a></p>
<p><a href="/forum-funding-system/funding-required/">{{$project->title}}</a></p>
<p class="bread-active">Contribute</p>
</div>
</div>
</div>
<section class="container full">
<div class="info-block">
<div class="row">
<div class="col-xs-12">
<h2>{{$project->title}}</h2>
<div class="row middle-xs between-xs">
<p class="author-list"><span><img src="/img/author-filled.png"></span>{{$project->gitlab_username}}</p>
<p class="date-list"><span><img src="/img/calendar.png"></span>{{$project->github_created_at}}</p>
<p class="bar-fund-status">Raised <span class="progress-number-funded">{{$project->target_amount}}</span> of <span class="progress-number-goal">[AMOUNT RAISED HERE]</span> XMR</p>
</div>
<div class="progress-bar">
<span class="fund-progress" style="width: [PERCENTAGE HERE]%"></span>
</div>
<p>Your contribution should be visible within 5 minutes of you sending your contribution. If for some reason it is not there, please contact a member of the Core Team!</p>
</div>
</div>
</div>
</section>
<section class="container full">
<div class="row">
<div class="col-xs-12">
<div class="tabs con-how">
<input class="input" name="tabs" type="radio" id="tab-1" checked="checked"/>
<label class="label" for="tab-1">QR Code</label>
<div class="panel col-xs-12">
<div class="panel-segment">
<h3>Contribute with a QR code</h3>
<p>1. Choose the amount of XMR you wish to contribute to this proposal</p>
<p>2. Scan this QR code or tap to open in your Monero wallet app:</p>
<p>
<a href="[MONERO LINK HERE]" class="qr"><img src="[PATH TO QR CODE HERE]"/></a>
</p>
<p>3. Send! Thank you! You are amazing!</p>
</div>
</div>
<input class="input" name="tabs" type="radio" id="tab-2"/>
<label class="label" for="tab-2">Integrated Address</label>
<div class="panel col-xs-12">
<div class="panel-segment">
<h3>Contribute using an integrated address</h3>
<p>1. Choose the amount of XMR you wish to contribute to this proposal</p>
<p>2. Enter the following XMR address:</p> <p class="string">{{$project->address}}</p>
<p>3. Send! Thank you! You are amazing!</p>
</div>
</div>
<input class="input" name="tabs" type="radio" id="tab-3"/>
<label class="label" for="tab-3">Payment ID</label>
<div class="panel col-xs-12">
<div class="panel-segment">
<h3>Contribute using a payment ID</h3>
<p>1. Choose the amount of XMR you wish to contribute to this proposal</p>
<p>2. Enter the following XMR address:</p> <p class="string">{{ env('WALLET_ADDRESS') }}</p>
<p>3. Enter the following payment ID that is unique to this proposal:</p> <p class="string">{{$project->payment_id}}</p>
<p>4. Send! Thank you! You're amazing!</p>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<footer class="container-fluid">
<div class="container">
<div class="row around-xs footer-wrapper">
<div class="row center-xs">
<div class="social-icons">
</div>
<div class="footer-links">
<ul class="list-unstyled list-inline">
</ul>
</div>
</div>
</div>
</div>
</footer>
</div>
</body>
</html>
\ No newline at end of file
......@@ -16,3 +16,4 @@ Route::get('/', function () {
});
Route::get('projects', ['as' => 'ffs', 'uses' => FundingController::class.'@index']);
Route::get('projects/{paymentId}', ['as' => 'ffs', 'uses' => FundingController::class.'@show']);
Route::get('projects/{paymentId}/donate', ['as' => 'ffs', 'uses' => FundingController::class.'@donate']);