コード例 #1
0
def generate():
	"""generate rss feed"""
	import os, urllib
	import webnotes
	from webnotes.model.doc import Document
	from webnotes.utils import escape_html
	
	host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST')
	
	items = ''
	blog_list = webnotes.conn.sql("""\
		select page_name as name, published_on, modified, title, content from `tabBlog Post` 
		where ifnull(published,0)=1
		order by published_on desc limit 20""", as_dict=1)

	for blog in blog_list:
		blog.link = urllib.quote(host + '/' + blog.name + '.html')
		blog.content = escape_html(blog.content or "")
		
		items += rss_item % blog

	modified = max((blog['modified'] for blog in blog_list))
		
	ws = Document('Website Settings', 'Website Settings')
	return (rss % {
				'title': ws.title_prefix,
				'description': ws.description or (ws.title_prefix + ' Blog'),
				'modified': modified,
				'items': items,
				'link': host + '/blog.html'
			}).encode('utf-8', 'ignore')
コード例 #2
0
def get_context():
	"""generate rss feed"""
		
	host = get_request_site_address()
	
	blog_list = webnotes.conn.sql("""\
		select page_name as name, published_on, modified, title, content from `tabBlog Post` 
		where ifnull(published,0)=1
		order by published_on desc limit 20""", as_dict=1)

	for blog in blog_list:
		blog.link = urllib.quote(host + '/' + blog.name + '.html')
		blog.content = escape_html(blog.content or "")
	
	if blog_list:
		modified = max((blog['modified'] for blog in blog_list))
	else:
		modified = now()

	ws = webnotes.doc('Website Settings', 'Website Settings')

	context = {
		'title': ws.title_prefix,
		'description': ws.description or ((ws.title_prefix or "") + ' Blog'),
		'modified': modified,
		'items': blog_list,
		'link': host + '/blog'
	}
	
	webnotes.response.content_type = "text/xml"
	
	# print context
	return context
	
コード例 #3
0
ファイル: blog_feed.py プロジェクト: rohitw1991/latestadberp
def generate():
    """generate rss feed"""
    import os, urllib
    import webnotes
    from webnotes.model.doc import Document
    from webnotes.utils import escape_html

    host = (os.environ.get("HTTPS") and "https://" or "http://") + os.environ.get("HTTP_HOST")

    items = ""
    blog_list = webnotes.conn.sql(
        """\
		select page_name as name, published_on, modified, title, content from `tabBlog Post` 
		where ifnull(published,0)=1
		order by published_on desc limit 20""",
        as_dict=1,
    )

    for blog in blog_list:
        blog.link = urllib.quote(host + "/" + blog.name + ".html")
        blog.content = escape_html(blog.content or "")

        items += rss_item % blog

    modified = max((blog["modified"] for blog in blog_list))

    ws = Document("Website Settings", "Website Settings")
    return (
        rss
        % {
            "title": ws.title_prefix,
            "description": ws.description or (ws.title_prefix + " Blog"),
            "modified": modified,
            "items": items,
            "link": host + "/blog.html",
        }
    ).encode("utf-8", "ignore")