[Nitro] just some suggestions
manveru
ulmo at valaraan.de
Wed Sep 7 17:57:13 EDT 2005
James Britt wrote:
> Emmanuel Piperakis wrote:
>
>> Hi all,
>> I know I am not a Ruby Guru, but here are some suggestions:
>> in Nitro, xhtml.rb, in date_select I believe the 3rd line should be
>> data ||= Date.today
>> cause data ||= Time.now makes the recieve object of class Time and it
>> is incompatible with Date objects in Og...
>>
>> Also date_select should have options for a wider range of year select
>> (not just +- 10 years)
>>
>> Also there should be an option for turning months to numbers, turning
>> off days, displaying years in '05 format, etc etc...
>>
>> I might try to rewrite it myself, but since I am no Ruby guru :-(
>>
>
> Ah, but skill to do comes of doing.
>
> James
>
Had some minutes left to look trough the xhtml.rb and changed some
things to what you wanted to have, would be better that someone who
knows more about the way og works could comment on that, also i had no
time to investigate into issue further... so one may have to modify the
receiving part also...
i have also no idea if the changes work with og - i have done absolutely
no testing except viewing it in a template... but one gets the idea how
this could be done.
hope this helps anyway
so long...
manveru
xhtml.rb
----------------------------------------------------------------
def date_select(date, options = {})
o = {
:days => true,
:months => true,
:months_numeric => false,
:years => true,
:years_2_digits => false,
:years_start => 10,
:years_end => 10
}.merge(options)
raise 'No name provided to date_select' unless name = o[:name]
date ||= Date.today
the_select = []
if o[:days] == true
the_select << %{
<select id="#{name}.day" name="#{name}.day">
#{options(:labels_values => (1..31).to_a, :selected =>
date.day)}
</select>}
end
if o[:months] == true
the_months = ''
the_months << %{<select id="#{name}.month"
name="#{name}.month">}
if o[:months_numeric] == true
the_months << %{"#{options(:labels => (1..12).to_a,
:values => (1..12).to_a, :selected => (date.month+1))}"}
else
the_months << %{"#{options(:labels => Date::MONTHNAMES,
:values => (1..12).to_a, :selected => (date.month+1))}"}
end
the_months << %{</select>}
the_select << the_months
end
if o[:years] == true
the_years = ''
the_years << %{<select id="#{name}.year" name="#{name}.year">}
if o[:years_2_digits] == true
years = ((Date.today.year -
o[:years_start])..(Date.today.year - o[:years_end])).to_a
years = years.map { |y| y = y.to_s[2,2] }
else
years = ((Date.today.year -
o[:years_start])..(Date.today.year - o[:years_end])).to_a
end
the_years << %{"#{options(:labels_values => years, :selected
=> date.year)}"}
the_years << %{</select>}
the_select << the_years
end
%{#{the_select.join(" ")}}
end
----------------------------------------------------------------------
More information about the Nitro-general
mailing list