Issue #431 - Prevent comment link expiry - Added functionality for comment linking
* `media.html`
* Changed comment textarea handle from `comment` => `field_comment`
* Active comment is hilighted with the CSS class name `comment_active`
and also with the hyperlink anchor #comment
* Changed media.html so that pagination always uses
Route('mediagoblin.user_pages.media_home') as base_url
* `user_pages/forms.py`
* Renamed MediaComment form field `comment` => `field_comment`
* `user_pages/routing.py`
* Added route for `/u/joar/m/123..456/c/234..567/`, points to `media_home`
* `user_pages/views.py`
* `media_home` now checks if the request contains a comment id parameter
then acts accordingly with pagination whether to call it with a
`jump_to_id` or not.
* `media_post_comment` - Updated MediaCommentForm field name
`comment` => `field_comment`
* `util.py`
* `redirect` now supports querystring arguments. - NOT USED (should we
keep it? I think so, it might be useful, sometime [don't call me a
code hoarder]).
* `Pagination.__init__` now accepts one further argument, the `jump_to_id`.
It assist the comment linking functionality in finding and returning the
proper page for a comment.
This feature will work for all kinds of objects. It might not be
optimal, but it is well functional :)
This commit is contained in:
@@ -17,5 +17,5 @@
|
||||
import wtforms
|
||||
|
||||
class MediaCommentForm(wtforms.Form):
|
||||
comment = wtforms.TextAreaField('Comment',
|
||||
[wtforms.validators.Required()])
|
||||
field_comment = wtforms.TextAreaField('Comment',
|
||||
[wtforms.validators.Required()])
|
||||
|
||||
@@ -24,6 +24,9 @@ user_routes = [
|
||||
Route('mediagoblin.user_pages.media_home', '/{user}/m/{media}/',
|
||||
requirements=dict(m_id="[0-9a-fA-F]{24}"),
|
||||
controller="mediagoblin.user_pages.views:media_home"),
|
||||
Route('mediagoblin.user_pages.media_home.view_comment',
|
||||
'/{user}/m/{media}/c/{comment}/',
|
||||
controller="mediagoblin.user_pages.views:media_home"),
|
||||
Route('mediagoblin.edit.edit_media', "/{user}/m/{media}/edit/",
|
||||
controller="mediagoblin.edit.views:edit_media"),
|
||||
Route('mediagoblin.user_pages.atom_feed', '/{user}/atom/',
|
||||
|
||||
@@ -95,8 +95,14 @@ def media_home(request, media, page, **kwargs):
|
||||
"""
|
||||
'Homepage' of a MediaEntry()
|
||||
"""
|
||||
if ObjectId(request.matchdict.get('comment')):
|
||||
pagination = Pagination(
|
||||
page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE,
|
||||
ObjectId(request.matchdict.get('comment')))
|
||||
else:
|
||||
pagination = Pagination(
|
||||
page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE)
|
||||
|
||||
pagination = Pagination(page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE)
|
||||
comments = pagination()
|
||||
|
||||
comment_form = user_forms.MediaCommentForm(request.POST)
|
||||
@@ -118,7 +124,7 @@ def media_post_comment(request):
|
||||
comment = request.db.MediaComment()
|
||||
comment['media_entry'] = ObjectId(request.matchdict['media'])
|
||||
comment['author'] = request.user['_id']
|
||||
comment['content'] = request.POST['comment']
|
||||
comment['content'] = request.POST['field_comment']
|
||||
|
||||
comment['content_html'] = cleaned_markdown_conversion(comment['content'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user