Markup locations that aren’t places in h-adr markup

This commit is contained in:
Jonny Barnes 2016-10-24 18:35:48 +01:00
parent 776ebd5bb0
commit 36c3fac33b
3 changed files with 11 additions and 6 deletions

View file

@ -283,7 +283,7 @@ class NotesController extends Controller
* *
* @param float The latitude * @param float The latitude
* @param float The longitude * @param float The longitude
* @return string The location name * @return string The location HTML
*/ */
public function reverseGeoCode(float $latitude, float $longitude): string public function reverseGeoCode(float $latitude, float $longitude): string
{ {
@ -303,7 +303,7 @@ class NotesController extends Controller
]); ]);
$json = json_decode($response->getBody()); $json = json_decode($response->getBody());
if (isset($json->address->town)) { if (isset($json->address->town)) {
$address = $json->address->town . ', ' . $json->address->country; $address = '<span class="p-locality">' . $json->address->town . '</span>, <span class="p-country-name">' . $json->address->country . '</span>';
Cache::forever($latlng, $address); Cache::forever($latlng, $address);
return $address; return $address;
@ -315,14 +315,15 @@ class NotesController extends Controller
return $address; return $address;
} }
if (isset($json->address->county)) { if (isset($json->address->county)) {
$address = $json->address->county . ', ' . $json->reversegeocode->country; $address = '<span class="p-region">' . $json->address->county . '</span>, <span class="p-country-name">' . $json->address->country . '</span>';
Cache::forever($latlng, $address); Cache::forever($latlng, $address);
return $address; return $address;
} }
Cache::forever($latlng, $json->address->country); $adress = '<span class="p-country-name">' . $json->address->country . '</span>';
Cache::forever($latlng, $address);
return $json->reversegeocode->addressparts->country; return $address;
}); });
} }
} }

View file

@ -35,5 +35,9 @@ class NotesTableSeeder extends Seeder
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755); mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image'); copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
} }
$noteWithCoords = App\Note::create([
'note' => 'Note from somehwere',
'location' => '53.499,-2.379'
]);
} }
} }

View file

@ -16,7 +16,7 @@
</div> </div>
<div class="note-metadata"> <div class="note-metadata">
<a class="u-url" href="/notes/{{ $note->nb60id }}"><time class="dt-published" datetime="{{ $note->iso8601_time }}">{{ $note->human_time }}</time></a>@if($note->client_name) via <a class="client" href="{{ $note->client_id }}">{{ $note->client_name }}</a>@endif <a class="u-url" href="/notes/{{ $note->nb60id }}"><time class="dt-published" datetime="{{ $note->iso8601_time }}">{{ $note->human_time }}</time></a>@if($note->client_name) via <a class="client" href="{{ $note->client_id }}">{{ $note->client_name }}</a>@endif
@if($note->address)in <span class="p-location"><span class="p-name">@if($note->placeLink)<a href="{{ $note->placeLink }}">@endif{{ $note->address }}@if($note->placeLink)</a>@endif</span><data class="p-latitude" value="{{ $note->latitude }}"><data class="p-longitude" value="{{ $note->longitude }}"></span>@endif @if($note->address)in <span class="h-adr">{!! $note->address !!}</span>@endif
@if($note->replies > 0)Replies: {{ $note->replies }}@endif @if($note->replies > 0)Replies: {{ $note->replies }}@endif
@if($note->tweet_id)@include('templates.social-links', ['tweet_id' => $note->tweet_id, 'nb60id' => $note->nb60id])@endif @if($note->tweet_id)@include('templates.social-links', ['tweet_id' => $note->tweet_id, 'nb60id' => $note->nb60id])@endif
@if ($note->placeLink) @if ($note->placeLink)