1. Olemis Lang
  2. bloodhound-trac

Source

bloodhound-trac / trac / wiki / templates / wiki_edit.html

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n">
  <xi:include href="layout.html" />

  <!--! Note: the wiki edit page can be presented according to several modes:

        - "standard" or "side  by side" edit mode (`sidebyside` is true in the second mode)
          In standard mode, the edit area is on top of the preview, in side by side mode
          there are next to each other.

        - "edit" or "edit+preview" mode (`action == 'preview'` is true in the second mode)
          In edit mode, only the textarea is visible, but not the preview.
          In sidebyside mode, we always have a preview.
          In this category, we also have the "collision mode" (`action == 'collision'`),
          which happens when a concurrent edit has been detected.

        - "wiki preview" or "diff preview" (`diff` is true in the second mode)
          When the preview is shown, it can be either an actual preview of the rendered wiki
          text, or it can be a diff view on the changes that have been made (a.k.a. "review mode").
          In the latter case, `changes[0].diffs` contains the data for the diffs, if any.
          See `preview_or_review` below.
    -->
  <head>
    <title>$title</title>
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#text").blur(function() {
          $("#scroll_bar_pos").val(this.scrollTop);
        }).get(0).scrollTop = $("#scroll_bar_pos").val();
        $("#editrows").change(function() {
          resizeTextArea("text", this.options[this.selectedIndex].value);
        });
        $("#sidebyside").change(function() {
          $("#edit input[type=submit][name=preview]").click();
        });
        <py:if test="not sidebyside and (action == 'preview' or diff)">
          $("#info").scrollToTop();
        </py:if>
        <py:if test="sidebyside">/*<![CDATA[*/
          function editorHeight() {
            return $("#text").closest("fieldset").innerHeight();
          }
          function previewHeight() {
            return $("#preview").innerHeight();
          }
          var preview_pad = previewHeight() - $("#preview").height();
          var editor_pad = editorHeight() - $("#text").height();
          function autoResizeText() {
            $("#preview").height(0); // neutralize preview
            $("#text").height("auto"); // adapt textarea to its content
            var text_height = $("#text").prop("scrollHeight");
            var wikipage_height = $("#preview div.wikipage").height();
            if (wikipage_height > text_height) {
              // expand #text to its natural height and adapt #preview to it
              $("#text").height(text_height).css("overflow-y", "hidden");
              $("#preview").height(Math.max(16, editorHeight() - preview_pad));
            } else {
              // expand .wikipage to its natural height and adapt #text to it
              $("#preview").height("auto");
              $("#text").height(Math.max(16, previewHeight() - editor_pad))
                .css("overflow-y", "auto");
            }
          }
          autoResizeText();
          $(window).resize(autoResizeText);
        /*]]>*/</py:if>
        <py:if test="sidebyside and not diff">
          $("#text").autoPreview("${href.wiki_render()}", {
              realm: "${page.resource.realm}", id: "${page.resource.id}"
            }, function(textarea, text, rendered) {
              var window_scroll_top = $(window).scrollTop();
              var editor_scroll_top = $("#text").scrollTop();
              $("#preview div.wikipage").html(rendered);
              autoResizeText();
              $(window).scrollTop(window_scroll_top);
              $("#text").scrollTop(editor_scroll_top);
          });
        </py:if>
        $(".foldable").enableFolding(true, true);
      });
    </script>
  </head>

  <body>
    <div id="content" class="wiki"
         py:with="preview_or_review = action == 'preview' and (not diff or changes[0].diffs)">
      <div class="trac-topnav" py:if="not sidebyside and preview_or_review" py:choose="">
        <a py:when="diff" href="#info" title="See the diffs">Review</a>
        <a py:otherwise="" href="#info" title="See the preview">Preview</a>
        &darr;
      </div>
      <h1 i18n:msg="name">Editing ${name_of(page.resource)}</h1>
      <div py:if="merge" class="system-message">
        <p>Someone else has modified that page since you started your edits.</p><br />
        <p i18n:msg=""><b>If you save right away, you risk to revert those changes</b>
        (highlighted below as deletions).</p><br />
        <p i18n:msg="">Please review all those changes and manually merge them with your
        own changes. <br />
        If you're unsure about what you're doing, please press <tt>Cancel</tt>
        (losing your changes) and start editing the latest version of the page
        again.</p>
      </div>

      <!--!

      Normal preview mode, edit form followed by preview:

       | [xi:include "wiki_edit_form.html"                  ]
       |
       | == Preview ==
       |
       | [.Revision #info...................................]
       |
       | [.....#preview.....................................]


      Side-by-side edit/preview mode:

       | [.Revision #info...................................]
       |
       | == Preview ==
       |                               [......#preview......]
       | [xi:include "wiki_edit_form.html"]

      (the  #preview will float at the right of the edit form's textarea)

      -->
      <py:if test="not sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
      <py:choose test="action">
        <py:when test="'preview'">
          <table id="info" summary="Revision info">
            <tbody>
              <tr><th scope="col" i18n:msg="version, author">
                Change information for future version ${page.version+1} (modified by $author):
              </th></tr>
              <tr><td class="message" xml:space="preserve">
                ${wiki_to_html(context.child(page.resource(version=None)), comment)}
              </td></tr>
            </tbody>
          </table>
          <div class="${sidebyside and 'sidebyside preview-right'}" py:choose="">
            <div class="trac-nav" py:if="not sidebyside and preview_or_review">
              <a href="#content" title="Go to the editor">Edit</a> &uarr;
            </div>
            <h2 py:if="not sidebyside" py:choose="">
              <py:when test="preview_or_review and diff">Review Changes</py:when>
              <py:when test="preview_or_review">Preview</py:when>
              <py:otherwise>No changes</py:otherwise>
            </h2>
            <div id="preview" class="trac-content">
              <div py:when="diff" class="diff">
                <xi:include href="diff_div.html" py:with="no_id=True" />
              </div>
              <div py:otherwise="" class="wikipage" xml:space="preserve">
                ${wiki_to_html(context.child(page.resource), page.text)}
              </div>
            </div>
            <div py:if="not sidebyside and page.text" class="trac-nav">
              <a href="#changeinfo"
                title="Go to Save, Preview, Review or Cancel buttons">Actions</a> &uarr;
            </div>
          </div>
        </py:when>
        <py:when test="'collision'">
          <div class="system-message">
            Sorry, this page has been modified by somebody else since you started
            editing. Your changes cannot be saved.
          </div>
        </py:when>
      </py:choose>
      <py:if test="sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>

      <xi:include href="list_of_attachments.html"
                  py:with="alist = attachments; compact = True; foldable = True"/>
    </div>
  </body>
</html>