Esempio n. 1
0
File: dj.py Progetto: hchapman/WBOR
 def post(self):
   errors = ""
   title = self.request.get("title")
   text = self.request.get("text")
   post_date = datetime.datetime.now();
   slug = self.request.get("slug")
   post = BlogPost.new(
     title=title,
     text=text,
     post_date=post_date,
     slug=slug)
   posts = BlogPost.get_last(num=2)
   if BlogPost.get_by_slug(slug, post_date=post_date):
     errors = ("Error: this post has a duplicate slug to another post from "
               "the same day.  This probably shouldn't happen often.")
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'errors': errors,
     'post': post,
     'posts': posts,
   }
   if errors:
     self.response.out.write(
         template.render(get_path("dj_createpost.html"), template_values))
   else:
     post.put()
     self.session.add_flash("Post \"%s\" successfully added." % title)
     self.redirect("/")
Esempio n. 2
0
    def post(self,post_id=None):
        title = self._get_title()
        body  = self._get_body()

        post = BlogPost() if post_id == None else ndb.Key(urlsafe = post_id).get()

        post.title = title
        post.body  = body
        post.put()
        self.redirect("/")
Esempio n. 3
0
 def post(self):
     #Check referer to prevent CSRF
     #if self.request.referer != "http://www.kylevermeer.com/blog/create_new":
     #    return webapp2.redirect('/about')
     title = self.request.get("title") 
     author = self.request.get("author")
     body = self.request.get("body")
     password = self.request.get("password")
     
     #Check password
     if password != "betsy says post":
         return webapp2.redirect('/blog')
         
     
     blog_post_number_query = BlogPost.all(keys_only=True)
     num_blog_posts = blog_post_number_query.count()
     new_blog_post_num = str(num_blog_posts+1)
     new_key_name = "BlogPost" + new_blog_post_num
     
     #Find last blog post to set up linked list
     last_blog_post = BlogPost.get_by_key_name("BlogPost"+str(num_blog_posts))
     new_blog_post = BlogPost(author=author,title=title,body=body, key_name= new_key_name)
     
     #If this is first blog post
     if last_blog_post is None:
         new_blog_post.next = None
     else :
         last_blog_post.previous = new_blog_post.key()
         last_blog_post.put()
         new_blog_post.next = last_blog_post.key()
     new_blog_post.previous = None
     new_blog_post.put()
     self.response.out.write("")
     return webapp2.redirect('/blog')
Esempio n. 4
0
    def post(self, post_id):
        """ checking whether user is login, if not, redirect to login page """
        if not self.user:
            self.redirect("/login")
        else:
            comment = self.request.get('comment')
            if comment:
                post = BlogPost.get_by_id(int(post_id))
                if not post:
                    msg = 'The post does not exist'
                    self.render('error.html', error=msg, user=self.user)
                else:
                    """ use post.key as the parent of the Comment instance """
                    c = Comment(parent=post.key,
                                comment=comment,
                                commented_by=self.user.name,
                                commented_by_ukey=self.user.key)
                    c.put()

                    # sleep 1s to make database updated
                    time.sleep(1)
                    """ get all comments from db again to display """
                    comments = Comment.query(
                        ancestor=post.key).order(-Comment.created).fetch()
                    self.render("comment.html",
                                p=post,
                                comments=comments,
                                user=self.user)
            else:
                msg = "Please enter a comment!"
                self.render('error.html',
                            error_comment=msg,
                            post_id=post_id,
                            user=self.user)
Esempio n. 5
0
 def post(self, post_id):
     """ make sure user is signed in and user owns the post """
     if not self.user:
         self.redirect("/login")
     else:
         post = BlogPost.get_by_id(int(post_id))
         edit_subject = self.request.get('subject')
         edit_content = self.request.get('content')
         if not post:
             msg = 'The post does not exist'
             self.render('error.html', error=msg, user=self.user)
         else:
             """ make sure user owns the post """
             if self.user.key.id() == post.user_id:
                 if edit_subject and edit_content:
                     post.subject = edit_subject
                     post.content = edit_content
                     post.put()
                     self.redirect('/blog/%s' % str(post.key.id()))
                 else:
                     error = "Please enter subject and content!"
                     self.render("edit-post.html",
                                 subject=edit_subject,
                                 content=edit_content,
                                 error=error,
                                 user=self.user,
                                 p=post)
             else:
                 msg = 'You are not allowed to edit this post'
                 self.render('error.html', error=msg, user=self.user)
