示例#1
0
def login_page_gen():
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Administration and moderation")
            ),
        E.BODY(
            E.H1(E.CLASS("heading"), "Farlight Engine Imageboard"),
            E.P(E.CLASS("loginmessage"), "You need to login"),
            E.FORM(E.CLASS("loginform"),
                   E.TABLE(
                       E.TR(E.TD('LOGIN'),
                            E.TD(E.INPUT(type = 'text', name = 'login', value = ''))
                            ),
                       E.TR(E.TD('PASSWORD'),
                            E.TD(E.INPUT(type = 'text', name = 'password', value = ''))
                            ),
                       ),
                   E.INPUT(type = 'submit', value = 'LOGIN'),
                   method = 'POST',
                   action = '/admin/login'
                   )
            )
        )
    return lxml.html.tostring(html)
示例#2
0
def process_file(input_file, output_file=None, encoding='utf-8'):
    if output_file is None:
        output_file = input_file + '.html'
    root = etree.parse(input_file).getroot()
    item = root.xpath("/items/item")[0]
    (method,) = item.xpath("method/text()")
    if method.lower() != "post":
        raise ValueError("Only POST requests are supported") # TODO
    (url,) = item.xpath("url/text()")
    (request,) = item.xpath("request")
    contents = request.text
    if request.get("base64"):
        contents = b64decode(contents)
    _, body = contents.split("\r\n\r\n", 1)
    output = E.HTML(
            E.HEAD(E.META(**{'http-equiv': 'Content-type',
                'content': 'text/html; charset=' + encoding})),
            E.BODY(
                E.FORM(
                    E.INPUT(type="submit"),
                    *(E.INPUT(type="hidden", name=name, value=value) for name, value
                        in decode_form_urlencoded_values(body, encoding)),
                    action=url, method=method
                    )
                )
            )
    with codecs.open(output_file, 'wb', encoding) as html_output:
        html_output.write(html.tostring(output, encoding=unicode))
    return output_file
示例#3
0
def password_change_menu():
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Administration and moderation")
            ),
        E.BODY(
            E.H1(E.CLASS("heading"), "Farlight Engine Imageboard"),
            E.P(E.CLASS("loginmessage"), "Change your password"),
            E.FORM(E.CLASS("loginform"),
                   E.INPUT(type = 'hidden', name = 'action', value = 'change'),
                   E.INPUT(type = 'hidden', name = 'instance', value = 'password'),
                   E.TABLE(
                       E.TR(E.TD('OLD PASSWORD'),
                            E.TD(E.INPUT(type = 'password', name = 'old_passwd', value = ''))
                            ),
                       E.TR(E.TD('NEW PASSWORD'),
                            E.TD(E.INPUT(type = 'password', name = 'new_passwd', value = ''))
                            ),
                       E.TR(E.TD('NEW PASSWORD AGAIN'),
                            E.TD(E.INPUT(type = 'password', name = 'new_passwd_again', value = ''))
                            ),
                       ),
                   E.INPUT(type = 'submit', value = 'LOGIN'),
                   method = 'POST',
                   action = '/admin'
                   )
            )
        )
    return lxml.html.tostring(html)
示例#4
0
 def manifest_html(self):
     """
     This is manifest.html the human useable form of the manifest.xml
     special object to list needed criteria or return a manifest given a
     set of criteria
     """
     web_page = \
             E.HTML(
                    E.HEAD(
                           E.TITLE(_("%s A/I Webserver -- "
                                     "Maninfest Criteria Test") %
                                     _DISTRIBUTION)
                    ),
                    E.BODY(
                           E.H1(_("Welcome to the %s A/I "
                                  "webserver") % _DISTRIBUTION),
                           E.H2(_("Manifest criteria tester")),
                           E.P(_("To test a system's criteria, all "
                                 "criteria listed are necessary. The "
                                 "format used should be:"),
                               E.BR(),
                               E.TT("criteria1=value1;criteria2=value2"),
                               E.BR(), _("For example:"),
                               E.BR(),
                               E.TT("arch=sun4u;mac=EEE0C0FFEE00;"
                                    "ipv4=172020025012;"
                                    "manufacturer=sun microsystems")
                           ),
                           E.H1(_("Criteria:")),
                           E.P(str(list(AIdb.getCriteria(
                               self.AISQL.getQueue(), strip=True)))),
                           E.FORM(E.INPUT(type="text", name="postData"),
                                  E.INPUT(type="submit"),
                                  action="manifest.xml",
                                  method="POST"
                           )
                    )
             )
     return lxml.etree.tostring(web_page, pretty_print=True)
