Exemplo n.º 1
0
    def test_save_as(self):
        # if a lang is not the default lang, save_as should be set accordingly
        page = Page('content', {'title': 'foobar', 'lang': 'fr'}) #default lang is en
        self.assertEqual(page.save_as, "foobar-fr.html")

        # otherwise, if a title is defined, save_as should be set
        page = Page('content', {'title': 'foobar'})
        page.save_as = 'foobar.html'
Exemplo n.º 2
0
    def test_save_as(self):
        # if a lang is not the default lang, save_as should be set accordingly
        page = Page('content', {
            'title': 'foobar',
            'lang': 'fr'
        })  #default lang is en
        self.assertEqual(page.save_as, "foobar-fr.html")

        # otherwise, if a title is defined, save_as should be set
        page = Page('content', {'title': 'foobar'})
        page.save_as = 'foobar.html'
Exemplo n.º 3
0
    def test_save_as(self):
        # if a lang is not the default lang, save_as should be set accordingly
        page = Page("content", {"title": "foobar", "lang": "fr"})  # default lang is en
        self.assertEqual(page.save_as, "foobar-fr.html")

        # otherwise, if a title is defined, save_as should be set
        page = Page("content", {"title": "foobar"})
        page.save_as = "foobar.html"

        # if no title is given, there is no save_as
        page = Page("content")
        self.assertFalse(hasattr(page, "save_as"))
Exemplo n.º 4
0
    def test_save_as(self):
        """If a lang is not the default lang, save_as should be set
        accordingly.

        """
        # if a title is defined, save_as should be set
        page = Page(**self.page_kwargs)
        page.save_as = 'foo-bar.html'

        # if a language is defined, save_as should include it accordingly
        self.page_kwargs['metadata'].update({'lang': 'fr', })
        page = Page(**self.page_kwargs)
        self.assertEqual(page.save_as, "foo-bar-fr.html")
Exemplo n.º 5
0
    def test_save_as(self):
        """If a lang is not the default lang, save_as should be set
        accordingly.

        """
        # if a title is defined, save_as should be set
        page = Page(**self.page_kwargs)
        page.save_as = 'foo-bar.html'

        # if a language is defined, save_as should include it accordingly
        self.page_kwargs['metadata'].update({
            'lang': 'fr',
        })
        page = Page(**self.page_kwargs)
        self.assertEqual(page.save_as, "foo-bar-fr.html")
Exemplo n.º 6
0
    def generate_context(self):
        all_pages = []
        for f in self.get_files(os.sep.join((self.path, 'pages'))):
            content, metadata = read_file(f)
            page = Page(content, metadata, settings=self.settings,
                        filename=f)
            if not is_valid_content(page, f):
                continue

            if self.settings.get('CLEAN_URLS_NO_PROXY'):
                # cleaning page url
                page.save_as = os.path.join(page.slug, 'index.html')
                page.url = os.path.dirname(page.save_as) + '/'

            all_pages.append(page)

        self.pages, self.translations = process_translations(all_pages)

        self._update_context(('pages', ))
        self.context['PAGES'] = self.pages