<commit_before>module PaginationStuff
  # intended to:
  # ActionController::Base.send :extend, PaginationStuff::ControllerStuff
  module ControllerStuff
    def pagination_stuff(*actions)
      opts = (Hash === actions.last ? actions.pop : {:limit => 5})
      define_method "set_pagination_vars" do
        @paginantion_limit = (params[:limit] || opts[:limit]).to_i
        @paginantion_offset = (params[:offset] || 0).to_i

        @pagination_stuff = {
          :limit =>   @paginantion_limit,
          :offset =>  @paginantion_offset
        }
      end

      protected :set_pagination_vars

      before_filter :set_pagination_vars, :only => actions
    end
  end

  # intended to:
  # ActionView::Base.send :include, PaginationStuff::ViewStuff::ClassMethods
  module ViewStuff
    def pagination_stuff(array)
      return "" if array.nil? or array.empty?
      
      out = ""
      
      offset = eval("@offset")
      limit = eval("@limit")
      size = array.size
      
      prev_offset = offset - limit
      prev_offset = nil if prev_offset <= 0
      
      if offset > 0
        prev_link = link_to("&larr;&nbsp;prev", :offset => prev_offset, :limit => limit)
      end

      if size > 0 and size >= limit
        next_link = link_to("next&nbsp;&rarr;", :offset => offset+limit, :limit => limit)
      end
      
      out << prev_link if prev_link
      
      if prev_link and next_link
        out << "&nbsp;&bull;&nbsp;"
      end

      out << next_link if next_link

      return out
    end<commit_msg>change you can believe in<commit_after>module PaginationStuff
  # intended to:
  # ActionController::Base.send :extend, PaginationStuff::ControllerStuff
  module ControllerStuff
    def pagination_stuff(*actions)
      opts = (Hash === actions.last ? actions.pop : {:limit => 5})
      define_method "set_pagination_vars" do
        @pagination_limit = (params[:limit] || opts[:limit]).to_i
        @pagination_page = (params[:page] || 1).to_i
        
        @pagination_offset = (@pagination_page*@pagination_limit) - @pagination_limit

        @pagination_stuff = {
          :limit =>   @pagination_limit,
          :offset =>  @pagination_offset
        }
      end

      protected :set_pagination_vars

      before_filter :set_pagination_vars, :only => actions
    end
  end

  # intended to:
  # ActionView::Base.send :include, PaginationStuff::ViewStuff::ClassMethods
  module ViewStuff
    def pagination_stuff(array)
      return "" if array.nil? or array.empty?
      
      out = ""
      
      offset  = @pagination_offset
      limit   = @pagination_limit
      page    = @pagination_page
      size = array.size
      
      prev_page = @pagination_page-1
      next_page = @pagination_page+1

      if @pagination_page > 1
        prev_link = link_to("&larr;&nbsp;prev", :page => (prev_page > 1 ? prev_page : nil), :limit => (params[:limit] ? limit : nil))
      end

      if size > 0 and size >= limit
        next_link = link_to("next&nbsp;&rarr;", :page => @pagination_page+1, :limit => (params[:limit] ? limit : nil))
      end
      
      out << prev_link if prev_link
      
      if prev_link and next_link
        out << "&nbsp;&bull;&nbsp;"
      end

      out << next_link if next_link

      return out
    end
{'fraction_non_alphanumeric': 0.11148442272449603, 'fraction_numerical': 0.003970678069639585, 'mean_word_length': 2.510182207931404, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1271694', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1005, 'n_words': 231}