Toggle for the static doc sidebar?

1 vue
Accéder directement au premier message non lu

Pat LeSmithe

non lue,
9 avr. 2009, 08:32:1509/04/2009
à sage-...@googlegroups.com

Please see the attached snapshots. The top and bottom bars also have a
search box and source link.

If there's interest, I can try to get the toggle working in live
documentation. I'd greatly appreciate a critique of the JavaScript code
for the toggle, as I'm not sure it always cooperates with jsMath.

To try this out, backup and replace

SAGE_ROOT/devel/sage/doc/common/templates/layout.html

with the attached layout.html. Most of the new version is just Sphinx's
default, which I found in SAGE_ROOT/local/blah/wherever. I couldn't
figure out how to override a macro. Anyway, then do something like

SAGE_ROOT/sage -docbuild tutorial html --jsmath

To display the favicon and logo, I downloaded

http://www.sagemath.org/pix/sageicon.png

to

SAGE_ROOT/devel/sage/doc/common/static

and inside the latter, I did

ln -s ../../../../../data/extcode/notebook/images/sagelogo.png .

(The original layout.html looks for sage_logo.png.) Thanks!

toggle1.png
toggle2.png
layout.html

William Stein

non lue,
9 avr. 2009, 13:00:2409/04/2009
à sage-...@googlegroups.com
On Thu, Apr 9, 2009 at 5:32 AM, Pat LeSmithe <qed...@gmail.com> wrote:
>
> Please see the attached snapshots.  The top and bottom bars also have a
> search box and source link.
>
> If there's interest, I can try to get the toggle working in live
> documentation.  I'd greatly appreciate a critique of the JavaScript code
> for the toggle, as I'm not sure it always cooperates with jsMath.

That looks very nice to me!

William

