コード例 #1
0
ファイル: rss.py プロジェクト: eblahm/eblahg
import webapp2
import fix_path
fix_path.fix()
from models import Article
from config import settings
import PyRSS2Gen
import datetime
from google.appengine.ext import db


class main(webapp2.RequestHandler):

    def get(self):
        query = Article.all().order('-pub_date')
        posts = query.fetch(10)

        rss_items = []
        for post in posts:
            this_link = self.request.host_url + "/posts/" + post.slug
            item = PyRSS2Gen.RSSItem(
                title=post.title,
                link=this_link,
                description=post.body_html,
                guid="",
                pubDate=post.pub_date
            )
            rss_items.append(item)

        rss = PyRSS2Gen.RSS2(
            title=settings['blog_title'],
            link=self.request.host_url,
コード例 #2
0
ファイル: models.py プロジェクト: eblahm/eblahg
from fix_path import fix
import re

from google.appengine.ext import db
from google.appengine.api import search

fix()
import markdown
import logging


def slugify(value):
    """
    Adapted from Django's django.template.defaultfilters.slugify.
    """
    import unicodedata
    value = unicode(value)
    value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
    value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
    return re.sub('[-\s]+', '-', value)

class Tag(db.Model):
    name = db.StringProperty()

class Article(db.Model):
    title = db.StringProperty()
    body = db.TextProperty()
    body_html = db.TextProperty()
    slug = db.StringProperty()
    word_count = db.IntegerProperty()
    pub_date = db.DateTimeProperty(auto_now_add=True)