Generate pager of purecss.
173684
def gen_pager_purecss(cat_slug, page_num, current):
    '''
    
    '''
    if page_num == 1:
        return ''

    pager_shouye = '''<li class="pure-menu-item {0}">
    <a class="pure-menu-link" href="{1}">&lt;&lt; 首页</a></li>'''.format(
        'hidden' if current <= 1 else '', cat_slug
    )

    pager_pre = '''<li class="pure-menu-item {0}">
                <a class="pure-menu-link" href="{1}/{2}">&lt; 前页</a>
                </li>'''.format('hidden' if current <= 1 else '',
                                cat_slug,
                                current - 1)
    pager_mid = ''
    for ind in range(0, page_num):
        tmp_mid = '''<li class="pure-menu-item {0}">
                <a class="pure-menu-link" href="{1}/{2}">{2}</a></li>
                '''.format('selected' if ind + 1 == current else '',
                           cat_slug,
                           ind + 1)
        pager_mid += tmp_mid
    pager_next = '''<li class="pure-menu-item {0}">
                <a class="pure-menu-link" href="{1}/{2}">后页 &gt;</a>
                </li> '''.format('hidden' if current >= page_num else '',
                                 cat_slug,
                                 current + 1)
    pager_last = '''<li class="pure-menu-item {0}">
                <a hclass="pure-menu-link" ref="{1}/{2}">末页
                &gt;&gt;</a>
                </li> '''.format('hidden' if current >= page_num else '',
                                 cat_slug,
                                 page_num)
    pager = pager_shouye + pager_pre + pager_mid + pager_next + pager_last
    return pager
1154201
function pages(req, res, next) {

    generator.getPage(req.url, function(err, page) {

      if (err || !page || !checkMethod(req, page)) return next();

      if (!isPageAuthorized(req, page)) {
        if (!server.login || page.nologin) return next();
        return server.login(req, res);
      }

      debug('page %s', page._href);

      // make req and res available to dynamic pages
      generator.req = req;
      generator.res = res;

      resHeaders(res, page);
      res.send(generator.renderDoc(page));

    });
  }
507888
def pager(text, color=None):
    """"""
    stdout = _default_text_stdout()
    if not isatty(sys.stdin) or not isatty(stdout):
        return _nullpager(stdout, text, color)
    if 'PAGER' in os.environ:
        if WIN:
            return _tempfilepager(text, os.environ['PAGER'], color)
        return _pipepager(text, os.environ['PAGER'], color)
    if os.environ.get('TERM') in ('dumb', 'emacs'):
        return _nullpager(stdout, text, color)
    if WIN or sys.platform.startswith('os2'):
        return _tempfilepager(text, 'more <', color)
    if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
        return _pipepager(text, 'less', color)

    import tempfile
    fd, filename = tempfile.mkstemp()
    os.close(fd)
    try:
        if hasattr(os, 'system') and os.system('more "%s"' % filename) == 0:
            return _pipepager(text, 'more', color)
        return _nullpager(stdout, text, color)
    finally:
        os.unlink(filename)
307845
function createPagination(req) {
  return function createPagination(pages, page, liClass, anchorClass) {
    var params = qs.parse(url.parse(req.url).query);
    var str = '';

    params.page = 1;
    var clas = (page == 1 && 'active') || '';

    for (var p = 1; p <= pages; p++) {
      params.page = p;
      clas = (page == p && 'active') || '';

      var href = '?' + qs.stringify(params);

      str += `<li class="${liClass} ${clas}"><a class="${anchorClass}" href="${href}">${p}</a></li>`;
    }

    return str;
  };
}
1036722
function () {
            var prevPageIndex,
                currentPageIndex,
                rowIndex,
                row,
                offset,
                state = this.state,
                pages = state.pages;

            prevPageIndex = util.bisectRight(pages, state.scrollTop, 'y0') - 1;
            if (prevPageIndex < 0) {
                return 1;
            }
            offset = state.scrollTop + pages[prevPageIndex].height / 2;
            currentPageIndex = util.bisectRight(pages, offset, 'y0') - 1;
            rowIndex = pages[currentPageIndex].rowIndex;
            row = state.rows[rowIndex];
            return 1 + row[0];

        }
962154
def open_pager(self):
        
        n_rows, n_cols = self.term.stdscr.getmaxyx()

        if self.config['max_pager_cols'] is not None:
            n_cols = min(n_cols, self.config['max_pager_cols'])

        data = self.get_selected_item()
        if data['type'] == 'Submission':
            text = '\n\n'.join((data['permalink'], data['text']))
            self.term.open_pager(text, wrap=n_cols)
        elif data['type'] == 'Comment':
            text = '\n\n'.join((data['permalink'], data['body']))
            self.term.open_pager(text, wrap=n_cols)
        else:
            self.term.flash()
