Skip to content

Commit

Permalink
Add titles to titleless pages (#1515)
Browse files Browse the repository at this point in the history
Closes #1502

Reviewed-by: Charmander <~@charmander.me>
  • Loading branch information
charmander authored Jan 1, 2025
2 parents 3808eea + b30eb09 commit c18ef8f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion weasyl/controllers/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def note_(request):
# Private message
data,
profile.select_myself(request.userid),
]))
], title=data['title']))


@login_required
Expand Down
3 changes: 2 additions & 1 deletion weasyl/controllers/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ def search_(request):
next_index = offset + limit if rcount - limit > 0 else None
return Response(define.webpage(request.userid, "etc/marketplace.html",
[results, form, commishinfo.CURRENCY_CHARMAP, commishinfo.PRESET_COMMISSION_CLASSES,
prev_index, next_index]))
prev_index, next_index],
title='Marketplace'))
4 changes: 2 additions & 2 deletions weasyl/controllers/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def messages_notifications_(request):
define._page_header_info.refresh(request.userid)
return Response(define.webpage(request.userid, "message/notifications.html", [
sort_notifications(notifications),
]))
], title='Notifications'))


@login_required
Expand All @@ -70,4 +70,4 @@ def messages_submissions_(request):
# Submissions
message.select_submissions(request.userid, 66, include_tags=False,
backtime=define.get_int(backtime), nexttime=define.get_int(nexttime)),
)))
), title='Submission Notifications'))
37 changes: 20 additions & 17 deletions weasyl/controllers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
from weasyl.error import WeasylError


def _get_page_title(userprofile: dict, what: str) -> str:
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
name = userprofile['full_name'] if has_fullname else userprofile['username']

return f"{name}'s {what}"


def _get_post_counts_by_type(userid, *, friends: bool, rating):
result = {
"submission": 0,
Expand Down Expand Up @@ -176,8 +183,7 @@ def submissions_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's submissions" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'submissions')
page = define.common_page_start(request.userid, title=page_title)

url_format = "/submissions/{username}?%s{folderquery}".format(
Expand Down Expand Up @@ -226,8 +232,7 @@ def collections_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's collections" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'collections')
page = define.common_page_start(request.userid, title=page_title)

url_format = "/collections?userid={userid}&%s".format(userid=userprofile['userid'])
Expand Down Expand Up @@ -265,8 +270,7 @@ def journals_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's journals" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'journals')
page = define.common_page_start(request.userid, title=page_title)

relation = profile.select_relation(request.userid, otherid)
Expand Down Expand Up @@ -302,8 +306,7 @@ def characters_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's characters" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'characters')
page = define.common_page_start(request.userid, title=page_title)

url_format = "/characters?userid={userid}&%s".format(userid=userprofile['userid'])
Expand Down Expand Up @@ -356,8 +359,7 @@ def shouts_(request):
status=403,
)

has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's shouts" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'shouts')
page = define.common_page_start(request.userid, title=page_title)

relation = profile.select_relation(request.userid, otherid)
Expand Down Expand Up @@ -390,8 +392,7 @@ def staffnotes_(request):
raise WeasylError("userRecordMissing")

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's staff notes" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'staff notes')
page = define.common_page_start(request.userid, title=page_title)

userinfo = profile.select_userinfo(otherid, config=userprofile['config'])
Expand Down Expand Up @@ -442,8 +443,7 @@ def favorites_(request):
raise WeasylError('hiddenFavorites')

userprofile = profile.select_profile(otherid, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = "%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page_title = _get_page_title(userprofile, 'favorites')
page = define.common_page_start(request.userid, title=page_title)

if feature:
Expand Down Expand Up @@ -509,6 +509,7 @@ def friends_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
page_title = _get_page_title(userprofile, 'friends')
relation = profile.select_relation(request.userid, otherid)
rating = define.get_rating(request.userid)

Expand All @@ -523,7 +524,7 @@ def friends_(request):
frienduser.select_friends(request.userid, otherid, limit=44,
backid=define.get_int(backid), nextid=define.get_int(nextid)),
_get_post_counts_by_type(otherid, friends=relation["friend"] or relation["is_self"], rating=rating),
]))
], title=page_title))


def following_(request):
Expand All @@ -541,6 +542,7 @@ def following_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
page_title = _get_page_title(userprofile, 'followed users')
relation = profile.select_relation(request.userid, otherid)
rating = define.get_rating(request.userid)

Expand All @@ -555,7 +557,7 @@ def following_(request):
followuser.select_following(request.userid, otherid, limit=44,
backid=define.get_int(backid), nextid=define.get_int(nextid)),
_get_post_counts_by_type(otherid, friends=relation["friend"] or relation["is_self"], rating=rating),
]))
], title=page_title))


def followed_(request):
Expand All @@ -573,6 +575,7 @@ def followed_(request):
raise WeasylError('noGuests')

userprofile = profile.select_profile(otherid, viewer=request.userid)
page_title = _get_page_title(userprofile, 'followers')
relation = profile.select_relation(request.userid, otherid)
rating = define.get_rating(request.userid)

Expand All @@ -587,4 +590,4 @@ def followed_(request):
followuser.select_followed(request.userid, otherid, limit=44,
backid=define.get_int(backid), nextid=define.get_int(nextid)),
_get_post_counts_by_type(otherid, friends=relation["friend"] or relation["is_self"], rating=rating),
]))
], title=page_title))

0 comments on commit c18ef8f

Please sign in to comment.