Implement public timeline view

Created a view to show the public timeline. Added logic to embed
images instead of having to follow a link.
This commit is contained in:
St John Karp 2018-08-11 10:38:31 -07:00
parent 6021bb0391
commit d7a3e81cff
10 changed files with 422 additions and 113 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Mastodon;
class TimelineController extends Controller
{
public function show_timeline()
{
$public_timeline = Mastodon::domain(env('MASTODON_API'))
->get('/timelines/public', ['local' => true]);
# Embed images.
foreach ($public_timeline as $index => $status)
{
$public_timeline[$index]['content'] = preg_replace(
'/<a href="([^>]+)\.(png|jpg|jpeg|gif)">([^<]+)<\/a>/',
'<a href="${1}.${2}"><img src="${1}.${2}" alt="${3}" /></a>',
$status['content']
);
}
return view('timeline', ['statuses' => $public_timeline]);
}
}

View File

@ -8,7 +8,8 @@
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
"laravel/tinker": "~1.0",
"revolution/laravel-mastodon-api": "^1.5"
},
"require-dev": {
"filp/whoops": "~2.0",

292
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "7f1915ec708986f5c88e22e683d74275",
"content-hash": "b7904d07d1e1765a0a199aa11d6301a3",
"hash": "92f25db138dc11525945a2c977eff7a9",
"content-hash": "fe6ad9502bf61c169c783babe3aac2e8",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@ -321,6 +321,187 @@
],
"time": "2017-06-15 17:19:42"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"shasum": ""
},
"require": {
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.0"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.3-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2018-04-22 15:46:56"
},
{
"name": "guzzlehttp/promises",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2016-12-20 10:07:11"
},
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2017-03-20 17:10:46"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
@ -1011,6 +1192,56 @@
],
"time": "2017-02-14 16:28:37"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06 14:39:51"
},
{
"name": "psr/log",
"version": "1.0.2",
@ -1262,6 +1493,63 @@
],
"time": "2018-07-19 23:38:55"
},
{
"name": "revolution/laravel-mastodon-api",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/kawax/laravel-mastodon-api.git",
"reference": "5fd8083599174da4fe4d15e7386d670fe5f0099b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kawax/laravel-mastodon-api/zipball/5fd8083599174da4fe4d15e7386d670fe5f0099b",
"reference": "5fd8083599174da4fe4d15e7386d670fe5f0099b",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.2",
"illuminate/support": "^5.5",
"php": ">=7.0.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "~3.5",
"phpunit/phpunit": "6.*"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Revolution\\Mastodon\\Providers\\MastodonServiceProvider"
],
"aliases": {
"Mastodon": "Revolution\\Mastodon\\Facades\\Mastodon"
}
}
},
"autoload": {
"psr-4": {
"Revolution\\Mastodon\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "kawax",
"email": "kawaxbiz@gmail.com"
}
],
"description": "Mastodon API for Laravel",
"keywords": [
"laravel",
"mastodon"
],
"time": "2018-05-17 06:29:25"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.1.2",

9
public/css/app.css vendored

File diff suppressed because one or more lines are too long

74
public/css/styles.css vendored Normal file
View File

@ -0,0 +1,74 @@
* {
font-family: inherit;
line-height: inherit;
color: inherit;
margin: 0;
}
* + * {
margin-top: 1.5em;
}
body, br, dt, dd, th, td, option {
margin-top: 0;
}
html {
background-color: lightgray;
font-family: "Adobe Caslon Pro", "Hoefler Text", Garamond, Times, "Times New Roman", serif;
font-feature-settings: "liga" on, "dlig" on, "hlig" on, "zero" on, "lnum" off, "onum" on, "kern" on, "ordn" on;
font-kerning: normal;
font-variant-ligatures: common-ligatures discretionary-ligatures historical-ligatures;
font-variant-numeric: oldstyle-nums ordinal slashed-zero;
font-size: 20px;
line-height: 1.4em;
text-rendering: optimizeLegibility;
}
body {
margin-left: auto;
margin-right: auto;
padding-top: 2em;
padding-bottom: 2em;
max-width: 40em;
}
div.status {
border: 1px solid black;
padding: 1em;
}
div.status img {
max-width: 100%;
}
div.status img.avatar {
max-width: 48px;
}
/* Tooltip container */
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}
/* Tooltip text */
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text - see examples below! */
position: absolute;
z-index: 1;
}
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}

1
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,26 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<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>jank.town | Public Timeline</title>
<link rel="stylesheet" href="/css/styles.css" />
</head>
<body>
@foreach ($statuses as $status)
<div class="status">
<div class="tooltip">
<a href="{{ $status['account']['url'] }}">
<img src="{{ $status['account']['avatar'] }}" alt="{{ $status['account']['acct'] }}" class="avatar" />
{{ $status['account']['display_name'] }}
</a>
<span class="tooltiptext">{{ $status['account']['acct'] }}</span>
</div>
<p>{!! $status['content'] !!}</p>
</div>
@endforeach
</body>
</html>

View File

@ -1,95 +0,0 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<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>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
<a href="{{ route('register') }}">Register</a>
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Laravel
</div>
<div class="links">
<a href="https://laravel.com/docs">Documentation</a>
<a href="https://laracasts.com">Laracasts</a>
<a href="https://laravel-news.com">News</a>
<a href="https://forge.laravel.com">Forge</a>
<a href="https://github.com/laravel/laravel">GitHub</a>
</div>
</div>
</div>
</body>
</html>

View File

@ -13,6 +13,6 @@ use Illuminate\Http\Request;
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
/*Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
});*/

View File

@ -11,6 +11,4 @@
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/', 'TimelineController@show_timeline');