[Jifty-commit] r532 - 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
Sun Jan 29 19:24:39 EST 2006
Author: jesse
Date: Sun Jan 29 19:24:38 2006
New Revision: 532
Modified:
/ (props changed)
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/lib/Jifty/Mason/Halo.pm
jifty/trunk/share/web/static/css/halos.css
jifty/trunk/share/web/static/js/bps_util.js
jifty/trunk/share/web/static/js/halo.js
jifty/trunk/share/web/templates/_elements/javascript
jifty/trunk/share/web/templates/_elements/wrapper
Log:
r23014 at truegrounds: jesse | 2006-01-30 01:21:39 +0100
* A lot more work on halos. The tool starts to feel useful.
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sun Jan 29 19:24:38 2006
@@ -63,7 +63,7 @@
error_format => 'text',
default_escape_flags => 'h',
autoflush => 0,
- #plugins => ['Jifty::Mason::Halo']
+ plugins => ['Jifty::Mason::Halo']
);
}
Modified: jifty/trunk/lib/Jifty/Mason/Halo.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Mason/Halo.pm (original)
+++ jifty/trunk/lib/Jifty/Mason/Halo.pm Sun Jan 29 19:24:38 2006
@@ -9,30 +9,60 @@
my $self = shift;
my $context = shift;
- my $STACK = $context->request->notes('_halo_stack') || $context->request->notes('_halo_stack' => []);
+ my $DEPTH = $context->request->notes('_halo_depth') || 0;
+ my $STACK = $context->request->notes('_halo_stack')
+ || $context->request->notes( '_halo_stack' => [] );
+ my $INDEX_STACK = $context->request->notes('_halo_index_stack')
+ || $context->request->notes( '_halo_index_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->notes('_halo_depth' => ++$DEPTH);
+
+ push @$STACK,
+ {
+ id => $halo_base,
+ start_time => Time::HiRes::time(),
+ path => $context->comp->path,
+ subcomponent => ( $context->comp->is_subcomp() ? 1:0),
+ name => $context->comp->name,
+ proscribed => ($self->_unrendered_component($context) ? 1 :0 ),
+ depth => $DEPTH
+ };
+
+ push @$INDEX_STACK, $#{@$STACK};
+ return if $self->_unrendered_component($context);
+
$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>
-});
+ $context->request->out(
+ qq{<span class="halo_button" id="halo-@{[$halo_base]}" onClick="toggle_display('halo-@{[$halo_base]}-menu')"><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);
+ my $INDEX_STACK = $context->request->notes('_halo_index_stack');
+ my $DEPTH = $context->request->notes('_halo_depth');
+
+ my $FRAME_ID = pop @$INDEX_STACK;
+ my $frame = $STACK->[$FRAME_ID];
+ $frame->{'render_time'} = int((Time::HiRes::time - $frame->{'start_time'}) * 1000)/1000;
+ $context->request->notes('_halo_depth' => $DEPTH-1 );
+
+ # If
+ return if $self->_unrendered_component($context);
+
+ # print out the div with our halo magic actions.
$self->render_halo_actions($context, $frame);
+ # if we didn't render a beginning of the span, don't render an end
$context->request->out('</span>') unless ($frame->{'proscribed'});
}
@@ -47,14 +77,16 @@
$context->request->out(
qq{
<div class="halo_actions" id="halo-@{[$stack_frame->{'id'}]}-menu">
-<span class="halo_path">@{[$comp->name]}</span>
+<span class="halo_name">@{[$comp->name]}</span>
<dl>
+<dt>Path</dt>
+<dt>@{[$comp->path]}</dd>
<dt>Render time</dt>
-<dd>@{[int((Time::HiRes::time - $stack_frame->{'start_time'}) * 1000)/1000]}</dd>
+<dd>@{[$stack_frame->{'render_time'}]}</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(Jifty->web->tangent( url =>"/=/edit/mason_component/".$comp->path, label => 'Edit'));
$context->request->out(qq{</dt>
<dt>Variables</dt>
@@ -65,11 +97,20 @@
})
}
-sub _proscribed_component {
+
+=head2 _unrendered_component CONTEXT
+
+Returns true if we're not currently inside the "Body" section of the
+webpage OR the current component is a subcomponent. (Rendering halos
+for subcomponents being too "heavy")
+
+=cut
+
+
+sub _unrendered_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;
@@ -78,4 +119,44 @@
}
}
+
+sub render_component_tree {
+ my $self = shift;
+ my @stack = @{ Jifty->web->mason->notes('_halo_stack') };
+
+ my $depth = 1;
+ Jifty->web->mason->out(q{<div id="render_info" onClick="toggle_display('render_info_tree')">Page info</div>});
+ Jifty->web->mason->out('<div id="render_info_tree">');
+ Jifty->web->mason->out('<ul>');
+
+ foreach my $item (@stack) {
+ if ( $item->{depth} > $depth ) {
+ Jifty->web->mason->out("<ul>");
+ } elsif ( $item->{depth} < $depth ) {
+ Jifty->web->mason->out("</ul>\n");
+ }
+
+ Jifty->web->mason->out( "<li>");
+
+ Jifty->web->mason->out(qq{<span class="halo_comp_info"} );
+
+ Jifty->web->mason->out(qq{onClick="toggle_display('halo-}.$item->{id}.qq{-menu');"});
+ Jifty->web->mason->out(qq{>}
+ . $item->{'path'} . " - "
+ . $item->{'render_time'}
+ . qq{</span>}
+ );
+
+ Jifty->web->mason->out(Jifty->web->tangent( url =>"/=/edit/mason_component/".$item->{'path'}, label => 'Edit'))
+ unless ($item->{subcomponent});
+ Jifty->web->mason->out( "</li>");
+ $depth = $item->{'depth'};
+ }
+
+ Jifty->web->mason->out('</ul>');
+ Jifty->web->mason->out('</div>');
+
+}
+
+
1;
Modified: jifty/trunk/share/web/static/css/halos.css
==============================================================================
--- jifty/trunk/share/web/static/css/halos.css (original)
+++ jifty/trunk/share/web/static/css/halos.css Sun Jan 29 19:24:38 2006
@@ -5,7 +5,7 @@
//border: solid 1px black;
//margin: 1em;
//padding: 0;
-position: absolute;
+position: fixed;
}
div.halo_actions dl {
@@ -24,7 +24,35 @@
span.halo_button {
color: yellow;
-position: fixed;
+position: absolute;
z-index: 9999;
font-size:2em;
}
+
+div#render_info_tree {
+ display: none;
+ position: fixed;
+ font-size: 0.5em;
+
+ border 1px solid yellow;
+
+ right: 1em;
+ bottom: 1.5em;
+
+border: 2px solid #fc0;
+padding: 1em;
+}
+
+div#render_info_tree ul {
+ list-style: none;
+ padding-left: 1em;
+}
+
+
+div#render_info {
+ position: fixed;
+right:0.5em;
+bottom:0;
+}
+
+
Modified: jifty/trunk/share/web/static/js/bps_util.js
==============================================================================
--- jifty/trunk/share/web/static/js/bps_util.js (original)
+++ jifty/trunk/share/web/static/js/bps_util.js Sun Jan 29 19:24:38 2006
@@ -83,7 +83,13 @@
}
}
-function jifty_button_click() {
+function toggle_display (id) {
+var e = document.getElementById(id);
+if (e.style.display !="block" ) {
+ e.style.display="block";
+} else {
+ e.style.display="none";
+}
+
-1;
}
Modified: jifty/trunk/share/web/static/js/halo.js
==============================================================================
--- jifty/trunk/share/web/static/js/halo.js (original)
+++ jifty/trunk/share/web/static/js/halo.js Sun Jan 29 19:24:38 2006
@@ -1,5 +1,5 @@
-function halo_toggle (toggler) {
-var e = document.getElementById(toggler.id+'-menu');
+function toggle_display (id) {
+var e = document.getElementById(id);
if (e.style.display !="block" ) {
e.style.display="block";
} else {
Modified: jifty/trunk/share/web/templates/_elements/javascript
==============================================================================
--- jifty/trunk/share/web/templates/_elements/javascript (original)
+++ jifty/trunk/share/web/templates/_elements/javascript Sun Jan 29 19:24:38 2006
@@ -3,7 +3,6 @@
<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 Sun Jan 29 19:24:38 2006
@@ -19,8 +19,10 @@
document.write('</div>');
document.write('<div id="jifty-wait-message" style="display: none">Loading...</div>');
--></script>
+% Jifty::Mason::Halo->render_component_tree();
</body>
</html>
+%$m->notes('in_body' => 0);
<%args>
$title => ""
</%args>
More information about the Jifty-commit
mailing list