[Jifty-commit] r530 - jifty/trunk/lib/Jifty/Mason
jifty/trunk/share/web/static/css jifty/trunk/share/web/static/js
jifty/trunk/share/web/templates/_elements
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jan 28 13:40:59 EST 2006
Author: jesse
Date: Sat Jan 28 13:40:59 2006
New Revision: 530
Added:
jifty/trunk/lib/Jifty/Mason/
jifty/trunk/lib/Jifty/Mason/Halo.pm
jifty/trunk/share/web/static/css/halos.css
jifty/trunk/share/web/static/js/halo.js
Modified:
/ (props changed)
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/share/web/static/css/main.css
jifty/trunk/share/web/templates/_elements/javascript
jifty/trunk/share/web/templates/_elements/wrapper
Log:
r23010 at truegrounds: jesse | 2006-01-28 19:30:06 +0100
* First pass at halos.
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sat Jan 28 13:40:59 2006
@@ -63,7 +63,7 @@
error_format => 'text',
default_escape_flags => 'h',
autoflush => 0,
- # plugins => ['Jifty::SetupRequest']
+ plugins => ['Jifty::Mason::Halo']
);
}
Added: jifty/trunk/lib/Jifty/Mason/Halo.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Mason/Halo.pm Sat Jan 28 13:40:59 2006
@@ -0,0 +1,81 @@
+use warnings;
+use strict;
+package Jifty::Mason::Halo;
+use base qw/HTML::Mason::Plugin/;
+use Time::HiRes ();
+
+
+sub start_component_hook {
+ my $self = shift;
+ my $context = shift;
+
+ my $STACK = $context->request->notes('_halo_stack') || $context->request->notes('_halo_stack' => []);
+ my $halo_base = Jifty->web->serial;
+ if ($self->_proscribed_component($context)) {
+ push @$STACK, { id => $halo_base, start_time => Time::HiRes::time(), proscribed => 1 };
+ return;
+ } else {
+ push @$STACK, { id => $halo_base, start_time => Time::HiRes::time(), proscribed => 0 };
+ }
+
+
+ $context->request->out('<span class="halo">');
+ $context->request->out(qq{<span class="halo_button" id="halo-@{[$halo_base]}" onClick="halo_toggle(this)"><img src="/images/halo.png" alt="O"/></span>
+});
+}
+
+sub end_component_hook {
+ my $self = shift;
+ my $context = shift;
+
+ my $STACK = $context->request->notes('_halo_stack');
+ my $frame = pop @$STACK;
+ return if $self->_proscribed_component($context);
+
+ $self->render_halo_actions($context, $frame);
+ $context->request->out('</span>') unless ($frame->{'proscribed'});
+
+}
+
+sub render_halo_actions {
+ my $self = shift;
+ my $context = shift;
+ my $stack_frame = shift;
+ my $comp = $context->comp();
+ my $args = $context->args;
+
+ $context->request->out(
+ qq{
+<div class="halo_actions" id="halo-@{[$stack_frame->{'id'}]}-menu">
+<span class="halo_path">@{[$comp->name]}</span>
+<dl>
+<dt>Render time</dt>
+<dd>@{[int((Time::HiRes::time - $stack_frame->{'start_time'}) * 1000)/1000]}</dd>
+<dt>});
+# XXX TODO: we shouldn't be doing direct rendering of this if we can avoid it.
+# but it would require a rework of how the render_xxx subs work in jifty core
+$context->request->out(Jifty->web->tangent( url =>"/=/edit/mason_component/@{[$comp->path]}", label => 'Edit'));
+
+$context->request->out(qq{</dt>
+<dt>Variables</dt>
+<dd>@{[YAML::Dump($args)]}</dd>
+
+</dl>
+</div>
+})
+}
+
+sub _proscribed_component {
+ my $self = shift;
+ my $context = shift;
+ if ( $context->comp->is_subcomp()
+ or $context->comp->name =~ /^(?:autohandler|dhandler)$/
+ or not $context->request->notes('in_body'))
+ {
+ return 1;
+ } else {
+ return undef;
+ }
+
+}
+1;
Added: jifty/trunk/share/web/static/css/halos.css
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/static/css/halos.css Sat Jan 28 13:40:59 2006
@@ -0,0 +1,30 @@
+
+div.halo_actions {
+display: none;
+float: left;
+//border: solid 1px black;
+//margin: 1em;
+//padding: 0;
+position: absolute;
+}
+
+div.halo_actions dl {
+ background: #ccc;
+ list-style-type: none;
+ border: yellow 2px solid;
+
+ margin: 0em;
+ padding: 0.5em;
+
+}
+
+div.halo_actions dl a {
+ color: black;
+}
+
+span.halo_button {
+color: yellow;
+position: fixed;
+z-index: 9999;
+font-size:2em;
+}
Modified: jifty/trunk/share/web/static/css/main.css
==============================================================================
--- jifty/trunk/share/web/static/css/main.css (original)
+++ jifty/trunk/share/web/static/css/main.css Sat Jan 28 13:40:59 2006
@@ -5,4 +5,5 @@
@import "combobox.css";
@import "keybindings.css";
@import "forms.css";
+ at import "halos.css";
@import "app.css";
Added: jifty/trunk/share/web/static/js/halo.js
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/static/js/halo.js Sat Jan 28 13:40:59 2006
@@ -0,0 +1,10 @@
+function halo_toggle (toggler) {
+var e = document.getElementById(toggler.id+'-menu');
+if (e.style.display !="block" ) {
+ e.style.display="block";
+} else {
+ e.style.display="none";
+}
+
+
+}
Modified: jifty/trunk/share/web/templates/_elements/javascript
==============================================================================
--- jifty/trunk/share/web/templates/_elements/javascript (original)
+++ jifty/trunk/share/web/templates/_elements/javascript Sat Jan 28 13:40:59 2006
@@ -3,6 +3,7 @@
<script type="text/javascript" src="/js/behaviour.js"></script>
<script type="text/javascript" src="/js/scriptaculous/scriptaculous.js"></script>
<script type="text/javascript" src="/js/jifty.js"></script>
+ <script type="text/javascript" src="/js/halo.js"></script>
<script type="text/javascript" src="/js/combobox.js"></script>
<script type="text/javascript" src="/js/key_bindings.js"></script>
<script type="text/javascript" src="/js/bps_util.js"></script>
Modified: jifty/trunk/share/web/templates/_elements/wrapper
==============================================================================
--- jifty/trunk/share/web/templates/_elements/wrapper (original)
+++ jifty/trunk/share/web/templates/_elements/wrapper Sat Jan 28 13:40:59 2006
@@ -1,4 +1,3 @@
-<& header, title => $title &>
<body>
<div id="headers">
<%Jifty->web->link( url => "/", label => Jifty->config->framework('ApplicationName'))%>
@@ -11,21 +10,24 @@
<div class="warning admin_mode">
Alert: Jifty <% Jifty->web->tangent( label => 'administration mode' , url => '/__jifty/admin/')%> is enabled.
</div>
-
% }
- <% Jifty->web->render_messages %>
- <% $m->content |n%>
- <div id="keybindings">
- <script><!--
- writeKeyBindingLegend();
- --></script>
- </div>
- </div>
- <div id="jifty-wait-message" style="display: none">Loading...</div>
+ <% Jifty->web->render_messages %>
+ <% $m->content |n%>
+ <script language="javascript"><!--
+ document.write('<div id="keybindings">');
+ writeKeyBindingLegend();
+ document.write('</div>');
+ document.write('<div id="jifty-wait-message" style="display: none">Loading...</div>');
+ --></script>
</body>
</html>
<%args>
$title => ""
</%args>
<%init>
+# First we set up the header.
+$m->comp( 'header', title => $title);
+# now that we've printed out the header, we're inside the body, so it's safe to print
+# halo markers.
+$m->notes('in_body' => 1);
</%init>
More information about the Jifty-commit
mailing list