Browse Source

add db config option to add a micropub endpoint

pull/5/head
Aaron Parecki 9 years ago
parent
commit
0df69a333a
3 changed files with 61 additions and 1 deletions
  1. +9
    -1
      compass/app/Http/Controllers/Controller.php
  2. +30
    -0
      compass/database/migrations/2015_12_28_221004_micropub.php
  3. +22
    -0
      compass/resources/views/settings.blade.php

+ 9
- 1
compass/app/Http/Controllers/Controller.php View File

@ -130,7 +130,7 @@ class Controller extends BaseController
->first();
if(!$db)
return redirect('/');
if($request->input('remove_user')) {
$user = DB::table('users')->where('url','=',$request->input('remove_user'))->first();
@ -164,6 +164,14 @@ class Controller extends BaseController
]);
}
return redirect('/settings/'.$db->name);
} else if($request->input('micropub_endpoint')) {
DB::table('databases')->where('id', $db->id)
->update([
'micropub_endpoint' => $request->input('micropub_endpoint'),
'micropub_token' => $request->input('micropub_token'),
]);
return redirect('/settings/'.$db->name);
}
}

+ 30
- 0
compass/database/migrations/2015_12_28_221004_micropub.php View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Micropub extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('databases', function ($table) {
$table->string('micropub_endpoint', 255);
$table->string('micropub_token', 1024);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

+ 22
- 0
compass/resources/views/settings.blade.php View File

@ -6,6 +6,8 @@
<div class="dashboard">
<h2>Database</h2>
<div class="panel">
<h3>Read Token</h3>
<div class="token"><code>{{ $database->read_token }}</code></div>
@ -46,6 +48,26 @@
</div>
<br><br>
<h2>Micropub Export</h2>
<p>Enter a Micropub endpoint and token below and any trips that are written to this database will be sent to the endpoint as well.</p>
<div class="panel">
<form action="/settings/{{ $database->name }}" method="post" class="pure-form pure-form-stacked">
<fieldset>
<label for="micropub_endpoint">Micropub Endpoint</label>
<input name="micropub_endpoint" type="url" placeholder="http://example.com/micropub" class="pure-input-1" value="{{ $database->micropub_endpoint }}">
<label for="micropub_token">Access Token</label>
<input name="micropub_token" type="text" placeholder="" class="pure-input-1" value="{{ $database->micropub_token }}">
<button type="submit" class="pure-button pure-button-primary">Save</button>
</fieldset>
</form>
</div>
</div>
<script>
jQuery(function($){

Loading…
Cancel
Save