Skip to content

Commit

Permalink
Merge branch 'release/6.0.34'
Browse files Browse the repository at this point in the history
* release/6.0.34:
  cleanup
  canvas-ui fixes
  asset updates
  Apply fixes from StyleCI (#992)
  append the read time attribute to posts
  escape the '$' for both bash and sed
  fix the proxies issue
  app and asset url rewrites
  updating the .env links
  fixes to the gitpod environment
  • Loading branch information
austintoddj committed Sep 3, 2021
2 parents 75f2b66 + 22ff2f0 commit aadbde5
Show file tree
Hide file tree
Showing 13 changed files with 638 additions and 618 deletions.
22 changes: 11 additions & 11 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ checkoutLocation: canvas

vscode:
extensions:
- [email protected]:bW1RGNnmWYQO43JdJgK34w==
- [email protected]:WIWu3zHU4VPT8r/v866LUw==
- [email protected]:GDba64T6G+TUi1qmc6BE3A==
- equinusocio.vsc-community-material-theme
- equinusocio.vsc-material-theme
- equinusocio.vsc-material-theme-icons
- esbenp.prettier-vscode
- octref.vetur
- eamodio.gitlens

github:
prebuilds:
Expand Down Expand Up @@ -47,8 +50,7 @@ tasks:
touch database/database.sqlite
# Write the database configuration to the .env file
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' .env
sed -i 's/DB_DATABASE=laravel/#DB_DATABASE=laravel/g' .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' .env && sed -i 's/DB_DATABASE=laravel/#DB_DATABASE=laravel/g' .env
# Link Canvas to the Laravel app
composer-link ../canvas/
Expand All @@ -65,12 +67,6 @@ tasks:
cd public/vendor/canvas
ln -s ../../../../canvas/public/* .
cd /workspace/laravel
# Trust any proxy in a chain of proxies
php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
sed -Ei "s|'proxies' => null|'proxies' => '**'|g" config/trustedproxy.php
command: |
cd /workspace/laravel
Expand All @@ -80,6 +76,10 @@ tasks:
# Write the local asset URL to the .env file
export url=$(gp url 8000); sed -Ei "1i\ASSET_URL=${url}" .env
# Trust any proxy in a chain of proxies
export url=$(gp url 8000); sed -Ei "s|APP_URL=http://localhost|APP_URL=${url}|g" .env
sed -Ei "s|\\\$proxies|\\\$proxies = '*'|g" app/Http/Middleware/TrustProxies.php
# Clear and cache the app configuration
php artisan config:clear
php artisan cache:clear
Expand Down
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.

4 changes: 2 additions & 2 deletions public/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/*!
* FilePond 4.28.2
* FilePond 4.29.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand All @@ -46,7 +46,7 @@
*/

/*!
* FilePondPluginImagePreview 4.6.7
* FilePondPluginImagePreview 4.6.8
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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=4cd6936efc67aef641e8",
"/js/app.js": "/js/app.js?id=c485dc511cf72829d8be",
"/css/app.css": "/css/app.css?id=ade4a5e16f09cdfbea3c"
}
16 changes: 8 additions & 8 deletions resources/js/ui/views/ShowPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ export default {
return {
title: this.post?.meta?.title,
meta: [
{ name: 'description', content: this.post?.meta?.description },
{ property: 'og:title', content: this.post?.meta?.title },
{ property: 'og:image', content: this.post?.featured_image },
{ property: 'og:description', content: this.post?.meta?.description },
{ name: 'description', content: this.post?.meta?.description || null },
{ property: 'og:title', content: this.post?.meta?.title || null },
{ property: 'og:image', content: this.post?.featured_image || null },
{ property: 'og:description', content: this.post?.meta?.description || null },
{ name: 'twitter:card', content: 'summary' },
{ name: 'twitter:title', content: this.post?.meta?.title },
{ name: 'twitter:description', content: this.post?.meta?.description },
{ name: 'twitter:image', content: this.post?.featured_image },
{ name: 'twitter:title', content: this.post?.meta?.title || null },
{ name: 'twitter:description', content: this.post?.meta?.description || null },
{ name: 'twitter:image', content: this.post?.featured_image || null },
],
};
},
Expand Down Expand Up @@ -212,7 +212,7 @@ export default {
NProgress.inc();
})
.catch(() => {
NProgress.done();
this.$router.push({ name: 'posts' });
});
},
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/ui/views/ShowTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
NProgress.inc();
})
.catch(() => {
NProgress.done();
this.$router.push({ name: 'tags' });
});
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/ui/views/ShowTopic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
NProgress.inc();
})
.catch(() => {
NProgress.done();
this.$router.push({ name: 'topics' });
});
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/ui/views/ShowUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default {
NProgress.inc();
})
.catch(() => {
NProgress.done();
this.$router.push({ name: 'posts' });
});
},
Expand Down
42 changes: 21 additions & 21 deletions resources/stubs/controllers/CanvasUiController.stub
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use Illuminate\Pagination\LengthAwarePaginator;
class CanvasUiController extends Controller
{
/**
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request)
{
Expand All @@ -30,18 +30,18 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @return LengthAwarePaginator
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function getPosts(Request $request): LengthAwarePaginator
{
return Post::latest()->published()->with('user', 'topic')->paginate();
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $slug
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function showPost(Request $request, $slug): JsonResponse
{
Expand All @@ -57,7 +57,7 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @return string
*/
public function getTags(Request $request): string
Expand All @@ -66,9 +66,9 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $slug
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function showTag(Request $request, $slug): JsonResponse
{
Expand All @@ -78,9 +78,9 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $slug
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function getPostsForTag(Request $request, $slug): JsonResponse
{
Expand All @@ -90,7 +90,7 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @return string
*/
public function getTopics(Request $request): string
Expand All @@ -99,9 +99,9 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $slug
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function showTopic(Request $request, $slug): JsonResponse
{
Expand All @@ -111,9 +111,9 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $slug
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function getPostsForTopic(Request $request, $slug): JsonResponse
{
Expand All @@ -123,9 +123,9 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $id
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function showUser(Request $request, $id): JsonResponse
{
Expand All @@ -135,14 +135,14 @@ class CanvasUiController extends Controller
}

/**
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param $id
* @return JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function getPostsForUser(Request $request, $id): JsonResponse
{
$user = User::find($id);

return $user ? response()->json($user->posts()->published()->with('topic')->paginate(), 200) : response()->json(null, 200);
return $user ? response()->json($user->posts()->published()->with('user', 'topic')->paginate(), 200) : response()->json(null, 200);
}
}
33 changes: 33 additions & 0 deletions src/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;

class Post extends Model
{
Expand Down Expand Up @@ -64,6 +65,15 @@ class Post extends Model
'published_at',
];

/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = [
'read_time',
];

/**
* The attributes that should be casted.
*
Expand Down Expand Up @@ -135,6 +145,29 @@ public function visits(): HasMany
return $this->hasMany(Visit::class);
}

/**
* Get the human-friendly estimated reading time of a given text.
*
* @return string
*/
public function getReadTimeAttribute(): string
{
// Only count words in our estimation
$words = str_word_count(strip_tags($this->body));

// Divide by the average number of words per minute
$minutes = ceil($words / 250);

// The user is optional since we append this attribute
// to every model and we may be creating a new one
return vsprintf('%d %s %s', [
$minutes,
Str::plural(trans('canvas::app.min', [], optional(request()->user())->locale), $minutes),
trans('canvas::app.read', [], optional(request()->user())->locale),
]
);
}

/**
* Check to see if the post is published.
*
Expand Down
Loading

0 comments on commit aadbde5

Please sign in to comment.