>
> To try this out, backup and replace
>
> SAGE_ROOT/devel/sage/doc/common/templates/layout.html
>
> with the attached layout.html.  Most of the new version is just Sphinx's
> default, which I found in SAGE_ROOT/local/blah/wherever.  I couldn't
> figure out how to override a macro.  Anyway, then do something like
>
> SAGE_ROOT/sage -docbuild tutorial html --jsmath
>
> To display the favicon and logo, I downloaded
>
> http://www.sagemath.org/pix/sageicon.png
>
> to
>
> SAGE_ROOT/devel/sage/doc/common/static
>
> and inside the latter, I did
>
> ln -s ../../../../../data/extcode/notebook/images/sagelogo.png .
>
> (The original layout.html looks for sage_logo.png.)  Thanks!
>
>
> >
>
> {%- block doctype -%} {%- endblock %} {%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} {%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} {%- macro relbar %}
>
> {{ _('Navigation') }}
>
> {%- if pagename != "search" %}
> {%- endif %} {%- for rellink in rellinks %}
> {{ rellink[3] }} {%- if not loop.first %}{{ reldelim2 }}{% endif %}
> {%- endfor %} {%- if pagename != "search" %} {%- if builder == 'html' %}
> source{{ reldelim2 }}
> {%- endif %} {%- endif %}
> toggle{{ reldelim2 }}
> {%- block rootrellink %}
> {{ shorttitle|e }}{{ reldelim1 }}
> {%- endblock %} {%- for parent in parents %}
> {{ parent.title }}{{ reldelim1 }}
> {%- endfor %} {%- block relbaritems %} {% endblock %}
>
> {%- endmacro %} {%- macro sidebar %} {%- if builder != 'htmlhelp' %}
> {%- block sidebarlogo %} {%- if logo %}
>
> {%- endif %} {%- endblock %} {%- block sidebartoc %} {%- if display_toc %}
>
> {{ _('Table Of Contents') }}
>
> {{ toc }} {%- endif %} {%- endblock %} {%- block sidebarrel %} {%- if prev %}
>
> {{ _('Previous topic') }}
>
> {{ prev.title }}
>
> {%- endif %} {%- if next %}
>
> {{ _('Next topic') }}
>
> {{ next.title }}
>
> {%- endif %} {%- endblock %} {%- if sourcename %}
>
> {{ _('This Page') }}
>
> {%- if builder == 'web' %}
> Comments ({{ comments|length }} so far)
> {{ _('Suggest Change') }}
> {{ _('Show Source') }}
> {%- elif builder == 'html' %}
> {{ _('Show Source') }}
> {%- endif %}
>
> {%- endif %} {%- if customsidebar %} {{ rendertemplate(customsidebar) }} {%- endif %} {%- block sidebarsearch %} {%- if pagename != "search" %}
>
> {% if builder == 'web' %}{{ _('Keyword search')}}{% else %}{{ _('Quick search') }}{% endif %}
>
> {%- if builder == 'web' %}
>
> {{ _('Enter a module, class or function name.') }}
>
> {%- endif %} {%- endif %} {%- endblock %}
> {%- endif %} {%- endmacro -%} {{ metatags }} {%- if builder != 'htmlhelp' %} {%- set titlesuffix = " — " + docstitle|e %} {%- endif %} {%- if builder == 'web' %} {%- for link, type, title in page_links %} {%- endfor %} {%- else %} {%- endif %} {%- if builder != 'htmlhelp' %} {%- for scriptfile in script_files %} {%- endfor %} {%- if use_opensearch %} {%- endif %} {%- if favicon %} {%- endif %} {%- endif %} {%- block linktags %} {%- if hasdoc('about') %} {%- endif %} {%- if hasdoc('copyright') %} {%- endif %} {%- if parents %} {%- endif %} {%- if next %} {%- endif %} {%- if prev %} {%- endif %} {%- endblock %} {% block extrahead %} {% endblock %}
> {%- block relbar1 %}{{ relbar() }}{% endblock %} {%- block sidebar1 %} {# possible location for sidebar #} {% endblock %} {%- block document %}
> {%- if builder != 'htmlhelp' %}
> {%- endif %}
> {% block body %} {% endblock %}
> {%- if builder != 'htmlhelp' %}
> {%- endif %}
> {%- endblock %} {%- block sidebar2 %}{{ sidebar() }}{% endblock %}
> {%- block relbar2 %}{{ relbar() }}{% endblock %} {%- block footer %}
> {%- if hasdoc('copyright') %} {% trans path=pathto('copyright'), copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %} {%- else %} {% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %} {%- endif %} {%- if last_updated %} {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %} {%- endif %} {%- if show_sphinx %} {% trans sphinx_version=sphinx_version|e %}Created using Sphinx {{ sphinx_version }}.{% endtrans %} {%- endif %}
> {%- endblock %}
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Pat LeSmithe

non lue,
12 avr. 2009, 12:27:5912/04/2009
à sage-...@googlegroups.com
William Stein wrote:
> On Thu, Apr 9, 2009 at 5:32 AM, Pat LeSmithe <qed...@gmail.com> wrote:
>> Please see the attached snapshots. The top and bottom bars also have a
>> search box and source link.
>>
>> If there's interest, I can try to get the toggle working in live
>> documentation. I'd greatly appreciate a critique of the JavaScript code
>> for the toggle, as I'm not sure it always cooperates with jsMath.
>
> That looks very nice to me!

The following patch seems to fix the toggle in the live documentation.
Should double-clicking on a live doc text cell bring up TinyMCE?

--- a/sage/server/notebook/twist.py Sun Apr 05 16:50:38 2009 -0700
+++ b/sage/server/notebook/twist.py Sun Apr 12 09:16:33 2009 -0700
@@ -170,6 +170,18 @@
cells = W.cell_list()
cells.pop()

+ # The first cell, if it's a text cell, may contain useful
+ # JavaScript code. For example, the sidebar toggle uses
+ # jQuery's $() to change a few CSS attributes. When the cell
+ # is rendered as HTML, however, sage.misc.html.math_parse()
+ # converts $ pairs to <span class='math'> elements. This
+ # breaks the toggle. We use a simple test to check for and
+ # escape the $'s.
+ c = cells[0]
+ c_text = c.plain_text()
+ if not c.is_interactive_cell() and '$(' in c_text and '.css('
in c_text:
+ c.set_input_text(c_text.replace('$(','\$('))
+
s = notebook.html(worksheet_filename = W.filename(),
username = self.username)

Jason Grout

non lue,
13 avr. 2009, 10:33:0013/04/2009
à sage-...@googlegroups.com
Pat LeSmithe wrote:
> William Stein wrote:
>> On Thu, Apr 9, 2009 at 5:32 AM, Pat LeSmithe <qed...@gmail.com> wrote:
>>> Please see the attached snapshots. The top and bottom bars also have a
>>> search box and source link.
>>>
>>> If there's interest, I can try to get the toggle working in live
>>> documentation. I'd greatly appreciate a critique of the JavaScript code
>>> for the toggle, as I'm not sure it always cooperates with jsMath.
>> That looks very nice to me!
>
> The following patch seems to fix the toggle in the live documentation.
> Should double-clicking on a live doc text cell bring up TinyMCE?


I think probably not. The docs are static, and no changes would be
saved to the files, so it seems deceiving to let someone edit the text.


Jason

--
Jason Grout

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message