Возвращает контекст для рендеринга представления текстовой страницы
    :param page: модель страницы
    :param request: запрос
    :return:
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}
213491
public function batch($page, Request $request)
    {
        $this->authorize($action = $request->get('batch_action'), $model = app('scaffold.module')->model());

        $response = app('scaffold.actions')->exec('batch::'.$action, [$model, $request]);

        if ($response instanceof Response || $response instanceof Renderable) {
            return $response;
        }

        return back()->with(
            'messages',
            [trans('administrator::messages.action_success')]
        );
    }
1016130
def get_params_from_page(path, file_name, method_count):
    
    # open the rendered file.
    file_name = file_name.replace(".rst", "")
    file_path = "{0}/../_build/html/endpoints/{1}/index.html".format(
        path, file_name)
    soup = bs4.BeautifulSoup(open(file_path))

    # Pull out the relevant section
    section = soup.find_all('div', class_='section')[method_count]

    # get the tbody of the params table
    tbody = section.find('tbody')
    params = []
    if tbody is not None:
        for row in tbody.find_all('tr'):
            name, param_type, required, description = row.find_all('td')
            required = required.text == 'Yes'
            param = dict(
                name=name.text,
                type=param_type.text,
                required=required,
                description=description.text
            )
            params.append(param)
    params = sorted(params, key=lambda k: not k['required'])
    return params
935287
def html(self, page, version=None):
        
        return (self._dokuwiki.send('wiki.getPageHTMLVersion', page, version)
                if version is not None
                else self._dokuwiki.send('wiki.getPageHTML', page))
459699
public function __HANDLER($page = null)
    {
        $parent = CMSNav::fullTree();
        $tree = new \samson\treeview\SamsonTree('tree/tree-template', 0, 'structure/addchildren');

        // Установим дерево ЭСС
        m()->view('index')
            ->title(t('Элементы структуры содержания сайта', true))
            ->set($tree->htmlTree($parent), 'tree');
    }
227733
def data
      {
        text: @page.description,
        type: :file,
        li_attr: list_attributes,
        data: {
          id: @page.id,
          url: @context.edit_translation_backend_page_path(@page, Udongo.config.i18n.app.default_locale),
          delete_url: @context.backend_page_path(@page, format: :json),
          deletable: @page.deletable?,
          draggable: @page.draggable?,
          update_position_url: @context.tree_drag_and_drop_backend_page_path(@page),
          visible: @page.visible?,
          toggle_visibility_url: @context.toggle_visibility_backend_page_path(@page, format: :json)
        },
        children: [] # This gets filled through Udongo::Pages::Tree
      }
    end
648134
def get_page_number_from_request(
        request, querystring_key=PAGE_LABEL, default=1):
    
    try:
        if request.method == 'POST':
            page_number = request.POST[querystring_key]
        else:
            page_number = request.GET[querystring_key]

        return int(page_number)
    except (KeyError, TypeError, ValueError):
        return default
162599
def page_factory(request):
    
    prefix = request.matchdict['prefix']  # /{prefix}/page1/page2/page3...
    settings = request.registry.settings
    dbsession = settings[CONFIG_DBSESSION]
    config = settings[CONFIG_MODELS]

    if prefix not in config:
        # prepend {prefix} to *traverse
        request.matchdict['traverse'] =\
            tuple([prefix] + list(request.matchdict['traverse']))
        prefix = None

    # Get all resources and models from config with the same prefix.
    resources = config.get(
        prefix, config.get(   # 1. get resources with prefix same as URL prefix
            '', config.get(   # 2. if not, then try to get empty prefix
                '/', None)))  # 3. else try to get prefix '/' otherwise None

    if not hasattr(resources, '__iter__'):
        resources = (resources, )

    tree = {}

    if not resources:
        return tree

    # Add top level nodes of resources in the tree
    for resource in resources:
        table = None
        if not hasattr(resource, '__table__')\
                and hasattr(resource, 'model'):
            table = resource.model
        else:
            table = resource

        if not hasattr(table, 'slug'):
            continue

        nodes = dbsession.query(table)
        if hasattr(table, 'parent_id'):
            nodes = nodes.filter(or_(
                table.parent_id == None,  # noqa
                table.parent.has(table.slug == '/')
            ))
        for node in nodes:
            if not node.slug:
                continue
            resource = resource_of_node(resources, node)
            tree[node.slug] = resource(node, prefix=prefix)
    return tree
1233247
def link_page_filter(self, page, modelview_name):
        
        new_args = request.view_args.copy()
        args = request.args.copy()
        args["page_" + modelview_name] = page
        return url_for(
            request.endpoint,
            **dict(list(new_args.items()) + list(args.to_dict().items()))
        )
