Beispiel #1
0
def listurl(_request):
    res=Response()
    rsslist=Rssurl.select()
    t=SimpleTemplate(file_path=relativepath('urllist.html'))
    body=t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Beispiel #2
0
 def get_form(self, value=''):
     body = """<textarea name="${name}" ${attrs}>${value}</textarea>"""
     t = SimpleTemplate(body)
     return t.render({
         'name': self.name,
         'value': value,
         'attrs': self.attrs
     })
Beispiel #3
0
 def get_label(self, error):
     body = ("""<label for="${name}">${label}\n"""
             """$if error:\n"""
             """<span class="error">${error}</span>\n"""
             """$endif\n"""
             """</label>""")
     t = SimpleTemplate(body)
     return t.render({'name': self.name, 'label': self.label, 'error': error})
Beispiel #4
0
def get_add_form(values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    body=t.render({'message': u'RSS巡回用URLの追加',
                   'form':addform,
                   'values':values, 'errors':errors})
    res.set_body(body)
    return res
Beispiel #5
0
def index(_request, foo='', d={'counter': 0}):
    body = base_body % ('<p>Logged in!</p>')
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] += 1
    res.set_body(body)
    return res
def index(_request, d={'counter': '0'}):
    body = """<html><body><p>${counter}</p></body></html>"""
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d['counter'] = '1'
    res.set_body(body)
    return res
Beispiel #7
0
 def get_form(self, value=""):
     body = """<textarea name="${name}" ${attrs}>${value}</textarea>"""
     t = SimpleTemplate(body)
     return t.render({
         "name": self.name,
         "value": value,
         "attrs": self.attrs
     })
Beispiel #8
0
def index(_request, d={"counter": 0}):
    body = """<html><body><p>${counter}</p></body></html>"""
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d["counter"] += 1
    res.set_body(body)
    return res
Beispiel #9
0
def login_form(_request, values={}, errors={}):
    body = base_body % ("${form.display(values, errors)}")
    res = Response()
    t = SimpleTemplate(body)
    values["password"] = ""
    body = t.render({"form": loginform, "values": values, "errors": errors})
    res.set_body(body)
    return res
Beispiel #10
0
def index(_request, foo="", d={"counter": 0}):
    body = base_body % ("<p>Logged in!</p>")
    res = Response()
    t = SimpleTemplate(body)
    body = t.render(d)
    d["counter"] += 1
    res.set_body(body)
    return res
Beispiel #11
0
def login_form(_request, values={}, errors={}):
    body = base_body % ('${form.display(values, errors)}')
    res = Response()
    t = SimpleTemplate(body)
    values['password'] = ''
    body = t.render({'form': loginform, 'values': values, 'errors': errors})
    res.set_body(body)
    return res
Beispiel #12
0
 def get_form(self, value=""):
     body = ("""<input type="text" name="${name}" value="${value}" """
             """${attrs} />""")
     t = SimpleTemplate(body)
     return t.render({
         "name": self.name,
         "value": value,
         "attrs": self.attrs
     })
Beispiel #13
0
 def get_form(self, value=''):
     body = ("""<input type="text" name="${name}" value="${value}" """
             """ ${attrs} />""")
     t = SimpleTemplate(body)
     return t.render({
         'name': self.name,
         'value': value,
         'attrs': self.attrs
     })
Beispiel #14
0
 def display(self, values={}, errors={}):
     container = ''
     for f in self.forms:
         container += f.display(values.get(f.name, ''),
                                errors.get(f.name, ''))
         container += """<br clear="all"/>"""
     body = ("""<form ${attrs}>\n""" """${container}\n""" """</form>\n""")
     t = SimpleTemplate(body)
     return t.render({'attrs': self.attrs, 'container': container})
