Create pagination links.
541721
public function create()
    {
        $content = '';
        $pageNumber = $this->getPageNumber();

        if ($pageNumber === 0) {
            $pageNumber = 1;
        }

        if ($this->lastPage > 1) {
            $content .= "<div class='pagination'>";

            $content .= $this->renderPreviousLink($pageNumber);

            //not enough pages to bother breaking it up
            if ($this->lastPage < 7 + ($this->adjacent * 2)) {
                for ($counter = 1; $counter <= $this->lastPage; $counter++) {
                    $content .= $this->createCurrentActiveLink($pageNumber, $counter);
                }
            } elseif ($this->lastPage > 5 + ($this->adjacent * 2)) {
                //close to beginning; only hide later pages
                if ($pageNumber < 1 + ($this->adjacent * 2)) {
                    for ($counter = 1; $counter < 4 + ($this->adjacent * 2); $counter++) {
                        $content .= $this->createCurrentActiveLink($pageNumber, $counter);
                    }
                    $content .= '...';
                    $content .= $this->createSecondLink();
                } elseif (
                    $this->lastPage - ($this->adjacent * 2) > $pageNumber
                    && $pageNumber > ($this->adjacent * 2)
                ) {
                    $content .= $this->createPrimaryLink();
                    $content .= '...';

                    for (
                        $counter = $pageNumber - $this->adjacent;
                        $counter <= $pageNumber + $this->adjacent;
                        $counter++
                    ) {
                        $content .= $this->createCurrentActiveLink($pageNumber, $counter);
                    }

                    $content .= '...';
                    $content .= $this->createPrimaryLink();
                    $content .= $this->createSecondLink();
                } else {
                    //close to end; only hide early pages

                    $content .= $this->createPrimaryLink();

                    $content .= '...';
                    for (
                        $counter = $this->lastPage - (2 + ($this->adjacent * 2));
                        $counter <= $this->lastPage;
                        $counter++
                    ) {
                        $content .= $this->createCurrentActiveLink($pageNumber, $counter);
                    }
                }
            }

            $content .= $this->renderNextLink($counter, $pageNumber);
        }

        $this->paginationLinks = $content;
    }
1020143
def rel_links(cls, page):
    """"""
    for match in cls.REL_RE.finditer(page):
      href, rel = match.group(0), match.group(1)
      if rel not in cls.REL_TYPES:
        continue
      href_match = cls.HREF_RE.search(href)
      if href_match:
        href = cls.href_match_to_url(href_match)
        parsed_href = urlparse(href)
        if any(parsed_href.path.endswith(ext) for ext in cls.REL_SKIP_EXTENSIONS):
          continue
        yield href
364072
def links(cls, page):
    """"""
    for match in cls.HREF_RE.finditer(page):
      yield cls.href_match_to_url(match)
1284429
def paginate(idx, max, url, &b)
      return '' if max == 0
      url = url.gsub(%r{^/?(.*?)/?$}, '\1')
      b ||= lambda{}
      link = lambda {|*args|
        i, title, text = args
        "<a href=\"/#{url}/#{i}#{'?' + @query_string if @query_string}\" " +
         "#{'onclick="return false;"' if (i == idx)} " +
         "class=\"#{'disabled ' if (i == idx)}#{b.call(i)}\" " +
         "title=\"#{title||"Go to page #{i}"}\">#{text||i}</a>"
      }
      res = '<div class="nav">'
      if (idx > 0)
        res << link.call(idx - 1, "Go to previous page", "&#171; Previous")
      else
        res << "<a href=\"/#{url}/0\" onclick=\"return false;\" " +
                "class=\"disabled\" title=\"Disabled\">&#171; Previous</a>"
      end
      if idx < 10
        idx.times {|i| res << link.call(i)}
      else
        (0..2).each {|i| res << link.call(i)}
        res << '&nbsp;&#8230;&nbsp;'
        ((idx-4)...idx).each {|i| res << link.call(i)}
      end
      res << link.call(idx, 'Current Page')
      if idx > (max - 10)
        ((idx+1)...max).each {|i| res << link.call(i)}
      else
        ((idx+1)..(idx+4)).each {|i| res << link.call(i)}
        res << '&nbsp;&#8230;&nbsp;'
        ((max-3)...max).each {|i| res << link.call(i)}
      end
      if (idx < (max - 1))
        res << link.call(idx + 1, "Go to next page", "Next &#187;")
      else
        res << "<a href=\"/#{url}/#{max-1}\" onclick=\"return false;\" " +
                "class=\"disabled\" title=\"Disabled\"}\">Next &#187;</a>"
      end
      res << '</div>'
    end
1295339
public function compilePaginations()
	{
		foreach ($this->site->getPaginations() as $pagination) 
		{
			$template = $this->twig->loadTemplate( 'index.html.tpl' );
			$content = $template->render(array('site' => $this->site, 'pagination' => $pagination));
			$this->createFile($content, $pagination);
		}
	}
613522
private function appendPaginationLinks()
    {
        if (class_basename($this->models) == 'LengthAwarePaginator') {
            // This set of models was paginated.  Make it append our current view variables.
            $this->models->appends(Input::only(config('gbrock-tables.key_field'),
                config('gbrock-tables.key_direction')));
        }
    }
669460
public static OffsetPaginationLinks create(
      OffsetPaginatedList<?> list, UriInfo uriInfo) {
    // Find offset and limit by inspecting the list metadata, if that's not provided then fall back
    // to inspecting the UriInfo.
    Long offset =
        list.metadata().offset() != null ? list.metadata().offset()
            : currentOffset(uriInfo, list.metadata().offsetFieldName());
    Integer limit =
        list.metadata().limit() != null ? list.metadata().limit()
            : currentLimit(uriInfo, list.metadata().limitFieldName());

    return new OffsetPaginationLinks(list, uriInfo, offset, limit);
  }
