<div id="sidebar-wrapper-right" class="sidebar-wrapper sidebar-wrapper-right">
  <div class="sidebar-bg" id="sidebar-bg-right"></div>
  <div class="side-bar sidebar-additional showing" id="sidebar-additional">
    <% unless user_signed_in? %>
      <div class="widget signin-cta-widget">
        <header class="signin-cta-widget-header">
          Join <%= community_name %>
        </header>
        <div class="widget-body">
          <% if SiteConfig.auth_allowed?("twitter") %>
            <a href="/users/auth/twitter?callback_url=<%= app_url("/users/auth/twitter/callback") %>" class="cta cta-button login-cta-button" data-no-instant>Sign In With Twitter</a>
          <% end %>
          <% if SiteConfig.auth_allowed?("github") %>
            <a href="/users/auth/github?state=navbar_basic" class="cta cta-button login-cta-button" data-no-instant>Sign In With GitHub</a>
          <% end %>
        </div>
      </div>
    <% end %>
    <% cache(cache_key_heroku_slug("main-article-right-sidebar-discussions-#{params[:timeframe]}"), expires_in: (params[:timeframe].blank? ? 120 : 360).seconds) do %>
      <% @sidebar_ad = DisplayAd.for_display("sidebar_right") %>
      <% if @sidebar_ad %>
        <div class="widget">
          <div class="widget-body" style="margin-top:-6px">
            <%= @sidebar_ad.processed_html.html_safe %>
          </div>
        </div>
      <% end %>
      <%= render "articles/sidebar_campaign" if SiteConfig.campaign_sidebar_enabled? %>
      <% if params[:timeframe].blank? && @classified_listings.any? %>
        <div class="widget" id="sidebar-listings-widget">
          <header class="widget-header-listings">
            <a href="/listings"><h4>Listings <span class="widget-listing-live-count"><%= @classified_listings.size %></span></h4></a>
            <button type="button" class="widget-minimize-button" id="sidebar-listings-widget-minimize-button">-</button>
          </header>
          <div class="widget-body widget-body-listings">
            <% @classified_listings.order("bumped_at DESC").limit(5).each do |listing| %>
              <a class="widget-listing-link" href="<%= listing.path %>">
                <span class="widget-listing-link-title"><%= listing.title %></span>
                <span class="widget-listing-link-category"><%= listing.category %></span>
              </a>
            <% end %>
            <a class="cta cta-button" href="/listings/new">CREATE A LISTING</a>
          </div>
        </div>
      <% end %>
      <% SiteConfig.sidebar_tags.each do |tag| %>
        <div class="widget">
          <header>
            <a href="/t/<%= tag %>"><h4>#<%= tag %></h4></a>
          </header>
          <div class="widget-body">
            <div class="widget-link-list">
              <% if tag == "help" %>
                <% Article.active_help.limit(5).pluck(:path, :title, :comments_count, :created_at).each do |plucked_article| %>
                  <%= render "articles/widget_list_item", plucked_article: plucked_article, show_comment_count: true %>
                <% end %>
              <% else %>
                <% Article.active_threads([tag], Timeframer.new(params[:timeframe]).datetime, 5).each do |plucked_article| %>
                  <%= render "articles/widget_list_item", plucked_article: plucked_article, show_comment_count: true %>
                <% end %>
              <% end %>
            </div>
          </div>
        </div>
      <% end %>
    <% end %>
    <% unless user_signed_in? %>
      <% cache("seo-boostable-posts-homepage-#{params[:timeframe]}-xoxo", expires_in: 18.hours) do %>
        <% boostable_posts = Article.seo_boostable(nil, Timeframer.new(params[:timeframe]).datetime) %>
        <% if boostable_posts.present? %>
          <div class="widget">
            <header>
              <h4>trending guides/resources</h4>
            </header>
            <div class="widget-body">
              <div class="widget-link-list">
                <% boostable_posts.each do |plucked_article| %>
                  <%= render "articles/widget_list_item", plucked_article: plucked_article, show_comment_count: false %>
                <% end %>
              </div>
            </div>
          </div>
        <% end %>
      <% end %>
    <% end %>
  </div>
</div>
