Skip to content

Commit ab91580

Browse files
committed
Merge branch 'develop'
2 parents d79786d + 30ce041 commit ab91580

13 files changed

+69
-58
lines changed

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# Laravel Blog
2-
Have you worked with Wordpress? Developers call this package wordpress-like laravel blog.
32

43
## [Installation Video - Less than 5 Minutes](https://youtu.be/N9NpFUqbftA)
54
[![Laravel Blog Package](http://img.youtube.com/vi/N9NpFUqbftA/0.jpg)](https://youtu.be/N9NpFUqbftA)
65

76
### Lightweight and Comprehensive
87

9-
Incredible features with a lightweight laravel blog package. I highly recommend it because:
8+
Incredible features with a lightweight laravel blog package.
109
- Quick installation (<3 minutes)
1110
- It's very easy to extend
1211
- Included great features out-of-box
@@ -132,7 +131,7 @@ You can see the single version in "single-lang" branch.
132131
## What/who this package is for:
133132

134133
- For websites running Laravel
135-
- Who wants to have a site blog. This laravel blog gives an easy to use interface to write blog posts/assign categories/manage existing posts
134+
- Anyone, who wants to have a site blog. This laravel blog gives an easy to use interface to write blog posts/assign categories/manage existing posts
136135
- Where only admin users can edit/manage the blog (this is not suitable for every user on your site to be able to manage posts)
137136
- For anyone who likes to add a wordpress-like laravel blog to laravel website
138137

@@ -201,8 +200,8 @@ Try adding this to config/app.php:
201200
- Ensure that /public/blog_images (or whatever directory you set it to in the config) is writable by the server
202201
- You might need to set a higher memory limit, or upload smaller image files. This will depend on your server. I've used it to upload huge (10mb+) jpg images without problem, once the server was set up correctly to handle larger file uploads.
203202

204-
## Version History
205-
- **9.2.x** Stable version of package
203+
## Version History
204+
- **9.3.x** Stable version of package
206205
- 9.0.x Multi-language support beta release
207206
- 8.0.x Compatibility with Laravel 8
208207
- 7.3.0 New Admin UI
@@ -212,12 +211,3 @@ Try adding this to config/app.php:
212211
- 1.0.5 - composer.json changes.
213212
- 1.0 - First release
214213
- 0.1 - Initial release
215-
216-
## Contributors ✨
217-
<table>
218-
<tr>
219-
<td align="center"><a href="https://github.com/samberrry"><img src="https://avatars.githubusercontent.com/u/20775532?v=4" width="80px;" alt=""/><br /><sub><b>Sam Berry</b></sub></a><br /></td>
220-
<td align="center"><a href="https://github.com/dasscheman"><img src="https://avatars.githubusercontent.com/u/6064248?v=4" width="80px;" alt=""/><br /><sub><b>Alef Barbeli</b></sub></a><br /> </td>
221-
222-
</tr>
223-
</table>

src/Controllers/BinshopsReaderController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct()
3535
* @param null $category_slug
3636
* @return mixed
3737
*/
38-
public function index($locale, Request $request, $category_slug = null)
38+
public function index($locale = null, Request $request, $category_slug = null)
3939
{
4040
// the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manageb log posts
4141

@@ -126,10 +126,12 @@ public function search(Request $request)
126126
* @param $category_slug
127127
* @return mixed
128128
*/
129-
public function view_category($locale, $hierarchy, Request $request)
129+
public function view_category(Request $request)
130130
{
131+
$hierarchy = $request->route('subcategories');
132+
131133
$categories = explode('/', $hierarchy);
132-
return $this->index($locale, $request, end($categories));
134+
return $this->index($request->get('locale'), $request, end($categories));
133135
}
134136

135137
/**
@@ -139,8 +141,10 @@ public function view_category($locale, $hierarchy, Request $request)
139141
* @param $blogPostSlug
140142
* @return mixed
141143
*/
142-
public function viewSinglePost(Request $request, $locale, $blogPostSlug)
144+
public function viewSinglePost(Request $request)
143145
{
146+
$blogPostSlug = $request->route('blogPostSlug');
147+
144148
// the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manage log posts
145149
$blog_post = BinshopsPostTranslation::where([
146150
["slug", "=", $blogPostSlug],

src/Middleware/DetectLanguage.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,33 @@
33

44
namespace BinshopsBlog\Middleware;
55

6+
use BinshopsBlog\Models\BinshopsConfiguration;
67
use Closure;
78
use BinshopsBlog\Models\BinshopsLanguage;
89

910
class DetectLanguage
1011
{
1112
public function handle($request, Closure $next)
1213
{
13-
$lang = BinshopsLanguage::where('locale', $request->route('locale'))
14+
$locale = $request->route('locale');
15+
$noLocaleRoute = false;
16+
17+
if (!$request->route('locale')){
18+
$noLocaleRoute = true;
19+
$locale = BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE');
20+
}
21+
$lang = BinshopsLanguage::where('locale', $locale)
1422
->where('active', true)
1523
->first();
1624

1725
if (!$lang){
1826
return abort(404);
1927
}
20-
$request->attributes->add(['lang_id' => $lang->id, 'locale' => $lang->locale]);
28+
$request->attributes->add([
29+
'lang_id' => $lang->id,
30+
'locale' => $lang->locale,
31+
'noLocaleRoute' => $noLocaleRoute
32+
]);
2133

2234
return $next($request);
2335
}

src/Models/BinshopsCategoryTranslation.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?php
22

3-
43
namespace BinshopsBlog\Models;
54

65
use Illuminate\Database\Eloquent\Model;
76

87
class BinshopsCategoryTranslation extends Model
98
{
10-
119
public $fillable = [
1210
'category_id',
1311
'category_name',
@@ -37,15 +35,16 @@ public function language()
3735
* Returns the public facing URL of showing blog posts in this category
3836
* @return string
3937
*/
40-
public function url($loacle)
38+
public function url($locale, $noLocaleRoute = false)
4139
{
4240
$theChainString = "";
4341
$cat = $this->category()->get();
4442
$chain = $cat[0]->getAncestorsAndSelf();
4543
foreach ($chain as $category){
4644
$theChainString .= "/" . $category->categoryTranslations()->where('lang_id' , $this->lang_id)->first()->slug;
4745
}
48-
return route("binshopsblog.view_category",[$loacle, $theChainString]);
46+
47+
return $noLocaleRoute ? route("binshopsblog.view_category",["", $theChainString]) : route("binshopsblog.view_category",[$locale, $theChainString]);
4948
}
5049

5150
/**

src/Models/BinshopsPostTranslation.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace BinshopsBlog\Models;
54

65
use Cviebrock\EloquentSluggable\Sluggable;
@@ -199,11 +198,9 @@ protected function check_valid_image_size(string $size = 'medium')
199198
throw new \InvalidArgumentException("Invalid image size ($size). BinshopsPost image size should not begin with 'image_'. Remove this from the start of $size. It *should* be in the binshopsblog.image_sizes config though!");
200199
}
201200

202-
203201
throw new \InvalidArgumentException("BinshopsPost image size should be 'large','medium','thumbnail' or another field as defined in config/binshopsblog.php. Provided size ($size) is not valid");
204202
}
205203

206-
207204
/**
208205
*
209206
* If $this->seo_title was set, return that.
@@ -219,14 +216,15 @@ public function gen_seo_title()
219216
}
220217
return $this->title;
221218
}
219+
222220
/**
223221
* Returns the public facing URL to view this blog post
224222
*
225223
* @return string
226224
*/
227-
public function url($loacle)
225+
public function url($loacle, $noLocaleRoute = false)
228226
{
229-
return route("binshopsblog.single", [$loacle, $this->slug]);
227+
return $noLocaleRoute ? route("binshopsblog.single", ["", $this->slug]) : route("binshopsblog.single", [$loacle, $this->slug]);
230228
}
231229

232230
/**

src/Views/binshopsblog/index.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class='btn border btn-outline-primary btn-sm '>
6363
@if($categories)
6464
@include("binshopsblog::partials._category_partial", [
6565
'category_tree' => $categories,
66-
'name_chain' => $nameChain = ""
66+
'name_chain' => $nameChain = "",
67+
'noLocaleRoute' => $noLocaleRoute
6768
])
6869
@else
6970
<span>No Categories</span>

src/Views/binshopsblog/partials/_category_partial.blade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
<li class="category-item-wrapper">
55
@php $nameChain = $nameChain .'/'. $trans->slug @endphp
66

7-
<a href="{{route("binshopsblog.view_category",[$locale, $nameChain ])}}">
7+
<a href="{{ $noLocaleRoute ? route("binshopsblog.view_category",["", $nameChain]) : route("binshopsblog.view_category",[$locale, $nameChain])}}">
88
<span class="category-item" value='{{$category->category_id}}'>
99
{{$trans->category_name}}
1010

1111
@if( count($category->siblings) > 0)
1212
<ul>
1313
@include("binshopsblog::partials._category_partial", [
1414
'category_tree' => $category->siblings,
15-
'name_chain' => $nameChain
15+
'name_chain' => $nameChain,
16+
'noLocaleRoute' => $noLocaleRoute
1617
])
1718
</ul>
1819
@endif
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class=''>
2-
@foreach($categories as $category)
3-
<a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->categoryTranslations[0]->url($locale)}}'>
4-
{{$category->categoryTranslations[0]->category_name}}
5-
</a>
6-
@endforeach
2+
@foreach($categories as $category)
3+
<a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->categoryTranslations[0]->url($locale, $noLocaleRoute)}}'>
4+
{{$category->categoryTranslations[0]->category_name}}
5+
</a>
6+
@endforeach
77
</div>

src/Views/binshopsblog/partials/disqus_comments.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
(d.head || d.body).appendChild(s);
1616
})();
1717
</script>
18-
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus</a>, and run by <a href='https://binshops.binshops.com/'>BinshopsBlog Laravel Blog package</a></noscript>
18+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus</a>, and run by <a href='https://binshops.com/'>BinshopsBlog Laravel Blog package</a></noscript>

src/Views/binshopsblog/partials/index_loop.blade.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{{--Used on the index page (so shows a small summary--}}
2-
{{--See the guide on binshops.binshops.com for how to copy these files to your /resources/views/ directory--}}
3-
{{--https://binshops.binshops.com/laravel-blog-package--}}
2+
{{--See the guide on binshops.com for how to copy these files to your /resources/views/ directory--}}
43

54
<div class="col-md-6">
65
<div class="blog-item">
@@ -9,7 +8,7 @@
98
<?=$post->image_tag("medium", true, ''); ?>
109
</div>
1110
<div class="blog-inner-item">
12-
<h3 class=''><a href='{{$post->url($locale)}}'>{{$post->title}}</a></h3>
11+
<h3 class=''><a href='{{$post->url($locale, $noLocaleRoute)}}'>{{$post->title}}</a></h3>
1312
<h5 class=''>{{$post->subtitle}}</h5>
1413

1514
@if (config('binshopsblog.show_full_text_at_list'))
@@ -22,7 +21,7 @@
2221
<span class="light-text">Authored by: </span> {{$post->post->author->name}} <span class="light-text">Posted at: </span> {{date('d M Y ', strtotime($post->post->posted_at))}}
2322
</div>
2423
<div class='text-center'>
25-
<a href="{{$post->url($locale)}}" class="btn btn-primary">View Post</a>
24+
<a href="{{$post->url($locale, $noLocaleRoute)}}" class="btn btn-primary">View Post</a>
2625
</div>
2726
</div>
2827
</div>

0 commit comments

Comments
 (0)