YaST/Web/Development/TrainingKit

From openSUSE

Contents

Developer Training Kit

This is the material that will help you to develop for YaST web, there are also additional development tips.

General knowledge for web service and web client

Web client specific knowledge

Layout and Theming

This part describes ways how the layout of WebYaST like text, stylesheet, images, icons,... can be changed or added.

Changing existing images,icons and stylesheets

Images, icons, stylesheets are stored in the public directory of the YaST-Webclient. The public directory contains and additional subdirectory vendor which is used for overwriting,exchaninging images, stylesheets,.... for special vendors. Each file in the public directory can be exchanged by putting a file with the same path into the vendor.

For example changing the WebYaST logo which is stored in:

---public
     |
     +---images
            |
            +---webyast-logo.png

the corresponding file has be created in:

---public
     |
     +---images
     |      |
     |      +---webyast-logo.png
     |
     +---vendor
            |
            +---images
                   |
                   +---webyast-logo.png

Please take care that all links in the views have to be defined by the AssetTagHelper like image_tag, stylesheet_link_tag, javascript_include_tag, ...

e.g.

   <%= link_to(image_tag("/images/webyast-logo.png", :alt =>"webyast" ),"/")  %>

instead of

   <a href="/"><img src="/images/webyast-logo.png" alt="webyast" /></a>


Add new images, icons, stylesheets,.... for Plugins

Icons, images,... are normally stored in the public directory of the webserver. In order to avoid flooding this directory each plugin can define his own public directory in:

  vendor/plugins/<plugin-name>/public

The webserver has a look into this directory if the requested file is not in the official public directory. So only new files will be regarded in the vendor/plugins/<plugin-name>/public directory.

In order to exchange existing files use the mechanism described above.

Changing Text

WebYaST uses gettext in order to provide translations for each text in the UI. These translations are located in the po directory split in so called textdomains. While running a WebYaST module different textdomains will be loaded. e.g. the status module loads (logfile output):

Loading standard textdomain: yast_webclient
Loading standard textdomain: yast_webclient_status

The concerning translations ( so called po-files) are located in

  • po/<language>/yast_webclient.po
  • vendor/plugins/status/po/<language>/yast_webclient_status.po

These po-files have to be translated into so called mo-files by the call rake makemo. The generated files are located in:

  • locale/<language>/LC_MESSAGES/yast_webclient.po
  • vendor/plugins/language/locale/<language>/LC_MESSAGES/yast_webclient_status.mo

This mechanism can also be used for changing text completely. Please regard when changing the text you have to provide translations by your own :-).

This is an example how to change the textdomain yast_webclient:

  • Copy po/<language>/yast_webclient.po to public/vendor/text/po/<language>/yast_webclient.po
  • Change the text in public/vendor/text/po/<language>/yast_webclient.po
  • Call rake makemo in public/vendor/text. The text will be translated into mo-files.

After restarting the webserver following entries are generated in the logfile:

Loading textdomain yast_webclient from public/vendor/text/locale
Loading standard textdomain yast_webclient_status

General Knowledge

Web service specific knowledge

Other

Reference Cards