Plugin Outlet after post-date


(cpradio) #1

I’d like to add a plugin outlet after post-date in post.hbs (see below)
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/templates/post.hbs#L27-L29

The one customization we do in post.hbs is put the post number behind the post-date (for whatever reason our community likes to reference things by post number).

Having the outlet would save us from having to overwrite the template for this customization

Any objections? If not, I’ll submit a PR for it.


(Robin Ward) #2

If all you’re adding is the post number, perhaps we needn’t make a whole outlet for it. Can you show me the markup you use for showing the post?


(cpradio) #3

https://github.com/sitepoint/discourse-theme/blob/discourse/v1.4.0.beta11/assets/javascripts/discourse/templates/post.hbs#L28-L30

The key part right now is

  #{{post_number}}

I’m just trying to come up with a solution where we don’t have to overwrite the entire template, as it has bitten us in the past.


(Robin Ward) #4

I think this is simple enough that we should consider adding it in core behind a site setting. @codinghorror would you object to a “show post number on posts” site setting default off? It’s much simpler than an outlet that would only ever be used for that purpose.


(Jeff Atwood) #5

Nobody has ever requested it… personally I don’t see the point of it, and this is not something I want to encourage. It’s a bit like signatures from my perspective. Including it as a site setting would be implicitly endorsing it.

Now if you want to include post number in the HTML payload, and then let people style with CSS or whatever… I know it is available because our share dialog includes it.


(cpradio) #6

Wouldn’t that mean writing it always and by default hiding it? Otherwise, the only other options are plugin outlet, or overwriting the entire post template.


(Jeff Atwood) #7

How does the share dialog get the post number?


(cpradio) #8

The .json payload has it, it just isn’t written to the screen. We are currently writing it by overwriting the entire post.hbs template and putting in {{post_number}} in the template.

So yes, it is in the payload, but it isn’t actually part of the markup. CSS can only impact what is in the markup.


(Mittineague) #9

It is in a couple of attribute values.
Maybe a JavaScript solution would be better than over-riding the template?


(cpradio) #10

Harder to version control. The template can be version controlled and follows the plugin paradigm (which is effectively javascript).

The outlet would just give us a reason to not overwrite the entire post template (or something similar).


(Jeff Atwood) #11

I support it being in one of the data attributes in the HTML @eviltrout


(cpradio) #12

Ah, sweet! that exists already.

That’s a much cleaner way to do this!

a.post-date:after {
  content: " #"attr(data-post-number);
}

ping @orodio


(Mittineague) #13

I’ll say. Purely CSS !