コード例 #1
0
ファイル: travis_fabfile.py プロジェクト: punchagan/statiki
def init_site():
    """ Initialize a nikola demo site. """

    from nikola.plugins.command.init import CommandInit, SAMPLE_CONF

    command = CommandInit()
    SAMPLE_CONF['SITE_URL'] = _get_site_url()
    SAMPLE_CONF.update(DATA)
    command.execute({'demo': True}, ['demo'])

    local('mv demo/* . && rmdir demo')
    local('touch files/.nojekyll')
    local('rm *.pyc')
コード例 #2
0
ファイル: import_blogger.py プロジェクト: getnikola/plugins
    def populate_context(channel):
        context = SAMPLE_CONF.copy()
        # blogger doesn't include the language in the dump
        context['DEFAULT_LANG'] = 'en'
        context['BLOG_TITLE'] = channel.feed.title

        context['BLOG_DESCRIPTION'] = ''  # Missing in the dump
        if not channel.feed.link.endswith('/'):
            context['SITE_URL'] = channel.feed.link + '/'
        else:
            context['SITE_URL'] = channel.feed.link

        context['BLOG_EMAIL'] = channel.feed.author_detail.email
        context['BLOG_AUTHOR'] = channel.feed.author_detail.name
        context['POSTS'] = '''(
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.html", "posts", "post.tmpl"),
            )'''
        context['PAGES'] = '''(
            ("articles/*.txt", "articles", "story.tmpl"),
            ("articles/*.rst", "articles", "story.tmpl"),
            )'''
        context['COMPILERS'] = '''{
            "rest": ('.txt', '.rst'),
            "markdown": ('.md', '.mdown', '.markdown', '.wp'),
            "html": ('.html', '.htm')
            }
            '''

        return context
コード例 #3
0
    def _write_site(self):
        context = SAMPLE_CONF.copy()

        context['DEFAULT_LANG'] = 'en'
        context['BLOG_TITLE'] = self._jekyll_config.get('title', 'EXAMPLE')

        context['BLOG_DESCRIPTION'] = self._jekyll_config.get(
            'description') or ''
        context['SITE_URL'] = self._jekyll_config.get('url', 'EXAMPLE')
        context['BLOG_EMAIL'] = self._jekyll_config.get('email') or ''
        context['BLOG_AUTHOR'] = self._jekyll_config.get('author') or ''

        context['POSTS'] = """(
            ("posts/*.md", "blog", "post.tmpl"),
            ("posts/*.rst", "blog", "post.tmpl"),
            ("posts/*.txt", "blog", "post.tmpl"),
            ("posts/*.html", "blog", "post.tmpl"),
            )"""

        if 'disqus_short_name' in self._jekyll_config:
            context['COMMENT_SYSTEM'] = 'disqus'
            context['COMMENT_SYSTEM_ID'] = self._jekyll_config[
                'disqus_short_name']

        if self._jekyll_config.get('', False):
            context['PRETTY_URLS'] = True
            context['INDEXES_PRETTY_PAGE_URL'] = True

        conf_template = self.generate_base_site()
        conf_out_path = self.get_configuration_output_path()

        conf_template_render = conf_template.render(**prepare_config(context))
        self.write_configuration(conf_out_path, conf_template_render)
