Beispiel #1
0
def show_tags():
    tags = Tag.all()
    tags_html = '\n'.join(list(map(lambda x: x.name + "<br>", tags)))
    form_html = "<form action=\"/tags\" method=\"POST\"><label>Enter a tag: </label><input name=\"tag-name\"></form>"
    #embed()
    return "<h1>The Ultimate Tag Manager</h1><h1>Hello World!</h1><img src=\"%s\" style=\"width:300px\"><div>%s</div><div>%s</div>" % (
        cfg['awesome_image'], tags_html, form_html)
Beispiel #2
0
def show_tags():
    g.setdefault(
        'image',
        cfg['awesome_image'])  # Flask.g: a way to pass var to a template
    #embed()
    # Note tags=Tag.all() ... another way to pass var to a Jinja2 template
    return render_template('index.html', tags=Tag.all())
Beispiel #3
0
 def post(self):
     self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
     postid = self.request.get("postid")
     userid = self.request.get("userid")
     posts = []
     followed = []
     if postid:
         query = Post.all()
         query.filter("postid = ", postid)
         posts = query.fetch(1000)
     elif userid:
         query = Stream.all()
         query.filter("userid = ", userid)
         query.order("-created")
         posts = query.fetch(30)
         query = Relation.all()
         query.filter("follower = ", userid)
         followed = query.fetch(1000)
     resultList = []
     for p in posts:
         resultTags = []
         postkey = ""
         outPostid = ""
         if postid:
             postkey = p.key()
             outPostid = postid
         else:
             postkey = p.postkey.key()
             outPostid = p.postkey.postid
         query = Tag.all()
         query.filter("postkey = ", postkey)
         tags = query.fetch(1000)
         for t in tags:
           found = False
           for f in followed:
             if t.userid == f.user:
               found = True
               break
             pass
           if found or postid:
             tag = {'user': t.userid,
                    'key': t.tag_key,
                    'value': t.tag_value}
             resultTags.append(tag)
           pass
         resultList.append({'postid': outPostid, 'post': p.post,
                            'tags': resultTags})
     resultStr = json.dumps(resultList, sort_keys=True,
                            indent=2)
     self.response.out.write(resultStr)
Beispiel #4
0
  def addRelation(self, follower, target, existing):
    found = False
    for cur in existing:
      if follower == cur.follower and target == cur.user:
        found = True
        break
      pass
    if not found:
      relation = Relation(follower=follower, user=target)
      relation.put()

      query = Tag.all()
      query.filter("userid = ", target)
      tags = query.fetch(1000)
      for tag in tags:
        tag.addToStream(follower)
Beispiel #5
0
def show_tags():
    tags = Tag.all()
    tags_html = '\n'.join(list(map(lambda x: "<a href=\"/tags/%s\">%s</a><br>" % (x.name, x.name), tags)))
    form_html = "<form action=\"/tags\" method=\"POST\"><label>Enter a tag: </label><input name=\"tag-name\"></form>"
    #embed()
    return "<h1>The Ultimate Tag Manager</h1><a href=\"/\">Home</a> <a href=\"/about\">About</a><h1>%s</h1><img src=\"%s\" style=\"width:300px\"><div>%s</div><div>%s</div>" % (cfg['title'], cfg['awesome_image'],tags_html, form_html)