Skip to content

Commit

Permalink
Merge branch 'master' into new_files_from_core
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandra Augustyn committed Dec 24, 2017
2 parents d12c1fc + 5b97f51 commit 5368d0b
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ script:
after_success:
- travis_retry php vendor/bin/coveralls -v -r /home/travis/build/GrupaZero/cms

after_failure:
- cat vendor/orchestra/testbench-core/laravel/storage/logs/laravel-$(date +"%Y-%m-%d").log

matrix:
fast_finish: true
10 changes: 10 additions & 0 deletions resources/views/blocks/basic.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="block {{isset($block->theme) ? $block->theme : 'col-sm-12'}}">
@if(isset($translation))
<div class="block-title">
<h4>{{ $translation->title }}</h4>
</div>
<div class="block-body">
{!! $translation->body !!}
</div>
@endif
</div>
10 changes: 10 additions & 0 deletions resources/views/blocks/menu.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="block {{isset($block->theme) ? $block->theme : 'col-sm-12'}}">
@if(isset($translation))
<div class="block-title">
<h2>{{ $translation->title }}</h2>
</div>
<div class="block-body">
{!! $translation->body !!}
</div>
@endif
</div>
15 changes: 15 additions & 0 deletions resources/views/blocks/slider.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="{{isset($block->theme) ? $block->theme : 'col-sm-12'}}">
<div id="slider-{{$block->id}}" class="slider">
<div class="jumbotron">
@if(isset($translation))
<h1>{{ $translation->title }}</h1>
<p>{!! $translation->body !!}</p>
@endif
<p>
<a class="btn btn-lg btn-success" href="{{ route('register') }}" role="button">
@lang('gzero-core::common.get_started_today')
</a>
</p>
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions resources/views/blocks/widget.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="block {{isset($block->theme) ? $block->theme : 'col-sm-12'}}">
@if(isset($translation))
<div class="block-title">
<h2>{{ $translation->title }}</h2>
</div>
<div class="block-body">
{!! $translation->body !!}
</div>
@endif
</div>
2 changes: 1 addition & 1 deletion resources/views/contents/_gallery.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="col-xs-6 col-md-3 image">
<a href="{{croppaUrl($image->getFullPath())}}" class="colorbox thumbnail"
rel="gallery" title="{{($imageTranslation)? $imageTranslation->title : ''}}">
<img class="img-responsive"
<img class="img-fluid"
title="{{($imageTranslation)? $imageTranslation->title : ''}}"
src="{{croppaUrl($image->getFullPath(), 180, 180)}}"
alt="{{($imageTranslation)? $imageTranslation->title : ''}}">
Expand Down
14 changes: 9 additions & 5 deletions resources/views/contents/_notPublishedContentMsg.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
@if(!$content->canBeShown())
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@lang('gzero-core::common.content_not_published')
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto">
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@lang('gzero-core::common.content_not_published')
</div>
</div>
</div>
@endif
15 changes: 5 additions & 10 deletions resources/views/contents/category.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@extends('gzero-core::layouts.master')
@extends('gzero-core::layouts.withRegions')
@section('bodyClass', $content->theme)

@section('title'){{ $translation->seoTitle() }}@stop
@section('seoDescription'){{ $translation->seoDescription() }}@stop
@section('title', $translation->seoTitle())
@section('seoDescription', $translation->seoDescription())
@section('head')
@parent
@include('gzero-cms::contents._canonical', ['paginator' => $children])
Expand All @@ -11,16 +11,11 @@
{!! $content->stDataMarkup($language->code) !!}
@endif
@stop
@section('mainContent')
@section('breadcrumbs')
{!! Breadcrumbs::render('category') !!}
@parent
@stop
@section('content')
<div class="row justify-content-md-center">
<div class="col col-md-auto">
@include('gzero-cms::contents._notPublishedContentMsg')
</div>
</div>
@include('gzero-cms::contents._notPublishedContentMsg')
<h1 class="content-title">
{{ $translation->title }}
</h1>
Expand Down
19 changes: 8 additions & 11 deletions resources/views/contents/content.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('gzero-core::layouts.master')
@extends('gzero-core::layouts.withRegions')
@section('bodyClass', $content->theme)
<?php $url = $content->routeUrl($language->code); ?>

Expand All @@ -8,8 +8,8 @@
@endif
@stop

@section('title'){{ $translation->seoTitle() }}@stop
@section('seoDescription'){{ $translation->seoDescription() }}@stop
@section('title', $translation->seoTitle())
@section('seoDescription', $translation->seoDescription())
@section('head')
@parent
@include('gzero-cms::contents._canonical')
Expand All @@ -18,16 +18,13 @@
{!! $content->stDataMarkup($language->code) !!}
@endif
@stop
@section('mainContent')

@section('breadcrumbs')
{!! Breadcrumbs::render('content') !!}
@parent
@stop

