Ejemplo n.º 1
0
def pcom_process_posts_page(postlist,archive,settings,list_meta,log,template_content):

    info_out = {'template_content': '',
    's3url': '',
    'posts_name': '',
    'posts_js_name': '',
    'posts_js_constant': '',
    'processed': False}

    post_type = ct.PCOM_SETTINGS_TYPE_POSTS
    posts_js = ct.PCOM_POSTLIST_CONSTANT_NAME_BASE + post_type + '.js'
    posts_name = sp.pcom_create_template_fileroot(post_type,settings)
    log['template_names'].append("Posts template base name: " + posts_name)

    if template_content:
        template_content = pcom_update_template_meta(template_content,{},no_meta=True)

        # create postlist js
        fileroot = post_type
        posts_constant,processed = pcom_process_template_postlist(postlist,archive,post_type,settings,list_meta,fileroot)

        if processed:
            info_out['template_content'] = template_content
            info_out['posts_js_name'] = posts_js
            info_out['posts_js_constant'] = posts_constant
            info_out['posts_name'] = posts_name
            info_out['s3url'] = posts_name + "/index.html"
            info_out['processed'] = True


    return info_out,log
Ejemplo n.º 2
0
def pcom_create_archive_info_references(list,base_string,settings):

    references = []

    for entry in list:
        sub_js_constant_root = entry['name']
        full_js_root = base_string.lower() + '-' + sub_js_constant_root
        filename = ct.PCOM_POSTLIST_CONSTANT_NAME_BASE + full_js_root + '.js'

        sub_fileroot = '_' + entry['fileroot']
        fileroot = base_string.lower() + sub_fileroot
        base_name = sp.pcom_create_template_fileroot(base_string,settings)
        url = base_name + '/' +  sub_js_constant_root + "/"
        s3url = url + 'index.html'

        test_html = base_name + '-' + sub_js_constant_root + ".html"
        title = entry['name']

        info = {'title': entry['name'],
        'description': '',
        'sub_js_root': ('-' + sub_js_constant_root),
        'full_js_root': full_js_root,
        'sub_fileroot': sub_fileroot,
        'fileroot': fileroot,
        'js_filename': filename,
        'test_html': test_html,
        'url': ("/" + url),
        's3url': s3url,
        'js_constant': '',
        'template_content':''}

        references.append(info)

    return references
Ejemplo n.º 3
0
def polimorf_add_main(main_data, sidebar_data, meta_present, wrap, fileroot,
                      settings, is_template, is_search):

    out_html = ct.PCOM_NO_ENTRY
    add_sidebar = ''
    template_tag = ''
    add_main = ''

    template_name = pcom_create_template_fileroot(fileroot, settings)

    if is_template and not is_search:

        template_tag = (
            ct.NL + pcom_open_custom_class_div("", sch.PM_MAIN_OUTER_OPEN) +
            ct.NL + pcom_open_custom_class_div("", sch.PM_MAIN_INNER_OPEN) +
            ct.NL + sch.PM_TEMPLATE_POSTLIST_INSERT + ct.NL +
            sch.PM_MAIN_INNER_CLOSE + ct.NL + sch.PM_MAIN_OUTER_CLOSE + ct.NL)

    if meta_present or is_template:

        if is_search:
            first_data = [pcom_insert_searchbar_for_search_page()]
            first_data.extend(main_data)
            main_data = first_data

        if main_data != ct.PCOM_NO_ENTRY:
            add_main = pcom_create_html_from_array(main_data) + template_tag
        elif is_template:
            add_main = template_tag

        if sidebar_data != [ct.PCOM_NO_ENTRY]:
            # add outer and inner wrappers to start
            add_main = (
                ct.NL +
                pcom_open_custom_class_div("", sch.PM_MAIN_OUTER_OPEN) +
                ct.NL +
                pcom_open_custom_class_div("", sch.PM_MAIN_INNER_OPEN) +
                ct.NL + sch.PM_MAIN_WITH_SIDEBAR_MAIN_OPEN + ct.NL + add_main +
                sch.PM_MAIN_WITH_SIDEBAR_MAIN_CLOSE + ct.NL)

            # add outer and inner wrappers to end
            add_sidebar = (sch.PM_MAIN_WITH_SIDEBAR_SIDEBAR_OPEN + ct.NL +
                           pcom_create_html_from_array(sidebar_data) +
                           sch.PM_MAIN_WITH_SIDEBAR_SIDEBAR_CLOSE + ct.NL +
                           sch.PM_MAIN_INNER_CLOSE + ct.NL +
                           sch.PM_MAIN_OUTER_CLOSE + ct.NL)

        if add_main != '':
            if wrap:
                out_html = (sch.PM_MAIN_WRAP_OPEN + add_main + add_sidebar)
            else:
                out_html = add_main + add_sidebar

        # finalise section html tabs
        if sidebar_data != [ct.PCOM_NO_ENTRY]:
            out_html = out_html.replace(ct.PCOM_SECTION_SIDEBAR_TAB, ct.T2)
        else:
            out_html = out_html.replace(ct.PCOM_SECTION_SIDEBAR_TAB, '')

    return out_html