1198185
private function displayPager()
    {
        $pager = ($this->maxPage > 9) ? $this->createFullPages() : $this->createSimplePages();
        echo '<div class="pager">';
        $this->displayLeftSide();
        for ($i = 0; $i < count($pager); $i++) {
            echo $pager[$i];
        }
        $this->displayRightSide();
        echo "</div>";
    }
737714
function ( oSettings, fnCallbackDraw )
			{
				if ( !oSettings.aanFeatures.p )
				{
					return;
				}
				
				var oClasses = oSettings.oClasses;
				var an = oSettings.aanFeatures.p;
	
				/* Loop over each instance of the pager */
				for ( var i=0, iLen=an.length ; i<iLen ; i++ )
				{
					if ( an[i].childNodes.length !== 0 )
					{
						an[i].childNodes[0].className = ( oSettings._iDisplayStart === 0 ) ? 
							oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
						
						an[i].childNodes[1].className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ? 
							oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
					}
				}
			}
109634
def gen_pager_bootstrap_url(cat_slug, page_num, current):
    '''
    
    '''
    pager = ''
    if page_num == 1 or page_num == 0:
        pager = ''
    elif page_num > 1:
        pager_mid, pager_pre, pager_next, pager_last, pager_home = '', '', '', '', ''

        pager = '<ul class="pagination">'

        if current > 1:
            pager_home = '''<li class="{0}" name='fenye' onclick='change(this);'>
                <a href="{1}/{2}">首页</a></li>'''.format('', cat_slug, 1)

            pager_pre = ''' <li class="{0}" name='fenye' onclick='change(this);'>
                <a href="{1}/{2}">上一页</a></li>'''.format('', cat_slug, current - 1)
        if current > 5:
            cur_num = current - 4
        else:
            cur_num = 1

        if page_num > 10 and cur_num < page_num - 10:
            show_num = cur_num + 10

        else:
            show_num = page_num + 1

        for num in range(cur_num, show_num):
            if num == current:
                checkstr = 'active'
            else:
                checkstr = ''

            tmp_str_df = '''<li class="{0}" name='fenye' onclick='change(this);'>
                  <a href="{1}/{2}">{2}</a></li>'''.format(checkstr, cat_slug, num)

            pager_mid += tmp_str_df
        if current < page_num:
            pager_next = '''

                  <li class="{0}" name='fenye' onclick='change(this);'
                  ><a href="{1}/{2}">下一页</a></li>'''.format('', cat_slug, current + 1)
            pager_last = '''

                  <li class="{0}" name='fenye' onclick='change(this);'
                 ><a href="{1}/{2}">末页</a></li>'''.format('', cat_slug, page_num)

        pager += pager_home + pager_pre + pager_mid + pager_next + pager_last
        pager += '</ul>'
    else:
        pass

    return pager
1078621
function (id_base) {
        this.span = document.createElement('span');
        this.span.id        = id_base + '-page-report';
        this.span.className = this.paginator.get('pageReportClass');
        this.update();
        
        return this.span;
    }
906884
def file_page_generator(my_file, max_page_size=2**28):
  
  page_start = "  <page>\n"
  page_end = "  </page>\n"
  chunk_size = max_page_size
  page_start = "  <page>\n"
  page_end = "  </page>\n"
  leftovers = ""
  while True:
    chunk = my_file.read(chunk_size)
    if not chunk:
      break
    chunk = leftovers + chunk
    current_pos = 0
    while True:
      start_pos = chunk.find(page_start, current_pos)
      if start_pos == -1:
        break
      end_pos = chunk.find(page_end, start_pos)
      if end_pos == -1:
        if len(chunk) - start_pos > max_page_size:
          leftovers = ""
        else:
          leftovers = chunk[start_pos:]
        break
      raw_page = chunk[start_pos + len(page_start):end_pos]
      if len(raw_page) < max_page_size:
        ret = parse_page(raw_page)
        if ret:
          yield ret
      current_pos = end_pos + len(page_end)
138531
def initialize_page_data(self):
        """"""
        if self.term.is_a_tty:
            self.display_initialize()
        self.character_generator = self.character_factory(self.screen.wide)
        page_data = list()
        while True:
            try:
                page_data.append(next(self.character_generator))
            except StopIteration:
                break
        if LIMIT_UCS == 0x10000:
            echo(self.term.center('press any key.').rstrip())
            flushout()
            self.term.inkey(timeout=None)
        return page_data
