コード例 #1
0
ファイル: pages.py プロジェクト: moppermonster/eventy
def page_not_found(page_title):
    '''
    Returns 404 specific for /pages
    '''
    raw = '> [Home](/)\n'
    raw = raw + '# Page not found!\n'
    if len(page_title) > 20:
        page_title = page_title[:15] + '...'
    raw = raw + '##### Page `' + page_title + '` is nowhere to be found'
    return build_markdown('404', raw)
コード例 #2
0
ファイル: pages.py プロジェクト: moppermonster/eventy
def single_page(page_title, event):
    '''
    Returns html for single message page
    '''

    if not event:
        raw = '> This page has yet to be configured!'
    else:
        raw = '# ' + event

    return build_markdown(page_title, raw, _type='eventyxl')
コード例 #3
0
ファイル: pages.py プロジェクト: moppermonster/eventy
def double_page(page_title, event):
    '''
    Returns html for double message page
    '''

    if not event:
        raw = '> This page has yet to be configured!'
    else:
        raw = '# ' + event[0]
        if event[1]:
            raw = raw + '\n## ' + event[1]

    return build_markdown(page_title, raw, _type='eventyxl')
コード例 #4
0
ファイル: editors.py プロジェクト: moppermonster/eventy
def single_edit(page_title, event):
    '''
    Returns html for single config page
    '''
    css = """<style> input { width: 100%;} </style>"""
    raw_md = '# Edit: ' + page_title
    raw_md = raw_md + '\n> [cancel](/) - [view file](/pages/' + page_title + ')\n\n'
    raw_md = raw_md + '## Old:\n\n'
    raw_md = raw_md + '```' + event + '```\n'
    raw_md = raw_md + '## New:\n\n'
    htm = build_markdown(page_title, raw_md, css=css)
    htm = htm + """<form method='POST'><input name="message"><br>"""
    htm = htm + """<br><input type="submit"></form>"""
    return htm
コード例 #5
0
def delete(page_name):
    '''editor'''
    raw_md = "[BACK](/)\n"
    raw_md = raw_md + '# Delete ' + page_name
    htm = utils.build_markdown('delete: ' + page_name, raw_md)
    if not page_name in PAGES:
        return pages.page_not_found(page_name)
    if request.method == 'GET':
        htm = htm + """Confirm deletion of """ + page_name
        htm = htm + """<form method='POST'><input type="submit"></form>"""
        return htm
    if request.method == 'POST':
        del PAGES[page_name]
        return redirect('/')
コード例 #6
0
ファイル: editors.py プロジェクト: moppermonster/eventy
def table_edit(page_title, event_list):
    '''
    Returns html for table config page
    '''

    css = """<style> input { width: 50%;} </style>"""
    raw_md = '# Edit: ' + page_title
    raw_md = raw_md + '\n> [cancel](/) - [view file](/pages/' + page_title + ')\n\n'
    raw_md = raw_md + '# Table:\n\n'
    raw_md = raw_md + '> Use `!` as date to show on top, `0` as date to show at bottom of table.\n\n'
    htm = build_markdown(page_title, raw_md, css=css)
    for i in range(8):
        htm = htm + '''<form method='POST'><input name="date-'''
        htm = htm + str(
            i) + '''", value="''' + event_list[i]['date'] + '''">'''
        htm = htm + '''<input name="entry-''' + str(i)
        htm = htm + '''", value="''' + event_list[i]['entry'] + '''">'''
        htm = htm + '<br>'
    htm = htm + '''<br><input type="submit"></form>'''
    return htm
コード例 #7
0
ファイル: pages.py プロジェクト: moppermonster/eventy
def table_page(page_title, event_list):
    '''
    Returns html for event table page
    '''

    top = []
    middle = []
    bottom = []

    for event in event_list:
        date = event['date']
        entry = event['entry']

        if not entry:
            continue
        if not date:
            date = '-'

        if date in ['!']:
            text = '| ' + 'тЪая╕П' + ' | ' + entry + ' | '
            top.append(text)
        elif date in ['0']:
            text = '| ' + 'ЁЯдЦ' + ' | ' + entry + ' | '
            bottom.append(text)
        else:
            text = '| ' + date + ' | ' + entry + ' | '
            middle.append(text)

    raw = '## ' + page_title + '\n| Date | Event |\n'
    raw = raw + '| --- | --- |\n'
    if top:
        raw = raw + '\n'.join(top) + '\n'
    if middle:
        raw = raw + '\n'.join(middle) + '\n'
    if bottom:
        raw = raw + '\n'.join(bottom) + '\n'

    return build_markdown(page_title, raw, _type='eventy')
コード例 #8
0
ファイル: homepage.py プロジェクト: moppermonster/eventy
def home(pages, message=''):
    '''
    Returns the homepage as html
    '''

    css = """
    <style>
    .alert {
        padding: 10px;
        background-color: #222;
        color: white;
    }

    .closebtn {
        margin-left: 15px;
        color: white;
        font-weight: bold;
        float: right;
        font-size: 22px;
        line-height: 20px;
        cursor: pointer;
        transition: 0.3s;
    }

    .closebtn:hover {
        color: #ec6733;
    }
    input {
        width: 100%;
    }
    </style>
    """

    page_types = ['double', 'single', 'table']

    raw = '# eventy\n\n'
    top_menu = '> [refresh](/) - [save](/write) - [github](/)\n<br>\n>'
    raw = raw + '\n' + top_menu + '\n'
    if not pages:
        raw = raw + '\n\n' + '> No available pages!' + '\n\n'
    else:
        raw = raw + '## Pages\n'
        raw = raw + '| Page | Type | Style | Edit | Delete |\n| --- | --- | --- | --- | --- |\n'
        for entry in pages:
            raw = raw + '| [' + entry + '](/pages/' + entry + ') | ' + pages[entry]['type'] + ' '
            raw = raw + '| '+ pages[entry]['style'] + ' | ' +'[edit](/pages/' + entry + '/edit) '
            raw = raw + '| [delete](/pages/' + entry + '/delete) |\n'

    raw = raw + '\n\n## Add a page\n\n'

    html = build_markdown('eventy', raw, css=css)

    html = html + """
        <form method="POST">
            <select name="new-type">
    """
    for _type in page_types:
        html = html + '<option value="'+_type+'">'+_type+'</option>+\n'
    html = html + """
            </select>
            <input name="new-page">
            <br><br>
            <input type="submit">
        </form>
    """

    if message:
        html = html + '<div class="alert">\n'
        html = html + """<span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>\n"""
        html = html + '' + message + '\n'
        html = html + '</div>'

    return html