mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-03-22 21:05:13 +08:00
Merge branch 'disable-comments' of git://github.com/Abijeet/BookStack into Abijeet-disable-comments
This commit is contained in:
commit
a5e49f642b
@ -161,13 +161,19 @@ class PageController extends Controller
|
||||
$page->html = $this->entityRepo->renderPage($page);
|
||||
$sidebarTree = $this->entityRepo->getBookChildren($page->book);
|
||||
$pageNav = $this->entityRepo->getPageNav($page->html);
|
||||
$page->load(['comments.createdBy']);
|
||||
|
||||
// check if the comment's are enabled
|
||||
$areCommentsEnabled = !setting('app-disable-comments');
|
||||
if ($areCommentsEnabled) {
|
||||
$page->load(['comments.createdBy']);
|
||||
}
|
||||
|
||||
Views::add($page);
|
||||
$this->setPageTitle($page->getShortName());
|
||||
return view('pages/show', [
|
||||
'page' => $page,'book' => $page->book,
|
||||
'current' => $page, 'sidebarTree' => $sidebarTree,
|
||||
'commentsEnabled' => $areCommentsEnabled,
|
||||
'pageNav' => $pageNav]);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => "Dieses Bild sollte 43px hoch sein.\nGrößere Bilder werden verkleinert.",
|
||||
'app_primary_color' => 'Primäre Anwendungsfarbe',
|
||||
'app_primary_color_desc' => "Dies sollte ein HEX Wert sein.\nWenn Sie nicht eingeben, wird die Anwendung auf die Standardfarbe zurückgesetzt.",
|
||||
'app_disable_comments' => 'Kommentare deaktivieren',
|
||||
'app_disable_comments_desc' => 'Deaktiviert Kommentare über alle Seiten in der Anwendung. Vorhandene Kommentare werden nicht angezeigt.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -34,6 +34,8 @@ return [
|
||||
'app_homepage' => 'Application Homepage',
|
||||
'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
|
||||
'app_homepage_default' => 'Default homepage view chosen',
|
||||
'app_disable_comments' => 'Disable comments',
|
||||
'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Esta imagen debería de ser 43px en altura. <br>Iágenes grandes seán escaladas.',
|
||||
'app_primary_color' => 'Color primario de la aplicación',
|
||||
'app_primary_color_desc' => 'Esto debería ser un valor hexadecimal. <br>Deje el valor vaío para reiniciar al valor por defecto.',
|
||||
'app_disable_comments' => 'Deshabilitar comentarios',
|
||||
'app_disable_comments_desc' => 'Deshabilita los comentarios en todas las páginas de la aplicación. Los comentarios existentes no se muestran. ',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -31,7 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Cette image doit faire 43px de hauteur. <br>Les images plus larges seront réduites.',
|
||||
'app_primary_color' => 'Couleur principale de l\'application',
|
||||
'app_primary_color_desc' => 'Cela devrait être une valeur hexadécimale. <br>Laisser vide pour rétablir la couleur par défaut.',
|
||||
|
||||
'app_disable_comments' => 'Désactiver les commentaires',
|
||||
'app_disable_comments_desc' => 'Désactive les commentaires sur toutes les pages de l\'application. Les commentaires existants ne sont pas affichés.',
|
||||
/**
|
||||
* Registration settings
|
||||
*/
|
||||
|
@ -34,11 +34,12 @@ return [
|
||||
'app_homepage' => 'Homepage Applicazione',
|
||||
'app_homepage_desc' => 'Seleziona una pagina da mostrare nella home anzichè quella di default. I permessi della pagina sono ignorati per quella selezionata.',
|
||||
'app_homepage_default' => 'Homepage di default scelta',
|
||||
'app_disable_comments' => 'Disattiva commenti',
|
||||
'app_disable_comments_desc' => 'Disabilita i commenti su tutte le pagine nell\'applicazione. I commenti esistenti non sono mostrati. ',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
*/
|
||||
|
||||
'reg_settings' => 'Impostazioni Registrazione',
|
||||
'reg_allow' => 'Consentire Registrazione?',
|
||||
'reg_default_role' => 'Ruolo predefinito dopo la registrazione',
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => '高さ43pxで表示されます。これを上回る場合、自動で縮小されます。',
|
||||
'app_primary_color' => 'プライマリカラー',
|
||||
'app_primary_color_desc' => '16進数カラーコードで入力します。空にした場合、デフォルトの色にリセットされます。',
|
||||
'app_disable_comments' => 'コメントを無効にする',
|
||||
'app_disable_comments_desc' => 'アプリケーション内のすべてのページのコメントを無効にします。既存のコメントは表示されません。',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
@ -108,5 +110,5 @@ return [
|
||||
'users_social_disconnect' => 'アカウントを接続解除',
|
||||
'users_social_connected' => '「:socialAccount」がプロフィールに接続されました。',
|
||||
'users_social_disconnected' => '「:socialAccount」がプロフィールから接続解除されました。'
|
||||
|
||||
|
||||
];
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'De afbeelding moet 43px hoog zijn. <br>Grotere afbeeldingen worden geschaald.',
|
||||
'app_primary_color' => 'Applicatie hoofdkleur',
|
||||
'app_primary_color_desc' => 'Geef een hexadecimale waarde. <br>Als je niks invult wordt de standaardkleur gebruikt.',
|
||||
'app_disable_comments' => 'Reacties uitschakelen',
|
||||
'app_disable_comments_desc' => 'Schakel opmerkingen uit op alle pagina\'s in de applicatie. Bestaande opmerkingen worden niet getoond.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Ten obrazek powinien mieć nie więcej niż 43px w pionie. <br>Większe obrazki będą skalowane w dół.',
|
||||
'app_primary_color' => 'Podstawowy kolor aplikacji',
|
||||
'app_primary_color_desc' => 'To powinna być wartość HEX. <br>Zostaw to pole puste, by powrócić do podstawowego koloru.',
|
||||
'app_disable_comments' => 'Wyłącz komentarze',
|
||||
'app_disable_comments_desc' => 'Wyłącz komentarze na wszystkich stronach w aplikacji. Istniejące komentarze nie są pokazywane.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -34,6 +34,8 @@ return [
|
||||
'app_homepage' => 'Página incial',
|
||||
'app_homepage_desc' => 'Selecione a página para ser usada como página inicial em vez da padrão. Permissões da página serão ignoradas.',
|
||||
'app_homepage_default' => 'Escolhida página inicial padrão',
|
||||
'app_disable_comments' => 'Desativar comentários',
|
||||
'app_disable_comments_desc' => 'Desativar comentários em todas as páginas no aplicativo. Os comentários existentes não são exibidos.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -34,6 +34,8 @@ return [
|
||||
'app_homepage' => 'Домашняя страница приложения',
|
||||
'app_homepage_desc' => 'Выберите страницу, которая будет отображаться на главной странице вместо стандартной. Права на страницы игнорируются для выбранных страниц.',
|
||||
'app_homepage_default' => 'Выбрана домашняя страница по-умолчанию',
|
||||
'app_disable_comments' => 'Отключить комментарии',
|
||||
'app_disable_comments_desc' => 'Отключить комментарии на всех страницах приложения. Существующие комментарии не отображаются.',
|
||||
|
||||
/**
|
||||
* Registration
|
||||
|
@ -31,6 +31,8 @@ return [
|
||||
'app_logo_desc' => 'Tento obrázok by mal mať 43px na výšku. <br>Veľké obrázky budú preškálované na menší rozmer.',
|
||||
'app_primary_color' => 'Primárna farba pre aplikáciu',
|
||||
'app_primary_color_desc' => 'Toto by mala byť hodnota v hex tvare. <br>Nechajte prázdne ak chcete použiť prednastavenú farbu.',
|
||||
'app_disable_comments' => 'Zakázať komentáre',
|
||||
'app_disable_comments_desc' => 'Zakázať komentáre na všetkých stránkach aplikácie. Existujúce komentáre sa nezobrazujú.',
|
||||
|
||||
/**
|
||||
* Registration settings
|
||||
|
@ -131,7 +131,7 @@
|
||||
</div>
|
||||
|
||||
@include('partials/book-tree', ['book' => $book, 'sidebarTree' => $sidebarTree])
|
||||
|
||||
|
||||
@stop
|
||||
|
||||
@section('body')
|
||||
@ -148,10 +148,11 @@
|
||||
@include('pages/page-display')
|
||||
|
||||
</div>
|
||||
|
||||
<div class="container small nopad">
|
||||
@include('comments/comments', ['page' => $page])
|
||||
</div>
|
||||
@if ($commentsEnabled)
|
||||
<div class="container small nopad">
|
||||
@include('comments/comments', ['page' => $page])
|
||||
</div>
|
||||
@endif
|
||||
@stop
|
||||
|
||||
@section('scripts')
|
||||
|
@ -38,6 +38,11 @@
|
||||
<p class="small">{{ trans('settings.app_secure_images_desc') }}</p>
|
||||
@include('components.toggle-switch', ['name' => 'setting-app-secure-images', 'value' => setting('app-secure-images')])
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('settings.app_disable_comments') }}</label>
|
||||
<p class="small">{{ trans('settings.app_disable_comments_desc') }}</p>
|
||||
@include('components.toggle-switch', ['name' => 'setting-app-disable-comments', 'value' => setting('app-disable-comments')])
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="setting-app-editor">{{ trans('settings.app_editor') }}</label>
|
||||
<p class="small">{{ trans('settings.app_editor_desc') }}</p>
|
||||
|
28
tests/Entity/CommentSettingTest.php
Normal file
28
tests/Entity/CommentSettingTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
class CommentSettingTest extends BrowserKitTest {
|
||||
protected $page;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->page = \BookStack\Page::first();
|
||||
}
|
||||
|
||||
public function test_comment_disable () {
|
||||
$this->asAdmin();
|
||||
|
||||
$this->setSettings(['app-disable-comments' => 'true']);
|
||||
|
||||
$this->asAdmin()->visit($this->page->getUrl())
|
||||
->pageNotHasElement('.comments-list');
|
||||
}
|
||||
|
||||
public function test_comment_enable () {
|
||||
$this->asAdmin();
|
||||
|
||||
$this->setSettings(['app-disable-comments' => 'false']);
|
||||
|
||||
$this->asAdmin()->visit($this->page->getUrl())
|
||||
->pageHasElement('.comments-list');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user