Skip to content

Commit

Permalink
Merge branch 'release/6.0.23'
Browse files Browse the repository at this point in the history
* release/6.0.23:
  compile assets
  Apply fixes from StyleCI (#943)
  wip
  wip
  adding tests
  Apply fixes from StyleCI (#941)
  wip
  Apply fixes from StyleCI (#940)
  cleanup and refactor
  wip
  Apply fixes from StyleCI (#936)
  set strict types
  • Loading branch information
austintoddj committed Mar 5, 2021
2 parents 453ea97 + 4377283 commit 00d6d4a
Show file tree
Hide file tree
Showing 41 changed files with 1,392 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/app.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions public/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
*/

/*!
* Sizzle CSS Selector Engine v2.3.5
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2020-03-14
* Date: 2021-02-16
*/

/*!
Expand All @@ -98,17 +98,17 @@
*/

/*!
* jQuery JavaScript Library v3.5.1
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2020-05-04T22:49Z
* Date: 2021-03-02T17:08Z
*/

/*!
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=90af637484ed2deeb568",
"/css/app.css": "/css/app.css?id=a49a08395034a6be9488"
"/js/app.js": "/js/app.js?id=e494ab5415f2d400ab5b",
"/css/app.css": "/css/app.css?id=17b9084a51cfbf270aa4"
}
10 changes: 5 additions & 5 deletions resources/js/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default [
name: 'stats',
component: AllStats,
},
{
path: '/stats/:id',
name: 'post-stats',
component: PostStats,
},
{
path: '/posts',
name: 'posts',
Expand All @@ -39,6 +34,11 @@ export default [
name: 'create-post',
component: EditPost,
},
{
path: '/posts/:id/stats',
name: 'post-stats',
component: PostStats,
},
{
path: '/posts/:id/edit',
name: 'edit-post',
Expand Down
8 changes: 4 additions & 4 deletions resources/js/views/AllStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</p>
</div>
<div class="card-body pt-0 pb-2">
<p class="card-text display-4">{{ suffixedNumber(data.totalViews) }}</p>
<p class="card-text display-4">{{ suffixedNumber(data.views) }}</p>
</div>
</div>
<div class="card shadow-lg">
Expand All @@ -54,7 +54,7 @@
</p>
</div>
<div class="card-body pt-0 pb-2">
<p class="card-text display-4">{{ suffixedNumber(data.totalVisits) }}</p>
<p class="card-text display-4">{{ suffixedNumber(data.visits) }}</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -186,11 +186,11 @@ export default {
},
plotViewPoints() {
return JSON.parse(this.data.traffic.views);
return JSON.parse(this.data.graph.views);
},
plotVisitPoints() {
return JSON.parse(this.data.traffic.visits);
return JSON.parse(this.data.graph.visits);
},
},
Expand Down
6 changes: 3 additions & 3 deletions resources/js/views/PostStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ export default {
},
plotViewPoints() {
return JSON.parse(this.data.traffic.views);
return JSON.parse(this.data.graph.views);
},
plotVisitPoints() {
return JSON.parse(this.data.traffic.visits);
return JSON.parse(this.data.graph.visits);
},
},
Expand All @@ -399,7 +399,7 @@ export default {
methods: {
fetchStats() {
return this.request()
.get(`/api/stats/${this.id}`)
.get(`/api/posts/${this.id}/stats`)
.then(({ data }) => {
this.data = data;
NProgress.inc();
Expand Down
127 changes: 56 additions & 71 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,101 +1,86 @@
<?php

use Canvas\Http\Controllers\Auth\AuthenticatedSessionController;
use Canvas\Http\Controllers\Auth\NewPasswordController;
use Canvas\Http\Controllers\Auth\PasswordResetLinkController;
use Canvas\Http\Controllers\HomeController;
use Canvas\Http\Controllers\PostController;
use Canvas\Http\Controllers\SearchController;
use Canvas\Http\Controllers\StatsController;
use Canvas\Http\Controllers\TagController;
use Canvas\Http\Controllers\TopicController;
use Canvas\Http\Controllers\UploadsController;
use Canvas\Http\Controllers\UserController;
use Canvas\Http\Middleware\AdminMiddleware;
use Canvas\Http\Middleware\AuthenticatedMiddleware;
use Canvas\Http\Middleware\Admin;
use Canvas\Http\Middleware\Authenticate;
use Illuminate\Support\Facades\Route;

// Authentication routes...
Route::namespace('Auth')->group(function () {
Route::get('login', [AuthenticatedSessionController::class, 'create'])
->name('canvas.login');
// Login routes...
Route::get('login', 'AuthenticatedSessionController@create')->name('canvas.login');
Route::post('login', 'AuthenticatedSessionController@store');

Route::post('login', [AuthenticatedSessionController::class, 'store']);
// Forgot password routes...
Route::get('forgot-password', 'PasswordResetLinkController@create')->name('canvas.password.request');
Route::post('forgot-password', 'PasswordResetLinkController@store')->name('canvas.password.email');

Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
->name('canvas.password.request');
// Reset password routes...
Route::get('reset-password/{token}', 'NewPasswordController@create')->name('canvas.password.reset');
Route::post('reset-password', 'NewPasswordController@store')->name('canvas.password.update');

Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
->name('canvas.password.email');

Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
->name('canvas.password.reset');

Route::post('reset-password', [NewPasswordController::class, 'store'])
->name('canvas.password.update');

Route::get('logout', [AuthenticatedSessionController::class, 'destroy'])
->name('canvas.logout');
// Logout routes...
Route::get('logout', 'AuthenticatedSessionController@destroy')->name('canvas.logout');
});

// API routes...
Route::middleware([AuthenticatedMiddleware::class])->group(function () {
Route::middleware([Authenticate::class])->group(function () {
Route::prefix('api')->group(function () {
// Stats routes...
Route::get('stats', 'StatsController');

// Upload routes...
Route::prefix('uploads')->group(function () {
Route::post('/', [UploadsController::class, 'store']);
Route::delete('/', [UploadsController::class, 'destroy']);
Route::post('/', 'UploadsController@store');
Route::delete('/', 'UploadsController@destroy');
});

// Post routes...
Route::prefix('posts')->group(function () {
Route::get('/', [PostController::class, 'index']);
Route::get('create', [PostController::class, 'create']);
Route::get('{id}', [PostController::class, 'show']);
Route::post('{id}', [PostController::class, 'store']);
Route::delete('{id}', [PostController::class, 'destroy']);
});

Route::prefix('stats')->group(function () {
Route::get('/', [StatsController::class, 'index']);
Route::get('{id}', [StatsController::class, 'show']);
Route::get('/', 'PostController@index');
Route::get('create', 'PostController@create');
Route::get('{id}', 'PostController@show');
Route::get('{id}/stats', 'PostController@stats');
Route::post('{id}', 'PostController@store');
Route::delete('{id}', 'PostController@destroy');
});

Route::prefix('tags')->middleware([AdminMiddleware::class])->group(function () {
Route::get('/', [TagController::class, 'index']);
Route::get('create', [TagController::class, 'create']);
Route::get('{id}', [TagController::class, 'show']);
Route::get('{id}/posts', [TagController::class, 'showPosts']);
Route::post('{id}', [TagController::class, 'store']);
Route::delete('{id}', [TagController::class, 'destroy']);
// Tag routes...
Route::prefix('tags')->middleware([Admin::class])->group(function () {
Route::get('/', 'TagController@index');
Route::get('create', 'TagController@create');
Route::get('{id}', 'TagController@show');
Route::get('{id}/posts', 'TagController@posts');
Route::post('{id}', 'TagController@store');
Route::delete('{id}', 'TagController@destroy');
});

Route::prefix('topics')->middleware([AdminMiddleware::class])->group(function () {
Route::get('/', [TopicController::class, 'index']);
Route::get('create', [TopicController::class, 'create']);
Route::get('{id}', [TopicController::class, 'show']);
Route::get('{id}/posts', [TopicController::class, 'showPosts']);
Route::post('{id}', [TopicController::class, 'store']);
Route::delete('{id}', [TopicController::class, 'destroy']);
// Topic routes...
Route::prefix('topics')->middleware([Admin::class])->group(function () {
Route::get('/', 'TopicController@index');
Route::get('create', 'TopicController@create');
Route::get('{id}', 'TopicController@show');
Route::get('{id}/posts', 'TopicController@posts');
Route::post('{id}', 'TopicController@store');
Route::delete('{id}', 'TopicController@destroy');
});

// User routes...
Route::prefix('users')->group(function () {
Route::get('/', [UserController::class, 'index'])->middleware([AdminMiddleware::class]);
Route::get('create', [UserController::class, 'create'])->middleware([AdminMiddleware::class]);
Route::get('{id}', [UserController::class, 'show']);
Route::get('{id}/posts', [UserController::class, 'showPosts']);
Route::post('{id}', [UserController::class, 'store']);
Route::delete('{id}', [UserController::class, 'destroy'])->middleware([AdminMiddleware::class]);
Route::get('/', 'UserController@index')->middleware([Admin::class]);
Route::get('create', 'UserController@create')->middleware([Admin::class]);
Route::get('{id}', 'UserController@show');
Route::get('{id}/posts', 'UserController@posts');
Route::post('{id}', 'UserController@store');
Route::delete('{id}', 'UserController@destroy')->middleware([Admin::class]);
});

// Search routes...
Route::prefix('search')->group(function () {
Route::get('posts', [SearchController::class, 'showPosts']);
Route::get('tags', [SearchController::class, 'showTags'])->middleware([AdminMiddleware::class]);
Route::get('topics', [SearchController::class, 'showTopics'])->middleware([AdminMiddleware::class]);
Route::get('users', [SearchController::class, 'showUsers'])->middleware([AdminMiddleware::class]);
Route::get('posts', 'SearchController@posts');
Route::get('tags', 'SearchController@tags')->middleware([Admin::class]);
Route::get('topics', 'SearchController@topics')->middleware([Admin::class]);
Route::get('users', 'SearchController@users')->middleware([Admin::class]);
});
});

// Catch-all route...
Route::get('/{view?}', [HomeController::class, 'index'])
->where('view', '(.*)')
->name('canvas');
Route::get('/{view?}', 'ViewController')->where('view', '(.*)')->name('canvas');
});
29 changes: 13 additions & 16 deletions src/Canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,18 @@ public static function baseStoragePath(): string
}

/**
* Check if a given URL is valid.
* Return a valid host URL or null.
*
* @param string|null $url
* @return bool
* @return string|null
*/
public static function isValidUrl(?string $url): bool
public static function parseReferer(?string $url): ?string
{
return filter_var($url, FILTER_VALIDATE_URL) ? true : false;
}
if (filter_var($url, FILTER_VALIDATE_URL)) {
return parse_url($url)['host'];
}

/**
* Trim a given URL and return the base.
*
* @param string|null $url
* @return mixed
*/
public static function trimUrl(?string $url)
{
return parse_url($url)['host'] ?? null;
return null;
}

/**
Expand All @@ -141,8 +134,12 @@ public static function trimUrl(?string $url)
* @param string $rating
* @return string
*/
public static function gravatar(string $email, int $size = 200, string $default = 'retro', string $rating = 'g'): string
{
public static function gravatar(
string $email,
int $size = 200,
string $default = 'retro',
string $rating = 'g'
): string {
$hash = md5(trim(Str::lower($email)));

return "https://secure.gravatar.com/avatar/{$hash}?s={$size}&d={$default}&r={$rating}";
Expand Down
Loading

0 comments on commit 00d6d4a

Please sign in to comment.