Ejemplo n.º 4
0
def polimorf_head_and_title(meta_present, settings, meta, filename, fileroot):
    # from settings and other processes
    add_page_title = settings['site_title']
    is_template, is_search = pcom_filter_template(fileroot, settings)
    template_name = pcom_create_template_fileroot(fileroot, settings)

    if meta['page_title'] != md.DEFAULT_PAGE_TITLE:
        if is_template and not is_search:
            add_page_title = template_name.capitalize(
            ) + sch.PM_TEMPLATE_TITLE_REPLACEMENT
        elif is_search:
            add_page_title = template_name.capitalize()
        else:
            add_page_title = meta['page_title']

    description = settings['site_description']
    if meta['page_description'] != md.DEFAULT_PAGE_DESCRIPTION:
        if is_template and not is_search:
            description = template_name.capitalize(
            ) + sch.PM_TEMPLATE_DESCRIPTION_REPLACEMENT
        elif is_search:
            description = template_name.capitalize()
        else:
            description = meta['page_description'].replace('"', '')

    # template class in body
    body_tag = """<body>"""
    if is_template and not is_search:
        body_tag = sch.PM_TEMPLATE_BODY_CLASS.replace(
            sch.PM_TEMPLATE_BODY_NAME, template_name)

    add_description = '"' + description + '"'

    out_html = ct.PCOM_NO_ENTRY

    if meta_present:
        out_html = (
            sch.PM_HTML_OPEN_DECLARATION + ct.T1 + """<title>""" +
            add_page_title + """</title>""" + ct.NL + ct.T1 +
            """<link rel="shortcut icon" type"image/x-icon" href="/images/favicon.ico" />"""
            + ct.NL + ct.T1 +
            """<meta name="viewport" content="width=device-width, initial-scale=1">"""
            + ct.NL + ct.T1 + """<meta name="description" content=""" +
            add_description + """>""" + ct.NL + ct.T1 +
            """<link rel="stylesheet" href="/extras/font-awesome-4.7.0/css/font-awesome.min.css" type="text/css" media="screen">"""
            + ct.NL + ct.T1 +
            """<link rel="stylesheet" href="/fonts/Faustina-FontFace.css" type="text/css" media="screen">"""
            + ct.NL + ct.T1 +
            """<link rel="stylesheet" href="/css/normalize.css" type="text/css" media="screen">"""
            + ct.NL + ct.T1 +
            """<link rel="stylesheet" href="/css/style-core.css" type="text/css" media="screen">"""
            + ct.NL + ct.T1 +
            """<link rel="stylesheet" href="/css/style-responsive.css" type="text/css" media="screen">"""
            + ct.NL + ct.T1 + sch.DEFAULT_HEADER_ADDITIONS_START + ct.NL +
            ct.T1 + sch.DEFAULT_HEADER_ADDITIONS_END + ct.NL + ct.T1 +
            sch.HEADER_ADDITIONS_START + ct.NL + ct.T1 +
            sch.HEADER_ADDITIONS_END + ct.NL + """</head>""" + ct.NL +
            body_tag + ct.NL)

    return out_html
Ejemplo n.º 5
0
def determine_bucket_and_key(htmlOut, target, list_bucket):

    # default is target
    bucket = target
    outkey = ''

    # check for index (index.page) or 404 (404.page) or template
    if htmlOut.filename == "index.page":
        outkey = "index.html"
    elif htmlOut.filename == "404.page":
        outkey = "404.html"
    elif htmlOut.is_template and not htmlOut.is_search:
        outkey = sp.pcom_get_template_key(htmlOut.fileroot,
                                          htmlOut.site_settings) + ".template"
        bucket = list_bucket
    elif htmlOut.is_search:
        url = sp.pcom_create_template_fileroot(ct.PCOM_SETTINGS_TYPE_SEARCH,
                                               htmlOut.site_settings)
        outkey = url + "/index.html"
    else:
        if htmlOut.meta['url']:
            string_end = len(htmlOut.meta['url']) - 1
            # strip any initial and end slashes
            start_char = htmlOut.meta['url'][0].replace('/', '')
            bulk = htmlOut.meta['url'][1:string_end]
            end_char = htmlOut.meta['url'][string_end].replace('/', '')

            url = start_char + bulk + end_char

            outkey = url + "/index.html"
        else:
            outkey = htmlOut.fileroot + "/index.html"

    return outkey, bucket