Esempio n. 6
0
    def get(self, post_id):
        """ checking whether user is login, if not, redirect to login page """
        if self.user:
            post = BlogPost.get_by_id(int(post_id))

            if not post:
                msg = 'The post does not exist'
                self.render('error.html', post_404=msg, user=self.user)
            else:
                user_id = post.user_id
                if not (self.user.key.id() == user_id):
                    """ if the user has never liked the post before or
                    no one has liked it before """
                    if post.liked_by.find(self.user.name) == -1 \
                            or post.like == 0:
                        error = "you can not unlike the post"
                        self.render('error.html', error=error, user=self.user)
                    else:
                        post.like -= 1
                        print str(post.like)
                        post.liked_by = \
                            post.liked_by.replace(self.user.name, "")
                        post.put()
                        self.render('permalink.html',
                                    post=post,
                                    user=self.user)
                else:
                    error = 'You are not allowed to Unlike your own post'
                    self.render('error.html', error=error, user=self.user)
        else:
            self.redirect("/login")
Esempio n. 7
0
 def get(self, post_id):
     if not self.user:
         self.redirect("/login")
     else:
         post = BlogPost.get_by_id(int(post_id))
         if not post:
             msg = 'The post does not exist'
             self.render('error.html', error=msg, user=self.user)
         else:
             # compare user id that created the post with the login user id
             if self.user.key.id() == post.user_id:
                 post.key.delete()
                 """ sleep 1s for google datastore to be updated, otherwise
                 deleted data still show up """
                 time.sleep(1)
                 """ delete all comments from the post also """
                 comments = Comment.query(
                     ancestor=post.key).order(-Comment.created).fetch()
                 if comments:
                     """ start deleting if there is comment """
                     for c in comments:
                         c.key.delete()
                 self.redirect('/blog')
             else:
                 msg = 'You are not allowed to delete this post'
                 self.render('error.html', error=msg, user=self.user)
Esempio n. 8
0
    def get(self, post_id):
        post = BlogPost.get_by_id(int(post_id))
        if not post:
            self.error(404)
            return

        self.render("permalink.html", post=post, user=self.user)
Esempio n. 9
0
  def get(self):
    ## Album list disabled until it is further optimized.
    #album_list = []
    album_list = Album.get_new(num=36)
    start = datetime.date.today() - datetime.timedelta(days=6)
    end = datetime.date.today() + datetime.timedelta(days=1)
    song_num = 10
    album_num = 10
    logging.debug("Calling get top")
    top_songs, top_albums = Play.get_top(start, end, song_num, album_num)
    posts = BlogPost.get_last(num=3)
    events = Event.get_upcoming(num=3)

    template_values = {
      'news_selected': True,
      'flash': self.flashes,
      'session': self.session,
      'album_list': album_list,
      'top_songs': top_songs,
      'top_albums': top_albums,
      'posts': posts,
      'events': events,
      }
    self.response.out.write(template.render(get_path("index.html"),
                                            template_values))
Esempio n. 10
0
 def get(self, post_id, comment_id):
     """ checking whether user is login, if not, redirect to login page """
     if not self.user:
         self.redirect("/login")
     else:
         post = BlogPost.get_by_id(int(post_id))
         if not post:
             msg = 'The post does not exist'
             self.render('error.html', error=msg, user=self.user)
         else:
             comment = Comment.get_by_id(int(comment_id), post.key)
             if comment:
                 """ make sure user owns the comment """
                 if self.user.key.id() == comment.commented_by_ukey.id():
                     comment.key.delete()
                     # sleep 1s to make database updated
                     time.sleep(1)
                     """ get all comments from db again to display """
                     comments = Comment.query(
                         ancestor=post.key).order(-Comment.created).fetch()
                     self.render("comment.html",
                                 p=post,
                                 comments=comments,
                                 user=self.user)
                 else:
                     msg = 'You are not allowed to delete this comment'
                     self.render('error.html', error=msg, user=self.user)
             else:
                 msg = 'Comment does not exist'
                 self.render('error.html', error=msg, user=self.user)
