Balazs Kutil

Showcasing Your (PHP) Web App With SUSE Studio

SUSE Studio, together with its Testdrive feature, can be used to setup a demo for your web application. You can then let users download and deploy the appliance and have the service up and running in a few minutes.

In this tutorial, I’ll use status.net as an example. It is a PHP app with MySQL backend. My tutorial should be quite generic though, so you can clone from my appliance and modify it to your liking.

Building XFCE Desktop With SUSE Studio

Although we recently hacked in an automagick recognition and start up of several more window managers (windowmaker, fvwm2…), into Studio, XFCE4 is still missing from the list. The reasons are that it simply doesn’t work out of the box without a few tweaks. However, these are easy to do thanks to Studio and I’ll present a step-by-step tutorial, where we’ll build an openSUSE 11.3 appliance with XFCE4 running. If you are already familiar with how to use Studio, just skip to the summary section at the end for a brief list of steps.

Loading External Plugins in CKEditor

Friend of mine needed help with $SUBJ, to extend CKEditor with some extra functionality without changing the source code in editor’s tree. Here is the solution:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Test</title>
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <script type="text/javascript" src="ckeditor/ckeditor_source.js"></script>
  </head>
 
  <body>
    <textarea cols="80" id="editor" name="editor" rows="10"></textarea>
    <script type="text/javascript">
      var editor = CKEDITOR.replace('editor');
      CKEDITOR.plugins.addExternal('myplugin', '/path/to/my/plugin/', 'plugin.js' );
      CKEDITOR.plugins.load('variables',
          function( plugins ) {
            plugins['myplugin'].init(editor);
          });
    </script>
  </body>
</html>

addExternal() (in _source/core/resourcemanager.js:151) only registers a resource, which then needs to be loaded using load() method (_source/core/plugins.js:23). Since it doesn’t automatically call the plugin’s init() function, we have to do it ourselves in the callback and pass it the CKEditor instance as a parameter.

Documentation for addExternal says: “Registers one or more resources to be loaded from an external path instead of the core base path.”. To be loaded actually doesn’t mean it gets loaded via this call.

L10n in Generated sfPropelPlugin Forms

After running

1
symfony propel:generate-module --non-verbose-templates   

Certain strings aren’t translated in automatically generated _form.php partial and Success templates (e.g. ‘Back to list’, ‘Are you sure?’, ‘Delete’, etc…). Indeed, the class responsible for generating these files doesn’t contain calls to l10n function __():

1
[Back to list]([?php echo url_for('...') ?])

I wrote a simple patch that fixes this in the _form.php, but then I realized, that the bug could be present in other templates as well. The final patch for all templates is here:

sfpropelplugin_default_l10n.patch