Desenvolvendo plugins para Discourse - Parte 2 - Conectar a uma plugin outlet

Yes, and presumably you can apply to every available Theme so this can’t be switched off? (to address @sarahann concern about this approach).

I could use display: none but it might now be as secure as we need it to be. And I figured it would be helpful to have a discussion on how to remove / change Discourse UI templates.

2 curtidas

It’s tricky to do properly, unfortunately. For a big customer of ours who needs functionality removed, my approach has been to hide the elements with CSS and remove the controller side actions by using add_to_class to overwrite the methods with an error in plugin.rb.

9 curtidas

I have a same problem. I’m working on plugin with topic, and I have to change the html structures but it’s impossible with only CSS. So I was tried to overwrite template but changes never applied.
So do you have find any solution for that?

You can override any template in the application if you like (although outlets are always preferred!). How were you doing it? did you confirm the name is exactly the same as the template you are replacing?

3 curtidas


I tried to override the “list/topic-list-item.raw.hbs” template, but even though I removed all of the content in template, the topic items still appearing as original, any changing in override template never worked.
Please help me what I was wrong.

See: GitHub - discourse/discourse-simple-theme: Sam's simple discourse theme for an example of how it is done.

4 curtidas

Hello,
When I run the command git grep “plugin-outlet” – “*.hbs” in my Linux Terminal, nothing shows up. Any ideas why? Thanks for your help!

Caveat: This is a sysadmin answer, not a plugin developer answer, and I can’t guess what you might have done before you did your git command.

Did you add it to git? What about

 grep -r plugin-outlet .
2 curtidas

Building on Jay’s shoulders here, you can of course focus on the specific file type:

grep -r "plugin-outlet" --include \*.hbs

3 curtidas

Há algo que você precise considerar de forma diferente se o plugin outlet se parecer com isto?

{{plugin-outlet name="users-top" connectorTagName="div" args=(hash model=model)}}

Os atributos connectorTagName e args significam que os desenvolvedores de plugins têm restrições particulares ou acessos extras ao usar esses outlets?

Sim, você deve trabalhar com a API que as plataformas estabelecem.

Em users-top, um model é passado para você, que pode ser utilizado, e o conector será renderizado com um div neste caso.

2 curtidas

Não encontrei {{plugin-outlet}}. Encontrei alguns componentes com o mesmo nome. Eles são os mesmos?

grafik

1 curtida

Acho que o código do Discourse mudou e que o guia pode estar desatualizado.

Procurando por este exemplo:

Encontrei isto em vez disso:

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/templates/topic.hbs#L80

E usando este incrível componente de tema (deprecated) Plugin outlet locations theme component, posso ver este outlet onde deveria estar:

Para responder à sua pergunta, minha suposição é que seja o mesmo, mas com uma nova sintaxe.

3 curtidas

Também encontrei esta tag. Alguém poderia confirmar se todas são iguais?

{{~raw-plugin-outlet name="topic-list-after-title"}}

A referência mais atualizada sobre plug-in outlets está aqui:

Tentarei atualizar o OP nos próximos dias.

5 curtidas

OP atualizado com a nova sintaxe e um link para a documentação completa

6 curtidas

Eu acho que o comando deveria ser atualizado para:

git grep "<PluginOutlet" -- "*.gjs"

Esse link diz “obsoleto” (deprecated).

Edição: Eu encontrei o link para fazer um PR sob a postagem principal, então fiz um PR.

2 curtidas

Substituído por:

https://meta.discourse.org/t/introducing-discourse-developer-toolbar/346215?u=merefield

3 curtidas