363701
def url(page)
      @base_url_params ||= begin
                             url_params = merge_get_params(default_url_params)
                             merge_optional_params(url_params)
                           end

      url_params = @base_url_params.dup
      add_current_page_param(url_params, page)

      # Add optional url_builder support
      (@options[:url_builder] || @template).url_for(url_params)
    end
98553
def url_for_page(page)
      view.url_for(view.default_url_options.merge({page_param.to_sym => page}).merge(options[:params] || {}))
    end
856581
def decode_page(page):
    
    if hasattr(page, 'read'):  # urllib
        if py3k:
            encoding = page.headers.get_param("charset") or "utf-8"
        else:
            encoding = page.headers.getparam("charset") or "utf-8"
        return text_type(page.read(), encoding=encoding)
    else:  # requests?
        encoding = page.headers.get("charset") or "utf-8"
        return text_type(page.content, encoding=encoding)
533243
public function getRelativeUrl($page, Request $request)
    {
        return $this->router->generate(
            $request->attributes->get('_route'),
            array_merge($this->getParametersFromRequest($request), array('page' => $page))
        );
    }
1059059
def page_url(self, page):
        '''
        
        '''
        if page is not None and page != 1:
            return self.url.qs_set(**{self.page_param: page})
        elif page is not None:
            return self.url.qs_delete('page')
235160
public function getHtml(Eresus_CMS_Request $request, TClientUI $page)
    {
        $legacyKernel = Eresus_CMS::getLegacyKernel();
        /* Если в URL указано что-либо кроме адреса раздела, отправляет ответ 404 */
        if ($legacyKernel->request['file']
            || $legacyKernel->request['query']
            || $page->subpage
            || $page->topic)
        {
            throw new Eresus_CMS_Exception_NotFound;
        }

        $subItems = $legacyKernel->db->select('pages', "(`owner`='" . $page->id .
            "') AND (`active`='1') AND (`access` >= '" .
            ($legacyKernel->user['auth'] ?
                $legacyKernel->user['access'] : GUEST)."')", "`position`");
        if (empty($page->content))
        {
            $page->content = '$(items)';
        }
        $templates = Templates::getInstance();
        $template = $templates->get('SectionListItem', 'std');
        if (false === $template)
        {
            $template = '<h1><a href="$(link)" title="$(hint)">$(caption)</a></h1>$(description)';
        }
        $items = '';
        foreach ($subItems as $item)
        {
            $items .= str_replace(
                array(
                    '$(id)',
                    '$(name)',
                    '$(title)',
                    '$(caption)',
                    '$(description)',
                    '$(hint)',
                    '$(link)',
                ),
                array(
                    $item['id'],
                    $item['name'],
                    $item['title'],
                    $item['caption'],
                    $item['description'],
                    $item['hint'],
                    $legacyKernel->request['url'] .
                    ($page->name == 'main' &&
                    !$page->owner ? 'main/' : '').$item['name'].'/',
                ),
                $template
            );
        }
        $result = str_replace('$(items)', $items, $page->content);
        return $result;
    }
1230135
def get_frontend_data_dict_for_cms_page(cms_page, cms_page_title, request, editable=False):
    
    placeholders = list(cms_page.placeholders.all())
    placeholder_frontend_data_dict = get_frontend_data_dict_for_placeholders(
        placeholders=placeholders,
        request=request,
        editable=editable
    )
    global_placeholder_data_dict = get_global_placeholder_data(placeholder_frontend_data_dict)
    data = {
        'containers': placeholder_frontend_data_dict,
        'meta': {
            'title': cms_page_title.page_title if cms_page_title.page_title else cms_page_title.title,
            'description': cms_page_title.meta_description or '',
        }
    }

    language_links = get_language_links(cms_page=cms_page, request=request)
    if language_links:
        data['meta']['languages'] = language_links

    if placeholder_frontend_data_dict:
        data['containers'] = placeholder_frontend_data_dict

    if global_placeholder_data_dict:
        data['global_placeholder_data'] = global_placeholder_data_dict

    post_processer = settings.DJANGOCMS_SPA_CMS_PAGE_DATA_POST_PROCESSOR
    if post_processer:
        func = get_function_by_path(post_processer)
        data = func(cms_page=cms_page, data=data, request=request)

    return data
168237
def page(self):
        
        if not self._page:
            try:
                self._page = self.paginator.page(
                    self.query_dict.get('page', 1))
            except InvalidPage:
                raise HttpError("Invalid page", status=HTTP_400_BAD_REQUEST)
        return self._page