view_page.rhtml 4.76 KB
<div id="article">

<%
  # AddThis Button
  if block_given? and File.exists?( RAILS_ROOT + '/config/web2.0.yml')
    opts = YAML.load_file( RAILS_ROOT + '/config/web2.0.yml' )
    if opts['addthis']
      opts = opts['addthis']
%>
<div id="addThis">
<script type="text/javascript">
  addthis_brand = '<%= escape_javascript( @environment.name ) %>';
<%=
  str = ''
  opts.each { |k, v|
    str += '  addthis_'+ k +' = "'+ escape_javascript( v ) +"\";\n"
  }
  str
%></script>
<a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]', '<%= escape_javascript( @environment.name()+' :: '+@page.title ) %>')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="/images/bt-bookmark.gif" width="53" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</div>
<% end; end %>

<div onmouseover="showArticleActions(true)"
     onmouseout="showArticleActions(false)">
  <%= article_title(@page, :no_link => true) %>
  <script type="text/javascript">
    function showArticleActions( show ) {
      var act = $("article-actions");
      if ( act ) act.className = ( show ? "show" : "hidden" );
    }
  </script>
  <% if logged_in? && current_user.person.has_permission?('post_content', profile) %>
    <div id="article-actions" class="hidden">
      <% unless @page.blog? %>
      <%= link_to content_tag( 'span', label_for_edit_article(@page) ),
          profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }),
          :class => 'button with-text icon-edit' %>
      <% end %>
      <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %>
        <% if @page != profile.home_page %>
          <%= link_to content_tag( 'span', _('Delete') ),
            profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page }),
            :class => 'button with-text icon-delete' %>
        <% end %>
        <% if profile.kind_of?(Person) && !environment.enabled?('disable_cms') %>
          <%= link_to content_tag( 'span', _('Spread this') ),
              profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page }),
              :class => 'button with-text icon-spread' %>
        <% end %>
        <% if @page.display_as_gallery? %>
          <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) %>
        <% else %>
          <%= lightbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) %>
        <% end %>
      <% end %>
      <% if profile.kind_of?(Enterprise) && @page.display_as_gallery? %>
        <%= button('upload-file', _('Upload files'), :controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent)) %>
      <% end %>
    </div>
  <% end %>
</div>

<% if !@page.tags.empty? %>
  <div id="article-tags">
    <%= _("This article's tags:") %>
    <%= @page.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tag', :id => t.name ) }.join("\n") %>
  </div>
<% end %>

<% if @page.display_hits? %>
  <div id="article-hits">
    <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %>
  </div>
<% end %>

<% if @page.parent && !@page.parent.path.blank? %>
<div id="article-parent">
  <%= link_to _('Go back'), @page.parent.url %>
</div>
<% end %>

<% if profile.enterprise? and !profile.enabled? and !profile.blocks.select {|b| b.class == DisabledEnterpriseMessageBlock}.any? %>
  <div id='profile-disabled'>
    <%= environment.message_for_disabled_enterprise %>
  </div>
<% end %>

<% cache(@page.cache_key(params)) do %>
  <div class="<%="article-body article-body-" + @page.css_class_name %>">
    <%= article_to_html(@page) %>
    <br style="clear:both" />
  </div> <!-- end class="article-body" -->
<% end %>

<% if ! @page.categories.empty? %>
<div id="article-cat">
  <h4><%= _('Categories') %></h4>
    <%= @page.categories.map {|item| link_to_category(item, false) }.join(", ") %>
</div>
<% end %>

<% if ! @page.source.nil? and ! @page.source.empty?%>
<div id="article-source">
  <%= _('Source: %s') % link_to(@page.source, @page.source) %>
</div>
<% end %>

<div class="comments">
  <% if @page.accept_comments? %>
  <h3 <%= 'class="no-comments-yet"' if @comments.size == 0 %>>
    <%= number_of_comments(@page) %>
  </h3>
  <%= render :partial => 'comment', :collection => @comments %>
  <%= render :partial => 'comment_form' %>
  <% end %>
</div><!-- end class="comments" -->

</div><!-- end id="article" -->