National Flags

https://github.com/Ebsy/discourse-nationalflags/blob/master/assets/javascripts/discourse/templates/components/user-nationalflags-preferences.hbs#L11

how to use a dynamic variable?

<img class="nationalflag-usersummary" src="/plugins/discourse-nationalflags/images/nationalflags/{{flagsource}}.png" />

to

<img class="nationalflag-usersummary" src="/plugins/{{PLUGIN_NAME}}/images/nationalflags/{{flagsource}}.png" />

upd:
code css in my plugin
forum - how to use a dynamic variable?
upd2: css - Have a variable in images path in Sass? - Stack Overflow

@font-face {
  font-family: Hellix-Light;
  src: url("/plugins/forum/fonts/Hellix-Light/Hellix-Light.eot");
  src: url("/plugins/forum/fonts/Hellix-Light/Hellix-Light.otf");
  src: url("/plugins/forum/fonts/Hellix-Light/Hellix-Light.woff");
  src: url("/plugins/forum/fonts/Hellix-Light/Hellix-Light.woff2");
}
3 Likes

I have this installed, works great! Any way to modify it to a more local level? Example I have a mostly US based group was looking to do State Shapes or State Flags.

Sure, this should be straightforward and you can probably do this all within GitHub (and not have to use git):

How to add your own flags or emblems:

  1. Fork the repo https://github.com/Ebsy/discourse-nationalflags/tree/master/public/images/nationalflags. This is a simple button press but you might need a new GitHub account if you don’t already have one.

image

  1. Edit (within your fork) https://github.com/Ebsy/discourse-nationalflags/blob/master/config/flags.yml to add your new emblem codes and image names. Emblem codes must be unique! Use a sensible convention. You can do this directly on GitHub.

image

  1. Edit (ditto) https://github.com/Ebsy/discourse-nationalflags/blob/master/config/locales/client.en.yml to add your descriptions, one for each new emblem/flag you wish to add. Codes should correspond to those in 2.

  2. Upload your new images (pref .png format and 64px x 48px) whose file names correspond to the entries you made in 2 into (within your fork) https://github.com/Ebsy/discourse-nationalflags/tree/master/public/images/nationalflags

image

  1. Replace the plugin url in your app.yml with your fork address https://github.com/your-github-username/discourse-nationalflags

  2. Rebuild ./launcher rebuild app

:us: :tada:

6 Likes

Having a community with people from lots of interesting-but-unusal countries, I noticed that there doesn’t seem to be alt text to describe the country name when you hover over the flag images.

I’m not great with flags; there are so many countries! Any chance of adding an alt tag for the image at some point? :slight_smile:

9 Likes

It appears this plugin no longer works with the current version of Discourse, preventing a rebuild in my case.

3 Likes

Cannot reproduce. I have just rebuilt two sites that use it and am having no problems with the rebuild, and have not experienced any issues with the functionality either.

4 Likes

Interesting, that’s good at least. I wonder if it’s a conflict with another plugin? I’m going to try to see if I can figure out which, if any, are causing it. Thank you.

3 Likes

Is there a way to retrieve the locale or the flag from a public profile? For example, my profile shows the canadian flag, but I want to retrieve the ca part given my username. The profile is public, so privacy isn’t a concern. How can I retrieve the flag of a user from http?

2 Likes

Sure just add .json on the end of the address and it will retrieve the data only.

You will see all custom fields including “nationalflags_iso” retrieved.

Firefox is better than Chrome for reviewing the data.

5 Likes

Thanks. That was exactly what I was looking for.

5 Likes

Wondering if this has automatic flag all the users based on IP .

2 Likes

Could someone kindly help me and tell me how I would move the flag next to username like here please:

2 Likes

Is there a way to make National Flags a required User Field on sign-up?

The lastest core update broke this plugin

** INCOMPATIBLE PLUGIN **

