Wikified Posts Component

Simple Description

This theme component enables you to make Wiki posts (and Shared Edits posts) more obvious.

Wikis and Shared Edits are a powerful feature of Discourse, but many users are unfamiliar with the concept and find the UI just a bit too subtle. This component makes it crystal clear, packaging the content from Change the style of a wiki post.

Screenshots

Detailed Description

Installing this component enables you to control the background colour of Wiki posts, and to add some text to the history/edit icon in the top right of the post.

It is a fork of discourse-wikified-post-background-color by @pacharanero, incorporates stuff from Change the style of a wiki post and re-used code from Personal Message Bubbles by @Rhidian.

Settings

Wiki post background color

The background colour of Wiki posts can be set to whatever you like. It defaults to ‘highlight’, but you can use any of these options:

  1. It works best when a Scheme colour is chosen (i.e. primary, secondary, tertiary, etc), as these are responsive to automatic dark mode.
  2. A named color recognised in CSS (e.g. blue, red, yellow, black, etc)
  3. An HTML color code (e.g. #effbfb, etc)

Shared edits background color

You can choose one of the same color options for Shared Edits posts (see the Shared Edits Plugin)

Wiki added text

This adds the little bit of green text (defaulting to Wiki Post) in the top right corner of the post:

image

This is dynamic, and changes colour along with the history icon if there has been a recent edit (this is an unintended happy thing):

image

If you don’t want any text there, then delete the text in the setting and save it.

Shared edits added text

The text displayed when it is a Shared Edits post. This is in the Danger color from your palate.

image

Roadmap

  1. Auto tag Topics with ‘wiki’

Please make suggestions as replies to this post.

Install this theme component

24 Likes

Lovely stuff @nathank
I’m going to archive the old wikified post background color repo, in favour of this your new version, which adds much more.

4 Likes

Anyone else getting this error?

Error: Undefined variable: "$Shared-edits-hide". on line 42 of common.scss >> @if ($Shared_edits_hide == "Yes"){ -----^

I can’t reproduce that, and can’t see any obvious problems in the code. Can you give us any more info?

1 Like

It’s because I had Shared edits hide set to No. The error appeared in the TC settings. Error is gone after setting it to Yes.

I don’t get it with it No nor Yes on the latest Discourse Beta. Are you on an old Discourse version? I haven’t put any version control in it at all sorry.

1 Like

Sorry, my bad - was a bit outdated, yeah. Forgot to test again after recent update until you mentioned it. Thanks. :slight_smile:

1 Like

Have just updated the component to better cater for Shared Edits posts.

This includes adapting it for the Shared Edits changes here:

2 Likes

Done a minor tweak to the default background colors as I couldn’t see @mentions easily.

Also Shared Edits background color now defaults to tertiary-very-low.

1 Like

An excellent component. But it improves visibility only on the topic page. Is it possible to modify it so that the wiki icon is displayed on the category page, the list of topics “recent”, “unread”, etc?

Good suggestion, and I’m sure it is possible (PR welcome!).

I address that by simply tagging posts with #wiki in my instances. It is of course semi-manual - you can identify the wiki posts / topics by advanced search. It has the added bonus of making them easily discoverable via the sidebar navigation.

I thought that it would be nice to have auto-tagging of wiki posts as part of this component some way (or do as you suggest) but it hasn’t caused me enough pain to put in the time to give this a crack I’m afraid.

2 Likes

I asked this in 2021 here: Add an icon in front of wikis in the topic list?

The answer was:

The feature request:

1 Like

I’m seeking for advice how to adapt the background colors to (automatic) dark mode.

Currently, the light bright colors I have chosen for backgrounds render the posts unreadable in dark mode.

Could it be possible to extend the color palette and do some color calculation to define background colors for wikis and pads?

You could use tags to mark “wiki”-topics.
Tags can be styled by CSS IIRC.
You would get the additional benefit of a listing / drill down option for them.

In addition, a wiki-tag could be added to topics including wikis automatically with a plugin.

This is why I recommend a Scheme colour:

If you want to go off-piste with your colours, you will need to find a clever way to deal with dark mode.

A nice feature would be to enable specification of a dark mode colour too. I’ll take a look at that when I get some spare time.

1 Like

Sure. But these colors are too dominant for a background.
Therefore I was dreaming of something like 10% scheme-color mixed with 90% background. I suppose SASS (or something similar) is not available in the frontend.
But would some CSS magic like this work?

Update: rgba(0, 255, 0, 0.1) works quite good in dark and light modes.

SASS functions are available in the customize theme section, it’s compiled when you save your modifications. Your can’t use SASS functions on theme or CSS variables though.
If you want to use a SASS function on a color from your color scheme, you must use the corresponding SASS variable.

Will work :white_check_mark:

body {
    background: darken($secondary, 10%);
}

Won’t work :x:

body {
    background: darken($my_theme_variable, 10%);
}

Won’t work :x:

body {
    background: darken(var(--secondary), 10%);
}

And on the paper, I think what your link describes should work. :slight_smile:

3 Likes

Maybe this is worth a shot. Here is a guide (for my own reference) on using the SASS mix() function:

https://subscription.packtpub.com/book/web-development/9781849694544/4/ch04lvl1sec45/the-mix-function