Skip to content

Commit bb40d5d

Browse files
committed
adding discourse forum page
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent 121c319 commit bb40d5d

File tree

8 files changed

+69
-6
lines changed

8 files changed

+69
-6
lines changed

_config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ markdown: kramdown
5252
tag_search_endpoint: https://ask.cyberinfrastructure.org/search?q=
5353
tag_color: danger # danger, success, warning, primary, info, secondary
5454

55+
# Add a page at /forum to list a set of discourse topics. The site needs
56+
# to enable "embed topics" setting
57+
# https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911
58+
discourse_site: "https://ask.cyberinfrastructure.org"
59+
discourse_per_page: 10
60+
discourse_category: "stanford-research-computing"
61+
discourse_tags: null # comma separated string, leave null to not filter
62+
5563
accentColor: red # purple, green, etc.
5664
themeColor: red # purple, green, blue, orange, purple, grey
5765
fixedNav: 'true' # true or false

_data/toc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
children:
1313
- title: Quizzes
1414
url: "docs/extras/example-quiz"
15+
- title: Discussion Forum
16+
url: "forum"
1517
- title: "About"
1618
url: "about"
1719
- title: "News"

_docs/getting-started.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ excluded_in_search: true
3636
---
3737
```
3838

39-
The example above is for a css file in the assets folder that is used as a template,
40-
but should not be included in search.
39+
The example above is for a css file in the assets folder that is used as a template, but should not be included in search. If you need to disable search entirely for a page, you can add the `disable_search` header:
40+
41+
```
42+
---
43+
layout: null
44+
disable_search: true
45+
---
46+
```
47+
48+
Disabling search will remove the search box at the top.
49+
4150

4251
### External Search
4352

@@ -47,6 +56,29 @@ For example, on an HPC site I'd want a tag like "mpi" to do a search on
4756
[http://ask.cyberinfrastructure.org](http://ask.cyberinfrastructure.org) for mpi.
4857
See the [tags](#tags) section below for how to configure this.
4958

59+
60+
### Discourse Forum
61+
62+
If you have a discourse forum that you want to show questions from,
63+
there is an [easy way](https://meta.discourse.org/t/embedding-a-list-of-discourse-topics-in-another-site/125911) to embed them here. Specifically, there is an include `{% raw %}{% include embed/discourse.html %}{% endraw %}` that is deployed at [/forum]({{ site.baseurl }}/forum/) and added to the table of contents under Extra -> Discussion Forum. You can add this include to wherever you want the questions to appear. The follow parameters are defined in the config.yml:
64+
65+
```yaml
66+
discourse_site: "https://ask.cyberinfrastructure.org"
67+
discourse_per_page: 10
68+
discourse_category: "stanford-research-computing"
69+
discourse_tags: null # comma separated string, leave null to not filter
70+
```
71+
72+
For the above, we embed 10 topics from the stanford-research-computing category of AskCI, and render 10 per page. Since there are few topics, we don't filter down to tags. If we did, we should provide a list of comma separated values.
73+
The page looks like this and is [live here]({{ site.baseurl }}/forum/):
74+
75+
![{{ site.baseurl }}/assets/img/discourse-forum.png]({{ site.baseurl }}/assets/img/discourse-forum.png)
76+
77+
Note that you aren't required to only embed one category - you can easily modify the code to include more than one by copy pasting the `d-topics-list`.
78+
79+
{% include alert.html type="info" content="To use this for your discourse site, you must enable the 'embed topics' setting." %}
80+
81+
5082
### Documentation
5183

5284
Documentation pages should be written in the `docs` folder of the repository,

_includes/embed/discourse.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<style>
2+
iframe {
3+
width: 100% !important;
4+
}
5+
</style>
6+
7+
# Discussion Forum
8+
9+
What questions are being asked on <a href="{{ site.discourse_site }}" target="_blank">{{ site.discourse_site }}</a>? The questions
10+
below are from the <a href="{{ site.discourse_site }}/c/{{ site.discourse_category }}" target="_blank">{{ site.discourse_category }}</a> category.
11+
12+
<hr>
13+
14+
<script src="{{ site.discourse_site }}/javascripts/embed-topics.js"></script>
15+
16+
<d-topics-list discourse-url="{{ site.discourse_site }}" category="{{ site.discourse_category }}" per-page="{{ site.discourse_per_page }}" {% if site.discourse_tags %}tags="{{ site.discouse_tags }}"{% endif %}></d-topics-list>

_includes/footer.html

-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@
4343
</footer>
4444
<script src="{{ site.baseurl }}/assets/js/application.js"></script>
4545
{% assign slashes = page.url | split: "/" %}
46-
<script>console.log('{{ slashes | size }}')</script>
4746
<script>app.initialize({version:"0.17.4", url:{base:'{{ site.baseurl }}'}})</script>

_includes/navigation.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</defs></svg>
66

77
<input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off>
8-
<input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off>
8+
{% if page.disable_search %}{% else %}<input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off>{% endif %}
99
<label class=md-overlay data-md-component=overlay for=__drawer></label> <a href="#{{ page.title | slugify }}" tabindex=1 class=md-skip> Skip to content </a>
1010
<header class=md-header data-md-component=header>
1111
<nav class="md-header-nav md-grid">
@@ -24,7 +24,7 @@
2424
</div>
2525
</div>
2626
<div class="md-flex__cell md-flex__cell--shrink">
27-
<label class="md-icon md-icon--search md-header-nav__button" for=__search></label>
27+
{% if page.disable_search %}{% else %}<label class="md-icon md-icon--search md-header-nav__button" for=__search></label>
2828
<div class=md-search data-md-component=search role=dialog>
2929
<label class=md-search__overlay for=__search></label>
3030
<div class=md-search__inner role=search>
@@ -42,7 +42,7 @@
4242
</div>
4343
</div>
4444
</div>
45-
</div>
45+
</div>{% endif %}
4646
</div>
4747
<div class="md-flex__cell md-flex__cell--shrink">
4848
<div class="md-header-nav__source">

assets/img/discourse-forum.png

117 KB
Loading

pages/forum.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Discussion Forum
3+
permalink: /forum/
4+
---
5+
6+
{% include embed/discourse.html %}

0 commit comments

Comments
 (0)