コード例 #4
0
    def populate_context(zipfile, names):
        # We don't get much data here
        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = 'en'
        context['BLOG_DESCRIPTION'] = ''
        context['SITE_URL'] = 'http://example.com/'
        context['BLOG_EMAIL'] = ''

        # Get any random post, all have the same data
        with zipfile.open(names[0], 'r') as post_f:
            data = json.load(post_f)
            context['BLOG_TITLE'] = data['actor']['displayName']
            context['BLOG_AUTHOR'] = data['actor']['displayName']

        context['POSTS'] = '''(
            ("posts/*.html", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.html", "stories", "story.tmpl"),
            ("stories/*.rst", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #5
0
ファイル: import_gplus.py プロジェクト: ChillarAnand/plugins
    def populate_context(zipfile, names):
        # We don't get much data here
        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = 'en'
        context['BLOG_DESCRIPTION'] = ''
        context['SITE_URL'] = 'http://example.com/'
        context['BLOG_EMAIL'] = ''

        # Get any random post, all have the same data
        with zipfile.open(names[0], 'r') as post_f:
            data = json.load(post_f)
            context['BLOG_TITLE'] = data['actor']['displayName']
            context['BLOG_AUTHOR'] = data['actor']['displayName']

        context['POSTS'] = '''(
            ("posts/*.html", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.html", "stories", "story.tmpl"),
            ("stories/*.rst", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #6
0
ファイル: import_feed.py プロジェクト: getnikola/plugins
    def populate_context(channel):
        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = channel.feed.title_detail.language \
            if channel.feed.title_detail.language else 'en'
        context['BLOG_TITLE'] = channel.feed.title

        context['BLOG_DESCRIPTION'] = channel.feed.get('subtitle', '')
        context['SITE_URL'] = channel.feed.get('link', '').rstrip('/')
        context['BLOG_EMAIL'] = channel.feed.author_detail.get('email', '') if 'author_detail' in channel.feed else ''
        context['BLOG_AUTHOR'] = channel.feed.author_detail.get('name', '') if 'author_detail' in channel.feed else ''

        context['POSTS'] = '''(
            ("posts/*.html", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.html", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown', '.wp'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #7
0
ファイル: import_jekyll.py プロジェクト: ChillarAnand/plugins
    def _write_site(self):
        context = SAMPLE_CONF.copy()

        context["DEFAULT_LANG"] = "en"
        context["BLOG_TITLE"] = self._jekyll_config.get("title", "EXAMPLE")

        context["BLOG_DESCRIPTION"] = self._jekyll_config.get("description") or ""
        context["SITE_URL"] = self._jekyll_config.get("url", "EXAMPLE")
        context["BLOG_EMAIL"] = self._jekyll_config.get("email") or ""
        context["BLOG_AUTHOR"] = self._jekyll_config.get("author") or ""

        context[
            "POSTS"
        ] = """(
            ("posts/*.md", "blog", "post.tmpl"),
            ("posts/*.rst", "blog", "post.tmpl"),
            ("posts/*.txt", "blog", "post.tmpl"),
            ("posts/*.html", "blog", "post.tmpl"),
            )"""

        if "disqus_short_name" in self._jekyll_config:
            context["COMMENT_SYSTEM"] = "disqus"
            context["COMMENT_SYSTEM_ID"] = self._jekyll_config["disqus_short_name"]

        if self._jekyll_config.get("", False):
            context["PRETTY_URLS"] = True
            context["INDEXES_PRETTY_PAGE_URL"] = True

        conf_template = self.generate_base_site()
        conf_out_path = self.get_configuration_output_path()

        conf_template_render = conf_template.render(**prepare_config(context))
        self.write_configuration(conf_out_path, conf_template_render)
コード例 #8
0
ファイル: import_feed.py プロジェクト: marian-vignau/plugins
    def populate_context(channel):
        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = channel.feed.title_detail.language \
            if channel.feed.title_detail.language else 'en'
        context['BLOG_TITLE'] = channel.feed.title

        context['BLOG_DESCRIPTION'] = channel.feed.get('subtitle', '')
        context['SITE_URL'] = channel.feed.get('link', '').rstrip('/')
        context['BLOG_EMAIL'] = channel.feed.author_detail.get(
            'email', '') if 'author_detail' in channel.feed else ''
        context['BLOG_AUTHOR'] = channel.feed.author_detail.get(
            'name', '') if 'author_detail' in channel.feed else ''

        context['POSTS'] = '''(
            ("posts/*.html", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.html", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown', '.wp'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #9
0
    def _write_site(self):
        context = SAMPLE_CONF.copy()

        context['DEFAULT_LANG'] = 'en'
        context['BLOG_TITLE'] = self._jekyll_config.get('title', 'EXAMPLE')

        context['BLOG_DESCRIPTION'] = self._jekyll_config.get('description') or ''
        context['SITE_URL'] = self._jekyll_config.get('url', 'EXAMPLE')
        context['BLOG_EMAIL'] = self._jekyll_config.get('email') or ''
        context['BLOG_AUTHOR'] = self._jekyll_config.get('author') or ''

        context['POSTS'] = """(
            ("posts/*.md", "blog", "post.tmpl"),
            ("posts/*.rst", "blog", "post.tmpl"),
            ("posts/*.txt", "blog", "post.tmpl"),
            ("posts/*.html", "blog", "post.tmpl"),
            )"""

        if 'disqus_short_name' in self._jekyll_config:
            context['COMMENT_SYSTEM'] = 'disqus'
            context['COMMENT_SYSTEM_ID'] = self._jekyll_config[
                'disqus_short_name']

        if self._jekyll_config.get('', False):
            context['PRETTY_URLS'] = True
            context['INDEXES_PRETTY_PAGE_URL'] = True

        conf_template = self.generate_base_site()
        conf_out_path = self.get_configuration_output_path()

        conf_template_render = conf_template.render(**prepare_config(context))
        self.write_configuration(conf_out_path, conf_template_render)
コード例 #10
0
    def populate_context(channel):
        context = SAMPLE_CONF.copy()
        # blogger doesn't include the language in the dump
        context['DEFAULT_LANG'] = 'en'
        context['BLOG_TITLE'] = channel.feed.title

        context['BLOG_DESCRIPTION'] = ''  # Missing in the dump
        if not channel.feed.link.endswith('/'):
            context['SITE_URL'] = channel.feed.link + '/'
        else:
            context['SITE_URL'] = channel.feed.link

        context['BLOG_EMAIL'] = channel.feed.author_detail.email
        context['BLOG_AUTHOR'] = channel.feed.author_detail.name
        context['POSTS'] = '''(
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.html", "posts", "post.tmpl"),
            )'''
        context['PAGES'] = '''(
            ("articles/*.txt", "articles", "story.tmpl"),
            ("articles/*.rst", "articles", "story.tmpl"),
            )'''
        context['COMPILERS'] = '''{
            "rest": ('.txt', '.rst'),
            "markdown": ('.md', '.mdown', '.markdown', '.wp'),
            "html": ('.html', '.htm')
            }
            '''

        return context
コード例 #11
0
    def populate_context(self, channel):
        """Populate context with config for the site."""
        wordpress_namespace = channel.nsmap['wp']

        context = SAMPLE_CONF.copy()
        self.lang = get_text_tag(channel, 'language', 'en')[:2]
        context['DEFAULT_LANG'] = self.lang
        context['TRANSLATIONS_PATTERN'] = DEFAULT_TRANSLATIONS_PATTERN
        context['BLOG_TITLE'] = get_text_tag(channel, 'title',
                                             'PUT TITLE HERE')
        context['BLOG_DESCRIPTION'] = get_text_tag(
            channel, 'description', 'PUT DESCRIPTION HERE')
        context['BASE_URL'] = get_text_tag(channel, 'link', '#')
        if not context['BASE_URL']:
            base_site_url = channel.find('{{{0}}}author'.format(wordpress_namespace))
            context['BASE_URL'] = get_text_tag(base_site_url,
                                               None,
                                               "http://foo.com/")
        if not context['BASE_URL'].endswith('/'):
            context['BASE_URL'] += '/'
        context['SITE_URL'] = context['BASE_URL']

        author = channel.find('{{{0}}}author'.format(wordpress_namespace))
        context['BLOG_EMAIL'] = get_text_tag(
            author,
            '{{{0}}}author_email'.format(wordpress_namespace),
            "*****@*****.**")
        context['BLOG_AUTHOR'] = get_text_tag(
            author,
            '{{{0}}}author_display_name'.format(wordpress_namespace),
            "Joe Example")
        extensions = ['rst', 'txt', 'md', 'html']
        if self.use_wordpress_compiler:
            extensions.append('wp')
        POSTS = '(\n'
        PAGES = '(\n'
        for extension in extensions:
            POSTS += '    ("posts/*.{0}", "posts", "post.tmpl"),\n'.format(extension)
            PAGES += '    ("stories/*.{0}", "stories", "story.tmpl"),\n'.format(extension)
        POSTS += ')\n'
        PAGES += ')\n'
        context['POSTS'] = POSTS
        context['PAGES'] = PAGES
        COMPILERS = '{\n'
        COMPILERS += '''    "rest": ('.txt', '.rst'),''' + '\n'
        COMPILERS += '''    "markdown": ('.md', '.mdown', '.markdown'),''' + '\n'
        COMPILERS += '''    "html": ('.html', '.htm'),''' + '\n'
        if self.use_wordpress_compiler:
            COMPILERS += '''    "wordpress": ('.wp'),''' + '\n'
        COMPILERS += '}'
        context['COMPILERS'] = COMPILERS

        return context
コード例 #12
0
ファイル: import_tumblr.py プロジェクト: getnikola/plugins
 def populate_context(site_data):
     context = SAMPLE_CONF.copy()
     context['BLOG_TITLE'] = site_data['title']
     context['BLOG_DESCRIPTION'] = site_data['description']
     context['POSTS'] = '''(
         ("posts/*.html", "", "post.tmpl"),
     )'''
     context['COMPILERS'] = '''{
     "rest": ('.txt', '.rst'),
     "markdown": ('.md', '.mdown', '.markdown'),
     "html": ('.html', '.htm')
     }
     '''
     return context
コード例 #13
0
 def populate_context(site_data):
     context = SAMPLE_CONF.copy()
     context['BLOG_TITLE'] = site_data['title']
     context['BLOG_DESCRIPTION'] = site_data['description']
     context['POSTS'] = '''(
         ("posts/*.html", "", "post.tmpl"),
     )'''
     context['COMPILERS'] = '''{
     "rest": ('.txt', '.rst'),
     "markdown": ('.md', '.mdown', '.markdown'),
     "html": ('.html', '.htm')
     }
     '''
     return context
コード例 #14
0
    def populate_context(channel):
        wordpress_namespace = channel.nsmap['wp']

        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = get_text_tag(channel, 'language', 'en')[:2]
        context['TRANSLATIONS_PATTERN'] = DEFAULT_TRANSLATIONS_PATTERN
        context['BLOG_TITLE'] = get_text_tag(channel, 'title',
                                             'PUT TITLE HERE')
        context['BLOG_DESCRIPTION'] = get_text_tag(
            channel, 'description', 'PUT DESCRIPTION HERE')
        context['BASE_URL'] = get_text_tag(channel, 'link', '#')
        if not context['BASE_URL']:
            base_site_url = channel.find('{{{0}}}author'.format(wordpress_namespace))
            context['BASE_URL'] = get_text_tag(base_site_url,
                                               None,
                                               "http://foo.com/")
        if not context['BASE_URL'].endswith('/'):
            context['BASE_URL'] += '/'
        context['SITE_URL'] = context['BASE_URL']

        author = channel.find('{{{0}}}author'.format(wordpress_namespace))
        context['BLOG_EMAIL'] = get_text_tag(
            author,
            '{{{0}}}author_email'.format(wordpress_namespace),
            "*****@*****.**")
        context['BLOG_AUTHOR'] = get_text_tag(
            author,
            '{{{0}}}author_display_name'.format(wordpress_namespace),
            "Joe Example")
        context['POSTS'] = '''(
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.md", "posts", "post.tmpl"),
            ("posts/*.wp", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.rst", "stories", "story.tmpl"),
            ("stories/*.txt", "stories", "story.tmpl"),
            ("stories/*.md", "stories", "story.tmpl"),
            ("stories/*.wp", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown', '.wp'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #15
0
ファイル: import_wordpress.py プロジェクト: mgaitan/nikola
    def populate_context(channel):
        wordpress_namespace = channel.nsmap["wp"]

        context = SAMPLE_CONF.copy()
        context["DEFAULT_LANG"] = get_text_tag(channel, "language", "en")[:2]
        context["TRANSLATIONS_PATTERN"] = DEFAULT_TRANSLATIONS_PATTERN
        context["BLOG_TITLE"] = get_text_tag(channel, "title", "PUT TITLE HERE")
        context["BLOG_DESCRIPTION"] = get_text_tag(channel, "description", "PUT DESCRIPTION HERE")
        context["BASE_URL"] = get_text_tag(channel, "link", "#")
        if not context["BASE_URL"]:
            base_site_url = channel.find("{{{0}}}author".format(wordpress_namespace))
            context["BASE_URL"] = get_text_tag(base_site_url, None, "http://foo.com/")
        if not context["BASE_URL"].endswith("/"):
            context["BASE_URL"] += "/"
        context["SITE_URL"] = context["BASE_URL"]

        author = channel.find("{{{0}}}author".format(wordpress_namespace))
        context["BLOG_EMAIL"] = get_text_tag(
            author, "{{{0}}}author_email".format(wordpress_namespace), "*****@*****.**"
        )
        context["BLOG_AUTHOR"] = get_text_tag(
            author, "{{{0}}}author_display_name".format(wordpress_namespace), "Joe Example"
        )
        context[
            "POSTS"
        ] = """(
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.md", "posts", "post.tmpl"),
            ("posts/*.wp", "posts", "post.tmpl"),
        )"""
        context[
            "PAGES"
        ] = """(
            ("stories/*.rst", "stories", "story.tmpl"),
            ("stories/*.txt", "stories", "story.tmpl"),
            ("stories/*.md", "stories", "story.tmpl"),
            ("stories/*.wp", "stories", "story.tmpl"),
        )"""
        context[
            "COMPILERS"
        ] = """{
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown', '.wp'),
        "html": ('.html', '.htm')
        }
        """

        return context
コード例 #16
0
    def populate_context(names, path, config):
        # get info from configuration file
        context = SAMPLE_CONF.copy()
        context["DEFAULT_LANG"] = config["site"]["lang"]
        context["BLOG_TITLE"] = config["site"]["title"]
        context["SITE_URL"] = config["site"]["url"]
        context["BLOG_DESCRIPTION"] = config["site"]["descr"] if config[
            "site"]["descr"] else ""
        context["BLOG_EMAIL"] = config["site"]["email"] if config["site"][
            "email"] else ""

        # Get any random post, all have the same data
        with open(os.path.join(path, names[0])) as f:
            soup = bs4.BeautifulSoup(f, "html.parser")

        context["BLOG_AUTHOR"] = soup.find("a", "author").text
        profile_url = soup.find("a").get("href")

        context["POSTS"] = """(
            ("posts/*.html", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
        )"""

        context["COMPILERS"] = """{
        "rest": (".txt", ".rst"),
        "html": (".html", ".htm")
        }"""

        if config["site"]["main_url"]:
            context["NAVIGATION_LINKS"] = """{{
    DEFAULT_LANG: (
        ("{}", "Back"),
        ("/archive.html", "Archives"),
        ("/categories/index.html", "Share status"),
    ),
}}""".format(config["site"]["main_url"])
        else:
            context["NAVIGATION_LINKS"] = """{
    DEFAULT_LANG: (
        ("/archive.html", "Archives"),
        ("/categories/index.html", "Share status"),
    ),
}"""

        # Disable comments
        context["COMMENT_SYSTEM"] = ""

        return context
コード例 #17
0
    def populate_context(channel):
        wordpress_namespace = channel.nsmap['wp']

        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = get_text_tag(channel, 'language', 'en')[:2]
        context['TRANSLATIONS_PATTERN'] = DEFAULT_TRANSLATIONS_PATTERN
        context['BLOG_TITLE'] = get_text_tag(channel, 'title',
                                             'PUT TITLE HERE')
        context['BLOG_DESCRIPTION'] = get_text_tag(channel, 'description',
                                                   'PUT DESCRIPTION HERE')
        context['BASE_URL'] = get_text_tag(channel, 'link', '#')
        if not context['BASE_URL']:
            base_site_url = channel.find(
                '{{{0}}}author'.format(wordpress_namespace))
            context['BASE_URL'] = get_text_tag(base_site_url, None,
                                               "http://foo.com/")
        if not context['BASE_URL'].endswith('/'):
            context['BASE_URL'] += '/'
        context['SITE_URL'] = context['BASE_URL']

        author = channel.find('{{{0}}}author'.format(wordpress_namespace))
        context['BLOG_EMAIL'] = get_text_tag(
            author, '{{{0}}}author_email'.format(wordpress_namespace),
            "*****@*****.**")
        context['BLOG_AUTHOR'] = get_text_tag(
            author, '{{{0}}}author_display_name'.format(wordpress_namespace),
            "Joe Example")
        context['POSTS'] = '''(
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.md", "posts", "post.tmpl"),
            ("posts/*.wp", "posts", "post.tmpl"),
        )'''
        context['PAGES'] = '''(
            ("stories/*.rst", "stories", "story.tmpl"),
            ("stories/*.txt", "stories", "story.tmpl"),
            ("stories/*.md", "stories", "story.tmpl"),
            ("stories/*.wp", "stories", "story.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown', '.wp'),
        "html": ('.html', '.htm')
        }
        '''

        return context
コード例 #18
0
ファイル: import_wordpress.py プロジェクト: bspeice/nikola
    def populate_context(self, channel):
        """Populate context with config for the site."""
        wordpress_namespace = channel.nsmap["wp"]

        context = SAMPLE_CONF.copy()
        context["DEFAULT_LANG"] = get_text_tag(channel, "language", "en")[:2]
        context["TRANSLATIONS_PATTERN"] = DEFAULT_TRANSLATIONS_PATTERN
        context["BLOG_TITLE"] = get_text_tag(channel, "title", "PUT TITLE HERE")
        context["BLOG_DESCRIPTION"] = get_text_tag(channel, "description", "PUT DESCRIPTION HERE")
        context["BASE_URL"] = get_text_tag(channel, "link", "#")
        if not context["BASE_URL"]:
            base_site_url = channel.find("{{{0}}}author".format(wordpress_namespace))
            context["BASE_URL"] = get_text_tag(base_site_url, None, "http://foo.com/")
        if not context["BASE_URL"].endswith("/"):
            context["BASE_URL"] += "/"
        context["SITE_URL"] = context["BASE_URL"]

        author = channel.find("{{{0}}}author".format(wordpress_namespace))
        context["BLOG_EMAIL"] = get_text_tag(
            author, "{{{0}}}author_email".format(wordpress_namespace), "*****@*****.**"
        )
        context["BLOG_AUTHOR"] = get_text_tag(
            author, "{{{0}}}author_display_name".format(wordpress_namespace), "Joe Example"
        )
        extensions = ["rst", "txt", "md", "html"]
        if self.use_wordpress_compiler:
            extensions.append("wp")
        POSTS = "(\n"
        PAGES = "(\n"
        for extension in extensions:
            POSTS += '    ("posts/*.{0}", "posts", "post.tmpl"),\n'.format(extension)
            PAGES += '    ("stories/*.{0}", "stories", "story.tmpl"),\n'.format(extension)
        POSTS += ")\n"
        PAGES += ")\n"
        context["POSTS"] = POSTS
        context["PAGES"] = PAGES
        COMPILERS = "{\n"
        COMPILERS += """    "rest": ('.txt', '.rst'),""" + "\n"
        COMPILERS += """    "markdown": ('.md', '.mdown', '.markdown'),""" + "\n"
        COMPILERS += """    "html": ('.html', '.htm'),""" + "\n"
        if self.use_wordpress_compiler:
            COMPILERS += """    "wordpress": ('.wp'),""" + "\n"
        COMPILERS += "}"
        context["COMPILERS"] = COMPILERS

        return context
コード例 #19
0
    def populate_context(channel):
        context = SAMPLE_CONF.copy()
        # blogger doesn't include the language in the dump
        context["DEFAULT_LANG"] = "en"
        context["BLOG_TITLE"] = channel.feed.title

        context["BLOG_DESCRIPTION"] = ""  # Missing in the dump
        if not channel.feed.link.endswith("/"):
            context["SITE_URL"] = channel.feed.link + "/"
        else:
            context["SITE_URL"] = channel.feed.link

        context["BLOG_EMAIL"] = channel.feed.author_detail.email
        context["BLOG_AUTHOR"] = channel.feed.author_detail.name
        context[
            "POSTS"
        ] = """(
            ("posts/*.txt", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
            ("posts/*.html", "posts", "post.tmpl"),
            )"""
        context[
            "PAGES"
        ] = """(
            ("articles/*.txt", "articles", "story.tmpl"),
            ("articles/*.rst", "articles", "story.tmpl"),
            )"""
        context[
            "COMPILERS"
        ] = """{
            "rest": ('.txt', '.rst'),
            "markdown": ('.md', '.mdown', '.markdown', '.wp'),
            "html": ('.html', '.htm')
            }
            """

        return context
コード例 #20
0
    def populate_context(folder, names, path):
        # We don't get much data here
        context = SAMPLE_CONF.copy()
        context['DEFAULT_LANG'] = 'de'
        context['BLOG_DESCRIPTION'] = ''
        context['SITE_URL'] = 'http://localhost:8000/'
        context['BLOG_EMAIL'] = ''
        context['BLOG_TITLE'] = "Static G+ stream archive"

        # Get any random post, all have the same data
        with open(os.path.join(path, names[0])) as f:
            soup = bs4.BeautifulSoup(f, "html.parser")
            context['BLOG_AUTHOR'] = soup.find("a", "author").text

        context['POSTS'] = '''(
            ("posts/*.html", "posts", "post.tmpl"),
            ("posts/*.rst", "posts", "post.tmpl"),
        )'''
        context['COMPILERS'] = '''{
        "rest": ('.txt', '.rst'),
        "html": ('.html', '.htm')
        }
        '''
        return context