Beispiel #15
0
def get_add_form(values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    body = t.render({
        "message": u"RSS巡回用URLの追加",
        "form": addform,
        "values": values,
        "errors": errors
    })
    res.set_body(body)
    return res
Beispiel #16
0
 def get_form(self, value=''):
     body=("""$for v in options:\n"""
           """${v[1]} : """
           """<input type="radio" name="${name}" value="${v[0]}"\n"""
           """$if value == v[0]:\n"""
           """ checked \n"""
           """$endif\n"""
           """>\n"""
           """$endfor\n""")
     t = SimpleTemplate(body)
     return t.render({'name': self.name, 'value': value, 'options': self.options, 'attrs': self.attrs})
Beispiel #17
0
def add(_request, title="", url=""):
    res = Response()
    values, errors = addform.validate({"title": title, "url": url})
    if [x for x in Rssurl.select(url=url)]:
        errors["url"] = u"このURLは登録済みです"
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを追加しました"})
    res.set_body(body)
    return res
Beispiel #18
0
 def get_form(self, value=''):
     body = ("""<select name="${name}" ${attrs}>\n"""
             """$for v in options:\n"""
             """<option value="${v[0]}"\n"""
             """$if value==v[0]:\n"""
             """ selected \n"""
             """$endif\n"""
             """>${v[1]}</option>\n"""
             """$endfor\n"""
             """</select>\n""")
     t = SimpleTemplate(body)
     return t.render({'name': self.name, 'value': value, 'options': self.options, 'attrs': self.attrs})
Beispiel #19
0
def login_form(_request, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    values["password"] = ""
    body = t.render({
        "form": loginform,
        "values": values,
        "errors": errors,
        "message": u"ログイン"
    })
    res.set_body(body)
    return res
Beispiel #20
0
def login_form(_request, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath('form.html'))
    values['password'] = ''
    body = t.render({
        'form': loginform,
        'values': values,
        'errors': errors,
        'message': u'ログイン'
    })
    res.set_body(body)
    return res
Beispiel #21
0
def get_edit_form(item_id, values={}, errors={}):
    res=Response()
    t=SimpleTemplate(file_path=relativepath('form.html'))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values={'item_id':item_id, 'title':item.title, 'url':item.url}
    body=t.render({'message': u'RSS巡回用URLの編集',
                   'form':editform,
                   'values':values, 'errors':errors})
    res.set_body(body)
    return res
Beispiel #22
0
def add(_request, title='', url=''):
    res=Response()
    values, errors=addform.validate({'title':title, 'url':url})
    if [ x for x in Rssurl.select(url=url)]:
        errors['url']=u'このURLは登録済みです'
    if errors:
        return get_add_form(values, errors)
    Rssurl(title=title, url=url)
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを追加しました'})
    res.set_body(body)
    return res
Beispiel #23
0
def edit(_request, item_id, title='', url=''):
    res=Response()
    values, errors=editform.validate({'item_id':item_id,
                            'title':title, 'url':url})
    if errors:
        return get_edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title=title
        item.url=url
    t=SimpleTemplate(file_path=relativepath('posted.html'))
    body=t.render({'message': u'巡回用URLを編集しました'})
    res.set_body(body)
    return res
Beispiel #24
0
def index(_request):
    rsslist=[]
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    
    res=Response()
    p=path.join(path.dirname(__file__), 'rsslist.html')
    t=SimpleTemplate(file_path=p)
    body=t.render({'rsslist':rsslist[:20]})
    res.set_body(body)
    return res
Beispiel #25
0
def edit_form(_request, item_id, values={}, errors={}):
    res = Response()
    t = SimpleTemplate(file_path=relativepath("form.html"))
    if not values:
        for item in Rssurl.select(id=item_id):
            pass
        values = {"item_id": item_id, "title": item.title, "url": item.url}
    body = t.render({
        "message": u"RSS巡回用URLの編集",
        "form": editform,
        "values": values,
        "errors": errors
    })
    res.set_body(body)
    return res
Beispiel #26
0
def edit(_request, item_id, title="", url=""):
    res = Response()
    values, errors = editform.validate({
        "item_id": item_id,
        "title": title,
        "url": url
    })
    if errors:
        return edit_form(item_id, values, errors)
    for item in Rssurl.select(id=item_id):
        item.title = title
        item.url = url
        item.update()
    t = SimpleTemplate(file_path=relativepath("posted.html"))
    body = t.render({"message": u"巡回用URLを編集しました"})
    res.set_body(body)
    return res
Beispiel #27
0
p = path.join(path.dirname(__file__), "editform.html")

if not f.getvalue("posted"):
    id = f.getvalue("id")
    rss = Rssurl(id=int(id))
    value_dic.update({"title": rss.title, "url": rss.url, "item_id": id})
else:
    id = f.getvalue("id")
    title = unicode(f.getvalue("title", ""), "utf-8", "ignore")
    url = unicode(f.getvalue("url", ""), "utf-8", "ignore")
    value_dic.update({"title": title, "url": url, "item_id": id})
    if not title:
        errors["title"] = u"タイトルを入力してください"
    if not url.startswith("http://"):
        errors["url"] = u"正しいURLを入力してください"

    if not errors:
        rss = Rssurl(id=int(f.getvalue("id")))
        rss.title = unicode(f.getvalue("title", ""), "utf-8", "ignore")
        rss.url = f.getvalue("url", "")
        rss.update()
        p = path.join(path.dirname(__file__), "posted.html")
        value_dic["message"] = u"RSS取得を編集しました"

t = SimpleTemplate(file_path=p)
res = Response()
body = t.render(value_dic)
res.set_body(body)
print res
Beispiel #28
0
def index(_request, name='', body='', submit=''):
    res = Response()
    t = SimpleTemplate(htmlbody)
    body = t.render({'name': name, 'body': body})
    res.set_body(body)
    return res
Beispiel #29
0
 def get_form(self, value=""):
     body = ("""<input type="submit" value="${label}" """
             """ ${attrs} />""")
     t = SimpleTemplate(body)
     return t.render({"label": self.label, "attrs": self.attrs})
Beispiel #30
0
 def get_form(self, value=''):
     body = ("""<input type="reset" value="${label}" """ """ ${attrs} />""")
     t = SimpleTemplate(body)
     return t.render({'label': self.label, 'attrs': self.attrs})