1307937
def pagination_link(relation)
      # split on ',' select the [url] in '<[url]>; rel="[relation]"', compact to all url's found (at most one) and take the first
      (@pagination_links ||= {})[relation] ||= @response.header['Link'] && @response.header['Link'].split(/,\s*<?/).map{ |link| link[/^\s*<?(.*?)>?;\s*rel="#{relation.to_s}"\s*$/, 1] }.compact.first
    end
1212976
private function generatePages()
    {
        $links = explode(',', $this->headers[self::LINK][0]);

        foreach ($links as $link) {
            // Run two preg_match to retrieve specific element in the string
            // snce the page attributes is not always at the same position,
            // we can't retireve both information in the same regex
            preg_match('/page=([^&>]*)/', $link, $page);
            preg_match('/rel="([a-z]+)"/', $link, $rel);

            if ($page[1] !== null && $rel[1] !== null) {
                $this->pages[$rel[1]] = $page[1];
            }
        }

        $this->pagesProcessed = true;

        return $this->pages;
    }
175609
protected function links()
    {
        /** @var  Paginator $paginator */
        $paginator = $this->grid->getConfig()
            ->getDataProvider()
            ->getPaginator();
        $input = $this->grid->getInputProcessor()->getInput();
        if (isset($input['page'])) {
            unset($input['page']);
        }
        return str_replace('/?', '?',$paginator->appends($this->input_key, $input)->render());
    }
298034
public function paginate()
    {
        $this->count = $this->query->get()->count();
        $this->limit = $this->limit ?: $this->count;
        $this->query->skip($this->offset)->take($this->limit);
    }
275058
private function createPaginationItems()
    {
        // Grab overrides if present
        $linkClass = $this->getOption('linkClass', 'page-link');
        $itemClass = $this->getOption('itemClass', 'page-item');
        $itemActiveClass = $this->getOption('itemActiveClass', 'page-item active');
        $previousCaption = ' &laquo; ' . $this->getOption('previousCaption', '');
        $nextCaption = $this->getOption('nextCaption', '') . ' &raquo; ';

        // To be returned
        $items = array();

        // First - check if first previous page available
        if ($this->paginator->hasPreviousPage()) {
            $items[] = $this->createListItem($itemClass, $this->renderLink($previousCaption, $this->paginator->getPreviousPageUrl(), $linkClass));
        }

        foreach ($this->paginator->getPageNumbers() as $page) {
            if (is_numeric($page)) {
                $currentClass = $this->paginator->isCurrentPage($page) ? $itemActiveClass : $itemClass;
                $items[] = $this->createListItem($currentClass, $this->renderLink($page, $this->paginator->getUrl($page), $linkClass));
            } else {
                $items[] = $this->createListItem($itemClass, $this->renderLink($page, '#', $linkClass));
            }
        }

        // Last - check if next page available
        if ($this->paginator->hasNextPage()) {
            $items[] = $this->createListItem($itemClass, $this->renderLink($nextCaption, $this->paginator->getNextPageUrl(), $linkClass));
        }

        return $items;
    }
1280834
def paginate_sources(owner=None, page=1, page_size=DEFAULT_PAGE_SIZE):
    ''''''
    sources = _sources_queryset(owner=owner)
    page = max(page or 1, 1)
    return sources.paginate(page, page_size)
61488
def wrap_paginated(self, data, renderer_context):
        """"""

        pagination_keys = ['count', 'next', 'previous', 'results']
        for key in pagination_keys:
            if not (data and key in data):
                raise WrapperNotApplicable('Not paginated results')

        view = renderer_context.get("view", None)
        model = self.model_from_obj(view)
        resource_type = self.model_to_resource_type(model)

        try:
            from rest_framework.utils.serializer_helpers import ReturnList

            results = ReturnList(
                data["results"],
                serializer=data.serializer.fields["results"],
            )
        except ImportError:
            results = data["results"]

        # Use default wrapper for results
        wrapper = self.wrap_default(results, renderer_context)

        # Add pagination metadata
        pagination = self.dict_class()

        pagination['previous'] = data['previous']
        pagination['next'] = data['next']
        pagination['count'] = data['count']

        wrapper.setdefault('meta', self.dict_class())

        wrapper['meta'].setdefault('pagination', self.dict_class())
        wrapper['meta']['pagination'].setdefault(
            resource_type, self.dict_class()).update(pagination)

        return wrapper
1351477
def build_queryset(self):
        """"""
        paths = [(os.path.join(self.build_prefix, 'index.html'), {})]
        self.request = None
        queryset = self.get_queryset()
        paginator = self.get_paginator(queryset, self.get_paginate_by(queryset))
        for page in paginator.page_range:
            paths.append(
                (os.path.join(self.build_prefix, 'page',
                              '%d' % page, 'index.html'), {'page': page}))
        for build_path, kwargs in paths:
            self.request = self.create_request(build_path)
            # Add a user with no permissions
            self.request.user = AnonymousUser()
            # Fake context so views work as expected
            self.kwargs = kwargs
            self.prep_directory(build_path)
            target_path = os.path.join(settings.BUILD_DIR, build_path)
            self.build_file(target_path, self.get_content())
13537
def next_page(self):
        
        for link in self.links:
            if link.rel.lower() == 'next':
                return self._load(link.href)
        raise PaginationError('No more entries.')
52529
private function createSimplePages()
    {
        $pager = [];
        for ($i = 1; $i <= $this->maxPage; $i++) {
            $pager[$i - 1] = $this->buildAnchor($i);
        }
        return $pager;
    }