Ejemplo n.º 6
0
    def __init__(self, content, log, site_settings, list_meta, filename,
                 dependencies, postlist):
        self.log = log
        self.site_settings = site_settings
        self.list_meta = list_meta

        self.filename = filename
        self.fileroot = filename.lower().replace('.post',
                                                 '').replace('.page', '')
        # check type of file
        self.is_root = sp.pcom_check_root(self.fileroot)
        self.is_template, self.is_search = sp.pcom_filter_template(
            self.fileroot, self.site_settings)
        # adjust fileroot for search
        if self.is_search:
            self.fileroot = sp.pcom_create_template_fileroot(
                self.fileroot, self.site_settings)

        # variable for adding template to page
        self.add_template = {}
        # reset some settings
        self.site_settings['current_file'] = filename
        self.site_settings['add_settings_to_dependencies'] = []
        self.site_settings['header_additions'] = []
        self.site_settings['footer_additions'] = []
        self.site_settings['add_default_header_additions'] = False
        self.site_settings['add_default_header_additions'] = False

        self.dependencies = dependencies
        self.all_data = {}
        self.html = ''
        self.html_array = []
        self.content = content
        self.insert_info = []
        self.postlist = postlist
        self.postlists_info = []
        self.content_meta_info = []
        self.pagination_info = {}
        self.pagination_name = ''
        self.raw_content = ''
        self.meta = {}

        # set postlist constant - check for search
        if not self.is_search:
            self.postlist_constant_name = 'postlist--' + sp.pcom_get_template_key(
                self.fileroot, self.site_settings) + '.js'
            self.pagination_name = ('pagination--' + sp.pcom_get_template_key(
                self.fileroot, self.site_settings) + '.js')
        else:
            self.postlist_constant_name = 'postlist--' + self.fileroot + '.js'
            self.pagination_name = 'pagination--' + self.fileroot + '.js'
Ejemplo n.º 7
0
def pcom_process_info_base_pages(info_list,base_type,template_content,postlist,archive,settings,list_meta,log):

    info_out = {'template_content': '',
    's3url': '',
    'base_name': '',
    'js_name': '',
    'js_constant': '',
    'processed': False}

    base_sub_info = []

    js_name = ct.PCOM_POSTLIST_CONSTANT_NAME_BASE + base_type + '.js'
    base_name = sp.pcom_create_template_fileroot(base_type,settings)
    log['template_names'].append(base_type + " template base name: " + base_name)

    if template_content:
        main_content = pcom_update_template_meta(template_content,{},no_meta=True)

        # create base info js
        if base_type == ct.PCOM_SETTINGS_TYPE_ARCHIVE:
            js_constant,base_sub_info,processed = \
            pcom_process_archive_info(archive,settings,base_type,base_name,base_type)
        else:
            js_constant,base_sub_info,processed = \
            pcom_process_template_list_info(info_list,settings,base_type,base_type)

        if processed:
            info_out['template_content'] = main_content
            info_out['js_name'] = js_name
            info_out['js_constant'] = js_constant
            info_out['base_name'] = base_name
            info_out['s3url'] = base_name + "/index.html"
            info_out['processed'] = True

            for ind,info in enumerate(base_sub_info):
                sub_content = pcom_update_template_meta(template_content,info)
                sub_js_constant,processed = \
                pcom_process_template_postlist(postlist,archive,base_type,settings,list_meta,info['fileroot'],sub=info['title'])

                base_sub_info[ind]['template_content'] = sub_content
                base_sub_info[ind]['js_constant'] = sub_js_constant


    return info_out,base_sub_info,log
Ejemplo n.º 8
0
def pcom_create_sub_template_backlink(type,settings):

    back_link_text = ''
    back_link = ''

    if settings['template_sub_header_back_link_text'][type] != ct.PCOM_JSON_LOAD_ERROR:
        back_link_text = settings['template_sub_header_back_link_text'][type].rstrip().lstrip()
        back_link_text = sp.pcom_replace_quotes(back_link_text)
        back_link_template = sch.PM_SUB_TEMPLATE_BACK_LINK
        back_link_url = "/" + sp.pcom_create_template_fileroot(type,settings) + "/"

        if back_link_text:
            back_link = '\\' +ct.NL
            back_link += back_link_template.replace(sch.PM_POSTLIST_TEMPLATE_BACKLINK_NAME,back_link_text)
            back_link = back_link.replace(sch.PM_POSTLIST_TEMPLATE_BACKLINK,back_link_url)

            back_link = sp.pcom_add_3tabs_to_content_line(back_link)

    return back_link