<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>
    <%- if @page and (@page.name == 'HomePage') and (%w( show published print ).include?(params['action'])) -%>
      <%= h(@web.name) + (@show_diff ? ' (changes)' : '') %>
    <%- elsif @web -%>
      <%= @title %> in <%= h @web.name %>
    <%- else -%>
      <%= @title %>
    <%- end -%>
  </title>

  <meta charset="UTF-8" />
  <meta name="robots" content="<%= @robots_metatag_value %>" />
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  
 
  <%= stylesheet_link_tag 'instiki', :media => 'all'  unless @inline_style %>
  <%= stylesheet_link_tag 'syntax', :media => 'all'  unless @inline_style %>
  <style type="text/css">
    h1#pageName, div.info, .newWikiWord a, a.existingWikiWord, .newWikiWord a:hover, [actiontype="toggle"]:hover, #TextileHelp h3 { 
      color: #<%= @web ? @web.color : "393" %>; 
    }
    a:visited.existingWikiWord {
      color: #<%= darken(@web ? @web.color : "393") %>;
    }
    <%= Rails.root.join('public', 'stylesheets', 'instiki.css').read if @inline_style %>
    <%= Rails.root.join('public', 'stylesheets', 'syntax.css').read if @inline_style %>
  </style>
  <%= "<style type='text/css'>#{@style_additions}</style>".html_safe if @style_additions %>
  <style type="text/css"><!--/*--><![CDATA[/*><!--*/    
    <%= @web && @web.additional_style ? @web.additional_style.html_safe : '' %>
  /*]]>*/--></style>
  <%= javascript_include_tag :defaults %>
  <%= javascript_include_tag 'page_helper' %>
  <%= csrf_meta_tag %>
  <%- if @web -%>
   <%- if @web.markup == :markdownMML -%>
  <script type="text/x-mathjax-config">
  <!--//--><![CDATA[//><!--
    MathJax.Ajax.config.path["Contrib"] = "<%= compute_public_path('', 'MathJax').split('/?')[0] %>";
    MathJax.Hub.Config({
      MathML: { useMathMLspacing: true },
      "HTML-CSS": { scale: 90,
                    noReflows: false,
                    extensions: ["handle-floats.js"]
       }
    });
    MathJax.Hub.Queue( function () {
       var fos = document.getElementsByTagName('foreignObject');
       for (var i = 0; i < fos.length; i++) {
         MathJax.Hub.Typeset(fos[i]);
       }
    });
  //--><!]]>
  </script>

    <script type="text/javascript">
      <!--//--><![CDATA[//><!--
      window.addEventListener("DOMContentLoaded", function () {
        var div = document.createElement('div');
        var math = document.createElementNS('http://www.w3.org/1998/Math/MathML', 'math');
        document.body.appendChild(div);
        div.appendChild(math);
      // Test for MathML support comparable to WebKit version https://trac.webkit.org/changeset/203640 or higher.
        div.setAttribute('style', 'font-style: italic');
        var mathml_unsupported = !(window.getComputedStyle(div.firstChild).getPropertyValue('font-style') === 'normal');
        div.parentNode.removeChild(div);
        if (mathml_unsupported) {
          // MathML does not seem to be supported...
          var s = document.createElement('script');
          s.src = "<%= compute_public_path('MathJax.js', 'MathJax').split('?')[0] %>?config=MML_HTMLorMML";
          document.querySelector('head').appendChild(s);
        } else {
          document.head.insertAdjacentHTML("beforeend", '<style>svg[viewBox] {max-width: 100%}</style>');
        }
      });
      //--><!]]>
    </script>

   <%- end -%>
  	<%= auto_discovery_link_tag(:atom, {:controller => 'wiki', :web => @web.address, :action => 'atom_with_headlines'},
  	      :title => 'Atom with headlines') %>
  	<%= auto_discovery_link_tag(:atom, {:controller => 'wiki', :web => @web.address, :action => 'atom_with_content'},
  	      :title => 'Atom with full content') %>
  <%- end -%>
</head>

<body xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://svg-edit.googlecode.com">

<div id="Container">
<div id="Content">
  <h1 id="pageName">
    <%= render(:file => 'svg_logo') if xhtml_enabled? %>
    <%- if @page and (@page.name == 'HomePage') and %w( show published print ).include?(@action_name) -%>
      <%= h(@web.name) + (@show_diff ? ' (changes)' : '') %>
    <%- elsif @web -%>
      <span class="webName"><%= @web.name %></span><br />
      <%= @title %>
    <%- else -%>
      <%= @title %>
    <%- end %>
  </h1>

<%= render(:file => 'navigation') unless @web.nil? || @hide_navigation %>

<%- if flash[:info] -%>
  <div class="info"><%= escape_preserving_linefeeds flash[:info] %></div>
<%- end -%>

<%- if @error or flash[:error] -%> 
    <div class="errorExplanation"><%= escape_preserving_linefeeds(@error || flash[:error]) %></div>
<%- end -%>

<%= @content_for_layout %>

<%- if @show_footer -%>
    <div id="footer">
    <div>This site is running on <a href="http://golem.ph.utexas.edu/instiki/show/HomePage">Instiki <%= "#{Instiki::VERSION::STRING}" %></a></div>
    <div>Powered by <a href="http://rubyonrails.com/">Ruby on Rails</a>  <%= "#{Rails::VERSION::STRING}" %></div>
    </div>
<%- end -%>

</div> <!-- Content -->

</div> <!-- Container -->

</body>
</html>
