fixes in blog list

This commit is contained in:
Anand Doshi
2012-07-13 00:46:59 +05:30
parent 4659b1eb25
commit f01059fd3e
3 changed files with 62 additions and 13 deletions

View File

@@ -1,5 +1,44 @@
import webnotes
@webnotes.whitelist(allow_guest=True)
def get_blog_list(args=None):
"""
args = {
'limit_start': 0,
'limit_page_length': 10,
}
"""
import webnotes
if not args: args = webnotes.form_dict
query = """\
select
cache.name as name, cache.html as content,
blog.owner as owner, blog.creation as published,
blog.title as title
from `tabWeb Cache` cache, `tabBlog` blog
where cache.doc_type = 'Blog' and blog.page_name = cache.name
order by published desc, name asc"""
from webnotes.widgets.query_builder import add_limit_to_query
query, args = add_limit_to_query(query, args)
result = webnotes.conn.sql(query, args, as_dict=1)
# strip html tags from content
import webnotes.utils
import website.web_cache
for res in result:
from webnotes.utils import global_date_format, get_fullname
res['full_name'] = get_fullname(res['owner'])
res['published'] = global_date_format(res['published'])
res['content'] = split_blog_content(res['content'])
res['content'] = res['content'][:1000]
return result
@webnotes.whitelist(allow_guest=True)
def get_recent_blog_list(args=None):
"""
@@ -64,4 +103,23 @@ def add_comment(args=None):
comment_html = website.web_cache.build_html(template_args)
return comment_html
def get_content(blog_page_name):
import website.web_cache
content = website.web_cache.get_html(blog_page_name)
content = split_blog_content(content)
import webnotes.utils
content = webnotes.utils.escape_html(content)
return content
def split_blog_content(content):
content = content.split("<!-- begin blog content -->")
content = len(content) > 1 and content[1] or content[0]
content = content.split("<!-- end blog content -->")
content = content[0]
return content