Example #1
0
def contact(page, url, code):
    """ """
    title       = page['title'][code]
    description = page['description'][code]
    content     = get_content_dict(page, code)
    
    if request.method == 'POST':
        text = request.form['text']
        name = request.form['name']
        email = '*****@*****.**'
        title = 'Info'
        text_email = """\
        <h3>I'm """+name+"""</h3>
        <p style="font-size:15px">"""+text+"""</p>"""
        text = 'I\'m %s \n %s' % (name, text)
        g.email_text = text_email
        g.message = 'email sent'
        g.status = 'mes-green'
Example #2
0
def contact(page, url, code):
    """ """
    title = page['title'][code]
    description = page['description'][code]
    content = get_content_dict(page, code)

    if request.method == 'POST':
        text = request.form['text']
        name = request.form['name']
        email = '*****@*****.**'
        title = 'Info'
        text_email = """\
        <h3>I'm """ + name + """</h3>
        <p style="font-size:15px">""" + text + """</p>"""
        text = 'I\'m %s \n %s' % (name, text)
        g.email_text = text_email
        g.message = 'email sent'
        g.status = 'mes-green'
Example #3
0
def render_content_page(num_of_path, path):
    """ 
    Using the path of the url, look inside the collection of pages 
    that matches the page. If it matches, then it is rendered. 

    The main for loop is searching the "page_document" by 
    the languages "code_lan", inside every page we serch the kind of
    url with a specific "num_of_path", like url_1.en or url_2.it 
        { 
            "_id" : ObjectId("123456"), 
            ...
            "url" : { 
                "en" : "about/story", 
                "it" : "chi_siamo/storia" 
            }, 
            "url_2" : { 
                "en" : [  "about",  "story" ], 
                "it" : [  "chi_siamo",  "storia" ] 
            }, 
            ... 
        }
    """
    languages = g.languages_object.available_lang_code

    # Retrive page document by g.lan
    code = g.lang
    page_document = get_page_content(code, num_of_path, path)

    if page_document is None: 
        # Retrive page document by one of the available languages
        for code_lan in languages:
            code = code_lan
            page_document = get_page_content(code, num_of_path, path)
            if page_document is not None:
                break
    
    # If page is None then there doesn't exist 
    # the page for that url
    if page_document is None:
        abort(404)
    else:
        
        # 1) dinamic page
        # ===============================================================
        page_from = page_document['from']
        page_import = page_document['import']
        if page_from and page_import:
            page_from = "pages."+page_from
            modules = page_from.split(".")
            if len(modules) == 1:
                module = __import__(page_from, globals(), locals(), [], -1)
                method_to_call = getattr(module, page_import)
            else:
                module = __import__(page_from, globals(), locals(), [], -1)
                module_called = getattr(module, modules[1])
                method_to_call = getattr(module_called, page_import)
            return method_to_call(page_document, path, code)
        
        # 2) static page
        # ===============================================================
        title = page_document['title'].get(code, '')
        description = page_document['description'].get(code, '')
        content = {}
        if page_document['content']:
            content = get_content_dict(page_document, code)
            
        # For every page you must specify the file where you want 
        # to use the contents stored in the database.
        template_file = 'pages/{0}.html'.format(page_document['file'])
        return render_template(template_file, **locals())
Example #4
0
def render_content_page(num_of_path, path):
    """ 
    Using the path of the url, look inside the collection of pages 
    that matches the page. If it matches, then it is rendered. 

    The main for loop is searching the "page_document" by 
    the languages "code_lan", inside every page we serch the kind of
    url with a specific "num_of_path", like url_1.en or url_2.it 
        { 
            "_id" : ObjectId("123456"), 
            ...
            "url" : { 
                "en" : "about/story", 
                "it" : "chi_siamo/storia" 
            }, 
            "url_2" : { 
                "en" : [  "about",  "story" ], 
                "it" : [  "chi_siamo",  "storia" ] 
            }, 
            ... 
        }
    """
    languages = g.languages_object.available_lang_code

    # Retrive page document by g.lan
    code = g.lang
    page_document = get_page_content(code, num_of_path, path)

    if page_document is None:
        # Retrive page document by one of the available languages
        for code_lan in languages:
            code = code_lan
            page_document = get_page_content(code, num_of_path, path)
            if page_document is not None:
                break

    # If page is None then there doesn't exist
    # the page for that url
    if page_document is None:
        abort(404)
    else:

        # 1) dinamic page
        # ===============================================================
        page_from = page_document['from']
        page_import = page_document['import']
        if page_from and page_import:
            page_from = "pages." + page_from
            modules = page_from.split(".")
            if len(modules) == 1:
                module = __import__(page_from, globals(), locals(), [], -1)
                method_to_call = getattr(module, page_import)
            else:
                module = __import__(page_from, globals(), locals(), [], -1)
                module_called = getattr(module, modules[1])
                method_to_call = getattr(module_called, page_import)
            return method_to_call(page_document, path, code)

        # 2) static page
        # ===============================================================
        title = page_document['title'].get(code, '')
        description = page_document['description'].get(code, '')
        content = {}
        if page_document['content']:
            content = get_content_dict(page_document, code)

        # For every page you must specify the file where you want
        # to use the contents stored in the database.
        template_file = 'pages/{0}.html'.format(page_document['file'])
        return render_template(template_file, **locals())