Skip Menu |

This queue is for tickets about the Mojolicious-Plugin-CountryDropDown CPAN distribution.

Report information
The Basics
Id: 76028
Status: resolved
Priority: 0/
Queue: Mojolicious-Plugin-CountryDropDown

People
Owner: HJANSEN [...] cpan.org
Requestors: SHAW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.04
Fixed in: (no value)



Subject: Rendering Dropdown
You add the country select to the stash, this makes displaying it a little odd, particularly compared to how other tag helpers work. sub countries { shift->show_country_list() } __DATA___ @@ countries.ep.html %= $country_drop_down OR %= stash('country_drop_down') Why not just %= country_drop_down() ? -Skye
There´s a new version of the module available which addresses your suggestion but breaks compatibility with the previous version: https://metacpan.org/release/HJANSEN/Mojolicious-Plugin-CountryDropDown-0.0501/ Therefore, I marked it as a beta release and I´d be happy to receive any feedback you´d care to provide before promoting it to an official release. I´m still getting my feet wet regarding public module releases and CPAN, so turnaround time is definitely higher than desirable but I´ll do my best to address any other concerns you´d raise.
These lines of code are a performance killer: for (@sorted) { $list{$_} = $lcm->country2code( $_, 'LOCALE_CODE_ALPHA_2', $lang ); } https://gist.github.com/2355239 I've made some basic changes that might help out: https://gist.github.com/b51fa0283645b2cc39cf If your going to allow the user to select what code format they should use (which probably isn't a bad idea) some modifications will be necessary, as the order of codes return by $lcm->all_country_codes ($format) will differ based on $format. I've also removed: my $_html = sub { # HTML generation stuff } Now mojo handles that stuff. Some other suggestions: * Maybe you should consider stubbing out the language specific country names to a localization framework..? * A way to prioritize countries. For example in the USA you might want Canada, Mexico, and USA at the top or the list. * Select multiple options * I'd also drop show_country_list. Not sure how useful it is to have an HTML fragment in the stash. * (Nitpicking here) maybe even rename the country_drop_down to country_select_field to be in line with Mojo conventions/lingo. I'm willing to help! -Skye
Am Di 10. Apr 2012, 19:13:55, SHAW schrieb: Show quoted text
> These lines of code are a performance killer: > > for (@sorted) { > $list{$_} = $lcm->country2code( $_, 'LOCALE_CODE_ALPHA_2', $lang ); > }
Is suspected something like that but wasn´t aware that the performance penalty was that severe. At the time of writing I wasn´t absolutely sure if Locale::Country::Multilingual would always return the same number of codes or names in the exact same order for every call to "all_country_codes" or "all_country_names($lang)" using any possible language. Otherwise I´d have written something like: my %countries = (); @countries{ $lcm->all_country_names($lang) } = $lcm->all_country_codes; (By the way: I was really surprised to see that using "zip" is even faster - if only marginally - than the hash slice assignment...) Show quoted text
> I've made some basic changes that might help out: > > https://gist.github.com/b51fa0283645b2cc39cf
I´ve adopted most of that for https://metacpan.org/release/HJANSEN/Mojolicious-Plugin-CountryDropDown-0.0502-TRIAL/ Show quoted text
> If your going to allow the user to select what code format they > should use (which probably isn't a bad idea)
Haven´t done that yet. Will look into it before releasing the next non-DEV version. Show quoted text
> * Maybe you should consider stubbing out the language specific > country names to a localization framework..?
Don´t really understand what you´re driving at, here. Show quoted text
> * A way to prioritize countries. For example in the USA you might > want Canada, Mexico, and USA at the top or the list.
Added some support for that. Show quoted text
> * Select multiple options
Haven´t tried yet but shouldn´t that be just a matter of providing the appropriate HTML attributes (and therefore already be possible)? Show quoted text
> * I'd also drop show_country_list. Not sure how useful it is to have > an HTML fragment in the stash.
It´s gone. Show quoted text
> * (Nitpicking here) maybe even rename the country_drop_down to > country_select_field to be in line with Mojo conventions/lingo.
Looks like it´d make sense. Done. Show quoted text
> I'm willing to help!
So I recognized ;-) Heiko
On Sun Apr 22 16:37:01 2012, HJANSEN wrote: Show quoted text
> > * Maybe you should consider stubbing out the language specific > > country names to a localization framework..?
> > Don´t really understand what you´re driving at, here.
Your module will only provide English translations -the default. Let the users handle translations on an as needed basis via Mojolicious::Plugin::I18N (or I18N2 http://github.com/sharifulin/ mojolicious-plugin-i18n2). register() would load the Mojolicious::Plugin::I18N plugin and set the default. Subsequent calls to country_select_field() would call I18N's l () method, something like: my $names = l 'country.names'; my $codes = l 'country.codes'; I think this will make your module a lot simpler, faster, and robust. Plus, some users may not like they names used by Locale::Country::Multilingual. Using the above approach they can easily change them. Show quoted text
> > * Select multiple options
> > ... already be possible
Yes, it is.
Unfortunately I haven´t had the time to catch up with this earlier but a few minutes ago I finally uploaded 0.0504-TRIAL to PAUSE. Cf. https://metacpan.org/release/HJANSEN/Mojolicious-Plugin-CountryDropDown-0.0504-TRIAL Am Fr 22. Jun 2012, 21:57:16, SHAW schrieb: Show quoted text
> On Sun Apr 22 16:37:01 2012, HJANSEN wrote:
> > > * Maybe you should consider stubbing out the language specific > > > country names to a localization framework..?
> > > > Don´t really understand what you´re driving at, here.
> > Your module will only provide English translations -the default. Let > the users handle translations on an as needed basis via > Mojolicious::Plugin::I18N (or I18N2 http://github.com/sharifulin/ > mojolicious-plugin-i18n2).
English is still the final fallback but unless an explicit value is set for the language the new version will try to use the language as detected by the I18N plugin. Most of the others concerns previously mentioned in this bug have also been dealt with. It is, however, still a development release, since I´m still not completely at ease with the API and some internals. Heiko
Subject: RT#76028 Rendering Dropdown
Most issues raised have been dealt with in version 0.06 which got released a few days back (at least as far as I understood them) . Therefore and because it´s getting harder to sort out the current state of the different sub-issues I´m closing this ticket. Feel free to open (a) new ticket(s) for any remaining (or new?) issue(s)! Thanks again for your improvement suggestions and effort. Heiko