710733
def buildPaginationHeader(resultCount, resultsPerPage, pageArg, url):
    ''''''
    lastPage = resultCount / resultsPerPage

    if pageArg:
        page = int(pageArg)
        next_url = re.sub("page=[0-9]+", "page={}".format(page + 1), url)
        prev_url = re.sub("page=[0-9]+", "page={}".format(page - 1), url)
        first_url = re.sub("page=[0-9]+", "page=1", url)
        last_url = re.sub("page=[0-9]+", "page={}".format(lastPage), url)
    else:
        page = 1
        next_url = url + "?page=2"
        prev_url = ""
        first_url = url + "?page=1"
        last_url = url + "?page={}".format(lastPage)

    if page == 1:
        headerLink = "<{}>; rel=next, <{}>; rel=last".format(next_url, last_url)
    elif page == lastPage:
        headerLink = "<{}>; rel=prev, <{}>; rel=first".format(prev_url, first_url)
    else:
        headerLink = "<{}>; rel=next, <{}>; rel=prev, <{}>; rel=first, <{}>; rel=last".format(next_url, prev_url, first_url, last_url)
    return headerLink
517635
protected function findInitializedPagerId()
    {
        foreach ($this->pagers as $key => $pager) {
            if (isset($pager->totalpages)) {
                return $key;
            }
        }

        return '';
    }
964599
private function generatePagePartEntity()
    {
        if (file_exists($this->bundle->getPath() . '/Entity/PageParts/AbstractPagePart.php')) {
            $abstractClass = $this->bundle->getNamespace() . '\Entity\PageParts\AbstractPagePart';
        } else {
            $abstractClass = 'Kunstmaan\PagePartBundle\Entity\AbstractPagePart';
        }

        list($entityCode, $entityPath) = $this->generateEntity(
            $this->bundle,
            $this->entity,
            $this->fields,
            'PageParts',
            $this->prefix,
            $abstractClass
        );

        // Add some extra functions in the generated entity :s
        $params = array(
            'bundle' => $this->bundle->getName(),
            'pagepart' => $this->entity,
            'adminType' => '\\' . $this->bundle->getNamespace() . '\\Form\\PageParts\\' . $this->entity . 'AdminType',
            'isV4' => $this->isSymfony4(),
        );
        $extraCode = $this->render('/Entity/PageParts/ExtraFunctions.php', $params);

        $pos = strrpos($entityCode, "\n}");
        $trimmed = substr($entityCode, 0, $pos);
        $entityCode = $trimmed."\n\n".$extraCode."\n}\n";

        // Write class to filesystem
        $this->filesystem->mkdir(dirname($entityPath));
        file_put_contents($entityPath, $entityCode);

        $this->assistant->writeLine('Generating entity : <info>OK</info>');
    }
957671
def generate_pages_by_file():
    """"""
    from veripress import app
    from veripress.model import storage
    from veripress.model.parsers import get_standard_format_name
    from veripress.helpers import traverse_directory

    deploy_dir = get_deploy_dir()

    def copy_file(src, dst):
        makedirs(os.path.dirname(dst), mode=0o755, exist_ok=True)
        shutil.copyfile(src, dst)

    with app.app_context(), app.test_client() as client:
        root_path = os.path.join(app.instance_path, 'pages')
        for path in traverse_directory(root_path):
            # e.g. 'a/b/c/index.md'
            rel_path = os.path.relpath(path, root_path)
            # e.g. ('a/b/c/index', '.md')
            filename, ext = os.path.splitext(rel_path)
            if get_standard_format_name(ext[1:]) is not None:
                # is source of custom page
                rel_url = filename.replace(os.path.sep, '/') + '.html'
                page = storage.get_page(rel_url, include_draft=False)
                if page is not None:
                    # it's not a draft, so generate the html page
                    makedirs(os.path.join(deploy_dir,
                                          os.path.dirname(rel_path)),
                             mode=0o755, exist_ok=True)
                    with open(os.path.join(deploy_dir, filename + '.html'),
                              'wb') as f:
                        f.write(client.get('/' + rel_url).data)
                if app.config['PAGE_SOURCE_ACCESSIBLE']:
                    copy_file(path, os.path.join(deploy_dir, rel_path))
            else:
                # is other direct files
                copy_file(path, os.path.join(deploy_dir, rel_path))
806267
function() {
        var w = 0;
        for (var p=0;p<this.pages.length;++p) {
            var cal = this.pages[p];
            w += cal.oDomContainer.offsetWidth;
        }
        if (w > 0) {
            this.oDomContainer.style.width = w + "px";
        }
    }