[yast-devel] Yast webclient - template helpers (translations, output formatters)
Hi, Another thing I noticed is that the webclient plugins do not use any shared code for generating HTML output or for translations. I defined some helpers in web-client/webclient/app/helpers/application_helper.rb file. These helpers are automatically available in all webclient templates. There is e.g. 'delete' => _("Delete") helper, and more should be added. The translators will translate the common texts just once not per plugin package. Moreover I added 'simple_table' helper for generating overview table (optionally with Add/Edit/Delete links), it's already used in samba_server plugin. It's not a generic function for creating any table layout, but for major yast overview dialogs it should be sufficient. I wanted to define some namespaces for the helpers, like Label for delete, but I failed. Rails could not find the functions in the namespace, any idea why? (I can send a patch if needed...) Again, we should share as much code as possible. So if you think that the code which you just have written could be used in some other plugin move it to the base webclient package (and don't forget to document it well). -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Ladislav Slezak wrote:
Hi,
Another thing I noticed is that the webclient plugins do not use any shared code for generating HTML output or for translations.
I defined some helpers in web-client/webclient/app/helpers/application_helper.rb file. These helpers are automatically available in all webclient templates.
There is e.g. 'delete' => _("Delete") helper, and more should be added. The translators will translate the common texts just once not per plugin package.
Moreover I added 'simple_table' helper for generating overview table (optionally with Add/Edit/Delete links), it's already used in samba_server plugin. It's not a generic function for creating any table layout, but for major yast overview dialogs it should be sufficient.
I wanted to define some namespaces for the helpers, like Label for delete, but I failed. Rails could not find the functions in the namespace, any idea why? (I can send a patch if needed...)
Again, we should share as much code as possible. So if you think that the code which you just have written could be used in some other plugin move it to the base webclient package (and don't forget to document it well).
--
Best Regards
Ladislav Slezák
At first I agree with sharing as much as possible. As I see modules is developed as plugins. If we move to much thinks to base, it become quite unintuitive and confusing. I find article about plugin dependencies http://onrails.org/articles/2006/03/04/managing-rails-plugins-dependencies . Maybe we could separate thinks to plugin structure and use only things which is necessary. I think that users need only subgroup of webyast modules, so we should give him only necessary thinks. This allows sharing code only during subgroup of modules and get to base only thinks which is useful for all modules. Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Ladislav Slezak schrieb:
Hi,
Another thing I noticed is that the webclient plugins do not use any shared code for generating HTML output or for translations.
I defined some helpers in web-client/webclient/app/helpers/application_helper.rb file. These helpers are automatically available in all webclient templates.
There is e.g. 'delete' => _("Delete") helper, and more should be added. The translators will translate the common texts just once not per plugin package.
Moreover I added 'simple_table' helper for generating overview table (optionally with Add/Edit/Delete links), it's already used in samba_server plugin. It's not a generic function for creating any table layout, but for major yast overview dialogs it should be sufficient.
Yes, an "UI building set" would be very nice. (e.g. for tables, lists, comboxes, ...) I can imaging that we will have less effort then when we are changing the UI e.g. stylesheets. Please go on here. I suggest that we should begin to document this on http://en.opensuse.org/YaST/Web
I wanted to define some namespaces for the helpers, like Label for delete, but I failed. Rails could not find the functions in the namespace, any idea why? (I can send a patch if needed...)
Duncan should know more about. He has already played with namespaces. :-)
Again, we should share as much code as possible. So if you think that the code which you just have written could be used in some other plugin move it to the base webclient package (and don't forget to document it well).
--
Best Regards
Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/
-- ******************************************************************************* Stefan Schubert SUSE LINUX GmbH - Maxfeldstrasse 5 - D-90409 Nuernberg, Germany e-mail: schubi@suse.de ------------------------------------------------------------------------------- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Stefan Schubert wrote:
Ladislav Slezak schrieb:
I wanted to define some namespaces for the helpers, like Label for delete, but I failed. Rails could not find the functions in the namespace, any idea why?
Duncan should know more about. He has already played with namespaces. :-)
I have finally solved the problem, now we have HTML and Label modules in web-client/webclient/app/helpers/view_helpers subdirectory. Example (display localized "Delete" string): <% require 'view_helpers/label' %> <%= Label.delete %> Feel free to add new functions/modules there. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Ladislav Slezak wrote:
I have finally solved the problem, now we have HTML and Label modules in web-client/webclient/app/helpers/view_helpers subdirectory.
Example (display localized "Delete" string):
<% require 'view_helpers/label' %> <%= Label.delete %>
Sorry, I have found out that my implementation was wrong, rails use a different way to include additional helpers: - create module <Name>Helper in <name>_helper.rb file in app/helpers subdirectory - add "helper :<name>" statement to the _controller_ method which renders the view - use the functions from the <Name>Helper module directly in the .erb template I have changed the helpers to match the expected format. Example usage: Using label_delete function from app/helpers/view_helpers/label_helper.rb file in a view. Controller: -------------------------8<------------------------------- class MyController < ApplicationController before_filter :login_required layout 'main' helper 'view_helpers/label' -------------------------8<------------------------------- (See http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.htm... for more details about 'helper' statement.) View: -------------------------8<------------------------------- <%= label_delete %> -------------------------8<------------------------------- Note: Because functions are included from helper modules you don't have to explicitly write the module names (namespaces). On the other hand this can potentially lead to name collisions when we put a lot of modules/functions there, so I suggest to use the module name as a function prefix. E.g. all functions in LabelHelper module will have prefix label_*, like label_delete in the above example. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
* Ladislav Slezak <lslezak@suse.cz> [Jun 03. 2009 16:18]: Hi,
I have finally solved the problem, now we have HTML and Label modules in web-client/webclient/app/helpers/view_helpers subdirectory.
Example (display localized "Delete" string):
<% require 'view_helpers/label' %> <%= Label.delete %>
this should be defined as a partial below app/view/layouts as its part of the view without a functional aspect. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
jreidinger
-
Klaus Kaempf
-
Ladislav Slezak
-
Stefan Schubert