Пример #1
0
  def post(self):
    self.acl.check_edit_pages()

    name = self.request.get('name')
    body = self.request.get('body')

    title = pages.get_title(pages.wikifier(self.settings).wikify(body))
    if not name:
      name = title

    page = pages.get(name, create=True)
    page.body = body
    page.title = title
    page.author = self.get_wiki_user(True)
    if not page.author and users.get_current_user():
      raise Exception('Could not determine who you are.')
    if self.request.get('pread'):
      page.pread = True
    else:
      page.pread = False
    pages.put(page)

    # Remove old page from cache.
    pages.cache.update(name)

    self.redirect('/' + pages.quote(page.title))
Пример #2
0
  def get(self):
    self.acl.check_read_pages()

    if '.rss' == self.request.path[-4:]:
      plist = {}
      for revision in WikiRevision.gql('ORDER BY created DESC').fetch(1000):
        page = revision.wiki_page.title
        if page not in plist:
          plist[page] = { 'name': page, 'title': self.get_page_name(page), 'created': revision.created, 'author': revision.author }
      self.generateRss('index-rss.html', template_values = {
        'items': [plist[page] for page in plist],
      });
    else:
      self.generate('index.html', template_values={'pages': [{
        'name': page.title,
        'uri': '/' + pages.quote(page.title),
      } for page in WikiContent.gql('ORDER BY title').fetch(1000)] })
Пример #3
0
  def get(self):
    content = memcache.get('/sitemap.xml')
    if True or not content:
      content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
      content += "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"

      settings = self.settings
      host = self.request.environ['HTTP_HOST']

      for page in WikiContent.all().fetch(1000):
        if settings.data.pread or page.pread:
          line = "<url><loc>http://%s/%s</loc>" % (host, pages.quote(page.title))
          if page.updated:
            line += "<lastmod>%s</lastmod>" % (page.updated.strftime('%Y-%m-%d'))
          line += "</url>\n"
          content += line
      content += "</urlset>\n"

      memcache.set('/sitemap.xml', content)

    self.response.headers['Content-Type'] = 'text/xml'
    self.response.out.write(content)
Пример #4
0
 def getStartPage(self):
   return '/' + pages.quote(self.settings.get('start_page'))