示例#5
0
def list_boards_menu(board_list, purpose):
    """need to put boards table creating to a separate function in future"""
    posts_num_cell = E.DIV(E.SPAN('????', style = 'display:inline-block; width:4em; text-align:center;'),
                           E.INPUT(type='number', size='6', min='0', value='1', style = 'width: 6em;'),
                           E.SELECT(E.OPTION('Секунды', value='1'),
                                    E.OPTION('Минуты', value='60'),
                                    E.OPTION('Часы', value='3600'),
                                    E.OPTION('Дни', value='86400', selected='')
                                    ),
                           E.BUTTON('GET', onclick='get_posts_num_from_time(this)', type = 'button'))
    tablerows = [E.TR(E.TD(E.A(b.address, href = '/'+b.address)),
                      E.TD(b.tablename),
                      E.TD(str(b.name)),
                      E.TD(str(b.fullname)),
                      E.TD(str(b.description)),
                      E.TD(str(b.category)),
                      E.TD(str(b.pictures)),
                      E.TD(str(b.bumplimit)),
                      E.TD(str(b.maxthreads)),
                      E.TD(copy.copy(posts_num_cell))
                      )for b in board_list]
    #purpose will be applyed later
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), 
            E.TITLE("Creating board"),
            E.SCRIPT(type = 'text/javascript', src = '/adminscript.js') #js
            ),
        E.BODY(
            E.DIV(E.CLASS('adminupdiv'),
                E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
                E.H2(E.CLASS("heading"), "Listing boards"),
                ),
            E.TABLE(
                E.CLASS("boardstable"),
                E.TR(E.TH('Адрес'),
                     E.TH('Таблица'),
                     E.TH('Название'),
                     E.TH('Полное название'),
                     E.TH('Описание'),
                     E.TH('Категория'),
                     E.TH('Максимум картинок'),
                     E.TH('Бамплимит'),
                     E.TH('Максимум тредов'),
                     E.TH('Постов за последнее время')
                     ),
                *tablerows
                )
            )
        )
    return lxml.html.tostring(html)
示例#6
0
def board_creation_menu(): #here is the html board creation menu
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Creating board")
            ),
        E.BODY(
            E.DIV(E.CLASS('adminupdiv'),
                E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
                E.H2(E.CLASS("heading"), "Create new board"),
                ),
            E.DIV(E.CLASS("boardcreateform"),
            E.FORM(
                   E.INPUT(type = 'hidden', name = 'action', value = 'create'),
                   E.INPUT(type = 'hidden', name = 'instance', value = 'board'),
                   E.TABLE(
                       E.TR(E.TD('Address'),
                            E.TD(E.INPUT(type = 'text', name = 'address', value = ''))
                            ),
                       E.TR(E.TD('Tablename'),
                            E.TD(E.INPUT(type = 'text', name = 'tablename', value = ''))
                            ),
                       E.TR(E.TD('Name'),
                            E.TD(E.INPUT(type = 'text', name = 'name', value = ''))
                            ),
                       E.TR(E.TD('Fullname'),
                            E.TD(E.INPUT(type = 'text', name = 'fullname', value = ''))
                            ),
                       E.TR(E.TD('Description'),
                            E.TD(E.INPUT(type = 'text', name = 'description', value = ''))
                            ),
                       E.TR(E.TD('Pics number'),
                            E.TD(E.INPUT(type = 'number', name = 'picsnum', value = '', min = '0', max = '10'))
                            ),
                       E.TR(E.TD('Bumplimit'),
                            E.TD(E.INPUT(type = 'number', name = 'bumplimit', value = '', min = '0'))
                            ),
                       E.TR(E.TD('Max threads'),
                            E.TD(E.INPUT(type = 'number', name = 'maxthreads', value = '', min = '-1'))
                            ),
                       E.TR(E.TD(E.INPUT(type='checkbox', name='delposts', value='1', checked='checked'), 'Удаление постов', colspan='2', style='text-align:center;')),
                       E.TR(E.TD(E.INPUT(type='checkbox', name='delopposts', value='1', checked='checked'), 'Удаление тредов', colspan='2', style='text-align:center;')),
                       ),
                   E.INPUT(type = 'submit', value = 'Create'),
                   method='POST',
                   action='/admin/'
                   )
            )
            )
        )
    return lxml.html.tostring(html)
