Skip to content

Commit

Permalink
add disqus fourm support
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-hadad committed Sep 21, 2018
1 parent 6c63336 commit 8b4111e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
25 changes: 24 additions & 1 deletion publishable/config/larecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,28 @@
'image' => '',
'description' => '',
]
]
],

/*
|--------------------------------------------------------------------------
| Fourm
|--------------------------------------------------------------------------
|
| Giving a chance to your users to post thier questions or feedback
| directly on your docs, is pretty nice way to engage them more.
| However, you can also enable/disable the fourm's visibility.
|
| Supported Services: 'disqus'
|
*/

'fourm' => [
'enabled' => false,
'default' => 'disqus',
'services' => [
'disqus' => [
'site_name' => '', // yoursite.disqus.com
]
]
],
];
7 changes: 1 addition & 6 deletions resources/views/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@
<div id="app">
@include('larecipe::partials.nav')

@if(config('larecipe.search.enabled') && config('larecipe.search.default') == 'algolia')
<algolia-search-box v-if="searchBox" @close="searchBox = false"
algolia-key="{{ config('larecipe.search.engines.algolia.key') }}"
algolia-index="{{ config('larecipe.search.engines.algolia.index') }}"
version="{{ $currentVersion }}"></algolia-search-box>
@endif
@include('larecipe::partials.plugins.search')

@yield('content')

Expand Down
1 change: 1 addition & 0 deletions resources/views/docs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<div class="col-12 col-md-9 article" :class="{'expanded': ! sidebar}">
{!! $content !!}
@include('larecipe::partials.plugins.fourm')
</div>
</div>
</div>
Expand Down
21 changes: 21 additions & 0 deletions resources/views/partials/plugins/fourm.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@if(config('larecipe.fourm.enabled'))
@if(config('larecipe.fourm.default') == 'disqus' && config('larecipe.fourm.services.disqus.site_name'))
<hr>
<div id="disqus_thread"></div>
<script async>
var disqus_config = function () {
this.page.url = '{{ url($canonical) }}';
this.page.identifier = '{{ $currentSection }}';
};
(function() {
var d = document, s = d.createElement('script');
s.src = "https://{{ config('larecipe.fourm.services.disqus.site_name') }}.disqus.com/embed.js";
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
@endif
@endif

6 changes: 6 additions & 0 deletions resources/views/partials/plugins/search.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@if(config('larecipe.search.enabled') && config('larecipe.search.default') == 'algolia')
<algolia-search-box v-if="searchBox" @close="searchBox = false"
algolia-key="{{ config('larecipe.search.engines.algolia.key') }}"
algolia-index="{{ config('larecipe.search.engines.algolia.index') }}"
version="{{ $currentVersion }}"></algolia-search-box>
@endif
15 changes: 15 additions & 0 deletions tests/Feature/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,19 @@ public function algolia_search_will_be_visible_only_if_selected_and_enabled()
$this->get('/docs/1.0')
->assertSee('algolia-search-box');
}

/** @test */
public function disqus_fourm_will_be_visible_only_if_selected_and_enabled()
{
Config::set('larecipe.fourm.default', '');
Config::set('larecipe.fourm.enabled', false);
$this->get('/docs/1.0')
->assertDontSee('disqus_thread');

Config::set('larecipe.fourm.default', 'disqus');
Config::set('larecipe.fourm.enabled', true);
Config::set('larecipe.fourm.services.disqus.site_name', 'larecipe');
$this->get('/docs/1.0')
->assertSee('disqus_thread');
}
}

0 comments on commit 8b4111e

Please sign in to comment.