@section('content')
<div class="row justify-content-md-center">
<div class="col-12 col-md-auto">
@include('gzero-cms::contents._notPublishedContentMsg')
</div>
</div>
@include('gzero-cms::contents._notPublishedContentMsg')
<h1 class="content-title">
{{ $translation->title }}
</h1>
Expand Down Expand Up @@ -91,4 +88,4 @@
</div>
</div>
</div>
@stop
@stop
4 changes: 2 additions & 2 deletions src/Gzero/Cms/CMSSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function seedContent($languages, $users)

dispatch_now(new AddContentTranslation($news, 'Aktualności', $pl, $user));
dispatch_now(new AddContentTranslation($offer, 'Oferta', $pl, $user));
dispatch_now(new AddContentTranslation($aboutUs, 'About us', $pl, $user, $this->generateContentTranslation($pl)));
dispatch_now(new AddContentTranslation($aboutUs, 'O nas', $pl, $user, $this->generateContentTranslation($pl)));

$contents = [$news, $offer, $aboutUs];

Expand Down Expand Up @@ -451,7 +451,7 @@ private function generateBodyHTML(Generator $faker)
}
// insert image
if ($i == $paragraphImageNumber) {
$html[] = '<p><img src="' . $imageUrl . '" class="img-responsive"/></p>';
$html[] = '<p><img src="' . $imageUrl . '" class="img-fluid"/></p>';
}
}
return implode('', $html);
Expand Down
5 changes: 4 additions & 1 deletion src/Gzero/Cms/Handlers/Block/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function handle(Block $block, Language $language)
if ($html !== null) {
return $html;
}
$html = view('blocks.basic', ['block' => $block])->render();
$html = view('gzero-cms::blocks.basic', [
'block' => $block,
'translation' => $block->getActiveTranslation($language->code),
])->render();
$this->putInCache($block, $language, $html);
return $html;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Gzero/Cms/Handlers/Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function handle(Block $block, Language $language)
if ($html !== null) {
return $html;
}
$html = view('blocks.menu', ['block' => $block])->render();
$html = view('gzero-cms::blocks.menu', [
'block' => $block,
'translation' => $block->getActiveTranslation($language->code)
])->render();
$this->putInCache($block, $language, $html);
return $html;
}
Expand Down
6 changes: 5 additions & 1 deletion src/Gzero/Cms/Handlers/Block/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public function handle(Block $block, Language $language)
['is_active', '=', true]
]
);
$html = view('blocks.slider', ['block' => $block, 'images' => $images])->render();
$html = view('gzero-cms::blocks.slider', [
'block' => $block,
'translation' => $block->getActiveTranslation($language->code),
'images' => $images
])->render();
$this->putInCache($block, $language, $html);
return $html;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Gzero/Cms/Handlers/Block/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function handle(Block $block, Language $language)
if ($html !== null) {
return $html;
}
$html = view('blocks.widget', ['block' => $block])->render();
$html = view('gzero-cms::blocks.widget', [
'block' => $block,
'translation' => $block->getActiveTranslation($language->code)
])->render();
$this->putInCache($block, $language, $html);
return $html;
}
Expand Down
21 changes: 0 additions & 21 deletions src/Gzero/Cms/Listeners/BlockLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function handleLaravelRoute(RouteMatched $event)
$this->handleBlockRendering($blocks);
$blocks = $blocks->groupBy('region');
view()->share('blocks', $blocks);
view()->share('sidebarsNumber', $this->getSidebarsNumber($blocks));
}
}

Expand All @@ -91,7 +90,6 @@ public function handleRoute(GzeroRouteMatched $event)
$this->handleBlockRendering($blocks);
$blocks = $blocks->groupBy('region');
view()->share('blocks', $blocks);
view()->share('sidebarsNumber', $this->getSidebarsNumber($blocks));
}

/**
Expand All @@ -108,23 +106,4 @@ protected function handleBlockRendering($blocks)
$block->view = $type->handle($block, $this->languageService->getCurrent());
}
}

/**
* It gets number of active sidebars regions
*
* @param Collection $blocks List of blocks
*
* @return int number of active sidebars
*/
protected function getSidebarsNumber($blocks)
{
$sidebarsNumber = 0;
foreach (['sidebarLeft', 'sidebarRight'] as $region) {
if ($blocks->has($region)) {
$sidebarsNumber++;
}
}
return $sidebarsNumber;
}

}
15 changes: 14 additions & 1 deletion src/Gzero/Cms/Models/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function blockable()
return $this->morphTo();
}


/**
* Get all of the files for the content.
*
Expand Down Expand Up @@ -133,6 +132,20 @@ public function setTypeAttribute($type)
$this->type()->associate($type);
}

/**
* Returns active translation in specific language
*
* @param string $languageCode Language code
*
* @return mixed
*/
public function getActiveTranslation($languageCode)
{
return $this->translations->first(function ($translation) use ($languageCode) {
return $translation->is_active === true && $translation->language_code === $languageCode;
});
}

/**
* Return a created presenter.
*
Expand Down

0 comments on commit 5368d0b

Please sign in to comment.