示例#7
0
 def _lxml_form_generator(self):
     """Is used for generating lxml post form"""
     formargs = []
     formargs.append(E.TR(
                           E.TD('EMAIL'),
                           E.TD(E.INPUT(type = 'text', name = 'email', value = '', id = 'emailfield'),
                                E.INPUT(type = 'submit', value = 'POST', id = 'postbutton')
                                ),
                           )
                     )
     formargs.append(E.TR(
                           E.TD('THEME'),
                           E.TD(E.INPUT(type = 'text', name = 'theme', value = '', size = '50')),
                           )
                     )
     formargs.append(E.TR(
                           E.TD('NAME'),
                           E.TD(E.INPUT(type = 'text', name = 'name', value = '', size = '50')),
                           )
                     )
     formargs.append(E.TR(
                           E.TD('TEXT'),
                           E.TD(E.TEXTAREA(name = 'text', rows = '8', cols = '50', placeholder = 'POST')),
                           )
                     )
     if self.pictures == 0:
         pass
     elif self.pictures == 1:
         formargs.append(E.TR(#should add checking if pics are available
                           E.TD('PICTURE'),
                           E.TD(E.INPUT(type = 'file', name = 'file0', accept = 'image/*'),
                                id = 'filecellone'),
                           )
                         )
     else:
         formargs.append(E.TR(#should add checking if pics are available
                           E.TD('PICTURE'),
                           E.TD(E.INPUT(type = 'file', name = 'file0', accept = 'image/*'),
                                E.BUTTON('+', type = 'button', onclick = 'add_file_input(this);', id = '0filebutton'),
                                E.SPAN(str(self.pictures), style = 'display:none;', id = 'maxfiles'),
                                id = 'filecellmany'),
                           )
                         )
     formargs.append(E.TR(#should add checking if deleting is available
                           E.TD('PASSWORD'),
                           E.TD(E.INPUT(type = 'password', name = 'password', value = '', size = '10'),
                                id = 'passwordcell'),
                           )
                     )
     if True:#should add checking if captcha is available
         formargs.append(E.TR(
                           E.TD(
                               E.CENTER('CAPTCHA WILL BE HERE'),
                               colspan = '2'
                               )
                           )
                         )
         formargs.append(E.TR(E.TD('CAPTCHA'),
                              E.TD(E.INPUT(type = 'text', name = 'captcha', value = '')),
                              )
                         )
         
     
     form = E.FORM(E.CLASS("postform"), #postform
                   E.INPUT(type = 'hidden', name = 'action', value = 'post'),
                   E.INPUT(type = 'hidden', name = 'op', value = '0', id = 'op_referer'),
                   E.SCRIPT('document.getElementById("op_referer").value = document.getElementById("thread").innerHTML;'),
                   E.TABLE(*formargs),
                   method = 'POST', action = '/'+self.address, enctype = 'multipart/form-data', id = 'postform')
     return form