Esempio n. 11
0
File: dj.py Progetto: hchapman/WBOR
 def get(self, event_key):
   event = models.Event.get(event_key)
   if not event:
     self.session.add_flash(
         "Unable to find the requested event.  Please try again.")
     self.redirect("/dj/")
     return
   day = event.event_date.strftime("%m/%d/%Y")
   hour = event.event_date.strftime("%H")
   minute = event.event_date.strftime("%M")
   posts = BlogPost.get_last(num=2)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'editing': True,
     'event': event,
     'day': day,
     'hour': hour,
     'minute': minute,
     'hours': [str(i).rjust(2, "0") for i in range(24)],
     'minutes': [str(i).rjust(2, "0") for i in range(0, 60, 15)],
     'posts': posts,
   }
   self.response.out.write(
       template.render(get_path("dj_create_event.html"), template_values))
Esempio n. 12
0
File: dj.py Progetto: hchapman/WBOR
 def post(self, date_string, slug):
   errors = ""
   title = self.request.get("title")
   text = self.request.get("text")
   slug = self.request.get("slug")
   post_key = ndb.Key(urlsafe=self.request.get("post_key"))
   post = BlogPost.get(post_key)
   if not post:
     self.session.add_flash(
       "The post you're looking for does not exist.  "
       "Something strange has occurred.")
     # this shouldn't happen unless people are fiddling around with
     # POST values by hand I think
     self.redirect("/")
     return
   if self.request.get("submit") == "Delete Post":
     post.delete()
     self.session.add_flash("Post deleted.")
     self.redirect("/")
     return
   duplicate = BlogPost.get_by_slug(slug, post_date=post.post_date)
   old_slug = post.slug
   post.slug = slug
   if duplicate:
     if duplicate.key != post_key:
       errors = ("This post has a duplicate slug to another post "
                 "from the same day.  Please rename the slug.")
       post.slug = old_slug
   post.title = title
   post.text = text
   posts = BlogPost.get_last(num=2)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'errors': errors,
     'post': post,
     'editing': True,
     'posts': posts,
   }
   if errors:
     self.response.out.write(
       template.render(get_path("dj_createpost.html"), template_values))
   else:
     post.put()
     self.session.add_flash("Successfully altered post %s" % post.title)
     self.redirect("/")
Esempio n. 13
0
 def get(self):
   template_values = {
     'token': self.request.get("token"),
     'session': self.session,
     'flash': self.flashes,
     'posts': BlogPost.get_last(num=3),
   }
   self.response.out.write(
     template.render(get_path("signup.html"), template_values))
Esempio n. 14
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   posts = BlogPost.get_last(2)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'posts': posts,
   }
   self.response.out.write(
       template.render(get_path("dj_createpost.html"), template_values))
Esempio n. 15
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   program = cache.getProgram(self.program_key)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'program': program,
     'posts': BlogPost.get_last(2),
   }
   self.response.out.write(
     template.render(get_path("dj_myshow.html"), template_values))
Esempio n. 16
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   dj = Dj.get(self.dj_key)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'dj': dj,
     'posts': BlogPost.get_last(1),
   }
   self.response.out.write(
     template.render(get_path("dj_self.html"), template_values))
Esempio n. 17
0
File: dj.py Progetto: hchapman/WBOR
 def get(self, date_string, slug):
   post_date = datetime.datetime.strptime(date_string, "%Y-%m-%d")
   post = BlogPost.get_by_slug(slug, post_date=post_date)
   if not post:
     self.session.add_flash(
         "The post you're looking for does not exist.  "
         "But you can look at actual posts below :)")
     self.redirect("/")
     return
   posts = BlogPost.get_last(num=2)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'post': post,
     'editing': True,
     'posts': posts,
   }
   self.response.out.write(
     template.render(get_path("dj_createpost.html"), template_values))
