Release 0.9.0
This commit is contained in:
56
bot/modules/telnet/templates/jinja2_macros.html
Normal file
56
bot/modules/telnet/templates/jinja2_macros.html
Normal file
@@ -0,0 +1,56 @@
|
||||
{%- macro construct_toggle_link(bool, active_text, deactivate_event, inactive_text, activate_event) -%}
|
||||
{%- set bool = bool|default(false) -%}
|
||||
{%- set active_text = active_text|default(none) -%}
|
||||
{%- set deactivate_event = deactivate_event|default(none) -%}
|
||||
{%- set inactive_text = inactive_text|default(none) -%}
|
||||
{%- set activate_event = activate_event|default(none) -%}
|
||||
{%- if bool == true -%}
|
||||
{%- if deactivate_event != none and activate_event != none -%}
|
||||
<span class="active"><a href="#" onclick="window.socket.emit('{{ deactivate_event[0] }}', {{ deactivate_event[1] }}); return false;">{{ active_text }}</a></span>
|
||||
{%- elif deactivate_event != none and activate_event == none -%}
|
||||
<span class="active"><a href="#" onclick="window.socket.emit('{{ deactivate_event[0] }}', {{ deactivate_event[1] }}); return false;">{{ active_text }}</a></span>
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{%- if deactivate_event != none and activate_event != none -%}
|
||||
<span class="inactive"><a href="#" onclick="window.socket.emit('{{ activate_event[0] }}', {{ activate_event[1] }}); return false;">{{ inactive_text }}</a></span>
|
||||
{%- elif deactivate_event != none and activate_event == none -%}
|
||||
<span class="inactive"><a href="#" onclick="window.socket.emit('{{ deactivate_event[0] }}', {{ deactivate_event[1] }}); return false;">{{ active_text }}</a></span>
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro construct_view_menu(views, current_view, module_name, steamid, default_view='frontend') -%}
|
||||
{#
|
||||
Dynamically construct a navigation menu for widget views.
|
||||
|
||||
Parameters:
|
||||
views: Dict of view configurations
|
||||
Example: {
|
||||
'frontend': {'label_active': 'back', 'label_inactive': 'main', 'action': 'show_frontend'},
|
||||
'options': {'label_active': 'back', 'label_inactive': 'options', 'action': 'show_options'}
|
||||
}
|
||||
current_view: Current active view name (string)
|
||||
module_name: Module name for socket.io event (e.g., 'telnet')
|
||||
steamid: User's steamid for action parameters
|
||||
default_view: View to return to when deactivating (default: 'frontend')
|
||||
#}
|
||||
{%- for view_id, config in views.items() -%}
|
||||
{%- if config.get('include_in_menu', True) -%}
|
||||
{%- set is_active = (current_view == view_id) -%}
|
||||
{%- set label_active = config.get('label_active', config.get('label', 'back')) -%}
|
||||
{%- set label_inactive = config.get('label_inactive', config.get('label', view_id)) -%}
|
||||
{%- set action = config.get('action', 'show_' ~ view_id) -%}
|
||||
{%- set default_action = config.get('default_action', 'show_' ~ default_view) -%}
|
||||
|
||||
<div>
|
||||
{{ construct_toggle_link(
|
||||
is_active,
|
||||
label_active,
|
||||
['widget_event', [module_name, ['toggle_' ~ module_name ~ '_widget_view', {'steamid': steamid, 'action': default_action}]]],
|
||||
label_inactive,
|
||||
['widget_event', [module_name, ['toggle_' ~ module_name ~ '_widget_view', {'steamid': steamid, 'action': action}]]]
|
||||
)}}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
@@ -0,0 +1,9 @@
|
||||
{%- from 'jinja2_macros.html' import construct_toggle_link with context -%}
|
||||
<div>
|
||||
{{ construct_toggle_link(
|
||||
options_view_toggle,
|
||||
"options", ['widget_event', ['telnet', ['toggle_telnet_widget_view', {'steamid': steamid, "action": "show_options"}]]],
|
||||
"back", ['widget_event', ['telnet', ['toggle_telnet_widget_view', {'steamid': steamid, "action": "show_frontend"}]]]
|
||||
)}}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<div id="telnet_table_widget_options_toggle" class="pull_out right">
|
||||
{{ control_switch_options_view }}
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
{%- from 'jinja2_macros.html' import construct_view_menu with context -%}
|
||||
<div id="telnet_table_widget_options_toggle" class="pull_out right">
|
||||
{{ construct_view_menu(
|
||||
views=views,
|
||||
current_view=current_view,
|
||||
module_name='telnet',
|
||||
steamid=steamid,
|
||||
default_view='frontend'
|
||||
)}}
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<tr{% if css_class != None %} class="{{ css_class }}"{% endif %}><td>{{ log_line }}</td></tr>
|
||||
@@ -0,0 +1,3 @@
|
||||
<tr>
|
||||
<th>Log</th>
|
||||
</tr>
|
||||
@@ -0,0 +1,3 @@
|
||||
<tr>
|
||||
<th>Log</th>
|
||||
</tr>
|
||||
@@ -0,0 +1,27 @@
|
||||
<header>
|
||||
<div>
|
||||
<span>Telnet Log</span>
|
||||
</div>
|
||||
</header>
|
||||
<aside>
|
||||
{{ options_toggle }}
|
||||
</aside>
|
||||
<main>
|
||||
<table>
|
||||
<caption>
|
||||
<span class="log_line">standard message</span>
|
||||
<span class="game_chat">player chat</span>
|
||||
<span class="player_logged">login / logout</span>
|
||||
<span class="bot_command">bot command</span>
|
||||
</caption>
|
||||
<thead>
|
||||
{{ table_header }}
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>{{ log_lines }}</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{ table_footer }}
|
||||
</tfoot>
|
||||
</table>
|
||||
</main>
|
||||
@@ -0,0 +1,27 @@
|
||||
<header>
|
||||
<div>
|
||||
<span>Telnet Log</span>
|
||||
</div>
|
||||
</header>
|
||||
<aside>
|
||||
{{ options_toggle }}
|
||||
</aside>
|
||||
<main>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Telnet Log Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th colspan="2"><span>widget-options</span></th>
|
||||
</tr>
|
||||
{% for key, value in widget_options.items() %}
|
||||
<tr>
|
||||
<td><span>{{key}}</span></td><td>{{value}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
@@ -0,0 +1,22 @@
|
||||
<header>
|
||||
<div>
|
||||
<span>Telnet Log</span>
|
||||
</div>
|
||||
</header>
|
||||
<aside>
|
||||
{{ options_toggle }}
|
||||
</aside>
|
||||
<main>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Test View</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"><span>Test</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
Reference in New Issue
Block a user