<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/diazo"
       xmlns:css="http://namespaces.plone.org/diazo/css"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<!-- GENERIC RULES WHICH APPLY ALWAYS -->
  <replace content='/html/head/title' theme='/html/head/title' />
  <append content='/html/head/base' theme='/html/head' />

  <drop theme="/html/head/meta[@name='viewport']" />
  <copy theme="/html/head" content="/html/head/meta" />
  <!-- remove the script and style from the prototype… -->
  <drop theme="/html/head/script" />
  <drop theme="/html/head/link" />
  <!-- … and deliver the one from plone resource registries -->
  <after theme-children="/html/head" content="/html/head/link | /html/head/style" />
  <after theme-children="/html/head" content="/html/head/script" />

  <!-- Add the globalstatusmessage viewlet. -->
  <append css:theme="body" css:content="#global-statusmessage" />
  <append css:theme="body" css:content-children="#webstats_js" />

  <!-- Copy over the id/class attributes on the body tag, this is
       important for Kupu and per-section styling -->
  <merge attributes="class" css:content="body" css:theme="body" />
  <copy attributes="id dir data-base-url data-pat-pickadate data-portal-url data-pat-tinymce data-pat-plone-modal data-i18ncatalogurl"
        css:content="body" css:theme="body" />

  <!-- Logo -->
  <replace css:content="#site-logo" css:theme="#site-logo" />

  <!-- insert the breadcrumbs into the header bar -->
  <replace css:content-children="#breadcrumbs"
           css:theme-children="nav.breadcrumbs" />

  <replace css:content="#notification-link"
           css:theme="#notification-link" />
  <before css:content="#root-zope-user-warning"
           css:theme="#user-avatar" />

  <!-- drop from theme elements that should not be visible to anonymous -->
  <rules css:if-content=".userrole-anonymous">
    <drop css:theme="#hamburger" />
    <drop css:theme="nav.tabs.navigation" />
  </rules>

  <!-- Portal Personal Tools -->
  <replace css:content-children="#portal-personaltools-wrapper"
           css:theme="#user-avatar" />

  <!-- adaptation of the global-nav -->
  <replace css:theme-children="nav.tabs.navigation.portal-tabs"
           css:content-children="#portal-globalnav li" />

  <drop css:theme="#buddies-toggle"
        css:if-not-content="#buddies-toggle" />

  <drop css:theme="#global-header #messages-link" />
  <drop css:theme="#global-header #osh-toggle" />

  <replace css:content="#buddies-toggle"
           css:theme="#buddies-toggle" />

  <replace css:content="#global-nav-search"
           css:theme="#global-nav-search" />


  <!-- Login Form -->
  <rules css:if-content="body.template-insufficient_privileges">
    <theme href="generated/unauthorised.html" />
    <replace css:content-children="#content .documentFirstHeading"
             css:theme-children="#document-content .error-unauthorised > h1"
      />
    <replace css:content-children="#content .documentDescription"
             css:theme-children="#document-content .error-unauthorised > p"
      />
  </rules>

  <rules css:if-content="body.template-login_form, body.template-logged_out, body.template-login_failed">
    <theme href="generated/index.html" />
    <copy attributes="method action" css:content="form#login_form" css:theme="form#login-panel" />
    <append css:theme="form fieldset.vertical" css:content="#login-form input[type='hidden']" />
    <replace css:theme-children="figure.splash">
        <img src="++theme++ploneintranet.theme/generated/media/logos/plone-intranet-square-dp.svg" />
    </replace>
    <replace css:theme=".colofon">
  		<p class="colofon">
  			<a href="++theme++ploneintranet.theme/generated/info.html">About this environment</a>
  		</p>

    </replace>
  </rules>

  <rules css:if-content="body.portaltype-event,
                         body.portaltype-ploneintranet-workspace-workspacefolder.template-view,
                         body.portaltype-ploneintranet-workspace-case.template-view,
                         body.app-workspace.portaltype-document,
                         body.app-workspace.portaltype-file,
                         body.app-workspace.portaltype-image,
                         body.app-workspace.portaltype-folder">
                         <theme href="generated/empty-workspace.html" />
    <!-- Main content rule: Put plone content into theme content -->
    <replace css:content-children="#portal-column-content" css:theme="#content" />
  </rules>

  <rules css:if-content="body.template-case-manager">
    <theme href="generated/apps/case-manager/index.html" />
    <!-- Main content rule: Put plone content into theme content -->
    <replace css:content-children="#portal-column-content" css:theme="#content" />
  </rules>

  <rules css:if-content="body.portaltype-todo">
      <theme href="generated/basisdaten/index.html" />
    <!-- Main content rule: Put plone content into theme content -->
    <replace css:content-children="#portal-column-content" css:theme="#content" />
  </rules>

  <rules css:if-content=".template-app-audit-log">
    <theme href="generated/apps/audit/index.html" />
    <replace css:content="#application-body"
             css:theme="#application-body"
             />
  </rules>

  <rules css:if-content="body.template-dashboard-html,
                         body.template-tagstream,
                         body.template-apps-html,
                         body.template-workspaces-html">
    <theme href="generated/empty-home.html" />
    <append css:content-children="#portal-column-content" css:theme="div.container" />
  </rules>

  <!-- this catches typical plone info pages -->
  <rules css:if-content="body.template-login_success,
                         body.template-insufficient_privileges">
    <theme href="generated/empty-home.html" />
    <append css:content-children="#content" css:theme="div.container" />
  </rules>

  <!-- XXX Do we really need that explicitly? -->
  <rules css:if-content="body.template-todo">
    <theme href="generated/panel-create-task.html" />
    <drop css:theme-children=".panel-body" />
    <append css:content-children="#content" css:theme=".panel-body" />
  </rules>

  <rules css:if-content="body.template-userprofile-view,
                         body.template-edit.portaltype-ploneintranet-userprofile-userprofile">
    <theme href="generated/liz-baker.html" />
    <drop css:theme-children="#person-timeline aside" />
    <drop css:theme-children="#person-timeline div.columns" />
    <append css:content-children="#portal-column-content aside" css:theme="aside" />
    <append css:content-children="#portal-column-content #main" css:theme="div.columns" />
  </rules>

  <rules css:if-content="body.template-notifications">
    <theme href="generated/notifications.html" />
    <drop css:theme-children="div.container" />
    <append css:content-children="#portal-column-content" css:theme="div.container" />
  </rules>

  <rules css:if-content="body.template-search,
                         body.template-search_images,
                         body.template-search_people,
                         body.template-search_files,
                         body.template-search_videos">
    <theme href="generated/search-results.html" />
    <drop css:theme-children="#content" />
    <append css:content-children="#portal-column-content" css:theme="#content" />
  </rules>

  <rules css:if-content="body.portaltype-ploneintranet-library-app,
                         body.portaltype-ploneintranet-library-section,
                         body.portaltype-ploneintranet-library-folder">
    <theme href="generated/library.html" />
    <replace css:theme="#content .container"
             css:content="#portal-column-content .container"/>
    <!-- hide tags for now -->
    <drop css:content="#viewlet-below-content #category" />
  </rules>
  <rules css:if-content="body.app-library.portaltype-document,
                         body.app-library.portaltype-news-item,
                         body.app-library.portaltype-link
                         body.app-library.portaltype-image,
                         body.app-library.portaltype-file">
    <theme href="generated/synode/index.html" />
    <replace css:theme="#content .container"
             css:content="#portal-column-content .container"/>
    <!-- hide tags for now -->
    <drop css:content="#viewlet-below-content #category" />
  </rules>

  <rules css:if-content="body.template-default_error_message">
    <theme href="generated/404.html" />
    <replace css:content-children="#content" css:theme-children="article.error-page" />
  </rules>

  <!-- if there is a visual-portal-wrapper -->
  <theme href="generated/empty.html"
         css:if-content="#visual-portal-wrapper" />
  <replace css:content-children="#content"
           css:theme-children="#original-content"
           css:if-content="#visual-portal-wrapper" />



  <notheme css:if-content="body.diazo.off"/>

  <!-- These rules are only needed
       until these functionalities are complete -->
  <drop css:theme="header #buddies-toggle" />
</rules>