Esempio n. 18
0
File: dj.py Progetto: hchapman/WBOR
  def get(self):
    dj_list = [] #Dj.getAll() # This is TERRIBLE PRACTICE

    template_values = {
      'dj_list': dj_list,
      'session': self.session,
      'flash': self.flashes,
      'posts': BlogPost.get_last(num=3),
    }
    self.response.out.write(template.render(get_path("dj_manage_djs.html"),
      template_values))
Esempio n. 19
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   posts = BlogPost.get_last(num=2)
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'editing': False,
     'hours': [str(i).rjust(2, "0") for i in range(24)],
     'minutes': [str(i).rjust(2, "0") for i in range(0, 60, 15)],
     'posts': posts,
   }
   self.response.out.write(
       template.render(get_path("dj_create_event.html"), template_values))
Esempio n. 20
0
    def post(self):
        """ make sure user is signed in before handling post request """
        if not self.user:
            self.redirect("/login")
        else:
            subject = self.request.get('subject')
            content = self.request.get('content')
            if subject and content:
                post = BlogPost(subject=subject,
                                content=content,
                                user_id=self.user.key.id())

                post.put()
                self.redirect('/blog/%s' % str(post.key.id()))
            else:
                error = "Please enter subject and content!"
                self.render("new-post.html",
                            subject=subject,
                            content=content,
                            error=error,
                            user=self.user)
Esempio n. 21
0
 def get(self, date_string, post_slug):
   post_date = datetime.datetime.strptime(date_string, "%Y-%m-%d")
   post = BlogPost.get_by_slug(post_slug, post_date=post_date)
   if not post:
     self.session.add_flash(
       "The post you requested could not be found.  Please try again.")
     self.redirect('/')
     return
   template_values = {
     'session': self.session,
     'post': post,
     }
   self.response.out.write(template.render("blog_post.html", template_values))
Esempio n. 22
0
def create_blog_post_response(year = None,month = None,day = None,title = None):
    blog_post_query = BlogPost.all().order('-date')
    if year is not None:
        blog_post_query.filter('year =',long(year))
        blog_post_query.filter('month =',long(month))
        blog_post_query.filter('day =',long(day))
        blog_post_query.filter('title =',unquote_plus(title))
    blog_post = blog_post_query.get()
    template_values = {
        "blog_post" : blog_post
    }
    template= jinja_environment.get_template('blog.html')
    return template.render(template_values)
Esempio n. 23
0
  def get(self):
    # TODO: Please please fix this. Although realistically it will be fixed on
    # models rework in future.
    # So general MGMT can edit contacts page
    contacts = BlogPost.get_by_slug("contacts-page")

    template_values = {
      'contact_selected': True,
      'session': self.session,
      'contacts': contacts
    }
    self.response.out.write(
      template.render(get_path("contact.html"), template_values))
Esempio n. 24
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   permissions = Permission.get_all()
   template_values = {
     'permissions': [{
       'key': p.key,
       'title': p.title,
       'dj_list': [Dj.get(d) for d in p.dj_list],
       } for p in permissions],
     'session': self.session,
     'flash': self.flashes,
     'posts': BlogPost.get_last(num=2),
   }
   self.response.out.write(
       template.render(get_path("dj_permissions.html"), template_values))
Esempio n. 25
0
File: dj.py Progetto: hchapman/WBOR
 def get(self):
   program_list = Program.get_by_dj(dj=self.dj_key)
   if len(program_list) <= 1:
     self.session.add_flash(
       "You don't have more than one radio program to choose between.")
     self.redirect("/dj/")
     return
   template_values = {
     'program_list': program_list,
     'session': self.session,
     'flash': self.flashes,
     'posts': BlogPost.get_last(num=1)
   }
   self.response.out.write(template.render(get_path("dj_selectprogram.html"),
     template_values))
Esempio n. 26
0
 def get(self, post_id):
     """ checking whether user is login, if not, redirect to login page """
     if not self.user:
         self.redirect("/login")
     else:
         post = BlogPost.get_by_id(int(post_id))
         if not post:
             msg = 'The post does not exist'
             self.render('error.html', error=msg, user=self.user)
         else:
             """ get all comments from the same post id """
             comments = Comment.query(
                 ancestor=post.key).order(-Comment.created).fetch()
             self.render("comment.html",
                         p=post,
                         comments=comments,
                         user=self.user)
