Patch #13763
openLive check of hostname setting
0%
Description
Hi,
this is a small patch, which provides a live check for the hostname setting in the admin menu.
This is just a function, you can attach as many input fields with different regexp as needed.
I defined this to prevent cases like #13352.
Best regards,
Daniel
Files
Related issues
Updated by Daniel Felix over 11 years ago
Forgot the fileupload. ;-)
Updated by Toshi MARUYAMA over 11 years ago
- Please use two spaces instead of tabs for intends.
- Please use "javascript_tag" instead of <script type="text/javascript">, refer r10371.
- I think that Rails validates_format_of is better than JS.
refer: source:tags/2.3.0/app/models/repository/subversion.rb#L23
Updated by Daniel Felix over 11 years ago
1. & 2. agreed
3. this script is in thought in addition to the normal validation. The rails validation works after submitting. This script check before the user try to save anything. A combination would be good, as the user won't be bothered to submit each config x-times.
Updated by Daniel Felix over 11 years ago
1. and 2. are corrected now.
Updated by Filou Centrinov over 11 years ago
- File valid_host_name.patch valid_host_name.patch added
I think also, that validation has to be done by rails instead of JS. My patch tries to store host values correctly, that means: "<anything>://" or "www" is deleted
Updated by Daniel Felix over 11 years ago
Yes there should be some validation via rails, but this won't be a live check anyway.
The user just can try and error until everything is fine. The frontend should provide a feedback to the client.
By the way, I would prefer this
v = v.gsub(/#{
@available_settings[name]['regexp']}/i,'') unless
@available_settings[name]['regexp'].blank? && v.blank?
instead of this:
v = v.gsub(/#{
@available_settings[name]['regexp']}/i,'') if !
@available_settings[name]['regexp'].blank? && !v.blank?
There would be less confusion because of the ommitting of the negotiation.
Updated by Filou Centrinov over 11 years ago
If you want to use unless
it would be:
v = v.gsub(/#{@@available_settings[name]['regexp']}/i,'') unless @@available_settings[name]['regexp'].blank? || v.blank?
(De Morgan's law)
Updated by Daniel Felix over 11 years ago
Filou Centrinov wrote:
If you want to use
unless
it would be:
[...]
(De Morgan's law)
Why @?
should be enough? You haven't changed anything instead of your double @?
Updated by Filou Centrinov over 11 years ago
available_settings
is definded as static which is definded with "@@
". An instance does not exist, so "@" won't work. Try it out.
You haven't changed anything instead of your double @?
I changed your logical conjunction. If you use unless
you have to use ||
instead of &&
because of De Morgan's law.
Updated by Daniel Felix over 11 years ago
Ah thanks. I haven't noticed the or. :-) this happens if you try to watch at something while your on the jump to your next meeting. :-)
Updated by Daniel Felix over 11 years ago
Hi there,
any news on this hostname validation patch?
I recently noticed this stumbling block as a friend of mine tried to install Redmine in his company.
Best regards,
Daniel