Return list of slugs that correspond to pages to generate.
559075
def _pages_to_generate(self):
        ''''''
        # right now it gets all the files. In theory, It should only
        # get what's changed... but the program is not doing that yet.

        all_pages = self.get_page_names()
        # keep only those whose status is published
        ptg = []
        for slug in all_pages:
            p = s2page.Page(self, slug, isslug=True)
            if p.published:
                ptg.append({'slug': p.slug, 'title':p.title, 'date': p.creation_date })

        # sort the ptg array in reverse chronological order of its entries.
        sptg = sorted(ptg, key=lambda x : x['date'],reverse=True)
        res = [ pinfo['slug'] for pinfo in sptg]
        return res
1039232
def show_slug_with_level(context, page, lang=None, fallback=True):
    """"""
    if not lang:
        lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE)

    page = get_page_from_string_or_id(page, lang)
    if not page:
        return ''

    return {'content': page.slug_with_level(lang)}
456068
def get_subpages_sorted(self, pages, page):
        """"""

        sorted_pages = []
        to_sort = []
        for subpage in page.subpages:
            # Do not resort subprojects even if they are
            # 'generated'.
            if pages[subpage].pre_sorted:
                sorted_pages.append(subpage)
            else:
                to_sort.append(subpage)

        return sorted_pages + sorted(
            to_sort, key=lambda p: pages[p].get_title().lower())
253391
def _page_gen(self):
        
        track = ""
        for page in self.__pages__:
            track += "/{page}".format(page=page)
        return track
480403
private function generateContentRules()
	{
		$rules = array();
		$criteria = Content::model()->getBaseCriteria();
		$content = Content::model()->findAll($criteria);
		foreach ($content as $el)
		{
			if ($el->slug == NULL)
				continue;

			$pageRule = $el->slug.'/<page:\d+>';
			$rule = $el->slug;


			$pageRule = $el->slug . '/<page:\d+>';
			$rule = $el->slug;

			$rules[$pageRule] = "content/index/id/{$el->id}/vid/{$el->vid}";
			$rules[$rule] = "content/index/id/{$el->id}/vid/{$el->vid}";
		}

		return $rules;
	}
1278514
def get_children_for_page(self, page):
        """"""
        if self.max_levels == 1:
            # If there's only a single level of pages to display, skip the
            # dict creation / lookup and just return the QuerySet result
            return self.pages_for_display
        return super().get_children_for_page(page)
811794
function(options) {
        var pages = [];
        var fromPage = options.page - 2;
        if (fromPage < 2) {
          fromPage = 2;
        }
        for (var page = fromPage; (page < (fromPage + options.shown)); page++) {
          pages.push(page);
        }
        return pages;
      }
575442
def pages(self):
        """"""
        if self.per_page == 0 or self.total is None:
            pages = 0
        else:
            pages = int(ceil(self.total / float(self.per_page)))
        return pages
892590
def list_names(cls):
        """"""
        ret = dict([(item['id'], item['name'])
                    for item in cls.list({'items_per_page': 500})])
        return ret
432591
def get_page_tpl_ctx(page, request):
    
    text = Template(page.text).render(Context())
    meta = MetaSeo(page)
    comments = get_object_comments(PageComment, page.id)
    comments_form = PageCommentForm(initial=get_comment_init(request, page))
    if page.slug == Page.MAIN_SLUG:
        crumbs = None
    else:
        crumbs = page.get_breadcrumbs()
    return {'page': page, 'comments': comments, 'comments_form': comments_form, 'text': text, 'meta': meta, 'crumbs': crumbs}
170986
def generate_posts(self):
		
		for post in self.posts:
			self.generate_page(
				['posts', post.slug],
				template='post.html.jinja',
				post=post,
			)
193628
public function slugs()
    {
        $slugs = collect();

        $this->all()->each(function ($item, $key) use ($slugs) {
            $slugs->push(strtolower($item['slug']));
        });

        return $slugs;
    }
