aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/models.py22
-rw-r--r--mediagoblin/static/css/base.css31
-rw-r--r--mediagoblin/static/images/icon_delete.pngbin0 -> 472 bytes
-rw-r--r--mediagoblin/static/images/icon_edit.pngbin0 -> 297 bytes
-rw-r--r--mediagoblin/static/images/icon_feed.pngbin0 -> 522 bytes
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media.html93
-rw-r--r--mediagoblin/templates/mediagoblin/utils/pagination.html9
-rw-r--r--mediagoblin/user_pages/views.py8
8 files changed, 86 insertions, 77 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index bf825a23..1d91a14b 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -23,7 +23,6 @@ from mediagoblin.auth import lib as auth_lib
from mediagoblin import mg_globals
from mediagoblin.db import migrations
from mediagoblin.db.util import DESCENDING, ObjectId
-from mediagoblin.util import Pagination
###################
# Custom validators
@@ -109,24 +108,13 @@ class MediaEntry(Document):
migration_handler = migrations.MediaEntryMigration
+ def get_comments(self):
+ return self.db.MediaComment.find({
+ 'media_entry': self['_id']}).sort('created', DESCENDING)
+
def main_mediafile(self):
pass
-
- def get_comments(self, page):
- cursor = self.db.MediaComment.find({
- 'media_entry': self['_id']}).sort('created', DESCENDING)
-
- pagination = Pagination(page, cursor)
- comments = pagination()
-
- data = list()
- for comment in comments:
- comment['author'] = self.db.User.find_one({
- '_id': comment['author']})
- data.append(comment)
-
- return (data, pagination)
-
+
def generate_slug(self):
self['slug'] = util.slugify(self['title'])
diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css
index 31573820..3b2a9a50 100644
--- a/mediagoblin/static/css/base.css
+++ b/mediagoblin/static/css/base.css
@@ -133,15 +133,6 @@ a.mediagoblin_logo:hover {
/* common website elements */
-.dotted_line {
- width:100%;
- height:0px;
- border-bottom: dotted 1px #5f5f5f;
- position:absolute;
- left:0px;
- margin-top:-20px;
-}
-
.button {
font-family:'Carter One', arial, serif;
height:32px;
@@ -164,6 +155,10 @@ a.mediagoblin_logo:hover {
padding-right:11px;
}
+.pagination{
+text-align:center;
+}
+
/* forms */
.form_box {
@@ -223,6 +218,17 @@ a.mediagoblin_logo:hover {
width:280px;
}
+/* comments */
+
+.comment_author {
+ margin-bottom:40px;
+ padding-top:4px;
+}
+
+.comment_content p {
+ margin-bottom:4px;
+}
+
/* media galleries */
ul.media_thumbnail {
@@ -240,3 +246,10 @@ li.media_thumbnail {
zoom:1;
. *display:inline;
}
+
+/* icons */
+
+img.media_icon{
+ margin:0 4px;
+ vertical-align:sub;
+}
diff --git a/mediagoblin/static/images/icon_delete.png b/mediagoblin/static/images/icon_delete.png
new file mode 100644
index 00000000..9d76a5db
--- /dev/null
+++ b/mediagoblin/static/images/icon_delete.png
Binary files differ
diff --git a/mediagoblin/static/images/icon_edit.png b/mediagoblin/static/images/icon_edit.png
new file mode 100644
index 00000000..480c73ad
--- /dev/null
+++ b/mediagoblin/static/images/icon_edit.png
Binary files differ
diff --git a/mediagoblin/static/images/icon_feed.png b/mediagoblin/static/images/icon_feed.png
new file mode 100644
index 00000000..11e5b1e7
--- /dev/null
+++ b/mediagoblin/static/images/icon_feed.png
Binary files differ
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html
index 3cebe2f9..e84c9872 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media.html
@@ -20,84 +20,89 @@
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
{% block mediagoblin_content %}
- {# temporarily, an "image gallery" that isn't one really ;) #}
{% if media %}
<div class="grid_8 alpha media_image">
- <h1>
- {{media.title}}
- </h1>
- <img class="media_image" src="{{ request.app.public_store.file_url(
+ <img src="{{ request.app.public_store.file_url(
media.media_files.main) }}" />
+ <h2>
+ {{media.title}}
+ </h2>
+
+ {% autoescape False %}
+ <p>{{ media.description_html }}</p>
+ {% endautoescape %}
+
<p>
- Uploaded on
+ &mdash;&nbsp;uploaded on
{{ "%4d-%02d-%02d"|format(media.created.year,
media.created.month, media.created.day) }}
by
<a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
user= media.uploader().username) }}">
{{- media.uploader().username }}</a>
- </p>
+ </p>
+ <br /><br />
- {% autoescape False %}
- <p>{{ media.description_html }}</p>
- {% endautoescape %}
-
- {% if media['uploader'] == request.user['_id'] %}
- <p><a href="{{ request.urlgen('mediagoblin.edit.edit_media',
- user= media.uploader().username,
- media= media._id) }}">Edit</a></p>
- {% endif %}
+ <h3>Comments</h3>
{% if request.user %}
<form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment',
user= media.uploader().username,
media=media._id) }}" method="POST">
- <h3>Post a comment!</h3>
{{ wtforms_util.render_field_div(comment_form.comment) }}
<div class="form_submit_buttons">
- <input type="submit" value="Submit" class="button" />
+ <input type="submit" value="Post comment!" class="button" />
</div>
</form>
{% endif %}
- {#
- {{ wtforms_util.render_textarea_div(submit_form.description) }}
- {{ wtforms_util.render_field_div(submit_form.file) }}
- #}
-
{% if comments %}
- <h3>Comments</h3>
{% for comment in comments %}
+ {% set comment_author = comment.author() %}
<div class="comment_wrapper" id="comment-{{ comment['_id'] }}">
- <div class="comment_author">By:
- <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
- user = comment['author']['username']) }}">
- {{ comment['author']['username'] }}
- </a>
- </div>
- <div class="comment_datetime">
- <a href="#comment-{{ comment['_id'] }}">
- {{ "%4d-%02d-%02d %02d:%02d"|format(comment.created.year,
- comment.created.month,
- comment.created.day,
- comment.created.hour,
- comment.created.minute) }}
- </a>
- </div>
<div class="comment_content">
{% autoescape False %}
{{ comment.content_html }}
{% endautoescape %}
- </div>
- </div>
+ </div>
+ <div class="comment_author">&mdash;
+ <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
+ user = comment_author['username']) }}">
+ {{ comment_author['username'] }}</a> at
+ <!--</div>
+ <div class="comment_datetime">-->
+ <a href="#comment-{{ comment['_id'] }}">
+ {{ "%4d-%02d-%02d %02d:%02d"|format(comment.created.year,
+ comment.created.month,
+ comment.created.day,
+ comment.created.hour,
+ comment.created.minute) }}
+ </a>
+ </div>
+ </div>
{% endfor %}
+
{% include "mediagoblin/utils/pagination.html" %}
</div>
{% endif %}
-
<div class="grid_4 omega media_sidebar">
- <p>This is a sidebar! Yay!</p>
+ <h3>Sidebar content here!</h3>
+ <p>
+ {% if media['uploader'] == request.user['_id'] %}
+ <p>
+ <a href="{{ request.urlgen('mediagoblin.edit.edit_media',
+ user= media.uploader().username,
+ media= media._id) }}"
+ ><img src="{{ request.staticdirect('/images/icon_edit.png') }}"
+ class="media_icon" />edit</a>
+ </p>
+ <p>
+ <img src="{{ request.staticdirect('/images/icon_delete.png') }}"
+ class="media_icon" />delete
+ </p>
+ {% endif %}
+ </p>
</div>
{% else %}
- <p>Sorry, no such media found.<p/>
+ <p>Sorry, no such media found.<p/>
{% endif %}
{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/utils/pagination.html b/mediagoblin/templates/mediagoblin/utils/pagination.html
index 2be0b92e..2423d08d 100644
--- a/mediagoblin/templates/mediagoblin/utils/pagination.html
+++ b/mediagoblin/templates/mediagoblin/utils/pagination.html
@@ -19,17 +19,17 @@
{% if pagination %}
<div class="pagination">
-
+ <p>
{% if pagination.has_prev %}
- <a href="{{ pagination.get_page_url(request, pagination.page-1) }}">&laquo; Prev</>
+ <a href="{{ pagination.get_page_url(request, pagination.page-1) }}">&laquo; Prev</a>
{% endif %}
{%- for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
- <a href="{{ pagination.get_page_url(request, page) }}">{{ page }}</a>
+ <a href="{{ pagination.get_page_url(request, page) }}">{{ page }}</a>
{% else %}
- <strong>{{ page }}</strong>
+ {{ page }}
{% endif %}
{% else %}
<span class="ellipsis">…</span>
@@ -39,6 +39,7 @@
{% if pagination.has_next %}
<a href="{{ pagination.get_page_url(request, pagination.page + 1) }}">Next &raquo;</a>
{% endif %}
+ </p>
</div>
{% endif %}
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index 399d2020..012d27a3 100644
--- a/mediagoblin/user_pages/views.py
+++ b/mediagoblin/user_pages/views.py
@@ -82,17 +82,19 @@ def user_gallery(request, page):
'media_entries': media_entries,
'pagination': pagination})
+MEDIA_COMMENTS_PER_PAGE = 50
@get_user_media_entry
@uses_pagination
-def media_home(request, media, **kwargs):
+def media_home(request, media, page, **kwargs):
"""
'Homepage' of a MediaEntry()
"""
- comment_form = user_forms.MediaCommentForm(request.POST)
+ pagination = Pagination(page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE)
+ comments = pagination()
- (comments, pagination) = media.get_comments(kwargs.get('page'))
+ comment_form = user_forms.MediaCommentForm(request.POST)
return render_to_response(
request,