コード例 #1
0
def get_pattern_markdown(template_name):
    replace_pattern = '{}$'.format(get_pattern_template_suffix())
    md_path = re.sub(replace_pattern, '', template_name)

    md_name = md_path + '.md'
    try:
        md_file = get_template(md_name)
    except TemplateDoesNotExist:
        return ''

    with open(md_file.origin.name, 'r', encoding='utf-8') as f:
        return markdown.markdown(f.read())
コード例 #2
0
ファイル: utils.py プロジェクト: petschna/linux-day
def get_pattern_config_str(template_name):
    replace_pattern = '{}$'.format(get_pattern_template_suffix())
    context_file = re.sub(replace_pattern, '', template_name)

    context_file = context_file + '.yaml'
    context_file = os.path.join(get_pattern_template_dir(), context_file)

    try:
        # Default encoding is platform-dependant, so we explicitly open it as utf-8.
        with open(context_file, 'r', encoding='utf-8') as f:
            return str(f.read())
    except IOError:
        return ''
コード例 #3
0
ファイル: utils.py プロジェクト: petschna/linux-day
def get_pattern_markdown(template_name):
    replace_pattern = '{}$'.format(get_pattern_template_suffix())
    md_file = re.sub(replace_pattern, '', template_name)

    md_file = md_file + '.md'
    md_file = os.path.join(get_pattern_template_dir(), md_file)

    try:
        # Default encoding is platform-dependant, so we explicitly open it as utf-8.
        with open(md_file, 'r', encoding='utf-8') as f:
            htmlmarkdown = markdown.markdown(f.read())
            return htmlmarkdown
    except IOError:
        return ''
コード例 #4
0
def get_pattern_config_str(template_name):
    replace_pattern = "{}$".format(get_pattern_template_suffix())
    context_path = re.sub(replace_pattern, "", template_name)

    context_name = context_path + ".yaml"
    try:
        context_file = get_template(context_name)
    except TemplateDoesNotExist:
        context_name = context_path + ".yml"
        try:
            context_file = get_template(context_name)
        except TemplateDoesNotExist:
            return ""

    return context_file.render()
コード例 #5
0
ファイル: utils.py プロジェクト: petschna/linux-day
def is_pattern(template_name):
    return (
        template_name.startswith(get_pattern_template_prefix())
        and template_name.endswith(get_pattern_template_suffix())
    )
コード例 #6
0
from django.conf.urls import url

from pattern_library import get_pattern_template_suffix, views

app_name = 'pattern_library'
urlpatterns = [
    # UI
    url(r'^$', views.IndexView.as_view(), name='index'),
    url(r'^pattern/(?P<pattern_template_name>[\w./-]+%s)$' %
        (get_pattern_template_suffix()),
        views.IndexView.as_view(),
        name='display_pattern'),

    # iframe rendering
    url(r'^render-pattern/(?P<pattern_template_name>[\w./-]+%s)$' %
        (get_pattern_template_suffix()),
        views.RenderPatternView.as_view(),
        name='render_pattern'),
]
コード例 #7
0
from django.conf.urls import url

from pattern_library import (
    get_pattern_template_prefix, get_pattern_template_suffix, views
)

app_name = 'pattern_library'
urlpatterns = [
    # UI
    url(r'^$', views.IndexView.as_view(), name='index'),
    url(
        r'^pattern/(?P<pattern_template_name>%s/[\w./-]+%s)$' % (
            get_pattern_template_prefix(), get_pattern_template_suffix()
        ),
        views.IndexView.as_view(),
        name='display_pattern'
    ),

    # iframe rendering
    url(
        r'^render-pattern/(?P<pattern_template_name>%s/[\w./-]+%s)$' % (
            get_pattern_template_prefix(), get_pattern_template_suffix()
        ),
        views.RenderPatternView.as_view(),
        name='render_pattern'
    ),
]