1367998
def list_catalog(self, cat_slug, **kwargs):
        '''
        
        '''
        post_data = self.get_post_data()
        tag = post_data.get('tag', '')

        def get_pager_idx():
            '''
            Get the pager index.
            '''
            cur_p = kwargs.get('cur_p')
            the_num = int(cur_p) if cur_p else 1
            the_num = 1 if the_num < 1 else the_num
            return the_num

        current_page_num = get_pager_idx()
        cat_rec = MCategory.get_by_slug(cat_slug)
        if not cat_rec:
            return False

        num_of_cat = MPost2Catalog.count_of_certain_category(cat_rec.uid, tag=tag)

        page_num = int(num_of_cat / CMS_CFG['list_num']) + 1
        cat_name = cat_rec.name
        kwd = {'cat_name': cat_name,
               'cat_slug': cat_slug,
               'title': cat_name,
               'router': router_post[cat_rec.kind],
               'current_page': current_page_num,
               'kind': cat_rec.kind,
               'tag': tag}


        # Todo: review the following codes.


        if self.order:
            tmpl = 'list/catalog_list.html'
        else:
            tmpl = 'list/category_list.html'

        infos = MPost2Catalog.query_pager_by_slug(
            cat_slug,
            current_page_num,
            tag=tag,
            order=self.order
        )

        # ToDo: `gen_pager_purecss` should not use any more.
        self.render(tmpl,
                    catinfo=cat_rec,
                    infos=infos,
                    pager=tools.gen_pager_purecss(
                        '/list/{0}'.format(cat_slug),
                        page_num,
                        current_page_num),
                    userinfo=self.userinfo,
                    html2text=html2text,
                    cfg=CMS_CFG,
                    kwd=kwd,
                    router=router_post[cat_rec.kind])
1341654
def generate_sections(self):
        """"""
        authors = Dataset.objects.values(
            'uploaded_by'
        ).annotate(
            upload_count=Count(
                'uploaded_by'
            )
        ).order_by('-upload_count')

        email_name_map = grab_names_from_emails(
            [row['uploaded_by'] for row in authors]
        )

        for author in authors:
            for emailKey in email_name_map:
                if author['uploaded_by'] == emailKey:
                    author['name'] = email_name_map[emailKey]

        return [
            {
                'slug': author['uploaded_by'],
                'name': author['name'],
                'count': author['upload_count']

            }
            for author in authors
        ]
1048583
public static function pages()
    {
        if (!getConfig('sitemap.pages')) {
            return [];
        }

        $table = TableRegistry::get('MeCms.PagesCategories');
        $url = Cache::read('sitemap', $table->getCacheName());

        if (!$url) {
            $alias = $table->Pages->getAlias();

            $categories = $table->find('active')
                ->select(['id', 'lft', 'slug'])
                ->contain($alias, function (Query $q) use ($alias) {
                    return $q->find('active')
                        ->select(['category_id', 'slug', 'modified'])
                        ->order([sprintf('%s.modified', $alias) => 'DESC']);
                })
                ->order(['lft' => 'ASC']);

            if ($categories->isEmpty()) {
                return [];
            }

            //Adds categories index
            $url[] = self::parse(['_name' => 'pagesCategories']);

            foreach ($categories as $category) {
                //Adds the category
                $url[] = self::parse(
                    ['_name' => 'pagesCategory', $category->slug],
                    ['lastmod' => array_value_first($category->pages)->modified]
                );

                //Adds each page
                foreach ($category->pages as $page) {
                    $url[] = self::parse(['_name' => 'page', $page->slug], ['lastmod' => $page->modified]);
                }
            }

            Cache::write('sitemap', $url, $table->getCacheName());
        }

        return $url;
    }
1017640
private function generateCategoryRules()
	{
		$rules = array();
		$categories = Categories::model()->findAll();
		foreach ($categories as $el)
		{
			if ($el->slug == NULL)
				continue;

			$pageRule = $el->slug.'/<page:\d+>';
			$rule = $el->slug;

			$pageRule = $el->slug . '/<page:\d+>';
			$rule = $el->slug;

			$rules[$pageRule] = "categories/index/id/{$el->id}";
			$rules[$rule] = "categories/index/id/{$el->id}";
		}

		return $rules;
	}
893992
def _clean_page_automatic_slug_renaming(self, slug, is_slug_safe):
        """"""

        if not callable(is_slug_safe):
            raise TypeError('is_slug_safe must be callable')

        if is_slug_safe(slug):
            return slug

        count = 2
        new_slug = slug + "-" + str(count)
        while not is_slug_safe(new_slug):
            count = count + 1
            new_slug = slug + "-" + str(count)
        return new_slug