Squashed commit of the following:

commit 2840f58c61c906f5ac408e9681cf33f802625f74
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Nov 25 15:52:58 2016 +0000

    Add changes

commit 86b515a20c65e4956766242db424d84082c7e99e
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Nov 25 15:42:00 2016 +0000

    gulp derived assets

commit def587e2f3805a0ba669d804b12d83e9f3ec5ea7
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Nov 25 15:41:43 2016 +0000

    Include new contact styles

commit 8256dc30b0ad23096b3dcde264826fc6cfaa8788
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Nov 25 15:41:19 2016 +0000

    Better styled contacts

commit f12ce1d6f68857d88ad6f39f8b835d036c793c8a
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 18:11:47 2016 +0000

    Sort out views for contacts, better h-card

commit 7be5fe82029b20f6cde3ce921f0cb625c27d21d6
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 18:09:00 2016 +0000

    quick code tidy

commit 71dad7e4918ff4e513715d4ef3a296fa39507ca1
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:58:32 2016 +0000

    Get contact editing working

commit 0b885190733979be4f5508d28523e8e0b45399a2
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:42:10 2016 +0000

    Improve form layout, add facebook entry

commit 0a6bd79e384dcd872cb9a89b1232afaf20e729b2
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:41:49 2016 +0000

    Add facebook column

commit 639d49045c9a213eafd970ceafe288a51cfc95c8
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:30:40 2016 +0000

    Update changelog

commit f4a018591d50bf9af7e1a64daa9e4a04daa6e1d4
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:27:42 2016 +0000

    Reference right view, use a better variable name when parsing a URL

commit 583f7d7f7cc577cf31b37bbc2bdcd8865c7b9980
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:26:58 2016 +0000

    Move mini-hcard to templates folder, update content

commit 2e1b13eff052b65cf2b86796a9509c81d9c86768
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Wed Nov 23 16:26:10 2016 +0000

    Add facebook column to contacts table
