Skip to content

Commit a48fb3a

Browse files
authored
Merge pull request #26 from laravelcm/patch-update-post
Patch update post
2 parents f59269b + a9c70a2 commit a48fb3a

File tree

15 files changed

+119
-21
lines changed

15 files changed

+119
-21
lines changed

app/Http/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Kernel extends HttpKernel
1616
protected $middleware = [
1717
// \App\Http\Middleware\TrustHosts::class,
1818
\App\Http\Middleware\TrustProxies::class,
19+
\App\Http\Middleware\HttpsProtocol::class,
1920
\Fruitcake\Cors\HandleCors::class,
2021
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
2122
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,

app/Http/Livewire/Articles/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function store()
7575

7676
$user->hasRole('user') ?
7777
$this->redirect('/articles/me') :
78-
$this->redirect('/admin/articles');
78+
$this->redirectRoute('articles.show', $article);
7979
}
8080

8181
public function render()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Http\Request;
7+
8+
class HttpsProtocol
9+
{
10+
public function handle(Request $request, Closure $next)
11+
{
12+
if (! $request->isSecure() && app()->environment('production')) {
13+
return redirect()->secure($request->getRequestUri());
14+
}
15+
16+
return $next($request);
17+
}
18+
}

app/View/Composers/TopContributorsComposer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TopContributorsComposer
1010
{
1111
public function compose(View $view)
1212
{
13-
$topContributors = Cache::remember('contributors', 60 * 60 * 24, function () {
13+
$topContributors = Cache::remember('contributors', 60 * 30, function () {
1414
return User::topContributors()
1515
->get()
1616
->filter(fn ($contributor) => $contributor->discussions_count >= 1)

config/lcm.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@
22

33
return [
44

5+
'ads' => [
6+
[
7+
'url' => 'https://github.com/mckenziearts/laravel-notify/?utm_source=laravelcm&amp;utm_medium=sidebar-widget',
8+
'image' => 'notify',
9+
'alt' => 'Laravel Notify',
10+
'description' => 'Découvrez la nouvelle version de Laravel Notify pour vos projets Laravel.',
11+
],
12+
],
13+
514
];

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/images/ads/notify.png

543 KB
Loading

public/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/js/app.js": "/js/app.js?id=e6d1da65dbde3830a462",
3-
"/css/app.css": "/css/app.css?id=0f7199b1ce806e8c86c5"
2+
"/js/app.js": "/js/app.js?id=cec3ed7f2c1a4238fc23",
3+
"/css/app.css": "/css/app.css?id=3c6caa92eb5af2e07d2a"
44
}

resources/js/helpers.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,53 @@ window.highlightCode = (element) => {
1515

1616
// Create Capitalize string
1717
window.capitalize = (string) => string.replace(/^\w/, (c) => c.toUpperCase());
18+
1819
// Create a snake case string
1920
window.snakeCase = (string) => string && string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(s => s.toLowerCase()).join('_');
21+
22+
// Share a content to social Media
23+
const share = function () {
24+
function popupCenter (url, title, width, height) {
25+
let popupWidth = width || 640
26+
let popupHeight = height || 440
27+
let windowLeft = window.screenLeft || window.screenX
28+
let windowTop = window.screenTop || window.screenY
29+
let windowWidth = window.innerWidth || document.documentElement.clientWidth
30+
let windowHeight = window.innerHeight || document.documentElement.clientHeight
31+
let popupLeft = windowLeft + windowWidth / 2 - popupWidth / 2
32+
let popupTop = windowTop + windowHeight / 2 - popupHeight / 2
33+
window.open(url, title, 'scrollbars=yes, width=' + popupWidth + ', height=' + popupHeight + ', top=' + popupTop + ', left=' + popupLeft)
34+
}
35+
36+
let twitter = document.querySelector('.share_twitter')
37+
if (twitter) {
38+
twitter.addEventListener('click', function (e) {
39+
e.preventDefault()
40+
let url = this.getAttribute('data-url')
41+
let shareUrl = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(document.title) + '&via=johns_corp' + '&url=' + encodeURIComponent(url)
42+
popupCenter(shareUrl, 'Partager sur Twitter')
43+
})
44+
}
45+
46+
let facebook = document.querySelector('.share_facebook')
47+
if (facebook) {
48+
facebook.addEventListener('click', function (e) {
49+
e.preventDefault()
50+
let url = this.getAttribute('data-url')
51+
let shareUrl = 'https://facebook.com/sharer/sharer.php?u=' + encodeURIComponent(url)
52+
popupCenter(shareUrl, 'Partager sur Facebook')
53+
})
54+
}
55+
56+
let linkedin = document.querySelector('.share_linkedin')
57+
if (linkedin) {
58+
linkedin.addEventListener('click', function (e) {
59+
e.preventDefault()
60+
let url = this.getAttribute('data-url')
61+
let shareUrl = 'https://www.linkedin.com/shareArticle?url=' + encodeURIComponent(url)
62+
popupCenter(shareUrl, 'Partager sur LinkedIn')
63+
})
64+
}
65+
}
66+
67+
share()

0 commit comments

Comments
 (0)