chiark / gitweb /
Use form-based buttons instead of hyperlinks
[disorder] / templates / macros.tmpl
index 1da66d402cdde054fd3e3722dc6b09a9e075fbd4..3132e570eaf9167051768e9c6b4be46e26dbf520 100644 (file)
@@ -56,20 +56,19 @@ and then redefines macros as desired.
 @menuitem{@current}{new}{true}
 @menuitem{@current}{login}{true}
 @menuitem{@current}{help}{true}
-@menuitem{@current}{about}{true}
    </p>
    <div class=logo>
-    <a href="http://www.greenend.org.uk/rjk/disorder/">
-     <img src="@image{logosmall}"
-          style="border-style:none"
-          alt="DisOrder"
-          title="Quack quack!  Visit the DisOrder website">
-    </a>
+@menuicon{@current}{about}{true}{logosmall}
    </div>
   <div style="clear:both"></div>
   </div>
 }
 
+@define {menuurl} {name}
+        {@if{@eq{name}{playing}}
+           {@url}
+           {@url?action=@name}}
+
 @# Menu entry
 @#  Used by @stdmenu
 @#  @current is the name of the current page (not necessarily the action that
@@ -82,13 +81,37 @@ and then redefines macros as desired.
             {    <a @if{@eq{@current}{@name}}
                        {class=activemenu}
                        {class=inactivemenu}
-@if{@eq{name}{playing}}
-   {       href="@url"}
-   {       href="@url?action=@name"}
+       href="@menuurl{@name}"
        title="@label{menu.@q{@name}verbose}">@label{menu.@name}</a>}
             {    <span class=invalidmenu 
           title="@label{menu.@q{@name}verbose}">@label{menu.@name}</span>}}
 
+@# Icon-based menu entry (very similar to @menuitem)
+@#  Used by @stdmenu
+@#  @current is the name of the current page
+@#  @name is the name of the menu item
+@#  @available is true if the menu item is available, else false
+@#  @icon is the name of the icon
+@#  
+@define {menuicon} {current name available icon}  
+        {@if{@available}
+            {    <a class=menuicon
+       href="@menuurl{@name}">
+     <img @if{@eq{@current}{@name}}
+             {class=activemenu}
+             {class=inactivemenu}
+          title="@label{menu.@q{@name}verbose}"
+          alt="@label{menu.@name}"
+          src="@image{@icon}">
+    </a>}
+            {    <span class=menuicon>
+     <img @if{@eq{@current}{@name}}
+             {class=activemenu}
+             {class=inactivemenu}
+          title="@label{menu.@q{@name}verbose}"
+          alt="@label{menu.@name}"
+          src="@image{@icon@_inactive}">
+    </a>}}
 
 @# Standard footer text
 @define {credits} {}
@@ -254,6 +277,27 @@ and then redefines macros as desired.
    </table>
 }
 
+@# Expand to a submit button
+@#  @text is the text to put inside the button
+@define {submit} {text}
+        {<span class=buttonouter><button class=button name=submit type=submit><span class=buttoninner>@text</span></button></span>}
+
+@# Expand to an action button
+@#  @text is the text to put inside the button
+@#  @long is the text to put in the caption
+@#  @action is the target action
+@define {actbutton} {text long action}
+        {<form method=GET class=button action="@url">
+           <input type=hidden name=action value="@action">
+           <input type=submit name=submit value="@text" title="@long">
+@formback@#
+         </form>}
+@# TODO @back support
+
+@# Used for inserting back= elements
+@define {back} {} {}
+@define {formback} {} {}
+
 Local variables:
 mode:sgml
 sgml-always-quote-attributes:nil