Skip to content
forked from sylque/discpage

A Discourse plugin to create static pages and attach discussions to headings

License

Notifications You must be signed in to change notification settings

psychedel/discpage

 
 

Repository files navigation

DiscPage

A Discourse plugin to create static pages and insert discussion balloons in the text.

To discuss this plugin, see the post on Meta.

Demo

Basic static page: http://www.docuss.org/t/discpage-demo

Full website: https://www.castafiore.org

Screenshots

A static page: Static Page

A static page with a balloon's right panel showing a topic list: Static page with topic list

A static page with a balloon's right panel showing a discussion: Static page with discussion

Installation

Follow those directions using https://github.com/sylque/discpage.git as the repository URL.

Basic Setup

1. Create a category for static pages

DiscPage requires that you create at least one category for holding static pages. You can learn how to create a category in this tutorial.

Set the category parameters as follow:

  • General tab / Category NamePage (for example)
  • Security tab / Edit Permissions
    • remove line everyone can… Create / Reply / See
    • add line admins can… Create / Reply / See
    • add line everyone can… See

2. Set those Discourse settings

In the Discourse Admin panel, open the Settings page and set:

  • tagging enabled → checked
  • discpage enabled → checked
  • discpage page categories → [static page category created above]

If your Discourse instance doesn't use tags (i.e. if tagging enabled was unchecked before you checked it as part of the above setup), set:

  • discpage hide tags → checked

3. My hamburger menu has turned red, what should I do?

Hamburger Menu

A red hamburger menu means that DiscPage is disabled. This occurs:

  1. when an error has prevented DiscPage from starting (in that case, check the debug console for a DiscPage-related error), and
  2. when you manually turn DiscPage off (see below).

Basic Features

Creating and managing static pages

When logged-in as admin, you can perform the following actions:

  • To create a static page, add the static page category to a topic: the initial post of the topic will be turned into a static page.

  • To edit a static page, click the "pencil" button at the top right of the static page (you can also turn DiscPage off from the hamburger menu, then edit the topic as you would do normally).

  • To style static pages, use the .dpg-page-content class. To style an individual page, use the html[data-dpg-page-id] data attribute. For example, go to Settings > Customize > Light Theme > Edit CSS/HTML and enter the following in the Common > CSS section:

    /* This will turn text to red in all static pages */
    .dpg-page-content {
      color: red;
    }
    
    /* This will turn text to yellow in static page 13 */
    html[data-dpg-page-id="13"] .dpg-page-content {
      color: yellow;
    }

Adding discussion balloons to a static page

To add a balloon, add [dpgb id=myBalloonId][/dpgb] to your topic text. For example:

## Introduction [dpgb id=intro][/dpgb]

The balloon id must contain only [a-zA-z_]. Unless you know what you're doing, it should be unique to the page.

When adding a balloon to a heading, selecting the balloon will highlight both the heading and the following subsection.

To append a balloon to the page title, add {dpg-title-balloon} anywhere in the page. The balloon id will be title.

Turning DiscPage off temporarily

At any time, if you need to see your website without DiscPage, use the DiscPage On/Off item in the hamburger menu. This comes handy when troubleshooting issues with tags or categories. When turning DiscPage off, the hamburger menu turns red (see above).

Keyboard shortcut: alt+a

Advanced Usage

Tuning the static page category

If you don't want static page topics to appear in /latest, use the Suppress-Categories-From-Latest plugin.

If you don't want static page topics to appear in digest emails, use the digest suppress categories Discourse setting.

If you want to delete the "about" topic of the category ("Make Unlisted" in Discourse terms), see here.

Enabling revisions

To add a button allowing users to navigate through page revisions, add {dpg-show-rev-button} anywhere in the page.

Adding JavaScript to a static page

Use the dpg_displaypage DOM custom event on the <html> tag. For example, you can add this code to a theme component's </head> section:

<script>
  document.documentElement.addEventListener('dpg_displaypage', e => {
    const pageData = e.detail 
    if (pageData.pageId === 19) {
      $(pageData.node).find('.cooked').append('
        <p>This paragraph has been dynamically added!</p>'
      )
    }
  }, false);
</script>  

Setting up a home page

To set a static page as the Discourse home page, use the discourse-home-page plugin.

Adding page navigation

You can customize your Discourse header with links pointing on static pages. To learn more about it, see Best way to customize the header and discourse-custom-header-links2.

More settings

  • discpage balloon category

    This will set the specified category (for example: Orange Balloon) to all topics created through DiscPage balloons. This category will be hidden by DiscPage, so that users don't use it outside of static pages.

    In fact, you can set multiple categories in here. Let's call PageCat the category of the static page the balloon belongs to. If there are more than one balloon category in this field, DiscPage will take the first one which is either a sibling of PageCat (same immediate parent) or the immediate parent of PageCat. If no such category is found, DiscPage will take the first category of the list. This feature allows to pair [static page category, balloon category], which is useful, for example, for multilingual forums or to set up static pages with different group permissions.

  • discpage never bump pages

    In Discourse, editing the last post of a topic bumps the topic. A DiscPage static page being usually the only post of a topic, any minor edit will bump it by default and force you to use the Reset Bump Date feature. The provided option disables the default behavior: editing a static page won't trigger a bump.

  • discpage hide sugg topics

    This will hide the "suggested topics" that are displayed at the bottom of topics created through DiscPage balloons.

License

MIT

At the moment, this project is released with minified source code only.

About

A Discourse plugin to create static pages and attach discussions to headings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 55.7%
  • SCSS 40.4%
  • Ruby 3.1%
  • Handlebars 0.8%