You are unable to build Discourse due to errors in the plugin at
/var/www/discourse/plugins/discourse-nationalflags

Please try removing this plugin and rebuilding again!
I, [2020-11-05T14:45:08.794566 #1]  INFO -- :
I, [2020-11-05T14:45:08.795106 #1]  INFO -- : Terminating async processes
I, [2020-11-05T14:45:08.795163 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main pid: 49
I, [2020-11-05T14:45:08.795215 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 166
2020-11-05 14:45:08.795 UTC [49] LOG:  received fast shutdown request
166:signal-handler (1604587508) Received SIGTERM scheduling shutdown...
2020-11-05 14:45:08.799 UTC [49] LOG:  aborting any active transactions
2020-11-05 14:45:08.802 UTC [49] LOG:  background worker "logical replication launcher" (PID 58) exited with exit code 1
2020-11-05 14:45:08.803 UTC [53] LOG:  shutting down
166:M 05 Nov 2020 14:45:08.808 # User requested shutdown...
166:M 05 Nov 2020 14:45:08.808 * Saving the final RDB snapshot before exiting.
2020-11-05 14:45:08.815 UTC [49] LOG:  database system is shut down
166:M 05 Nov 2020 14:45:09.329 * DB saved on disk
166:M 05 Nov 2020 14:45:09.329 # Redis is now ready to exit, bye bye...
1 Like

I believe this may fix it, PR raised:

https://github.com/Ebsy/discourse-nationalflags/pull/14

forgive me for the typo! :grimacing:

4 Likes

Thanks Rob, unfortunately it’s back again.

** INCOMPATIBLE PLUGIN **

You are unable to build Discourse due to errors in the plugin at
/var/www/discourse/plugins/discourse-nationalflags

Please try removing this plugin and rebuilding again!
I, [2020-11-30T14:32:04.274044 #1]  INFO -- :
I, [2020-11-30T14:32:04.274927 #1]  INFO -- : Terminating async processes
I, [2020-11-30T14:32:04.275231 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main pid: 49
I, [2020-11-30T14:32:04.275574 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 166
2020-11-30 14:32:04.275 UTC [49] LOG:  received fast shutdown request
166:signal-handler (1606746724) Received SIGTERM scheduling shutdown...
2020-11-30 14:32:04.285 UTC [49] LOG:  aborting any active transactions
2020-11-30 14:32:04.292 UTC [49] LOG:  background worker "logical replication launcher" (PID 58) exited with exit code 1
2020-11-30 14:32:04.292 UTC [53] LOG:  shutting down
2020-11-30 14:32:04.321 UTC [49] LOG:  database system is shut down
166:M 30 Nov 2020 14:32:04.328 # User requested shutdown...
166:M 30 Nov 2020 14:32:04.329 * Saving the final RDB snapshot before exiting.
166:M 30 Nov 2020 14:32:04.378 * DB saved on disk
166:M 30 Nov 2020 14:32:04.379 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1628 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
a8ea6480b7070def0c0cfa68b65d9bdb510bc53284b3c0e5dfa6441d128ab199
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
2 Likes

Yeah I’m not sure why the custom wizard API changed again. I’ll have a word with the team.

3 Likes

OK this will have to be a two-phase fix.

First phase is to expedite a resolution to the build crash:

https://github.com/Ebsy/discourse-nationalflags/commit/a62110aecae171e2fa1d312aef475aad64a6fd0a

I’ve just rebuilt a server again, and this is now building ok.

Unfortunately I don’t believe this will make the flag plugin work with CW again. CW went through a huge refactor that means this integration may no longer work.

I’ll follow up at some stage soon with changes to make it actually work within Wizards again.

3 Likes

Hi, i was looking for some help, i recently installed the plugin and haven’t been able to make it work, its enabled, i can see the setting in the user preferences yet the country list is empty:
imagen
is there anything im missing?

1 Like

What happens when you hit the down arrow? Working for me!

1 Like