def submission_(request): username = request.matchdict.get('name') submitid = request.matchdict.get('submitid') form = request.web_input(submitid="", ignore="", anyway="") rating = define.get_rating(request.userid) submitid = define.get_int(submitid) if submitid else define.get_int(form.submitid) extras = { "pdf": True, } if define.user_is_twitterbot(): extras['twitter_card'] = submission.twitter_card(submitid) try: item = submission.select_view( request.userid, submitid, rating, ignore=define.text_bool(form.ignore, True), anyway=form.anyway ) except WeasylError as we: we.errorpage_kwargs = extras if 'twitter_card' in extras: extras['options'] = ['nocache'] if we.value in ("UserIgnored", "TagBlocked"): extras['links'] = [ ("View Submission", "?ignore=false"), ("Return to the Home Page", "/index"), ] raise login = define.get_sysname(item['username']) canonical_path = request.route_path('submission_detail_profile', name=login, submitid=submitid, slug=slug_for(item['title'])) if request.GET.get('anyway'): canonical_path += '?anyway=true' if login != username: raise httpexceptions.HTTPMovedPermanently(location=canonical_path) extras["canonical_url"] = canonical_path extras["title"] = item["title"] page = define.common_page_start(request.userid, **extras) page.append(define.render('detail/submission.html', [ # Myself profile.select_myself(request.userid), # Submission detail item, # Subtypes macro.MACRO_SUBCAT_LIST, # Violations [i for i in macro.MACRO_REPORT_VIOLATION if 2000 <= i[0] < 3000], ])) return Response(define.common_page_end(request.userid, page))
def GET(self, a="", b=None): if b is None: username, submitid = None, a else: username, submitid = a, b now = time.time() form = web.input(submitid="", ignore="", anyway="") rating = define.get_rating(self.user_id) submitid = define.get_int(submitid) if submitid else define.get_int(form.submitid) extras = { "pdf": True, } if define.user_is_twitterbot(): extras['twitter_card'] = submission.twitter_card(submitid) try: item = submission.select_view( self.user_id, submitid, rating, ignore=define.text_bool(form.ignore, True), anyway=form.anyway ) except WeasylError as we: we.errorpage_kwargs = extras if 'twitter_card' in extras: extras['options'] = ['nocache'] if we.value in ("UserIgnored", "TagBlocked"): extras['links'] = [ ("View Submission", "?ignore=false"), ("Return to the Home Page", "/index"), ] raise login = define.get_sysname(item['username']) if username is not None and login != username: raise web.seeother('/~%s/post/%s/%s' % (login, submitid, slug_for(item["title"]))) extras["canonical_url"] = "/submission/%d/%s" % (submitid, slug_for(item["title"])) extras["title"] = item["title"] page = define.common_page_start(self.user_id, options=["mediaplayer"], **extras) page.append(define.render('detail/submission.html', [ # Myself profile.select_myself(self.user_id), # Submission detail item, # Subtypes macro.MACRO_SUBCAT_LIST, # Violations [i for i in macro.MACRO_REPORT_VIOLATION if 2000 <= i[0] < 3000], ])) return define.common_page_end(self.user_id, page, now=now)
def profile_(request): name = request.params.get('name', '') name = request.matchdict.get('name', name) userid = define.get_int(request.params.get('userid')) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, userid, name) if not otherid: raise WeasylError("userRecordMissing") userprofile = profile.select_profile(otherid, viewer=request.userid) is_unverified = otherid != request.userid and not define.is_vouched_for( otherid) if is_unverified and request.userid not in staff.MODS: can_vouch = request.userid != 0 and define.is_vouched_for( request.userid) return Response( define.webpage( request.userid, "error/unverified.html", [request, otherid, userprofile['username'], can_vouch], ), status=403, ) extras = { "canonical_url": "/~" + define.get_sysname(userprofile['username']) } if not request.userid: # Only generate the Twitter/OGP meta headers if not authenticated (the UA viewing is likely automated). twit_card = profile.twitter_card(otherid) if define.user_is_twitterbot(): extras['twitter_card'] = twit_card # The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there. extras['ogp'] = { 'title': twit_card['title'], 'site_name': "Weasyl", 'type': "website", 'url': twit_card['url'], 'description': twit_card['description'], 'image': twit_card['image:src'] if 'image:src' in twit_card else define.get_resource_url('img/logo-mark-light.svg'), } if not request.userid and "h" in userprofile['config']: raise WeasylError('noGuests') has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, **extras) define.common_view_content(request.userid, otherid, "profile") if 'O' in userprofile['config']: submissions = collection.select_list(request.userid, rating, 11, otherid=otherid) more_submissions = 'collections' featured = None elif 'A' in userprofile['config']: submissions = character.select_list(request.userid, rating, 11, otherid=otherid) more_submissions = 'characters' featured = None else: submissions = submission.select_list(request.userid, rating, 11, otherid=otherid, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(request.userid, otherid, rating) if userprofile['show_favorites_bar']: favorites = favorite.select_submit(request.userid, rating, 11, otherid=otherid) else: favorites = None statistics, show_statistics = profile.select_statistics(otherid) page.append( define.render( 'user/profile.html', [ request, # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), macro.SOCIAL_SITES, # Relationship profile.select_relation(request.userid, otherid), # Myself profile.select_myself(request.userid), # Recent submissions submissions, more_submissions, favorites, featured, # Folders preview folder.select_preview(request.userid, otherid, rating), # Latest journal journal.select_latest(request.userid, rating, otherid=otherid), # Recent shouts shout.select(request.userid, ownerid=otherid, limit=8), # Statistics information statistics, show_statistics, # Commission information commishinfo.select_list(otherid), # Friends lambda: frienduser.has_friends(otherid), is_unverified, ])) return Response(define.common_page_end(request.userid, page))
def profile_(request): form = request.web_input(userid="", name="") form.name = request.matchdict.get('name', form.name) form.userid = define.get_int(form.userid) config = define.get_config(request.userid) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") userprofile = profile.select_profile(otherid, images=True, viewer=request.userid) extras = {"canonical_url": "/~" + define.get_sysname(form.name)} if define.user_is_twitterbot(): extras['twitter_card'] = profile.twitter_card(otherid) extras['options'] = ['nocache'] if not request.userid and "h" in userprofile['config']: return Response( define.errorpage( request.userid, "You cannot view this page because the owner does not allow guests to view their profile.", **extras)) has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, **extras) define.common_view_content(request.userid, otherid, "profile") if 'O' in userprofile['config']: submissions = collection.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'collections' featured = None elif 'A' in userprofile['config']: submissions = character.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'characters' featured = None else: submissions = submission.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(request.userid, otherid, rating) if userprofile['show_favorites_bar']: favorites = favorite.select_submit(request.userid, rating, 11, otherid=otherid, config=config) else: favorites = None page.append( define.render( 'user/profile.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), macro.SOCIAL_SITES, # Relationship profile.select_relation(request.userid, otherid), # Myself profile.select_myself(request.userid), # Recent submissions submissions, more_submissions, favorites, featured, # Folders preview folder.select_preview(request.userid, otherid, rating, 3), # Latest journal journal.select_latest( request.userid, rating, otherid=otherid, config=config), # Recent shouts shout.select(request.userid, ownerid=otherid, limit=8), # Statistics information profile.select_statistics(otherid), # Commission information commishinfo.select_list(otherid), # Friends frienduser.select(request.userid, otherid, 5, choose=None), # Following followuser.select_following(request.userid, otherid, choose=5), # Followed followuser.select_followed(request.userid, otherid, choose=5), ])) return Response(define.common_page_end(request.userid, page))
def submission_(request): username = request.matchdict.get('name') submitid = request.matchdict.get('submitid') form = request.web_input(submitid="", ignore="", anyway="") rating = define.get_rating(request.userid) submitid = define.get_int(submitid) if submitid else define.get_int(form.submitid) extras = {} if not request.userid: # Only generate the Twitter/OGP meta headers if not authenticated (the UA viewing is likely automated). twit_card = submission.twitter_card(submitid) if define.user_is_twitterbot(): extras['twitter_card'] = twit_card # The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there. extras['ogp'] = { 'title': twit_card['title'], 'site_name': "Weasyl", 'type': "website", 'url': twit_card['url'], 'description': twit_card['description'], # >> BUG AVOIDANCE: https://trello.com/c/mBx51jfZ/1285-any-image-link-with-in-it-wont-preview-up-it-wont-show-up-in-embeds-too # Image URLs with '~' in it will not be displayed by Discord, so replace ~ with the URL encoded char code %7E 'image': twit_card['image:src'].replace('~', '%7E') if 'image:src' in twit_card else define.cdnify_url( '/static/images/logo-mark-light.svg'), } try: item = submission.select_view( request.userid, submitid, rating, ignore=define.text_bool(form.ignore, True), anyway=form.anyway ) except WeasylError as we: we.errorpage_kwargs = extras if we.value in ("UserIgnored", "TagBlocked"): extras['links'] = [ ("View Submission", "?ignore=false"), ("Return to the Home Page", "/index"), ] raise login = define.get_sysname(item['username']) canonical_path = request.route_path('submission_detail_profile', name=login, submitid=submitid, slug=slug_for(item['title'])) if request.GET.get('anyway'): canonical_path += '?anyway=true' if login != username: raise httpexceptions.HTTPMovedPermanently(location=canonical_path) extras["canonical_url"] = canonical_path extras["title"] = item["title"] submission_files = item["sub_media"].get("submission") submission_file = submission_files[0] if submission_files else None extras["pdf"] = bool(submission_file) and submission_file["file_type"] == "pdf" page = define.common_page_start(request.userid, **extras) page.append(define.render('detail/submission.html', [ # Myself profile.select_myself(request.userid), # Submission detail item, # Subtypes macro.MACRO_SUBCAT_LIST, # Violations [i for i in macro.MACRO_REPORT_VIOLATION if 2000 <= i[0] < 3000], ])) return Response(define.common_page_end(request.userid, page))
def GET(self, name=""): now = time.time() form = web.input(userid="", name="") form.name = name if name else form.name form.userid = define.get_int(form.userid) config = define.get_config(self.user_id) rating = define.get_rating(self.user_id) otherid = profile.resolve(self.user_id, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") userprofile = profile.select_profile(otherid, images=True, viewer=self.user_id) extras = { "canonical_url": "/~" + define.get_sysname(form.name) } if define.user_is_twitterbot(): extras['twitter_card'] = profile.twitter_card(otherid) extras['options'] = ['nocache'] if not self.user_id and "h" in userprofile['config']: return define.errorpage( self.user_id, "You cannot view this page because the owner does not allow guests to view their profile.", **extras) has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != '' extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(self.user_id, **extras) define.common_view_content(self.user_id, otherid, "profile") if 'O' in userprofile['config']: submissions = collection.select_list( self.user_id, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'collections' featured = None elif 'A' in userprofile['config']: submissions = character.select_list( self.user_id, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'characters' featured = None else: submissions = submission.select_list( self.user_id, rating, 11, otherid=otherid, options=["cover"], config=config, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(self.user_id, otherid, rating) if userprofile['show_favorites_bar']: favorites = favorite.select_submit(self.user_id, rating, 11, otherid=otherid, config=config) else: favorites = None page.append(define.render(template.user_profile, [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), macro.SOCIAL_SITES, # Relationship profile.select_relation(self.user_id, otherid), # Myself profile.select_myself(self.user_id), # Recent submissions submissions, more_submissions, favorites, featured, # Folders preview folder.select_preview(self.user_id, otherid, rating, 3), # Latest journal journal.select_latest(self.user_id, rating, otherid=otherid, config=config), # Recent shouts shout.select(self.user_id, ownerid=otherid, limit=8), # Statistics information profile.select_statistics(otherid), # Commission information commishinfo.select_list(otherid), # Friends frienduser.select(self.user_id, otherid, 5, choose=None), # Following followuser.select_following(self.user_id, otherid, choose=5), # Followed followuser.select_followed(self.user_id, otherid, choose=5), ])) return define.common_page_end(self.user_id, page, now=now)
def profile_(request): form = request.web_input(userid="", name="") form.name = request.matchdict.get('name', form.name) form.userid = define.get_int(form.userid) config = define.get_config(request.userid) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") userprofile = profile.select_profile(otherid, images=True, viewer=request.userid) extras = { "canonical_url": "/~" + define.get_sysname(form.name) } if not request.userid: # Only generate the Twitter/OGP meta headers if not authenticated (the UA viewing is likely automated). twit_card = profile.twitter_card(otherid) if define.user_is_twitterbot(): extras['twitter_card'] = twit_card # The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there. extras['ogp'] = { 'title': twit_card['title'], 'site_name': "Weasyl", 'type': "website", 'url': twit_card['url'], 'description': twit_card['description'], 'image': twit_card['image:src'] if 'image:src' in twit_card else define.cdnify_url('/static/images/logo-mark-light.svg'), } if not request.userid and "h" in userprofile['config']: return Response(define.errorpage( request.userid, "You cannot view this page because the owner does not allow guests to view their profile.", **extras)) has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != '' extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'],) page = define.common_page_start(request.userid, **extras) define.common_view_content(request.userid, otherid, "profile") if 'O' in userprofile['config']: submissions = collection.select_list( request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'collections' featured = None elif 'A' in userprofile['config']: submissions = character.select_list( request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'characters' featured = None else: submissions = submission.select_list( request.userid, rating, 11, otherid=otherid, options=["cover"], config=config, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(request.userid, otherid, rating) if userprofile['show_favorites_bar']: favorites = favorite.select_submit(request.userid, rating, 11, otherid=otherid, config=config) else: favorites = None statistics, show_statistics = profile.select_statistics(otherid) page.append(define.render('user/profile.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), macro.SOCIAL_SITES, # Relationship profile.select_relation(request.userid, otherid), # Myself profile.select_myself(request.userid), # Recent submissions submissions, more_submissions, favorites, featured, # Folders preview folder.select_preview(request.userid, otherid, rating, 3), # Latest journal journal.select_latest(request.userid, rating, otherid=otherid, config=config), # Recent shouts shout.select(request.userid, ownerid=otherid, limit=8), # Statistics information statistics, show_statistics, # Commission information commishinfo.select_list(otherid), # Friends lambda: frienduser.has_friends(otherid), ])) return Response(define.common_page_end(request.userid, page))
def GET(self, a="", b=None): if b is None: username, submitid = None, a else: username, submitid = a, b now = time.time() form = web.input(submitid="", ignore="", anyway="") rating = define.get_rating(self.user_id) submitid = define.get_int(submitid) if submitid else define.get_int( form.submitid) extras = { "pdf": True, } if define.user_is_twitterbot(): extras['twitter_card'] = submission.twitter_card(submitid) try: item = submission.select_view(self.user_id, submitid, rating, ignore=define.text_bool( form.ignore, True), anyway=form.anyway) except WeasylError as we: we.errorpage_kwargs = extras if 'twitter_card' in extras: extras['options'] = ['nocache'] if we.value in ("UserIgnored", "TagBlocked"): extras['links'] = [ ("View Submission", "?ignore=false"), ("Return to the Home Page", "/index"), ] raise login = define.get_sysname(item['username']) if username is not None and login != username: raise web.seeother('/~%s/post/%s/%s' % (login, submitid, slug_for(item["title"]))) extras["canonical_url"] = "/submission/%d/%s" % ( submitid, slug_for(item["title"])) extras["title"] = item["title"] page = define.common_page_start(self.user_id, options=["mediaplayer"], **extras) page.append( define.render( template.detail_submission, [ # Myself profile.select_myself(self.user_id), # Submission detail item, # Subtypes macro.MACRO_SUBCAT_LIST, # Violations [ i for i in macro.MACRO_REPORT_VIOLATION if 2000 <= i[0] < 3000 ], ])) return define.common_page_end(self.user_id, page, now=now)
def profile_(request): form = request.web_input(userid="", name="") form.name = request.matchdict.get('name', form.name) form.userid = define.get_int(form.userid) config = define.get_config(request.userid) rating = define.get_rating(request.userid) otherid = profile.resolve(request.userid, form.userid, form.name) if not otherid: raise WeasylError("userRecordMissing") userprofile = profile.select_profile(otherid, images=True, viewer=request.userid) extras = {"canonical_url": "/~" + define.get_sysname(form.name)} if not request.userid: # Only generate the Twitter/OGP meta headers if not authenticated (the UA viewing is likely automated). twit_card = profile.twitter_card(otherid) if define.user_is_twitterbot(): extras['twitter_card'] = twit_card # The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there. extras['ogp'] = { 'title': twit_card['title'], 'site_name': "Weasyl", 'type': "website", 'url': twit_card['url'], 'description': twit_card['description'], 'image': twit_card['image:src'] if 'image:src' in twit_card else define.cdnify_url('/static/images/logo-mark-light.svg'), } if not request.userid and "h" in userprofile['config']: return Response( define.errorpage( request.userid, "You cannot view this page because the owner does not allow guests to view their profile.", **extras)) has_fullname = userprofile[ 'full_name'] is not None and userprofile['full_name'].strip() != '' extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'], ) page = define.common_page_start(request.userid, **extras) define.common_view_content(request.userid, otherid, "profile") if 'O' in userprofile['config']: submissions = collection.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'collections' featured = None elif 'A' in userprofile['config']: submissions = character.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config) more_submissions = 'characters' featured = None else: submissions = submission.select_list(request.userid, rating, 11, otherid=otherid, options=["cover"], config=config, profile_page_filter=True) more_submissions = 'submissions' featured = submission.select_featured(request.userid, otherid, rating) if userprofile['show_favorites_bar']: favorites = favorite.select_submit(request.userid, rating, 11, otherid=otherid, config=config) else: favorites = None statistics, show_statistics = profile.select_statistics(otherid) page.append( define.render( 'user/profile.html', [ # Profile information userprofile, # User information profile.select_userinfo(otherid, config=userprofile['config']), macro.SOCIAL_SITES, # Relationship profile.select_relation(request.userid, otherid), # Myself profile.select_myself(request.userid), # Recent submissions submissions, more_submissions, favorites, featured, # Folders preview folder.select_preview(request.userid, otherid, rating, 3), # Latest journal journal.select_latest( request.userid, rating, otherid=otherid, config=config), # Recent shouts shout.select(request.userid, ownerid=otherid, limit=8), # Statistics information statistics, show_statistics, # Commission information commishinfo.select_list(otherid), # Friends lambda: frienduser.has_friends(otherid), ])) return Response(define.common_page_end(request.userid, page))