-
Notifications
You must be signed in to change notification settings - Fork 130
ia5 web interface customization
This page describes how to replace existing pages from the ia5 web interface with custom content.
You can also visit the official documentation for a more detail:
Question:
I have setup some modes in the past to be able to quickly enable rules that only should run now and then (e.g. automatic x-mas lighting through a MH-controllable socket).
I have added support for mode control by editing the mh/web/ia5/modes/main.shtml file as documented here: http://misterhouse.wikispaces.com/Modes
However, this is not really the way to go since you're in this case making customizations in the main code tree. I think this should go somewhere into the 'local' folder.
Can somebody point me to/explain me how to set this up? The wiki was not really helping me there (http://misterhouse.wikispaces.com/WebPages).
Answer:
This is very easy to do by using HTML aliases, which are a very nice feature that allows us to customize different parts of the web interface without modifying the corresponding files shipped with the MH distribution.
Follow these steps to try it out:
- Create a test file 'xmas.pl' in my user code directory with just these two lines:
$mode_xmastree = new Generic_Item; #noloop
$mode_xmastree->set_states('on', 'off'); #noloop
- Edit mh.private.ini and add this line:
html_alias_ia5 = /home/mrhouse/web
In my installation, the MH distribution is installed at /opt/misterhouse. This is the official MH code, and it is read-only for the user that run the mh executable (I created a "mrhouse" user for that). /home/mrhouse is the home directory for the "mrhouse", so the mh process, run by the "mrhouse" user, can write anywhere in this directory.
-
Create /home/mrhouse/web/modes and copy web/ia5/modes/main.shtml (from the official MH code) there.
-
Modify /home/mrhouse/web/modes/main.shtml by adding this:
<tr>
<td align='middle'> <!--#include
file="/bin/button_toggle.pl?mode_xmastree&/ia5/modes/main.shtml"--> </td>
</tr>
- Now visiting the modes page shows a button for the new mode. The first time it is shown it does not show the current mode because it has not be set yet. However, after you click on the button one time, it will start showing the mode, and it will cycle through the possible states as you click on the button.
Using HTML aliases is the correct way to customize the web interface. There are a bunch of different aliases that are recognized. Look at bin/mh.ini and search for "alias" to see them.
Contributed by Eloy Paris through the mailing list.
Lieven Hollevoet tried this out, works fine!