Esempio n. 27
0
def edit(post_id=None, post=None, user=None):
    '''
  Create or edit a post.
  '''
    user = user or None
    post = post.get() if post else None
    if request.method == 'POST':
        post = post or BlogPost(parent=user.key)
        post.fill(**request.form.to_dict())
        if not post.empty('subject', 'content'):
            try:
                key = post.put()
                return redirect(url_for('edit', post_id=post.uid))
            except Exception as ex:
                print('post crud error', ex)
                return abort(500)
    return render_template('edit.html', page=None, user=user, post=post)
Esempio n. 28
0
    def get(self, post_id):
        if not self.user:
            self.redirect("/login")
        else:
            post = BlogPost.get_by_id(int(post_id))

            if not post:
                msg = 'The post does not exist'
                self.render('error.html', error=msg, user=self.user)
            else:
                # get user who created the post
                user_from_post = post.user_id
                # compare user id that created the post with the login user id
                if self.user.key.id() == user_from_post:
                    self.render("edit-post.html", p=post, user=self.user)
                else:
                    msg = 'You are not allowed to edit this post'
                    self.render('error.html', error=msg, user=self.user)
Esempio n. 29
0
File: dj.py Progetto: hchapman/WBOR
 def get(self, dj_key):
   dj = Dj.get(dj_key)
   # TODO: CRITICAL: CRITICAL: Don't show every goddamn DJ
   dj_list = [] # Seriously screw this crap
   #dj_list = cache.getAllDjs()
   if not dj:
     self.session.add_flash(
         "The DJ specified (" + dj_key +
         ") does not exist.  Please try again.")
     self.redirect("/dj/djs/")
   else:
     template_values = {
       'dj_list': dj_list,
       'dj': dj,
       'session': self.session,
       'flash': self.flashes,
       'posts': BlogPost.get_last(num=3),
     }
     self.response.out.write(
         template.render(get_path("dj_manage_djs.html"), template_values))
Esempio n. 30
0
 def post(self, post_id, comment_id):
     post = BlogPost.get_by_id(int(post_id))
     if not post:
         msg = 'The post does not exist'
         self.render('error.html', error=msg, user=self.user)
     else:
         comment = Comment.get_by_id(int(comment_id), post.key)
         c = self.request.get('edit-comment-txt')
         """ checking whether user is login, if not, redirect to login page """
         if not self.user:
             self.redirect("/login")
         else:
             """ make sure user owns the comment """
             if comment:
                 if self.user.key == comment.commented_by_ukey:
                     if c:
                         comment.comment = c
                         comment.put()
                         # sleep 1s to make database updated
                         time.sleep(1)
                         """ get all comments from db again to display """
                         comments = Comment.query(ancestor=post.key).order(
                             -Comment.created).fetch()
                         self.render("comment.html",
                                     p=post,
                                     comments=comments,
                                     user=self.user)
                     else:
                         error = "Please enter comment!"
                         self.render("error.html",
                                     error_comment=error,
                                     user=self.user,
                                     comment_id=comment_id,
                                     post_id=post_id)
                 else:
                     msg = 'You are not allowed to edit this comment'
                     self.render('error.html', error=msg, user=self.user)
             else:
                 msg = 'Comment does not exist'
                 self.render('error.html', error=msg, user=self.user)
Esempio n. 31
0
    def get(self, post_id):
        """ checking whether user is login, if not, redirect to login page """
        if self.user:
            post = BlogPost.get_by_id(int(post_id))

            if not post:
                msg = 'The post does not exist'
                self.render('error.html', error=msg, user=self.user)
            # to check if the user of a post is different from login user
            else:
                user_id = post.user_id
                post.like += 1
                if not (self.user.key.id() == user_id):
                    if post.liked_by:
                        # check if the user has already liked the post
                        if post.liked_by.find(self.user.name) == -1:
                            # not liked it yet
                            post.liked_by = "%s,%s" % (post.liked_by,
                                                       self.user.name)
                            post.put()
                            self.rebder('permalink.html',
                                        post=post,
                                        user=self.user)
                        else:
                            error = "You've already liked this post"
                            self.render('error.html',
                                        error=error,
                                        user=self.user)
                    else:  # you are the first person to like the post
                        post.liked_by = self.user.name
                        post.put()
                        self.render('permalink.html',
                                    post=post,
                                    user=self.user)
                else:
                    error = 'You are not allowed to like your own post'
                    self.render('error.html', error=error, user=self.user)
        else:
            self.redirect("/login")
