How to show Full Name in Embeds

Hi Guys

I just read through this post How to display full name in comments embeds

I ran these commands.

cd /var/discourse
./launcher enter app
x86_64 arch detected.
root@discourse-app:/var/www/discourse# cd app/views/embed/
root@discourse-app:/var/www/discourse/app/views/embed# nano comments.html.erb

Nano was not installed so I installed it and edited comments.html.erb replacing the lines mentioned in the referred post.

I then exited the launcher and ran

./launcher rebuild app

After the rebuild it did not make any difference, I still see usernames instead of Full Names in the embeds.

Where have I gone wrong?

Thanks

2 Likes

Welcome, Mark! :wave:

Rebuilding the app re-download Discourse, and will overwrite any change you made inside the container.

If you want to bring modifications to Discourse, editing these files this way is not the proper way to do so.

Customize features of Discourse is usually made either with a theme component:

Or a plugin:

If you have some coding knowledge, I suggest you have a look at these links. :slight_smile:


This link might be particularly interesting:

At first glance, it seems to do exactly what you’re looking for. It just targets another file in the same parent folder.

1 Like

@Canapin Thanks for your suggestions.

I’ve created this repo GitHub - OptDev/optuma-discourse-custom-embed: This Discourse Plugin overrides the default embed template code

but I’m not making much progress.

I run this command and it builds without error

./launcher enter app

But I don’t seem to be seeing the changes I’m expecting in embeds. I’ve added a couple of custom css class names and I’ve changed <%= post.user.username %> to <%= post.user.name %>. Would appreciate some more nudging in the right direction to get this working. I can’t imagine it’s too complicated to override a plugin template file from another plugin.

What I have been able to do is enter the app and manually copy my plugins version of the template over to /var/www/discourse/app/views/embed/ then I restart the app and I see the results I’m looking for.

I just need to have the auto-magically happen when the plugin is loaded, and that’s where I’m stuck.

Any ideas why this is not overriding the /app/views/embed/comments.html.erb file with the one I have in my plugin?

after_initialize do
  ::EmbedController.prepend_view_path File.expand_path("../embed", __FILE__)
end

Okay, I had this right, it just had a path issue.

Now I just need to figure out how to get it to pull from a private git repo.

1 Like

Just add private access token to the cloned URL

@merefield What would that look like in the app.yml file?

Never mind I found it here. Install Plugins in Discourse

One thing to note, in the doco it says to use a “token”…

git clone https://<token>@github.com/owner/repo.git

I found I needed to use your github user name and token

git clone https://<github-username>:<token>@github.com/owner/repo.git

1 Like

Did your plugin work as intended in the end? :slight_smile:

@Canapin Yes! Got it all working. Here is what the plugin.rb ended up looking like. Turned out I just had a path issue where I was putting the custom version of the file.

I ended up putting it in a folder /custom_views/embed/comments.html.erb

# frozen_string_literal: true

# name: optuma_discourse_custom_embed
# about: A simple plugin to used to customise the template in the forum embeds
# version: 1.0.0
# authors: Optuma Pty Ltd
# url: https://github.com/OptDev/optuma-discourse-custom-embed
# required_version: 2.7.0

after_initialize do
  ::EmbedController.prepend_view_path File.expand_path("../custom_views", __FILE__)
end
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.