This commit is contained in:
Jonny Barnes 2016-11-25 15:53:14 +00:00
parent 73e4e09a04
commit 23b6e440ba
19 changed files with 143 additions and 55 deletions

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Contact;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Filesystem\Filesystem;
class ContactsAdminController extends Controller
@ -66,10 +67,10 @@ class ContactsAdminController extends Controller
$contact->nick = $request->input('nick');
$contact->homepage = $request->input('homepage');
$contact->twitter = $request->input('twitter');
$contact->facebook = $request->input('facebook');
$contact->save();
$contactId = $contact->id;
return view('admin.newcontactsuccess', ['id' => $contactId]);
return view('admin.newcontactsuccess', ['id' => $contact->id]);
}
/**
@ -88,6 +89,7 @@ class ContactsAdminController extends Controller
$contact->nick = $request->input('nick');
$contact->homepage = $request->input('homepage');
$contact->twitter = $request->input('twitter');
$contact->facebook =$request->input('facebook');
$contact->save();
if ($request->hasFile('avatar')) {

View file

@ -17,10 +17,10 @@ class ContactsController extends Controller
$filesystem = new Filesystem();
$contacts = Contact::all();
foreach ($contacts as $contact) {
$contact->homepagePretty = parse_url($contact->homepage)['host'];
$file = public_path() . '/assets/profile-images/' . $contact->homepagePretty . '/image';
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
$contact->image = ($filesystem->exists($file)) ?
'/assets/profile-images/' . $contact->homepagePretty . '/image'
'/assets/profile-images/' . $contact->homepageHost . '/image'
:
'/assets/profile-images/default-image';
}
@ -37,10 +37,10 @@ class ContactsController extends Controller
{
$filesystem = new Filesystem();
$contact = Contact::where('nick', '=', $nick)->firstOrFail();
$contact->homepagePretty = parse_url($contact->homepage)['host'];
$file = public_path() . '/assets/profile-images/' . $contact->homepagePretty . '/image';
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
$contact->image = ($filesystem->exists($file)) ?
'/assets/profile-images/' . $contact->homepagePretty . '/image'
'/assets/profile-images/' . $contact->homepageHost . '/image'
:
'/assets/profile-images/default-image';

View file

@ -178,15 +178,16 @@ class Note extends Model implements HasMedia
try {
$contact = Contact::where('nick', '=', mb_strtolower($matches[1]))->firstOrFail();
} catch (ModelNotFoundException $e) {
//assume its an actual twitter handle
return '<a href="https://twitter.com/' . $matches[1] . '">' . $matches[0] . '</a>';
}
$path = parse_url($contact->homepage)['host'];
$contact->photo = (file_exists(public_path() . '/assets/profile-images/' . $path . '/image')) ?
'/assets/profile-images/' . $path . '/image'
$host = parse_url($contact->homepage, PHP_URL_HOST);
$contact->photo = (file_exists(public_path() . '/assets/profile-images/' . $host . '/image')) ?
'/assets/profile-images/' . $host . '/image'
:
'/assets/profile-images/default-image';
return trim(view('mini-hcard-template', ['contact' => $contact])->render());
return trim(view('templates.mini-hcard', ['contact' => $contact])->render());
},
$text
);

View file

@ -1,5 +1,10 @@
# Changelog
## Version {next}
- improved contact h-cards
- Better look in /contacts
- h-cards now have person-tags (issue#36)
## Version 0.0.16.1 (2016-11-22)
- Break words
- Added a footer to all pages

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFacebookToContacts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
$table->string('facebook')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropColumn('facebook');
});
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -18,3 +18,4 @@ html {
@import "pagination";
@import "note-form";
@import "mapbox";
@import "contacts";

14
resources/assets/sass/contacts.scss vendored Normal file
View file

@ -0,0 +1,14 @@
//contacts.scss
.contact {
display: flex;
flex-direction: row;
margin-top: 1em;
border-bottom: 1px dashed grey;
}
.contact img {
margin-right: 0.2rem;
width: 100px;
height:100px;
}

View file

@ -7,13 +7,35 @@ Edit Contact « Admin CP
@section('content')
<h1>Edit Contact</h1>
<form action="/admin/contacts/edit/{{ $contact->id }}" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<label for="name">Real Name:</label> <input type="text" name="name" id="name" placeholder="Real Name" value="{{ $contact->name }}"><br>
<label for="nick">Nick:</label> <input type="text" name="nick" id="nick" placeholder="local_nick" value="{{ $contact->nick }}"><br>
<label for="homepage">Homepage:</label> <input type="text" name="homepage" id="homepage" placeholder="https://homepage.com" value="{{ $contact->homepage }}"><br>
<label for="twitter">Twitter Nick:</label> <input type="text" name="twitter" id="twitter" placeholder="Twitter handle" value="{{ $contact->twitter }}"><br>
<label for="avatar">Avatar:</label> <input type="file" accept="image/*" value="Upluad" name="avatar" id="avatar"><br>
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<fieldset class="note-ui">
<legend>Conctact</legend>
<div>
<label for="name">Real Name:</label>
<input type="text" name="name" id="name" placeholder="Real Name" value="{{ $contact->name }}">
</div>
<div>
<label for="nick">Nick:</label>
<input type="text" name="nick" id="nick" placeholder="local_nick" value="{{ $contact->nick }}">
</div>
<div>
<label for="homepage">Website:</label>
<input type="text" name="homepage" id="homepage" placeholder="https://homepage.com" value="{{ $contact->homepage }}">
</div>
<div>
<label for="twitter">Twitter Nick:</label>
<input type="text" name="twitter" id="twitter" placeholder="Twitter handle" value="{{ $contact->twitter }}">
</div>
<div>
<label for="facebook">Facebook Profile ID:</label>
<input type="text" name="facebook" id="facebook" placeholder="Facebook ID" value="{{ $contact->facebook }}">
</div>
<div>
<label for="avatar">Avatar:</label>
<input type="file" accept="image/*" value="Upload" name="avatar" id="avatar">
</div>
<input type="submit" name="submit" value="Submit">
</fieldset>
</form>
<p>Or do you want to <a href="/admin/contacts/delete/{{ $contact->id }}">delete</a> this contact?</p>
<p>Instead of uploading an image, you can <a href="/admin/contacts/edit/{{ $contact->id }}/getavatar">grab from their homepage</a>?</p>

View file

@ -7,21 +7,23 @@ List Contacts « Admin CP
@section('content')
<h1>Contacts</h1>
<table>
<tr>
<th>Real Name</th>
<th>Nick</th>
<th>Homepage</th>
<th>Twitter</th>
<th></th>
</tr>
<tr>
<th>Real Name</th>
<th>Nick</th>
<th>Homepage</th>
<th>Twitter</th>
<th>Facebook</th>
<th></th>
</tr>
@foreach($contacts as $contact)
<tr>
<td>{{ $contact->name }}</td>
<td>{{ $contact->nick }}</td>
<td>{{ $contact->homepage }}</td>
<td>{{ $contact->twitter }}</td>
<td><a href="/admin/contacts/edit/{{ $contact->id }}">edit</a></td>
</tr>
<tr>
<td>{{ $contact->name }}</td>
<td>{{ $contact->nick }}</td>
<td>{{ $contact->homepage }}</td>
<td>{{ $contact->twitter }}</td>
<td>{{ $contact->facebook }}</td>
<td><a href="/admin/contacts/edit/{{ $contact->id }}">edit</a></td>
</tr>
@endforeach
</table>
@stop

View file

@ -1,10 +0,0 @@
<div class="contact h-card">
<div class="contact-info">
<span class="p-name">{{ $contact->name }}</span> <a href="/contacts/{{ $contact->nick }}">{{ '@' . $contact->nick }}</a>
<ul class="contact-links">
<li><i class="fa fa-globe fa-fw"></i><a href="{{ $contact->homepage }}" class="u-url">{{ $contact->homepagePretty }}</a></li>
@if($contact->twitter != null)<li><i class="fa fa-twitter fa-fw"></i><a href="https://twitter.com/{{ $contact->twitter }}">{{ $contact->twitter }}</a></li>@endif
</ul>
</div>
<img src="{{ $contact->image }}" alt="" class="u-photo">
</div>

View file

@ -5,5 +5,5 @@ Contacts « Jonny Barnes
@stop
@section('content')
@include('contact-template', array('contact' => $contact))
@include('templates.contact', array('contact' => $contact))
@stop

View file

@ -6,6 +6,6 @@ Contacts « Jonny Barnes
@section('content')
@foreach($contacts as $contact)
@include('contact-template', array('contact' => $contact))
@include('templates.contact', array('contact' => $contact))
@endforeach
@stop

View file

@ -1,4 +0,0 @@
<a class="h-card vcard mini-h-card" href="{{ $contact->homepage }}">
<img class="u-photo photo logo" alt="" src="{{ $contact->photo }}">
{!! $contact->name !!}
</a>

View file

@ -0,0 +1,15 @@
<div class="h-card contact">
<div>
<img src="{{ $contact->image }}" alt="" class="u-photo">
</div>
<div>
<span class="p-name">{{ $contact->name }}</span> <a href="/contacts/{{ $contact->nick }}">{{ '@' . $contact->nick }}</a>
<ul class="contact-links">
<li><a class="u-url" href="{{ $contact->homepage }}">{{ $contact->homepageHost }}</a></li>
@if($contact->twitter)<li><a class="u-url" href="https://twitter.com/{{ $contact->twitter }}">Twitter Profile</a></li>@endif
@if($contact->facebook)<li><a class="u-url" href="https://www.facebook.com/{{ $contact->facebook }}">Facebook Profile</a></li>@endif
</ul>
</div>
</div>

View file

@ -0,0 +1,8 @@
<span class="u-category h-card">
<a class="mini-h-card u-url p-name" href="{{ $contact->homepage }}">
<img class="u-photo" alt="" src="{{ $contact->photo }}">
{!! $contact->name !!}
</a>
@if ($contact->facebook)<a class="u-url" href="https://www.facebook.com/{{ $contact->facebook }}"></a>@endif
@if ($contact->twitter)<a class="u-url" href="https://twitter.com/{{ $contact->twitter }}"></a>@endif
</span>