Esempio n. 32
0
File: dj.py Progetto: hchapman/WBOR
  def get(self):
    djkey = self.dj_key

    template_values = {
      'session': self.session,
      'flashes': self.session.get_flashes(),
      'posts': BlogPost.get_last(3),
    }
    permissions = {
      'djs': Permission.DJ_EDIT,
      'programs': Permission.PROGRAM_EDIT,
      'albums': Permission.ALBUM_EDIT,
      'permissions': Permission.PERMISSION_EDIT,
      'genres': Permission.GENRE_EDIT,
      'blogs': Permission.BLOG_EDIT,
      'events': Permission.EVENT_EDIT,}
    permissions_dict = dict(('manage_%s'%key,
                             Permission.get_by_title(perm).has_dj(djkey)) for
                            (key, perm) in permissions.iteritems())
    template_values.update(permissions_dict)
    self.response.out.write(
      template.render(get_path("dj_main.html"), template_values))
Esempio n. 33
0
  def get(self):
    labels = Permission.PERMISSIONS
    try:
      seth = Dj.get_by_email("*****@*****.**")
    except NoSuchEntry:
      seth = Dj.new(fullname='Seth Glickman',
                    email='*****@*****.**', username='******',
                    password='******')
      seth.put()
      hchaps = Dj.new(fullname='Harrison Chapman',
                      email="*****@*****.**", username="******",
                      password="******")

      program = Program.new(
        title='Seth\'s Show', slug='seth',
        desc='This is the show where Seth plays his favorite music.',
        dj_list=[seth.key],
        page_html='a <b>BOLD</b> show!')
      program.put()
    for l in labels:
      try:
        permission = Permission.get_by_title(l)
      except NoSuchEntry:
        permission = Permission.new(l, [])
        permission.put()
      finally:
        if seth.key not in permission.dj_list:
          permission.add_dj(seth.key)
          permission.put()
    if not BlogPost.get_last(num=3):
      post1 = BlogPost.new(
        title="Blog's first post!",
        text="This is really just filler text on the first post.",
        slug="first-post", post_date=datetime.datetime.now())
      post1.put()
      time.sleep(2)
      post2 = BlogPost.new(
        title="Blog's second post!",
        text="More filler text, alas.",
        slug="second-post", post_date=datetime.datetime.now())
      post2.put()
      contactspage = BlogPost.new(
        title="Contacts Page",
        text="This is a dummy stub for the contacts page. Lorem ipsum whatnot",
        slug="contacts-page", post_date=datetime.datetime.now())
      contactspage.put()
    artists = [
      "Bear In Heaven",
      "Beck",
      "Arcade Fire",
      "Andrew Bird",
      "The Antlers",
      "Arcade Fire",
      "The Beach Boys",
      "Brian Wilson",
      "The Beatles",
      "Beethoven",
      "Beirut",
      "Belle & Sebastian",
      "Benji Hughes",
      "Club 8",
      "Crayon Fields",
      ]
    for a in artists:
      if not (ArtistName._RAW.query()
              .filter(ArtistName._RAW.artist_name == a)
              .fetch(1, keys_only=True)):
        ar = ArtistName.new(artist_name=a)
        ar.put()
    self.session.add_flash("Permissions set up, ArtistNames set up, "
                           "Blog posts set up, DJ Seth entered.")
    self.redirect('/')
Esempio n. 34
0
 def get(self):
     posts = BlogPost.query().order(-BlogPost.created).fetch()
     self.render('base.html', posts=posts, user=self.user)
Esempio n. 35
0
 def get(self):
     posts = BlogPost.query().order(-BlogPost.created_at).fetch()
     self.write_template("index.html",{
         "posts":posts
     })