Rename a few files and minor cleanup
Within the blog plugin, rename a few files and clean up a few things that can be cleaned up.
This commit is contained in:
parent
0a97e5e16f
commit
eebd8fe3ed
@ -87,7 +87,7 @@ def setup_plugin():
|
|||||||
pluginapi.register_routes(routes)
|
pluginapi.register_routes(routes)
|
||||||
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
|
||||||
pluginapi.register_template_hooks({"user_profile": "mediagoblin/blog/url_to_blogs_dashboard.html",
|
pluginapi.register_template_hooks({"user_profile": "mediagoblin/blog/url_to_blogs_dashboard.html",
|
||||||
"blog_dashboard_home": "mediagoblin/blog/url_to_blogging.html",
|
"blog_dashboard_home": "mediagoblin/blog/url_to_dashboard.html",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
||||||
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
||||||
|
{% set blog_owner_name = blog_owner.username %}
|
||||||
{% block title -%}
|
{% block title -%}
|
||||||
{% trans %}{{ blog_owner }} 's Blog{% endtrans %} — {{ super() }}
|
{% trans %}{{ blog_owner_name }}'s Blog{% endtrans %} — {{ super() }}
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
|
||||||
{% block mediagoblin_head -%}
|
{% block mediagoblin_head -%}
|
||||||
@ -36,7 +36,7 @@
|
|||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
|
||||||
{% block mediagoblin_content %}
|
{% block mediagoblin_content %}
|
||||||
<div class="b_list_owner"> <h1><font color="black"> {{ blog.title }} <font size="2">by {{ blog_owner }}</font> </font></h1></div>
|
<div class="b_list_owner"> <h1><font color="black"> {{ blog.title }} <font size="2">by {{ blog_owner_name }}</font> </font></h1></div>
|
||||||
<div>
|
<div>
|
||||||
{% for post in blog_posts %}
|
{% for post in blog_posts %}
|
||||||
<div class="b_listing_title"><a href="{{ post.url_for_self(request.urlgen) }}">
|
<div class="b_listing_title"><a href="{{ post.url_for_self(request.urlgen) }}">
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
{% set blog_about_url = request.urlgen('mediagoblin.media_types.blog.blog_about',
|
{% set blog_about_url = request.urlgen('mediagoblin.media_types.blog.blog_about',
|
||||||
blog_slug=blog.slug, user=blog_owner) %}
|
blog_slug=blog.slug, user=blog_owner_name) %}
|
||||||
<a style="text-decoration:underline" href="{{ blog_about_url}}">About Blog</a>
|
<a style="text-decoration:underline" href="{{ blog_about_url}}">About Blog</a>
|
||||||
<br/>
|
<br/>
|
||||||
{{ render_pagination(request, pagination) }}
|
{{ render_pagination(request, pagination) }}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
{%if blogs %}
|
{%if blogs %}
|
||||||
<h3>Blog</h3>
|
<h3>Blog</h3>
|
||||||
{% set blogs_url = request.urlgen('mediagoblin.media_types.blog.blog_admin_dashboard',
|
{% set blogs_url = request.urlgen('mediagoblin.media_types.blog.blog_admin_dashboard',
|
||||||
blogs=blogs, user=user.username) %}
|
user=user.username) %}
|
||||||
|
|
||||||
<p><a href="{{ blogs_url }}"><em>Go to user's blog</em></a></p>
|
<p><a href="{{ blogs_url }}"><em>Go to user's blog</em></a></p>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
|
@ -209,19 +209,18 @@ def blogpost_edit(request):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@active_user_from_url
|
||||||
@uses_pagination
|
@uses_pagination
|
||||||
def blog_dashboard(request, page):
|
def blog_dashboard(request, page, url_user=None):
|
||||||
"""
|
"""
|
||||||
Dashboard for a blog, only accessible to
|
Dashboard for a blog, only accessible to
|
||||||
the owner of the blog.
|
the owner of the blog.
|
||||||
"""
|
"""
|
||||||
url_user = request.matchdict.get('user')
|
|
||||||
user = request.db.User.query.filter_by(username=url_user).one()
|
|
||||||
blog_slug = request.matchdict.get('blog_slug', None)
|
blog_slug = request.matchdict.get('blog_slug', None)
|
||||||
blogs = request.db.Blog.query.filter_by(author=user.id)
|
blogs = request.db.Blog.query.filter_by(author=url_user.id)
|
||||||
config = pluginapi.get_config('mediagoblin.media_types.blog')
|
config = pluginapi.get_config('mediagoblin.media_types.blog')
|
||||||
max_blog_count = config['max_blog_count']
|
max_blog_count = config['max_blog_count']
|
||||||
if request.user and (request.user.id == user.id or request.user.has_privilege(u'admin')):
|
if request.user and (request.user.id == url_user.id or request.user.has_privilege(u'admin')):
|
||||||
if blog_slug:
|
if blog_slug:
|
||||||
blog = blogs.filter(Blog.slug==blog_slug).first()
|
blog = blogs.filter(Blog.slug==blog_slug).first()
|
||||||
if not blog:
|
if not blog:
|
||||||
@ -238,32 +237,30 @@ def blog_dashboard(request, page):
|
|||||||
{'blog_posts_list': blog_posts_on_a_page,
|
{'blog_posts_list': blog_posts_on_a_page,
|
||||||
'blog_slug':blog_slug,
|
'blog_slug':blog_slug,
|
||||||
'blog':blog,
|
'blog':blog,
|
||||||
'user':user,
|
'user':url_user,
|
||||||
'pagination':pagination
|
'pagination':pagination
|
||||||
})
|
})
|
||||||
if not request.user or request.user.id != user.id or not blog_slug:
|
if not request.user or request.user.id != url_user.id or not blog_slug:
|
||||||
blogs = blogs.all()
|
blogs = blogs.all()
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
'mediagoblin/blog/list_of_blogs.html',
|
'mediagoblin/blog/list_of_blogs.html',
|
||||||
{
|
{
|
||||||
'blogs':blogs,
|
'blogs':blogs,
|
||||||
'user':user,
|
'user':url_user,
|
||||||
'max_blog_count':max_blog_count
|
'max_blog_count':max_blog_count
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@active_user_from_url
|
||||||
@uses_pagination
|
@uses_pagination
|
||||||
def blog_post_listing(request, page):
|
def blog_post_listing(request, page, url_user=None):
|
||||||
"""
|
"""
|
||||||
Page, listing all the blog posts of a particular blog.
|
Page, listing all the blog posts of a particular blog.
|
||||||
"""
|
"""
|
||||||
blog_owner = request.matchdict.get('user')
|
|
||||||
blog_slug = request.matchdict.get('blog_slug', None)
|
blog_slug = request.matchdict.get('blog_slug', None)
|
||||||
owner_user = User.query.filter_by(username=blog_owner).one()
|
|
||||||
blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
|
blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
|
||||||
|
if not blog:
|
||||||
if not owner_user or not blog:
|
|
||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
all_blog_posts = blog.get_all_blog_posts(u'processed').order_by(MediaEntry.created.desc())
|
all_blog_posts = blog.get_all_blog_posts(u'processed').order_by(MediaEntry.created.desc())
|
||||||
@ -276,7 +273,7 @@ def blog_post_listing(request, page):
|
|||||||
'mediagoblin/blog/blog_post_listing.html',
|
'mediagoblin/blog/blog_post_listing.html',
|
||||||
{'blog_posts': blog_posts_on_a_page,
|
{'blog_posts': blog_posts_on_a_page,
|
||||||
'pagination': pagination,
|
'pagination': pagination,
|
||||||
'blog_owner': blog_owner,
|
'blog_owner': url_user,
|
||||||
'blog':blog
|
'blog':blog
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user